Skip to content

feat(choice): answer cards on the remote desktop; cheaper builds, CI plans, markdown fences - #1616

Merged
huichen merged 17 commits into
mainfrom
pr/huichen
Nov 15, 2026
Merged

huichen merged 17 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 15, 2026 •

Copy link
Copy Markdown
Collaborator

Lands the choice-card answer path on the remote desktop and the send queue, plus a pass over local build and CI cost, a markdown fence-nesting fix, and a TUI driver test that no longer overflows its stack.

A futureos-choice card can now be answered with nothing typed: the pick travels with the prompt into the queue, a waiting row shows a chip naming the answer, and that chip re-offers the card's own options so the pick can be changed before the message leaves. The same chip exists on the phone. On the build side, dev/test drop to line-tables-only debuginfo and make test-* goes through cargo nextest (falling back to cargo test), with the Actions-cache quota and target/debug/incremental cleanup documented and scripted.

Commits

  • feat(choice): answer cards on remote desktop, and carry the pick into the queue
  • docs(choice): record steps 1–8 as implemented, and whitelist the prompt asset
  • test(choice): pin the two things the design says must not break
  • refactor(choice): one signature for a changed queued answer
  • perf(build): cut local build cost with line-tables-only debuginfo and nextest
  • perf(ci): reclaim the Actions cache quota and document build-speed tooling
  • style(desktop): order the choice-card imports
  • perf(ci): make the npm-cache and Windows-agent plans executable
  • fix(markdown): read a quoted document fence as nested
  • test(tui): run the empty-detail driver test on a big-stack thread

Verification

Local, with the pinned toolchain (rustc 1.99.1, Homebrew 1.96.0 shadowed) and ulimit -n 8192:

  • cargo fmt --all -- --check — clean
  • cargo check -p future-rpc -p future-agent -p future-host -p future-tui -p future-remote-protocol --all-targets — clean
  • cargo test -p future-rpc --lib — 272 passed, 0 failed
  • cargo test -p future-host --lib — did not finish: stopped at 470 s with no failure reported (future-host lib tests took 457 s on 2026-11-14, so this is a timeout, not a red). CI is the backstop for that crate.
  • desktop: npx tsc --noEmit clean; npx vitest run on the five changed test files (ChoiceCardAnswer, SendQueuePanel, agentQueue, RemoteComposer, remoteComposerDraft) — 135 passed
  • mobile: npx tsc --noEmit clean; npx jest on the two changed test files (sessionQueue, SendQueuePanel) — 33 passed
  • cargo test -p future-tui --lib workbench::run::driver_tests — 69 passed (at 81f71baf0, and again after rebasing onto the branch tip); cargo fmt -p future-tui -- --check and cargo clippy -p future-tui --all-targets -- -D warnings clean

The last commit is a CI follow-up: the first run's ESLint and applicable Stylelint step failed on perfectionist/sort-imports in three files this branch touches (RemoteChoiceChip.tsx, RemoteComposer.test.tsx, agentClient.ts). 065fb2e4c only reorders those imports; npx eslint on the three files reports 0 problems, npx tsc --noEmit is clean, and RemoteComposer.test.tsx still passes 89/89.

The first four commits were self-tested at 5b1bcbc53; the two perf commits, refactor(choice) and the lint follow-up landed on the branch afterwards, and the frozen tip was re-checked with fmt + cargo check.

81f71baf0 follows a red Rust Linux test / tui-cli and Rust Windows test / tui-cli that aborted with a stack overflow in workbench::run::driver_tests::workspace_panel::a_row_with_no_body_keeps_the_detail_pane_a_box. The cause is a single debug frame, not recursion: that async test had 1,058,609 bytes of locals and awaited futures on its thread before its first statement, which overflows the 2 MiB test stack on Linux and the 1 MiB one on Windows while macOS happened to fit. The test now runs its body unchanged on a 32 MiB thread through the same with_big_stack helper live::tests already uses for this reason; no assertion was relaxed, no test disabled, no global RUST_MIN_STACK introduced.

User-visible changes

  • Answering a choice card from the remote desktop: before, answering a futureos-choice card needed typed words, and a pick taken from a waiting row could not be changed after it was queued. After, a pick alone makes the prompt sendable, the sent sentence is prefixed with the answer ([question → answer] before the words), and a queued row carries a chip that re-opens the card's options so the pick can be switched or cleared. Older clients are unaffected: the new choice field is absent for prompts that answered no card. Rollback: 16e7e5e9d (feature), 55a0e0337 (the single-object handoff signature).
  • Phone queue rows get the same chip; the row's existing pencil and bin keep their meaning. Rollback: 16e7e5e9d.
  • Local Rust builds: [profile.dev] / [profile.test] now use debug = 1 (line tables only) instead of Cargo's default 2. Before, a cold cargo build -p future-agent took 50 s and 2,608 MB in target/debug; after, 37 s and 1,911 MB. Panic backtraces keep file.rs:LINE; line coverage is unchanged (llvm-cov on future-config: 135 lines / 114 hit under both). Cold cargo nextest run -p future-agent --no-run: 79 s → 64 s. Rollback: 216c37da9.
  • make test-* now runs scripts/run-rust-tests.mjs, which uses cargo nextest when installed and falls back to cargo test otherwise, so a fresh clone still works. make test-desktop-rust stays on cargo test because gui_main_thread_drive is harness = false. Rollback: 216c37da9.
  • New manual maintenance scripts: scripts/ci/prune-node-caches.sh (lists, and with --apply deletes, the per-ref node-cache-* entries; needs only repo scope) and scripts/dev/prune-target-incremental.sh (deletes target/debug/incremental, refuses while a cargo/rustc process is alive). Neither runs automatically. Rollback: d830ba893.
  • Markdown fences: a fenced block quoted inside another fence is now read as nested content instead of closing the outer block, so a document that shows a fence example no longer renders the rest of the document as code (or loses it). Applies to every client that renders through @future-os/markdown (desktop, mobile web views). Rollback: e1e44b7ce.
  • CI plans: the affected-projects plan can now select the npm-cache and Windows-agent work that was documented but never executed; developers see those jobs actually run on the matching diffs. No product behaviour. Rollback: e789271db.

Notes

  • The wire change is additive only: QueuedRunChoice on RpcCommand.choice (field 193) and QueuedRunState.choice (field 9). No existing field number moved.
  • undefined for an absent answer is deliberate — it does not survive JSON, so a relay writes exactly the bytes it wrote before.
  • The two perf commits change workflow files and scripts; the CI cache fix that would stop writing per-ref npm caches needs workflow scope this machine's token does not have, so it stays documented rather than applied.
  • test(tui) is a test-harness change only: it fixes a stack overflow the debug frame of one driver test caused on Linux and Windows. No product behaviour.

… the queue

Steps 5 and 7 of docs/design/choice-cards.zh-CN.md §11, the two the first
pass left undone.

Remote desktop (§5.4, step 5). The peer drew the card already — it goes
through the same `MessageBlock` — but nothing could be clicked: the answer
lived only in the local composer. `RemoteComposer` now keeps it in its own
draft, offers it as a chip above the field, folds it into the sent text in
`sendNow` (the one path that puts text on the wire), and exposes
`selectChoice` so the transcript can write a pick back. The disable
conditions are the part that matters: `hasDraft` counts the answer, because
`(!text.trim() && uploads.length === 0)` would otherwise keep Send grey for
a reader who has answered and typed nothing — the exact bug the design
records in §5.2.1.

Queue (§5.8, step 7). A queued message drawn from a card now carries the
pick, not just the sentence it wrote. `QueuedRunState` grows a `choice`
field beside `attachments` — the same precedent — so the row can offer the
card's other options instead of asking the reader to re-type a sentence.
On the desktop and the phone the chip *is* the button: those rows already
have a pencil for their words, and a second one a few pixels away meaning
something else is the ambiguity the whole design exists to remove. Changing
a pick rewrites the bracketed head of the text and leaves whatever the
reader typed after it alone, so `edit_queued_run` stays the one path.

Wire: `RpcCommand.choice`, `QueuedRunChoice`, and an `edit_queued_run`
that carries the pick alongside the new text. Absent means "no change";
an empty `selectedIds` is a real answer and stores the card without a pick.
…pt asset

The design doc's status line still said steps 1–3, written before the remote
and queue work landed. It now names 1–8 and says plainly that step 9 — the
visual regression that swaps the injected prototypes for the real
components — is the one left.

Two §11 entries described the implementation differently from what shipped,
so they are corrected rather than left to mislead the next reader: the queue
row opens its options through a portal-positioned `SelectMenu` (not
`ChoicePopover`, which is positioned inside the editor's wrapper), and the
phone's `ChoiceSheet` is owned by `ComposerDock` because a sheet is a `Modal`
and does not belong inside a list of rows.

`check-docs` was failing on main because `agent/src/prompt/choice.md` — a
compiled prompt asset loaded through `include_str!`, like its four
neighbours — was never added to the placement whitelist.
No production code changes — the assertions the first pass owed.

Remote (step 5). The acceptance is not "the card has a button", it is "a pick
goes out with nothing typed". `hasDraft` is what decides that, so the test
that guards it was mutated to prove it: dropping `choice !== null` from
`hasDraft` turns exactly one test red — "is sendable with nothing typed" —
and restoring it brings back 89/89. Mutating the send order (`[answer] words`
→ `words [answer]`) reddens the other one. Both are state assertions, not
screenshots.

Drafts written before the answer field existed now have two cases. They are
built the way this build actually wrote them — save through the public API,
delete the `choice` key — rather than hand-written JSON, so the test cannot
drift from the real envelope. A loader that demanded the key reddens both,
plus the two older shape tests.

Queue (step 7), both panels rather than one:

- Wire compatibility: absent `choice` stays `undefined` (never an invented
  empty answer), a malformed answer is dropped, and an answer with no option
  left to switch to is not offered — because a chip that opens an empty list
  is worse than no chip. A mutant that turns absent into `{}` reddens five
  tests across the two surfaces.
- Serialized shape: `undefined` does not survive JSON, so a relay writes the
  same bytes it always wrote. Asserted on `JSON.stringify`, not on the parsed
  key list, which would pin an in-memory detail the `attachments` precedent
  already settles the other way.
- Render, desktop: the chip is a BUTTON carrying one non-pencil icon, it
  opens the card's own rows, and picking returns the whole answer (not just
  an id — the question and the other options have to survive). The row's own
  pencil and bin stay exactly one each. Swapping the chevron for a pencil
  reddens that, which is the point: two pencils a few pixels apart meaning
  different things is the ambiguity the design exists to remove.
- Render, phone: same constraint on the separate implementation — one chip,
  the row's `send-queue-edit` and `send-queue-remove` untouched. Renaming the
  row's pencil reddens it.

Mobile queue parsing had zero `choice` coverage before this; it has the same
three cases now, and the pre-existing "rows come back in the session's own
order and shape" test turned out to guard the invariant too.
The desktop panel handed a change up as the whole answer; the phone handed up
the picked ids and rebuilt the object from the row. Same name, two meanings —
the kind of drift that makes the next change wrong on one surface only.

The object wins. An id list cannot gain a field (a note attached to an answer,
say) without the signature changing again, and rebuilding from the row on the
phone silently dropped whatever the caller knew and the row did not. No dual
signature is kept: this is an internal handoff with no outside consumer, and
accepting both shapes would let the mistake be written again.

Two assertions, one per surface, and each proves the shape rather than the
behaviour: `Array.isArray(answer)` is false and the object carries the card's
question and every option. Reverting either side to ids reddens exactly its own
test — checked both ways. Behaviour alone was not enough to lock this: a handler
that rebuilt from the row still passed, which is precisely the bug the change
removes.
… nextest

Local iteration is Cargo, and two settings were leaving money on the table.

`dev`/`test` kept Cargo's default `debug = 2` (full type and variable
debuginfo). Line tables are all a panic backtrace needs for `file.rs:LINE`,
so `debug = 1` keeps a failing test's location and halves the artefacts:

    cargo build -p future-agent, cold, 32-core Mac
      default  50 s  2,608 MB in target/debug
      debug=1  37 s  1,911 MB
    cargo nextest run -p future-agent --no-run, cold
      default  79 s  4,179 MB
      debug=1  64 s  3,261 MB
    incremental rebuild after a one-line edit: 601 ms vs 612 ms (unchanged)

`debug = 0` is not used: it was measurably slower cold than `1` (44 s), because
rustc then redoes work it would otherwise reuse, and it drops backtraces to
`??`. Line coverage is unaffected — `cargo llvm-cov` on `future-config` reports
the same 135 lines found / 114 hit (84.4%) under both levels, because llvm-cov
maps hits through exactly these line tables.

`make test-*` now go through scripts/run-rust-tests.mjs, which runs cargo
nextest with one process per test and falls back to `cargo test` when nextest
is not installed, so a fresh clone still works before anyone installs it. This
mirrors CI, which #1614/#1615 already moved to nextest; measured warm on this
workspace: `future-goal` (1301 tests) 8 s against 50 s for `cargo test
--no-fail-fast`, because libtest serialises per test binary and lets the slowest
one set the lane's wall time. `test-desktop-rust` stays on `cargo test`:
`desktop/src-tauri`'s `gui_main_thread_drive` target is `harness = false`, so
nextest exits while enumerating it.
…oling

The repository-wide Actions cache quota is 10 GB and only `refs/heads/main`
entries are restorable, so a per-ref entry is pure liability: it takes quota
nobody else can read and evicts the entries that were hitting.

Measured 2026-11-15: 27 entries / 10.19 GB, of which 21 entries / 6.40 GB were
`node-cache-*` written by actions/setup-node with `cache: npm`. That keys the
tarball by ref, so each PR wrote its own ~318 MB (Linux) + ~305 MB (macOS) copy
— once per closed PR, plus one on `dev-huichen` — while the six `v0-rust-*`
entries the Rust lanes actually restore (0.48–0.94 GB each) were being evicted
to make room.

scripts/ci/prune-node-caches.sh lists those entries and deletes them with
`--apply`. Deleting a cache needs only `repo` scope, not `workflow` scope, so it
runs on a machine whose token cannot push workflow edits. Applying it took the
total from 10.19 GB to 3.79 GB with all six Rust entries intact.

The durable fix — stop writing per-ref npm caches — belongs in the workflow
(setup-node without `cache: npm`, or saving only on main), because `npm ci` still
measures 27–88 s per TypeScript job and the cache is worth keeping where it can
be shared. That change needs `workflow` scope this machine does not have.

scripts/dev/prune-target-incremental.sh reclaims target/debug/incremental, which
is regenerable accelerator state and was 67 GB of a 148 GB `target/` on a volume
down to 54 GB free; it refuses to run while a cargo/rustc process is alive.
Deleting it cost one cold rebuild (5.8 s for `cargo check -p future-config`).

Documents both scripts, the profile levels, `--profile local` and the nextest
fallback in build-and-install.md/.zh-CN.md, and the quota arithmetic in
ci.md/.zh-CN.md.
@huichen huichen changed the title feat(choice): answer cards on the remote desktop and carry the pick into the queue; leaner dev/test builds feat(choice): answer cards on remote desktop and carry the pick into the queue; cheaper dev builds Nov 15, 2026
Both remaining CI items were prose with no numbers or file coordinates, so
whoever picks them up had to re-investigate. Write them as checklists against
this tree, and land the half that is not blocked on a `workflow` token.

Cache quota: the seven `cache: npm` sites are enumerated with file and line, and
the durable shape is a restore-only `actions/cache/restore` step whose key omits
`github.ref`, because a per-ref write is invisible to every other PR. Removing
the cache outright is explicitly ruled out: `npm ci` cost 883 s over 22
invocations (mean 40.1 s, max 88 s) in run 43637520669.

Runner cost: measured run 43637520669 at 22.4 min wall clock over 51 jobs, with
peak concurrency 20 and a single job -- Rust Windows test / agent -- occupying
21.9 of those minutes at Build 245 s + Tests 981 s. Its 981 s predates nextest
(1024 s in run 43635381613). Collapsing crates per OS would cost 35.5/55.5/35.6
min, worse than today, so the plan shards that one lane instead: 2-way takes the
run to ~14 min, 3-way to ~11 min.

Implemented here, since neither needs workflow scope: `shardedTestGroups()`
publishes a second matrix the Windows caller alone consumes (the three OS callers
share one `rust_tests` JSON, so sharding it would hit all three), and
`rust-checks.mjs` turns `CI_TEST_SHARD=n/N` into `--partition hash:n/N`,
rejecting anything that is not n/N. Verified: `--partition` splits 7 tests 3+4
with no overlap, and the invalid form exits 1.
A reply that quotes a whole Markdown file inside a ```markdown fence puts
another fence (`futureos-choice`) inside it, and CommonMark gives a fence no
way to nest: the inner run closes the outer block. Everything the author meant
to be inside it was then parsed as the reply's own Markdown — measured on a
real reply, the list under the quoted file became untitled bullets in the
middle of the message, the heading after it vanished into a second empty code
block, and a shell transcript below was read as prose with its `$(…)` turned
into an inline formula.

The author's intent is unambiguous, so read those fences as nested. The repair
is applied to the source and is length-preserving: instead of lengthening the
outer fence past its body, whose inserted characters would shift every mdast
offset the streaming projector and `splitStreamingMarkdown` slice by, the outer
delimiters are swapped to tildes of the same width. A backtick run is content
inside a tilde fence and vice versa, so the characters stay at their offsets
and only the grouping changes; delimiters are never part of the rendered code,
so the block still reads exactly as written.

Only fences whose info string names a document language (`markdown`, `md`) get
the treatment — in any other language ``` is ordinary text, which CommonMark
already handles. Applied in `parseMdast`, the single entry every parse path
shares, and in the desktop streaming processor, which parses on its own.
`a_row_with_no_body_keeps_the_detail_pane_a_box` aborted with a stack
overflow on both the Linux and the Windows `tui-cli` legs of run
43673617419 (jobs 132689090751 and 132689090757) while the macOS leg
passed, and a rerun reproduced it.

Nothing recurses: the test is one async fn, and a debug build lays every
local and every awaited future of it into a single ~1 MiB frame — the
same figure measured at 1, 2 and 4 MiB of stack, so it is a fixed frame
and not an unbounded expansion. Its steps then need as much again, which
is over the 2 MiB a `cargo test` thread gets; the per-frame cost of the
debug codegen is what puts Linux and Windows over it and macOS under it.
No product code is involved, and `tui/src/rpc/types.rs` (the only TUI
change in this PR) is not on the path.

Run the body on a thread with a 32 MiB stack, the way
`live::tests::with_big_stack` already does for `Live::apply`, whose frame
is bigger still. The body, its assertions and its waits are unchanged;
the test now passes with the test thread's stack forced down to 1 MiB,
which is what aborted before.
@huichen huichen changed the title feat(choice): answer cards on remote desktop and carry the pick into the queue; cheaper dev builds feat(choice): answer cards on the remote desktop; cheaper builds, CI plans, markdown fences Nov 15, 2026
@huichen
huichen merged commit e8eb0d1 into main Nov 15, 2026
100 of 102 checks passed
@huichen
huichen deleted the pr/huichen branch November 15, 2026 05:31
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