Skip to content

fix: thinking-box polish — six small correctness fixes#19

Merged
shoom1 merged 6 commits into
developfrom
fix/thinking-box-polish
Jun 12, 2026
Merged

fix: thinking-box polish — six small correctness fixes#19
shoom1 merged 6 commits into
developfrom
fix/thinking-box-polish

Conversation

@shoom1

@shoom1 shoom1 commented Jun 12, 2026

Copy link
Copy Markdown
Owner

Six independent fixes, one commit each:

  1. expand_key wired into the hintThinkingBoxControl was always created with its default (c-t), so a custom AppInfo.expand_key changed the binding but the hint still read ctrl-t to expand. The manager now forwards expand_key to every box.
  2. StreamingContent.set_line() negative-index bounds — an out-of-range negative index now raises a clear IndexError naming the caller's index, leaving content untouched.
  3. Per-box truncation in deprecated finish_thinking()finish_all() reports each box's max_collapsed_lines (5th tuple element) and finish_thinking() uses it instead of the session-wide max_thinking_height, matching ThinkingContext.finish().
  4. Renderer-safe clear() — screen clearing goes through app.renderer.clear() while running (raw \033[2J writes desynced the renderer); escape-code fallback when not running. Display.clear() now handles only its own state.
  5. ANSI-aware line countingget_line_count() strips SGR escapes before width math, so styled ansi-format content no longer renders an oversized box.
  6. Header width tracks the terminal — the separator was hardcoded to 80 columns; it now reads the running app's output size (fallback 80).

Each fix has a regression test. Identified in docs/notes/project_review_20260612.md (findings 5–7).

shoom1 added 6 commits June 12, 2026 13:07
ThinkingBoxControl was always created with its default expand_key
("c-t"), so a custom AppInfo.expand_key changed the actual binding
but the truncation hint still read "ctrl-t to expand". The manager
now takes expand_key and forwards it to every box it creates.
StreamingContent.set_line(-5, ...) on shorter content fell through
normalization still negative, skipped the extend loop, and failed on
the list assignment with an error naming the normalized index. It now
raises immediately with the index the caller passed, and leaves the
content untouched.
finish_all() now reports each box's max_collapsed_lines, and
finish_thinking() uses it instead of the session-wide
max_thinking_height — matching the per-box finish path used by
ThinkingContext.finish(). Boxes created with a custom max_lines were
previously truncated to the wrong limit on the deprecated path.
Display.clear() raw-printed \033[2J\033[H to stdout, bypassing
prompt_toolkit's renderer. With the app running, the renderer's idea
of what is on screen goes stale and the next repaint draws against
the wrong baseline. Screen clearing now lives in
ThinkingPromptSession.clear(): app.renderer.clear() when running,
escape-code fallback when not. Display.clear() handles only its own
state (history buffer + pending output).
get_line_count measured raw len(line), so SGR escape sequences in
ansi-format content inflated the wrapping estimate and the collapsed
box was sized taller than its visible content. Escape sequences are
now stripped before width math.
The header line was rendered at a hardcoded 80 columns, so it never
spanned wider terminals and overflowed narrower ones. The width now
comes from the running app's output size, falling back to 80 outside
a running app.
@shoom1 shoom1 merged commit 3addf7d into develop Jun 12, 2026
@shoom1 shoom1 deleted the fix/thinking-box-polish branch June 12, 2026 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant