Skip to content

feat(remote,tui,agent,mobile): download tiers; review overlays; one usage count; one reply - #1364

Merged
huichen merged 13 commits into
mainfrom
pr/huichen
Oct 26, 2026
Merged

huichen merged 13 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Six changes land together through the integration branch: a desktop save-as gets its own remote download tier, the workbench's review overlays and pointer navigation are refined and its preference boxes sized to their content, an agent model request counts its usage once, a superseded mobile reply settles instead of streaming twice, and the download tiers are written down with the acceptance that proves them.

The branch also carries the work that landed on dev-huichen while the PR was open, so the commit list below is the complete set of non-merge commits in origin/main..origin/dev-huichen at the frozen head ed012b3a9.

What changed

  • Remote download tiers — host/src/remote_host/files.rs and host/src/remote_peer/transfer.rs carry the tier through the prepare/pull side, including the refusal case; packages/remote-protocol/src/files.rs and packages/remote-client/src/transfer.rs add the wire field and its client half; desktop/src-tauri/src/commands/remote_peer.rs routes a save-as through the new tier.
  • Workbench review overlays — tui/src/workbench/{mod,screen,i18n}.rs refine the review overlays and pointer navigation, and fold the diff box's own title back inside it so the function stays within the argument budget; tui/examples/workbench_demo.rs and docs/guide/tui.md follow.
  • One usage count per request — agent/src/agent/run_loop.rs, agent/src/llm/adapters/openai_chat.rs, agent/src/models/mod.rs and agent/src/types/mod.rs stop a single model request from being counted twice.
  • A superseded reply settles — mobile/src/features/chat/messages/* and packages/remote-client/src/projection.ts mark the replaced reply finished instead of leaving two streaming rows.
  • Docs — docs/architecture/remote-download-tiers.md (with its Chinese counterpart) records the tiers and how each was accepted; docs/README*.md index it.

Commits

  • fix(tui): size the preference boxes to their content
  • fix(mobile): settle a superseded reply instead of drawing two streaming
  • fix(agent): count one model request's usage once
  • feat(tui): refine review overlays and pointer navigation
  • docs: record the remote download tiers and their acceptance
  • feat(remote): give a desktop save-as its own download tier

Seven merge commits sit on the branch as well (the feat/dl-tiers, fix/two-streaming, feat/usage-double-count, feat/tui-visual-audit and fix/tui-overlay-box-height task-branch merges plus two origin/main syncs); they add no content of their own beyond the commits above and the landed main history.

Verification

Run by the sweep at the earlier frozen tip 4981f4e99 with rustc/clippy 1.97.0 from rustup, in a throwaway worktree sharing the repo target directory:

  • cargo fmt --all -- --check → clean
  • cargo clippy -p future-host -p future-remote-protocol -p future-remote-client --all-targets -- -D warnings → clean
  • cargo test -p future-host --lib -- remote_host::files remote_peer::transfer → 78 passed
  • cargo test -p future-remote-protocol -p future-remote-client → all passed
  • cargo check -p futureos → clean (the desktop command compiles against the new protocol field)

Re-checked at the current frozen tip ed012b3a9 with rustc/clippy 1.99.1 (the toolchain pinned by rust-toolchain.toml after #1363):

  • cargo clippy --locked -p future-tui -p future-cli --all-targets -- -D warnings → clean
  • cargo clippy --locked -p futureos --all-targets -- -D warnings → clean
  • cargo fmt -p future-tui -p future-cli -p futureos -- --check → clean
  • cargo test -p futureos --lib → 364 passed

Notes

  • The protocol change is additive: packages/remote-protocol gains a field rather than reusing one, so an older peer keeps its existing single-ceiling behaviour.
  • No default limit changes for an existing save path; only the interactive save-as moves to the new tier.
  • Rust was upgraded to 1.99.1 and Tauri to 2.12.5 on main in chore: upgrade Tauri to 2.12.5 and Rust to 1.99.1 #1363; this branch merged origin/main afterwards and builds with it.
  • The earlier frozen head e3a137378 failed the tui-cli and desktop clippy jobs on too_many_arguments in diff_review_box; that call shape is fixed by the newest commit in this list, so the failure belonged to the stale head rather than to the branch.

huichen and others added 9 commits October 26, 2026 10:47
A desktop saving a file from a paired host was measured against the phone's
rules — 10 MiB and a type allow-list — so a 12.5 MB installer was refused
with advice to use the desktop panel it was already using.

The limits are a phone's, and right for a phone: previews decode inside
10 MiB, its reader acts on a fixed set of types, a tap can be metered. A
desktop writes bytes to a path the user chose and shares none of that.

`download_prepare`'s mode now names the client's intent: a new `download`
variant carries the desktop tier (512 MiB, no type list), chosen as the
pulling client's own `MAX_DOWNLOAD_BYTES` so the host never prepares what
the client must refuse. The phone's variants, thresholds and wording are
untouched, and an unimplemented mode is still refused before the file is
judged. A host that predates the variant answers a matched refusal and the
desktop asks again for `original` — today's request, today's outcome.
The split needs to be findable by the next session that wonders why a
download has two ceilings: what each tier is for, where 512 MiB comes from,
which refusals say which sentence, and what was measured on 2026-10-26 —
including the network-scale test that was not run and the two costs that
wait for it.
The Future gateway ends a streaming request with more than one usage block:
a coarse frame it synthesizes itself (no cache breakdown, an estimated
prompt) and then the provider's real block, which also arrives on the
trailing empty-choices chunk. process_usage_event added every block to the
session counters, so one request became two records: on a
future/kimi-k3.1-pro session with 526,759 real prompt tokens and 526,336
served from cache, input summed to 1,133,921 and the hit rate read 46%
instead of 99.9%.

Tokens are now folded per call, like cost already was: process_usage_event
merges the call's blocks (the block with the cache breakdown wins, the later
one breaks ties, a missing field never overwrites a present one) and the
call's total reaches the counters once, in charge_request_usage. The
compaction summary observer follows the same rule, and a block that claims
more cached bytes than prompt tokens now warns (and trips a debug assert),
so a regression of this shape cannot pass unnoticed.

Also add models::cache_hit_rate as the single definition of the ratio
(cache_read / prompt, because prompt_tokens includes the cached subset) and
report it as tokens.cacheHitRate in get_session_stats.
The live lane is at-most-once per event, so an `agent_end` can be dropped. A
reply whose terminal never reached the client kept its generating flag — and
its clock — until some later reconcile happened to settle the whole lane; once
the next prompt's run started, the transcript drew two generating dots at once,
one of them counting past three hours (reported on a phone, 2026-10-26).

The Agent runs one turn per session, so a newer run's own events prove the
older reply is over. Settle it the way the desktop labels a stream that ended
without a terminal (`[RESPONSE_UNCONFIRMED]`), and drop the live clock with the
flag. Only a reply stamped with a different run id is touched: two runs cannot
interleave, and a compaction frame carries the surrounding run's identity
rather than a write of its own.

A call whose result never arrived keeps `status: "running"` in the projection —
no event will ever say otherwise — so the reply now tells the row it has
stopped: in a settled reply an unfinished call reads "interrupted" instead of
"running" (the desktop's own RunsPanel rule).
@huichen
huichen enabled auto-merge (squash) October 26, 2026 02:56
@huichen huichen changed the title feat(remote,desktop): give a desktop save-as its own download tier; record the tiers feat(agent,remote,tui): count one model request's usage once; download tiers; TUI visual audit Oct 26, 2026
@huichen huichen changed the title feat(agent,remote,tui): count one model request's usage once; download tiers; TUI visual audit feat(remote,tui,agent,mobile): download tiers; review overlays; one usage count; one reply Oct 26, 2026
box_geometry was handed the window height when a list scrolled, so a tall terminal stretched the preference and shortcut boxes to almost the whole frame and left the rows pinned to its top edge. Pass the rows actually drawn, and fold the diff box's own title back inside it so it stays within the argument budget.
@huichen
huichen merged commit a8e728e into main Oct 26, 2026
31 checks passed
@huichen
huichen deleted the pr/huichen branch October 26, 2026 04:03
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