Repository navigation
perf(remote): trim the history page a phone does not read - #846
Merged
Merged
Conversation
The lean declaration covered the live lane; the durable history read was
still sending every reasoning body, every tool output and every tool-call
argument. Measured through the shipping trim over the three heaviest real
sessions (`scripts/measure-lean-history.py`):
entries before MiB after MiB saved
6300 11.74 3.86 67.1%
2462 4.57 1.25 72.7%
2166 3.56 1.12 68.4%
Three payloads, each unread rather than merely unrendered:
- reasoning body (25.6-32.2% of a page). The block stays, so the row that
says the model reasoned still appears.
- tool-result body (22.0-26.5%). `foldToolEntry` reads `toolCallId` and
`isError` and nothing else.
- tool-call arguments beyond the four a target can come from
(12.3-17.8%). `targetFromArgs` reads `command`, `path`, `file_path` or
`filePath` and no other key for any tool name, so keeping exactly those
four is behaviour-preserving even for a tool this client has never seen.
Nothing here adds, removes or reorders an entry or a block, so a page's
`nextOffset`/`hasMore`/flush-cursor arithmetic and the client's gap-fill are
untouched. It is applied *before* the page byte budget rather than after:
the budget sheds whole oldest exchanges to fit one reply, so measuring the
trimmed page is what lets it hold more of them per round trip.
Both history shapes are trimmed — the paged read the phone actually uses
(`before` + limit) and the full read — because they are separate code paths.
The reasoning row needed the client half of the same change: the shared
projection only produced a thinking segment when the block had text, which
is exactly what a lean page does not send. It now projects the row from the
block's presence, matching what the live lane already does.
Same declaration as the lean event lane: it is the same client generation,
because the reasoning row, the tool target and the tool outcome are precisely
the three things that generation reads differently.
huichen
enabled auto-merge (squash)
September 25, 2026 17:25
huichen
added a commit
that referenced
this pull request
Sep 25, 2026
…ll (#850) * test(mobile): verify the lean lane through the real render surface 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". * fix(thread-projection): keep a bodyless reasoning row after a tool call `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. * style(desktop): rustfmt the lean fixture generator 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.
This was referenced Sep 25, 2026
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.
Follows #844, which did this for the live event lane. The durable history read was still sending every reasoning body, every tool output and every tool-call argument.
Effect
Through the shipping trim over the three heaviest real sessions (
scripts/measure-lean-history.py, which dumps a session'sget_session_entriesreply from the live read-only agent and runs the real Rust rewrite over it):Measured per payload:
Why each one is a removal, not a fidelity trade
targetFromArgsreadscommandfor a shell call andpath/file_path/filePathotherwise, and reads no other argument key for any tool name — an unrecognized name is treated asshelland still only readscommand. Keeping exactly those four keys is therefore behaviour-preserving even for a tool this client has never seen.foldToolEntryreadstoolCallIdandisErrorand nothing else.Two properties that keep it safe
It never changes structure. Nothing adds, removes or reorders an entry or a block — entries keep their identity and count — so a page's
nextOffset/hasMore/flush-cursor arithmetic and the client's gap-fill are untouched. (The event lane needed careful cursor handling for exactly this reason; here it is a field-level shrink.)It runs before the byte budget, not after. The budget sheds whole oldest exchanges to fit one reply, so measuring the trimmed page is what lets it hold more of them per round trip.
Both history shapes are covered — the paged read the phone actually uses (
before+ limit) and the full read — because they are separate code paths. The first falsification attempt is what caught that: I made the trim unconditional on the paged path only, and the test still passed, because it was exercising the other one.The client half
The reasoning row needed a matching change in the shared projection: it only produced a thinking segment when the block had text, which is precisely what a lean page no longer sends. It now projects the row from the block's presence — the same fix the live lane already received in #844. Without it, a lean history page would show no reasoning rows at all.
Verification
cargo fmt --check+cargo clippy --all-targets -D warningsclean on pinned 1.97.tsc --noEmit+eslintclean. Desktop TS (consumes the shared projection package): 145 files / 1255 pass;tsc+eslintclean.targetFromArgstopathalone fails the new argument-key test — which is how I found that test was only covering one of the four keys.Follow-ups, deliberately not in this PR
MessageUsage/MessageRunstill serialize their unset sub-fields ("error":nullon nearly every entry). Worth 79.9 KiB = 0.66% of a full page, 2.0% of a trimmed one. It belongs with perf(rpc): omit unset and empty optionals from history entries #842's class of change rather than here: every change in this PR is capability-gated, and mixing in an ungated field change would blur the rollback boundary.tool_resultblocks in the journal haveis_errorNULL and none is true, sofoldToolEntryhas no failure signal to read and every history tool row renders as completed. Removing the output text does not change that. Fixing it means writing the flag (or an exit code) at record time.