Skip to content

feat(ui): inline collapsible thinking trail#16

Merged
lavindeep merged 1 commit into
ui-reworkfrom
feat/ui-thinking-trail-toggle
Jun 28, 2026
Merged

feat(ui): inline collapsible thinking trail#16
lavindeep merged 1 commit into
ui-reworkfrom
feat/ui-thinking-trail-toggle

Conversation

@lavindeep

Copy link
Copy Markdown
Owner

Surfaces the model's reasoning inline in the full-screen app as a faint, collapsible thinking trail (DESIGN §31.19). Additive and gated — a default session with no streamed thinking is byte-identical.

What it does

  • stream_thinking now retains the thinking text (display-only — never recorded in history or fed back to the model) on a per-reasoning-phase _Trail.
  • Collapsed by default: first 10 non-blank lines under a thinking · N reasoning header; once lines are hidden, footer … +N hidden lines · press t to expand. Expanded: full trail + press t to collapse. Caret / (ASCII >/v).
  • t toggles the latest trail — the active one while the model runs, the most-recent after. Gated to an empty dock with no active approval; older trails freeze (no per-trail selection, by design). With no trail it falls through to ordinary self-insert (event.data * event.arg, repeat-count included) so a message starting with t still types.
  • Any non-thinking transcript content finalizes the active trail, so a tool call between two reasoning phases yields two separate inline blocks.
  • show_reasoning=False builds no trail; cancel/error/stale-turn cleanup clears only the active trail and never resets finished ones.
  • Every displayed thinking line is _sanitize_line-stripped (model-controlled text).

Verification

Phase gate (green):

ruff check .          → All checks passed!
ruff format --check . → 140 files already formatted
mypy shellpilot --strict → Success: no issues found in 80 source files
pytest -q             → 1447 passed

17 new tests (red-first), covering collapsed/expanded/footer wording, two-phase trails, new-turn-defaults-collapsed, abort/stale cleanup preserving finished trails, show_reasoning=False, sanitization, the show_plan_progress finalize invariant, idle-toggle cache-bust, and all t-key edges (toggle / literal fall-through / numeric-arg repeat / dock-text / during-approval).

Live validationnemotron-3-super:cloud, full-screen app (SHELLPILOT_UI=app):

❯ smallest positive integer divisible by every integer 1..10? ...
▸ thinking · 229 reasoning        ← collapsed trail, live reasoning count, thinking streamed inline
⏺ run_command(python3 -c ...)     ← model proposed a tool → trail finalized
  MEDIUM command   Approve? [y]es / [e]dit / [n]o   ← `t` correctly inert during approval
  ❯ n   ⎿ ✗ declined by user
▸ thinking · 92 reasoning         ← SECOND trail (new reasoning phase)
2520
✓ done · 45s · 321 reasoning · 762 total
  • t → latest flips to ▾ thinking · 92 reasoning + press t to collapse; the older 229 trail stays (untouched).
  • t again → back to ; dock stays empty (toggled, not typed).

Confirmed end-to-end: real cloud thinking → inline collapsible trail, two-phase blocks, latest-only toggle, finished-trail reopen, approval-mode gating, done line.

Targets ui-rework. Does not touch main.

Surface the model's reasoning inline as a faint, collapsible trail
(design section 31.19). stream_thinking now retains the thinking text
(display-only — never recorded in history or fed back to the model) on a
per-phase _Trail; the collapsed view shows the first 10 non-blank lines
under a "thinking - N reasoning" header with a "+N hidden lines - press t
to expand" footer, and the expanded view shows the full trail with a
"press t to collapse" footer.

t on an empty dock with no active approval toggles the latest trail (the
active one while the model runs, the most-recent after); older trails
freeze, with no per-trail selection by design. When there is no trail it
falls through to ordinary self-insert (event.data * event.arg) so a
message starting with t still types, repeat-count included. Any
non-thinking transcript content finalizes the active trail, so a tool
call between two reasoning phases yields two separate inline blocks.
show_reasoning=False builds no trail; cancel/error/stale-turn cleanup
clears only the active trail and never resets finished ones.
@lavindeep lavindeep merged commit 861c218 into ui-rework Jun 28, 2026
2 checks passed
@lavindeep lavindeep deleted the feat/ui-thinking-trail-toggle branch June 28, 2026 13:09
lavindeep added a commit that referenced this pull request Jul 2, 2026
feat(ui): inline collapsible thinking trail
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