Repository navigation
perf(remote): fetch a lean shell row's command on tap (#851) - #851
Merged
Merged
Conversation
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.
huichen
enabled auto-merge (squash)
September 25, 2026 18:18
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.
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 was referenced Sep 25, 2026
huichen
added a commit
that referenced
this pull request
Sep 25, 2026
… shape (#855) The render fixtures froze the pre-#848/#849 wire: every history `tool_result` spelled out `isError` — `false` on the exit-127 failure and on the successes (which never carry a flag now), and `true` only on a hand-authored probe row. `lean-render-history` asserted that shape, so it would have stayed green against a page the phone no longer receives. - the full fixture records the real failure (`isError: true` on the exit-127 call) and omits the uninformative flag everywhere else (#849); - the lean page is regenerated through the shipping trim, and the generator's self-check asserts the shape on both the full page and its trimmed form; - both history scenarios flip: the exit-127 row reads 运行失败 (its command still arrives through the on-open fetch #851 added) and the soft-fail grep reads 已运行. lean-render-full-history's single failing row is that same recorded failure. Verified in the real mobile render surface: all five lean scenarios pass, the two new assertions were falsified (dropping the fetch trigger and restoring the old `isError: false` shape each fail the step), and the live full-feed `failed === 2` check still holds.
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.
A lean history page kept every shell call's
arguments, and on the heaviest sessions the commands alone were ~1/3 of the bytes a phone actually reads — bytes no phone surface shows until the row is opened. The trim now drops a shell-like call'sargumentswhole (read/write/edit keep the path keys their row label derives from), and the row fetches its command back by identity when it is opened.get_tool_call_argsreads one call'sname/argumentsfrommessage_blocksby(session, run, tool_call_id), mirroringget_tool_output(miss = explicit nulls, never another call's arguments).lean_events_v1declaration is in force. An undeclared client gets the sameUnsupported commandan older bridge would give, and its pages still carry every argument (behaviour unchanged).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. The page and the row carrytoolCallId+ the entry'srunIdfor exactly this.Measured (real sessions, shipping trim, per phone page)
python3 scripts/measure/measure-lean-history.py --sessions 3 --pages 3(new--pagesmode: the phone's own backward pages, 3 user exchanges each, newest first; the trim and byte counts run in the shipping Rust code):First page (first screen) of the top session: 236 entries, 396,653 B untrimmed → 168 KiB under the old trim → 109,527 B now (−34.8% vs old). Average per-page saving vs the old trim 27.9% (12.5–50.0%).
Validation
cargo test -p future-agent --lib get_tool_call_args(hit/miss/cross-session/cross-run) — 1882 lib tests green.cargo test -p future-rpc --lib(command policy).cargo test --lib remote_host::lean(trim unit tests) and the two bridge e2e testslean_history_trims_only_for_a_client_that_declared_it/tool_call_args_is_reachable_only_for_a_client_that_declared_lean(declared vs undeclared, identity forwarded to the agent, missing identity refused locally, withdrawal takes the command away).npx jest --runInBand(2060 tests),tsc --noEmit,eslint; desktopnpx vitest run(1255 tests) for the shared-package consumers.--all-targets -D warningsonfuture-agent,future-rpcanddesktop/src-tauri.Real-data audit: the newest page of the heaviest session keeps
toolCallIdon all 120 calls andrunIdon all 113 assistant entries, while shell rows losearguments(file rows keeppath); the same call resolves in the liveagent.dbtoshell|{"command":"cd ... && git ..."}. A running agent that predates this change answersunknown command: get_tool_call_args, which is exactly the failure the row must (and does) tolerate.