Commit ccdcb0d
authored
feat(shell): polish prompt rendering and recaps (#49)
* feat(shell): polish prompt rendering and recaps
* docs: update changelog for shell recaps
* fix(tui): wrap markdown prose on word boundaries
* fix(ui): correct huge new-file write render + harden ANSI/recap/hooks
Apply verified fixes from the branch code-diff review:
- write/_file_diff: a brand-new file >10k lines produced a one-line diff
summary ("removed 1 / added 1") instead of "Wrote N lines". The summary
block's "- (0 lines)" line made preview.removed==1, so the diff path was
taken regardless of _is_existing_file_diff. Add DiffPreview.is_new_file
(every block's old side empty) and gate the diff path on it, fixing both
routing clauses. Pre-existing bug; validated across new/existing × huge/small.
- render_utils.sanitize_ansi: strip 8-bit C1 controls (0x80-0x9F), incl. the
single-byte CSI/OSC/PM/APC introducers terminals still interpret.
- _live_view: route the per-turn recap banner through sanitize_ansi.
- wire/types.HookOutput: bound stdout/stderr with max_length (12_032, headroom
for the engine's truncation marker) so oversized payloads fail at the wire
boundary instead of being silently accepted.
- auth/browser_login_page: cap the asset data-uri cache (lru_cache maxsize=16).
- hooks/engine: document why OnResolved stays Callable[..., None] (the runtime
intentionally supports both 5- and 6-arg callbacks; a strict Protocol/overload
rejects one valid arity — confirmed via the type gate).
- tests: backfill session_recap (3 -> 24 tests, incl. summarize_session via a
fake session), huge-new-file write render, and C1 ANSI stripping.
* feat(shell): classify destructive commands + address review comments
- soul/permission: add shell_destructive_reason() to flag irreversible
commands (recursive force-delete, force-push, hard reset, raw disk writes)
so auto mode routes them into a deliberation turn instead of auto-approving.
Reuses the shell_mutation_reason tokenizer (shlex split, wrapper unwrap,
git-subcommand extraction) for wrapper/quote/chain hardening.
- CodeRabbit review fixes: annotate /recap slash command with -> None; show
hook "timed out" status even when the hook produced output; make the
streaming-block test helper fail loudly when the label is missing.
- tests: cover destructive classification, the recap/visualize paths, and the
hardened test helper.
* style: apply ruff format to test_visualize_running_prompt
* test: silence unused kwargs in hook-timeout test lambda (CodeRabbit)
* test: silence unused kwargs in second live-view print lambda (CodeRabbit)
* fix(auth): commit browser-login brand assets needed by login page
icon.svg and favicon.ico under web/static/brand are read at runtime by
auth/browser_login_page to embed branding in the OAuth callback HTML, but the
whole web/static tree is gitignored — so CI's clean checkout lacked them and
test_openai_callback_html_* failed with FileNotFoundError (passed locally only
because the files exist on disk). Force-add the two required assets so the
feature and its tests work from a fresh clone.
* test(web): gate static-cache tests on index.html, not dir existence
Committing the brand assets makes web/static/ exist in CI for the first time,
which previously un-skipped test_index_html_has_no_cache_header — but the built
frontend (index.html, assets/) still isn't present, so GET / would 404. Guard
on index.html existence instead, matching the 'web static assets not built'
intent: runs where the app is built (local/prod), skips where only brand assets
exist (CI).1 parent 691cc49 commit ccdcb0d
50 files changed
Lines changed: 1973 additions & 130 deletions
File tree
- src/pythinker_code
- auth
- hooks
- soul
- ui
- print
- shell
- components
- selectors
- tool_renderers
- visualize
- utils/rich
- web/static/brand
- wire
- tests_e2e
- tests
- auth
- core
- hooks
- ui_and_conv
- web
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| |||
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | 231 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | | - | |
250 | | - | |
251 | | - | |
252 | | - | |
253 | | - | |
254 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
255 | 241 | | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
260 | | - | |
261 | | - | |
262 | | - | |
263 | | - | |
264 | | - | |
265 | | - | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
279 | | - | |
280 | | - | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | | - | |
289 | | - | |
290 | | - | |
291 | | - | |
292 | | - | |
293 | | - | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | 242 | | |
298 | 243 | | |
299 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
323 | 323 | | |
324 | 324 | | |
325 | 325 | | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
326 | 330 | | |
327 | 331 | | |
328 | 332 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | | - | |
20 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
21 | 28 | | |
22 | 29 | | |
23 | 30 | | |
24 | 31 | | |
25 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
26 | 91 | | |
27 | 92 | | |
28 | 93 | | |
| |||
332 | 397 | | |
333 | 398 | | |
334 | 399 | | |
335 | | - | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
336 | 409 | | |
337 | 410 | | |
338 | 411 | | |
| |||
0 commit comments