Repository navigation
fix(thread-projection): keep a bodyless reasoning row after a tool call - #850
Merged
Merged
Conversation
The lean lane's client half (#844/#846) is three reads: a reasoning row from its boundary alone, a tool target from `tool_start`'s complete arguments, and a tool outcome from `tool_end`'s structured fields. They are covered by unit tests against the projector, but nothing had fed them to the screens the phone actually draws. This adds a render fixture set and five screenshot-harness scenarios: - `scripts/screenshots/gen-lean-render-fixtures.mjs` authors the full-feed wire shapes (live lane and history page) and derives the lean ones through the shipping Rust trims (a new ignored test in `remote_host::lean`, driven the same way `measure-lean-history.py` drives its measurement) — so a capture cannot test a hand-trimmed paraphrase of the wire. - `?leanRender=<mode>` feeds those slices to the real conversation screen; the projection, components, i18n and layout stay the shipped implementation. - The scenarios assert the three reads plus the control: the same run as the full feed must not regress (reasoning body, `[exit: N]` outcome path), and the trimmed payloads must stay off screen. The mid-run scenario reproduces a real bug in the client half, fixed in the next commit: a bodyless reasoning slot after a tool call was swallowed by the tool run's "hop over whitespace-only text".
`buildSegments` gathers a run of adjacent tool slots while hopping over whitespace-only text between them. The hop tested `!current.text.trim()` for every slot type, so a reasoning slot with no body — the normal case in the lean feed, whose deltas are never published — read as whitespace and was dropped: its row disappeared, and the tool calls on either side of it were glued into one burst. Only a text slot can be glue between tools. A bodyless reasoning row after a tool call (the live tail of a run that thinks again, or between two calls) now renders, with a regression test for both shapes.
huichen
enabled auto-merge (squash)
September 25, 2026 18:11
The generator test was added while working in the mobile harness, so the desktop backend's rustfmt was never run on it. CI's `cargo fmt --check --manifest-path desktop/src-tauri/Cargo.toml` caught it. No behaviour change: rustfmt only.
huichen
added a commit
that referenced
this pull request
Sep 25, 2026
Merging origin/main brought the lean render-verification fixtures (#850), which are generated *through* the shipping trims — so this change's trim (a shell call's arguments are now fetched on open, not carried by the page) has to regenerate them, and the generator's self-check has to assert the new rule (file rows keep a path, shell rows keep nothing). The harness also answers the on-open fetch from the full page, so the history scenario keeps asserting that the command appears after the tap — now through the same lazy path the phone uses. Falsified by making the mock resolver return null: the scenario then fails with 'the history row target is wrong'. Re-captured locally on http://localhost:8098: lean-render-history, -live, -live-mid, -full, -full-history all pass (the live lane still shows commands — it never trimmed them).
huichen
added a commit
that referenced
this pull request
Sep 25, 2026
* perf(remote): fetch a lean shell row's command on tap A lean history page kept every shell call's arguments, and on the heaviest sessions the commands alone were ~1/3 of the page a phone actually reads — bytes no phone surface shows until the row is opened. The trim now drops a shell-like call's `arguments` whole (read/write/edit keep the path keys their row label is derived from), and the row fetches its command back by identity when it is opened: - agent: `get_tool_call_args` reads one call's name/arguments from message_blocks by (session, run, tool_call_id), mirroring `get_tool_output`. - desktop remote host: the command is reachable only while the client's `lean_events_v1` declaration is in force; undeclared clients get the same "Unsupported command" an older bridge would give, and their pages still carry every argument (behaviour unchanged). - mobile: a history tool row with no target and a call identity fetches it on tap through `useConversationController` (cached per session+run+call, so a virtualized remount never re-asks), shows the command, and leaves the row exactly as it was when the fetch fails. * chore(scripts): audit a real lean page's trim shape The measurement script reports bytes; this one reports the shape behind them — which argument keys a shell row keeps versus loses, and that the toolCallId and runId a lazy fetch needs survive — through the same shipping Rust trim. * test(remote): keep the lean render fixtures in step with the trim Merging origin/main brought the lean render-verification fixtures (#850), which are generated *through* the shipping trims — so this change's trim (a shell call's arguments are now fetched on open, not carried by the page) has to regenerate them, and the generator's self-check has to assert the new rule (file rows keep a path, shell rows keep nothing). The harness also answers the on-open fetch from the full page, so the history scenario keeps asserting that the command appears after the tap — now through the same lazy path the phone uses. Falsified by making the mock resolver return null: the scenario then fails with 'the history row target is wrong'. Re-captured locally on http://localhost:8098: lean-render-history, -live, -live-mid, -full, -full-history all pass (the live lane still shows commands — it never trimmed them).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found while verifying the lean lane through the real render surface, and it is a real regression from #844.
The bug
#844 let
buildSegmentsemit a reasoning segment with no text, because the lean feed never streams reasoning deltas and the row is still the only indication that the model reasoned. What it missed: the tool-run gathering loop hops over whitespace-only slots, and it tested!current.text.trim()for every slot type:A bodyless reasoning slot therefore read as whitespace and was swallowed. Two symptoms, both from the same line:
This is the normal case in a lean feed, not an edge case: any run that thinks again after a tool call hits it.
The fix
Only a whitespace-only text slot can be glue between tools, so the test is now narrowed to that type. A bodyless reasoning slot falls through to the
break, which flushes the tool run; the outer loop then emits the reasoning slot as its own segment and starts a fresh run after it. One condition, no restructuring.Verification
a reasoning row after a tool call survives with no body.tsc --noEmit+eslintclean.@future-os/thread-projectionto this worktree): 145 files / 1255 tests pass;tsc+eslintclean.Also in this PR
A render fixture set plus five screenshot-harness scenarios that feed the real conversation UI the lean lane's three reads (reasoning row from its boundary, tool target from
tool_start, tool outcome fromtool_end's structured fields). The fixtures are derived by the shipping Rust trims — a new ignored test inremote_host::lean, driven the waymeasure-lean-history.pydrives its measurement — so a capture cannot test a hand-trimmed paraphrase of the wire. The generator self-checks that no dropped event type and no stripped field survived.That is how the bug above was found: unit tests against the projector never exercised the tool-run gathering path with an empty reasoning slot.
Captures are gitignored; the scenario and generator are reproducible from the committed commands.