Repository navigation
feat(desktop): rail in one control row with search;color themes, CLI session prune, tui model list - #1283
Merged
Conversation
… continuation Three entry points can bring the Agent up for one data root (`future agent`, `future headless`, `future tui`), and each answers "who starts it, who owns it, what happens when it dies" differently. This records the design that unifies them, as a document only: no code changes, and P1 is not started. What the design settles: - The OS instance lock stays the sole arbiter. It is released by the kernel when the holder is killed, so no leader lease or stale-pid recovery is needed. - A client that loses the race yields and waits instead of failing. Today the loser becomes `Phase::Failed` and headless exits outright. - Waiting is bounded (180s) and must be stated on screen, per entry point, with a defined behaviour when the cap is reached. No client may wait silently. - A crash-loop breaker with fixed numbers: 3 attempts in 300s opens it, 60s cooldown, one half-open attempt, doubling to a 600s cap. - Restart continuation follows the *cause* a run ended with, not the number of attached clients. A graceful stop currently settles `cancelled`, which is why "stop the Agent and start it again" resumes nothing today. What it separates out as still open: the TUI embedding the Agent in-process (D6), letting the Agent outlive the TUI (P2), and whether an explicit user stop should be restarted by another client (D7). Those are marked as product decisions awaiting the user, with options and costs only — no code paths. D9 (the Agent triggers continuation itself) and D10 (continue inside the loop without a synthetic user message) are recorded as plans. D10 cannot run today: `run_loop.rs` rejects a conversation whose tail is an assistant message. The document says so in three places so nobody reads the plan as shipped behaviour. `make check-docs` passes (309 docs, 0 pairs pending bilingualization).
`excludes_second_owner_and_releases_on_drop` still waited up to two seconds for `drop` to become visible to this process, for the same fork/`flock` window the previous commit removed from its sibling: a sibling test's `Command::spawn` lends this process's lock descriptors to the child until it execs, so an immediate re-lock can read as contended through no fault of the guard. The wait also hid a real leak behind a deadline. The release check now runs in the child process the sibling test already uses, against the directory under test rather than `HOME`, and makes one attempt -- so a guard that never releases still fails, at once. Falsified: keeping the guard alive makes the fixture fail with the "already running" message instead of the test passing late.
`the_headless_loop_runs_a_queued_request_it_is_woken_for` failed with "the woken headless loop never executed the queued request", which reads like a loop/agent race and is why two sessions dismissed it as an unrelated failure. It was neither: the run's task used the machine's temp directory as its `cwd`, and every run snapshots its working tree before and after (`review::capture_after` forks `git`), with the prompt pipeline waiting for that snapshot. This machine's temp directory holds 327,726 entries, so one run took 16.8-18.2 s inside a 20 s budget. Measured, isolated, before the change: 1 failure in 10 runs, and after it 5 runs of 0.27-0.32 s. The deadline, the poll and the assertion are untouched; the test now waits for the loop it is about instead of for a snapshot of every other test's leftovers. Falsified by putting `cwd` back: the same test took 17.1 s, 17.3 s and 20.07 s -- the last within 70 ms of the deadline it is supposed to fail against, and a slow runner crosses it.
The remote bridge's test web listener bound the fixed production port 8022, so every test that started a bridge in one binary was racing for one process-wide socket: `wait_for_web_port_free` existed to serialize them, with a 30 s budget and a comment about five failures at 5 s. A fixed port also collides with anything else on the machine holding it, including a running Desktop. `web_bind_port` now asks for the OS's choice in a fixture and keeps `WEB_PORT` in production; `bind_web_listener` returns the port the listener actually took and the status URL is built from it, so what a test connects to is what it advertises. `wait_for_web_port_free` and its 23 call sites are gone: a socket that is still unwinding cannot be taken by the next fixture when the next fixture gets a different port. The bind-failure test keeps a real collision by taking a port itself and pinning the listener to it (`pin_web_port`, a fixture-only guard that restores the default on drop). Falsified both ways with 8022 held by another process: before, the bridge reported `web server bind on port 8022 failed: Address already in use (os error 48)` and the test failed on `left: None`; after, the same test passed, its listener on an ephemeral port.
…eight Two reports from use, both reproduced on a real render before touching anything. **The top row had no height.** Grid children were given only `gridColumn` and left their row to CSS, so placement went through the auto-placement cursor: the add tile — drawn first — took row one, every cell moved down a row, and the last ones landed in an *implicit* row while the declared `repeat(rows, minmax(0,1fr))` collapsed. Measured: three cells read as `rows: 346px 346px 70px` with the third cell 70px tall, every child's `gridRowStart` reported as `auto`. Children now get both axes from `gridAreaOf`, so the template decides size and the index decides the square. After: four children at 628×379, `rows: 379px 379px`, squares (1,1) (1,2) (2,1) (2,2). **The bar's text sat above the traffic lights' line.** Every other top bar in the app — the rail's header, the thread header, the context panel, the new-conversation header — is `h-12`, centring its text at 24px, which is the line the lights sit on. The panel's bar was `h-9` (18px). It is now `BAR_HEIGHT`, `h-12`, and `barChrome.test.ts` reads those other headers' source to check the two cannot drift apart again. Measured: bar 36px / label centre 18px before, 48px / 24px after. Tests: layout gains the placement table plus a property run over every documented shape (distinct squares, none beyond the template); VibeStage asserts every grid child states both axes and no two share a square; barChrome pins the height against three other headers. Both fixes were falsified by putting the bug back (4 and 3 tests red respectively). Harness scenario `vibe-add-slot` (three cells plus the tile) records the numbers.
The activity rail's conversation list had its controls in two rows that each did the wrong job. The search was a magnifier glyph that expanded into a field on a row of its own — a whole line for a rarely used control, and an affordance nobody could discover. The recent view's "..." sat in the row of the workspaces/recent switch, one pixel from a control it does not act on: it marks the *list* as a batch, not the switch. Now there are two bands with one job each: the switch answers "which list", and one row under it holds that list's own controls — the machine picker, the search field (always on screen; Escape clears it while it has focus and does nothing when it does not) and the list's menu at the row's right end. The picker gained a `compact` shape for that row: glyph, name and chevron in a quarter of the width instead of a band of its own. The old `openSearch`/`closeSearch` strings are gone with the mode they named; the search command is now a focus rather than an open.
…t menu The first structural assertion ran in the tree view, where the recent list's menu is not rendered at all — so it passed against a layout that had just been put back with the menu inside the switch band. Read it in the recent view, and assert the menu exists elsewhere, so the check can only pass when it is drawn somewhere and is not there.
The panel and `future task list` showed the oldest task at the top because the store ordered rows by `created_at` ascending. Order newest first, with `rowid` breaking same-millisecond ties so a script that creates several tasks still reads them back in the order it made them.
…efault The fold shipped opt-in, but the reading it produces is the one a finished reply usually wants: the answer, with the work that produced it one press away. Default it on for both clients — a stored `false` is now the only thing that turns it off, so a reader who prefers the whole transcript keeps that choice on the next launch. Nothing changes about how the transcript arrives: the fold is still drawn by whichever client is reading, so the phone's switch still covers every paired desktop, and no wire or desktop setting is involved. The suites that describe a reply's blocks as a whole now pin the fold off (the setting has its own suites), and the mobile steps scenario opens the answer's process before the run inside it, since the rows are two taps in.
huichen
enabled auto-merge (squash)
October 21, 2026 07:35
… halves of one The activity rail had two ways to say "which list" and they answered the same question. `ActivitySection` carried `chat` and `workspace` (a page, and the half of the list to draw), the view switch carried `workspace` and `recent`, and the collapsed rail's two icons set the first while the switch set the second — so the two could disagree, "recent" had no collapsed entry at all, and a chat reading as a child of the workspaces was the visible result. Now there is one axis. `RailView` is three lists — workspaces, chats, recent — and `ActivitySection` keeps only the pages that are not a list (`skill`, `tasks`, `remote`, `settings`) plus the conversation column itself. Everything that used to branch on the section branches on the tab: the drawn rows, the pinned section, the keyboard walks, the batch scopes. - Each tab is one list: the workspace tab draws workspaces and their conversations, the chats tab draws the conversations that belong to none, and recent is unchanged. A pinned row lands in its own list's pinned section, and a tab with none draws no heading. - Search spans the lists, flat, each row saying where it lives — a per-tab filter answers "no matches" while the hit sits one tab away. Three empty answers are now three sentences: this list is empty, nothing anywhere matches, matches are in another list. - Every tab has the list's own menu at the right end of the control row (the batch), plus the tab's create control beside it: "new workspace" on the workspace tab, the machine-aware "new conversation" on the chats tab. - The two section-wide fold controls went with the two section headings they lived on; per-workspace folding is unchanged, and a tab is already the choice to look at that list. - ⌘1/2/3 are the three lists and the pages moved to ⌘4/5/6. `section.chat` and `section.workspace` are retired; a saved binding for one is dropped on read. - Choosing a tab is remembered (`select`); opening a conversation moves it for the run without claiming it as the preference (`follow`), so the next launch returns to the list the user chose. - Batch scopes are paths (`chat`, `recent`, `workspace/<id>`), so the tab's menu and a workspace heading's menu are one rule with different prefixes.
…design
Found by testing the document rather than the code: an anchor/structure pass,
a bilingual section comparison, and a check of every factual claim it makes
about the code.
- §9.1's action cell still prescribed the rejected criterion. It said a graceful
exit should settle in-flight runs "from the active-subscription count", which
is exactly the rule §9.2 premise 1 replaces with the cause. Following the
table would have implemented the design that was rejected.
- The English §9.2 premise 2 was the pre-correction text while the Chinese one
carried the corrected argument, so the two languages said different things
about where the consent switch lives. Both now state the one fact: consent
has to live wherever the executor can read it, with `set_default_model` as the
existing shape for a sessionless RPC that writes `settings.json`.
- Runtime paths under the FutureOS home were written as `agent/settings.json`
and `agent/agent-instance.lock`. In this repository `agent/` is a crate
directory, so those read as source paths; they are now `~/.future/agent/...`,
matching what the code resolves and what §9.2 already said.
Also drops the conversational framing from that section ("the user pointed out",
"my previous round was inaccurate"). An architecture document outlives the
conversation that produced it, so it states the fact and the trade-off.
No behaviour changes, no code touched. Verified: `make check-docs` (311 docs,
0 pairs pending), the docs gate's own 35 regression tests, heading parity and
in-page anchors on both languages, and every code claim the document makes
(constants, the assistant-tail guard, the abort signature, the call sites of
the continuation pass).
…creating one
Its "new conversation" button created a chat on the spot, because the
conversations page does — and that page *is* a list of chats that belong to no
workspace, so there is nothing for it to ask. The recency page is not: it holds
both kinds. So the same button skipped the chooser on one page and opened it on
the page beside it, and from the one list that holds every workspace's
conversations there was no way to start a *workspace* conversation at all.
It now opens the workspaces page's dialog: workspace or chat first, with that
machine's workspace list behind the workspace answer (and the machine choice
before either, when more than one machine can take the work). Only the
conversations page keeps the immediate path, since only there the answer is
already known.
One thing fell out of it: choosing "chat" after the dialog had opened on
"workspace" used to carry the selected workspace into the draft. A chat belongs
to no workspace, and `startConversation` now passes the workspace only with the
workspace answer.
Tested on the real UI: on the recency page the button draws two answers in the
order workspace-then-chat with the workspace list under them, and nothing is
created until the dialog is confirmed. Reverting to the old branch fails that
scenario ("the chooser is missing: 0 radios") and the three new screen tests.
The workspace and chats lists keep their "..." (the way into a batch over that whole list). The recent list loses its. A batch is "the rows under this heading" — a workspace, the chats list — and both of those have a boundary a reader can point at. The recent list's only boundary is time, so a selection there would mean every conversation on the machine, which is not a batch anyone can picture, and it is not the list a reader goes to in order to delete something. Deleting a single conversation from it is unchanged: that is the row's own menu, and it still works. The list's control row is now decided from what it has to hold rather than from the selection mode alone, so a tab with no menu, no create control and no paired machine does not leave an empty strip where those controls used to be. The search field stays where it is, in that row — it is the rail's one way to narrow any list, and its placement is deliberately unchanged by this change.
The machine picker and the search field go back to the row they have always been in: above the workspace row, i.e. above the list switch, directly over the list they filter. The previous change had them under the switch, which read as if the filter belonged to whichever list happened to be selected rather than to the list drawn beneath it. So the rail now stacks three rows, each with one job: the filter (machine + search) first, then which list, then the open list's own actions. The recent list keeps no "..." — a batch is "the rows under this heading", and this list's only boundary is time, so a selection there would mean every conversation on the machine. With no batch and nothing to add to that list, its action row is not drawn at all rather than left as an empty strip; the filter row above it is untouched.
… not two halves of one" This reverts commit 5e4ffc9.
…nk the search to a glyph Four things, and the first three are one correction: the rail went back to two lists because three did not earn their keep. **Workspaces and chats are one list again.** The workspace tree draws workspaces and their conversations, then the conversations that belong to none — the shape the rail had before the tabs. The switch is back to two entries, workspaces and recent, and `ActivitySection` is back to carrying the two halves of the tree: a workspace conversation and a chat are drawn by the same list from the shell's section, which is what made the "chats live inside the workspaces" reading possible in the first place, and what the tabs were supposed to fix. They did not: the split cost a second control answering the same question, and it moved two things the reader already knew where to find. So it is gone, revert by revert, and the rail is the two-list rail it was. **The search is a magnifier until it is clicked.** It was a field drawn all the time; the rail is a narrow column and the list is the point, so the row now holds one small glyph and the field appears in its place on a click. Escape closes it *and* clears the query — a hidden field must not keep filtering a list the reader thinks is complete. `⌘⇧F` opens it, which is the only way in without a mouse. **A conversation opened from the recent list no longer moves the list.** The shell sets its section from the conversation's own mode, and the rail used to follow that section into the workspace list — so the row the reader had just clicked disappeared from under the pointer, reported as "clicking a conversation in the recent list jumps the sidebar to the workspaces". The list the reader chose is theirs to change; the section only decides what the *merged* list draws. **Nothing above the list offers `+` or `…` any more.** Those act on something inside the list, so they live on the heading they act on: "new workspace" and "new conversation" on the section headings, a batch on a workspace's or a section's menu. Above the list there are now two rows with one job each — the switch, then the machine picker and the search.
Reported as "why is the search under workspaces/recent — shouldn't it be above?". It should, and it was: the row holding the machine picker and the search sits directly over the list it narrows, with the list switch under it. A revert put the two rows the other way round, and nothing caught it — every test read one row at a time, so an order that says "this filter belongs to the selected list" passed. So the swap is one change and the assertion is the other: the row order is now read as a document position (search row first, switch second, both above the list), in the paired case and in the case where the search is that row's only control.
…d level The boolean switch became a two-level choice, on both clients: "Default" shows a settled reply as its final answer (the work folded into one row above it), "Detailed" keeps the whole reply in the order it happened. Default is the shipped level, so nothing changes for a reader who never opens the setting. Desktop stores the level as `future.reply.detail` and reads it through `useReplyDetail`; the retired `future.reply.finalAnswerOnly` boolean is deliberately not read, because a `false` there cannot be told apart from one an older default wrote. Mobile keeps the level in its appearance record, where it still covers every paired computer, and draws it as two chips beside the theme and text-size choices (a phone has no room for a select). Both settings rows describe the level they are on, and the phone scenario now switches to 详细 and back, reading the painted chip (react-native-web leaves `aria-checked` unset on a radio).
Command-response dual-write is retired, so the Agent answers `list_models` with a typed `payload` and an empty `data` string. Every sibling print-mode call site in this file already decodes through `future_rpc::decode::response_data`; `list_models` was the one leftover reading `resp.data` directly, so `future tui --list-models` failed with `EOF while parsing a value at line 1 column 0` while `future models` worked. The test mock only ever set `data`, which is why the existing tests stayed green. It can now answer typed-only, mirroring the real dispatcher, and the fixture carries the full `ListModelsPayload` shape that `encode` requires — a partial fixture cannot round-trip through the typed wire. A decoded response without a `models` array is still an error: reporting "0 model(s)" would hide a payload the client cannot read.
`WebPortPin` and `pin_web_port` were gated on `any(test, feature = "test-support")`, but only this crate's own `#[cfg(test)]` tests call them. The CLI and the desktop both enable `test-support` without compiling those tests, so every one of their builds saw the two items as dead code -- a `-D warnings` failure in the workspace clippy pass that sank `Rust check / tui-cli` on #1283: error: struct `WebPortPin` is never constructed error: function `pin_web_port` is never used Gate them on `#[cfg(test)]` instead. The static they write to keeps the wider gate: `web_bind_port` still reads it in `test-support` builds, and fixture mode is only ever set by this crate's tests.
`future session delete` takes one id and `future session list` shows only what exists, so cleaning up abandoned conversations meant looping over the list by hand. `future session prune --older-than <age>` is that loop: a dry run by default, `--yes` to apply, `--keep <id>` to protect a session, and the Agent's per-session refusal (an active run, a running compaction) reported instead of failing the batch. The age is read from each session's newest history entry, not from the summary's `updatedAtMs`: that value moves on any write, so a rename — or one storage upgrade rewriting every session's metadata snapshot — makes a dormant conversation read as freshly used. The summary stays the cheap filter and only the sessions it reports inside the window need one bounded backward page.
A batch carries one 30-second deadline and the Agent reclaims every deleted session's space before answering, so a full 32-session batch on a large database runs past it: the reply is lost while the deletion went on to complete. Two changes follow from that. Batches are eight sessions, and a failed batch is retried once, so one slow session cannot cost seven others their deadline. And the outcome is read back from the session list instead of trusted from the reply — a session still listed is reported failed with the Agent's reason, one that is gone is reported deleted even when no reply arrived.
Settings → General had one Theme row (Light / Dark / System), which answered "how bright" but not "what does it look like". It is now two independent choices, the way the apps people compare us to do it: - **Appearance** — Light / Dark / Follow system, unchanged, still `.dark`. - **Color theme** — FutureOS (default), Nord, Solarized, Gruvbox, Rosé Pine, Catppuccin, applied as `data-palette` on `<html>`. Every palette ships both renditions, so a chosen look still follows the system: Rosé Pine in a light window is Dawn, in a dark one Moon, and flipping the OS appearance never re-asks for a theme. A palette only reassigns the same `--color-*` tokens `@theme` / `:root.dark` declare, so no component knows palettes exist; the picker previews a palette by carrying its own `data-palette`, which works because each block also matches a nested element. The two places that cannot use CSS variables now resolve both axes instead of one: the embedded terminal (one xterm palette per theme per rendition, in an exhaustive Record so a new theme fails to compile until it has colors) and Shiki code highlighting (each theme reuses its upstream project's editor theme). The 400-line palette table is generated from upstream values and adjusted until it meets the contrast floors documented in COLOR.md. Tests: `styles/globals.test.ts` pins every palette's token set, the rule order the cascade depends on, and that the FutureOS preview mirror never drifts from the canonical blocks; the terminal test now checks all twelve palettes; `lib/theme.test.ts` covers the second axis, including that the two axes do not disturb each other. The highlighter test caught a real bug on the way: the memoized `highlight` was missing `palette` in its dependency list, so code blocks kept the previous theme's colors. Harness: `shot/prefs.ts` pins language / appearance / color theme from the URL before the app is imported, defaulting them, so a scenario that switches theme cannot leak into the next capture and a dark-mode machine still captures the light default. New scenarios `settings-themes` and `settings-themes-dark` assert the previews paint their own palettes in both renditions.
The rule was only implied: the existing bullet listed the writes the main worktree *permits* (the finish fast-forward, the --no-ff merge, the push, the guarded collapse reset), which a reader can take as an exhaustive list of exceptions rather than a prohibition on everything else. Say it outright, and give the reason that makes it matter beyond tidiness: uncommitted tracked edits there block every other session's merge until they are gone, and work done there has no task branch to land on. Measured 2026-10-21: 19 unstaged files in the main worktree left two other sessions unable to merge, one of them polling in a sleep loop for the tree to clear. Untracked scratch files stay allowed, since they do not block a merge.
The picker had six palettes, and each one was written out by hand in three places — the stylesheet, the terminal palette table and the Shiki table. Adding eight more that way would have tripled the drift risk, so the palettes now live as data: `src/theme/palettes.json` holds one object per theme (tokens for both renditions, the terminal palette, the syntax theme), the stylesheet's `[data-palette]` blocks are generated from it, and the terminal and the code highlighter read it through `src/theme/palettes.ts`. That is the shape opencode uses for its built-in themes — one data object per theme, semantic roles with a light and a dark value, selected from a picker or a config key — and it is what makes fourteen themes maintainable: adding one is a JSON object plus an id, not 80 hand-copied colors. New: Ayu, Dracula, Everforest, Kanagawa, Nightfox, One Dark, Tokyo Night, Vesper. The default stays FutureOS, and the list is ordered default-first then alphabetically, so the picker reads as a catalogue. Each theme keeps both renditions (Vesper or Tokyo Night in a light window is their light variant), the terminal and syntax colors come from the theme's own upstream project, and where an upstream palette is deliberately low-contrast (Everforest, Kanagawa) its ink ramp is nudged to our floors rather than shipping 3:1 body text. Verification: the generator is `desktop/scripts/gen-theme-palettes.mjs`; `styles/globals.test.ts` fails when the stylesheet is stale, and the new `src/theme/palettes.test.ts` checks every theme's token set in both renditions, the contrast floors (text on every surface, white on solid fills, every ANSI color on the terminal's own background) and that each Shiki id really exists. The six existing palettes are byte-identical — verified by diffing the generated blocks against the previous ones — so nothing already shipped changed. Captures confirm the chrome paints each palette's own surface and that a modal's dimmed backdrop is the only grey left in a warm theme.
huichen
added a commit
that referenced
this pull request
Oct 21, 2026
…ky tests Three tests decided a state transition by waiting on something other than the transition itself. Each failed on `main` and on #1283's head on 2026-10-21, and each is fixed here at its own seam rather than by loosening an assertion. **`rpc::grpc_client::tests::manager_loop_top_stop_with_idle_manager`** (`test task did not reach its synchronization point: Elapsed(())` on Windows). The stream manager's first act on an empty session is to reach the idle branch, and the test arms a gate at the top of that branch — but `GrpcClient::new` spawns the manager, so on a multi-thread runtime the task could reach the branch before the gate was armed, take an empty slot, and park on a wakeup that never came. Split construction: `new()` is now `build()` plus `start_tasks()`, and a test that must arm a gate in between uses the test-only `new_dormant()`. `session_poke_between_empty_read_and_wait_is_not_lost` and `disconnect_between_idle_check_and_wait_releases_the_client` had the same ordering and use the same seam. **`rpc::grpc_client::tests::subscribe_failure_modes`** (`never connected: Elapsed(())` on macOS). The fixture's connect-state bound was 10 s. Measured on a loaded host, the same handshake took 0.91 s to 14.96 s across concurrent copies, so the bound sat inside the spread. It is now `CONNECT_STATE_BOUND = 60 s` (4x the worst measured), which bounds the whole `wait_conn` family — a genuine regression still reports, it just takes longer to say so. **`index::tests::interactive_resize_during_and_after_startup`** (exit 1 with `future-tui: interrupted during startup` on macOS). The fixture decided startup was over from the mock's command log plus a grace of `unary_delay_ms + 400`, but startup keeps issuing unary calls after its last handshake command (`list_models` follows the session handshake), so at a 400 ms delay the grace and the end of startup were a dead heat and the ctrl+c landed in the startup interrupt arm. `run_interactive` now signals the transition itself through a test-only gate, so the driver waits on the real edge and the host's speed drops out of the assertion. `cli/tests/remote_start_refusal.rs`: on Windows the interrupt helper asserted a successful `AttachConsole`, which also fails when the child has already exited — and the parent can only check liveness *before* spawning the helper, so a child that shuts down on its own in that window made the helper red. Attach is now retried briefly and treated as moot when the child is gone; a live child without a console is still a failure.
huichen
added a commit
that referenced
this pull request
Oct 21, 2026
#1283 (d4dc86c) replaced the palette section of `styles/globals.css` and, in the same edit, deleted every rule that is not a color: the `:root` base block, two hand-written animation utilities, the rail toolbar's container query and the two `::highlight()` rules. Nothing failed: the stylesheet still compiles, every class is still used, and the palette suites only look at `--color-*`. What that cost, all of it app-wide rather than rail-only: - `-webkit-font-smoothing: antialiased` (and the `-moz-` twin) went with it, so macOS painted subpixel-antialiased glyphs and every label read heavier -- `text-sm font-medium` most visibly, which is the rail's row title. - The font stack fell back to Tailwind's `ui-sans-serif, system-ui`, losing the CJK preferences (PingFang / Microsoft YaHei / Source Han). - `--text-*` stopped multiplying `--app-font-scale`, so the Settings text-size choice reached only the `leading-*` overrides: sizes were dead. - The light `--shadow-*` values vanished, leaving light-theme panels, dialogs and the floating rail flat (the dark ones still lived in `:root.dark`). - `animate-pop-in` and `animate-skill-entry-pulse` lost their keyframes while three components kept the class; the selection toolbar lost its container query, so its labels stopped collapsing; `::highlight(thread-search-*)` stopped painting in-thread search hits. Restored verbatim from d4dc86c^, with a comment on why the smoothing flags matter, and placed in the same order as before (`:root.dark` then `:root` then the palette blocks, which the specificity notes in `globals.css` require). `globals.test.ts` gains a base-rendition suite so this cannot happen quietly again: the type tokens must read `var(--app-font-scale)`, the font stack and both smoothing flags must be declared, light shadows must differ from the dark ones, the base block must sit between `:root.dark` and the palettes, and each hand-written animation keyframe plus the container query and highlight names must exist. Falsified by reverting only the stylesheet: 6 tests red, 20 green; restored, 26 green. The full desktop suite passes (5006 tests), as do `tsc --noEmit`, eslint on the suite and stylelint. Rendered evidence, harness `rail-tree` at 1280x860 before/after: mean ink in the 288px rail column 13.33 -> 11.64, i.e. the rows' strokes are visibly lighter again; the built stylesheet keeps every restored rule, and `.text-sm` still resolves through `var(--text-sm)`, so the text-size setting scales it.
huichen
added a commit
that referenced
this pull request
Oct 21, 2026
…d locks, run continuation (#1286) * fix(desktop): split KaTeX into its own chunk and drop a no-op dynamic import The install build reported two warnings, both pointing at real bundle work: - `index` was 2,024 kB, over the 2,000 kB budget. Almost a quarter of it was KaTeX (458 kB of source), which only a conversation that shows a formula needs. It now loads through `lazyKatex` on the first formula and lands as a 259 kB chunk; `index` is 1,766 kB and the build is warning-free. Until the chunk arrives a formula renders its own source, so the line keeps its height instead of popping in. - The composer's `import("./remotePromptOutbox")` could never split anything: the composer and `AppShell` both import that module statically, so it only earned an INEFFECTIVE_DYNAMIC_IMPORT warning. It calls the module directly now; the `active` flag still guards a recovery that settles after unmount. Tests: `MarkdownMath` / `MathFallback` wait for the engine before asserting its markup, and `MathLazyLoad` covers the split itself (source first, formula once the chunk lands). Desktop suite: 364 files / 5,000 tests green, plus `tsc`, `eslint` and `npm run build`'s worker check. * feat(agent,cli,tui,host): supervise the Agent across all three entry points Three entry points can bring the Agent up for one data root, and each answered "who starts it, who owns it and what happens when it dies" differently. Measured before this change: a `kill -9` of the owning process left the survivors reconnecting forever (40s, two cases), and a client that met a held instance lock exited 1 instead of waiting for the owner to finish starting. What the supervisor does now, in `future-rpc::supervision` so all entries share one policy: - **Yielding instead of failing.** `ConnectionError::InstanceBusy` and `host::Error::AgentBusy` give "another process owns this data root" a type of its own; `AgentHost` maps it to `Stopped`, never `Failed`, so the host stays restartable. Both gates apply before any wait: a genuine failure (a dead explicit endpoint, a version mismatch) is still reported immediately. - **Bounded waiting.** A client that meets a held lock waits up to 180s (the same budget `AgentHost::START_TIMEOUT` uses, not stacked on top of it), says so after 30s with the holder's pid/host, and stops with a stated reason. Headless exits at the cap and leaves the retry to its supervisor; the TUI keeps a usable screen and a permanent status line. - **Self-healing.** Headless, the TUI and the Desktop now watch the endpoint instead of the launch they performed once. When nothing answers and the lock is free, they start an Agent; when another process holds it, they wait. Measured: 3s (headless) and 1s (TUI) to a new Agent after the owner was killed. - **A crash-loop breaker.** 3 starts in 300s opens a 60s cooldown that doubles to 600s. The budget is cleared only once the Agent has stayed reachable for 60s: clearing it on "became ready" would let an Agent that the host kills on every run (OOM, a per-user quota) reset the breaker each lap, which is the case the breaker exists for. - **Restart continuation in the Agent.** The instance lock makes this the one trigger, so two clients cannot both continue the same interrupted task. It resumes from the Agent's own journal, skips streaming sessions, sessions parked on an approval, sessions with no model, sub-sessions and anything older than seven days, and never does more than three per start. Off by default (`resumeInterruptedOnStart` in `~/.future/agent/settings.json`): continuing sends a prompt the user did not type and spends their credits with nobody watching. It logs what it checked even when it continues nothing. - Not under `cfg(test)`: a unit test that does not redirect HOME would otherwise read the developer's real settings and, once the switch is on, send prompts into their real sessions. Verified with a release binary in isolated homes and a local stub model endpoint (no real credential spent): see §13 of `docs/architecture/agent-supervision` for the before/after of each case, including the two continuations and the switch-off default. Also fixes a pre-existing `-D warnings` failure that blocked the workspace clippy pass on this branch: `WebPortPin`/`pin_web_port` were gated on `test-support`, which the desktop and CLI enable without compiling this crate's `#[cfg(test)]` tests, making them dead code there. Known pre-existing, not addressed here: `grpc::tests::the_public_serve_wrappers…` fails in a worktree whose path makes `target/test-homes/.../.future/run/agent.sock` longer than a unix `sun_path` (104 bytes on macOS). It passes from the shorter main-worktree path and fails identically on this branch's base commit. * test(rpc): cap the jitter bound in the restart-delay assertion The base is capped at 30s, so attempt 5's lower bound is 24s, not 25.6s; the assertion failed intermittently, depending on the process-seeded jitter. * feat(scripts): a lab guard that makes an experiment's data root provably isolated An experiment launch that forgot to export FUTURE_HOME still ran, and only the desktop's own lock stopped it from opening the real ~/.future. Luck, not design. `scripts/dev/lab-guard.sh` closes that, and every gate fails closed. Home gate (whitelist, not blacklist): - **Set and non-empty.** Unset or empty is the accident itself: the app falls back to ~/.future. - **Absolute.** A relative or `~` value is *ignored* by the app (it requires an absolute root), so it silently falls back too. - **Resolved before comparing.** `~` is expanded and symlinks are resolved (`os.path.realpath`), so a `/tmp` link into the real home is seen as the real home. - **Under `/tmp`, `$TMPDIR` or `/private/var/folders`.** On macOS `$TMPDIR` lives in `/var/folders/…`, so a `/tmp`-only rule would reject valid labs. Every root is resolved the same way as the candidate, and the path must be *under* a root (the bare root is refused), with `/tmpfoo` not matching `/tmp`. Cleanup (`pids` / `kill`) never trusts a column position: - Candidates come from verified supervisors (command line names this guard and this exact lab root) plus their descendants plus a recursive `lsof +D` sweep, so a child that opens no file under the lab is still found. - A pid is signalled only if its command line names the root, or its parentage does, **and** it holds nothing under the real data root. Anything skipped is printed with its reason. - TERM first (so a supervisor's trap can forward it), KILL only survivors. `run` also sets HOME/USERPROFILE to the lab root and clears FUTURE_AGENT_GRPC_ADDR / FUTURE_AGENT_SOCKET: an inherited endpoint override points a "lab" run at the real Agent, the same class of accident. Not on any product entry point's path: nothing under agent/, host/, cli/, tui/, desktop/ or packages/ references it, and `future headless --help` is unaffected. `lab-guard.test.sh` pins 17 cases (unset, empty, real root, real home, relative, `~`, three whitelisted roots, bare root, look-alike prefix, two symlink escapes, the `.future`-as-root mistake, the exported environment, pid discovery, orphan cleanup, and the real-root refusal). Weakening the guard was verified to fail two of them, so the assertions are not vacuous. Two defects were found by running it, not by reading it: `lsof <dir>` does not recurse (so a child was invisible and killing the supervisor orphaned it), and SIGKILL bypassed the supervisor's trap. Both are fixed above. * fix(tui,cli): wait on events instead of the host's speed in three flaky tests Three tests decided a state transition by waiting on something other than the transition itself. Each failed on `main` and on #1283's head on 2026-10-21, and each is fixed here at its own seam rather than by loosening an assertion. **`rpc::grpc_client::tests::manager_loop_top_stop_with_idle_manager`** (`test task did not reach its synchronization point: Elapsed(())` on Windows). The stream manager's first act on an empty session is to reach the idle branch, and the test arms a gate at the top of that branch — but `GrpcClient::new` spawns the manager, so on a multi-thread runtime the task could reach the branch before the gate was armed, take an empty slot, and park on a wakeup that never came. Split construction: `new()` is now `build()` plus `start_tasks()`, and a test that must arm a gate in between uses the test-only `new_dormant()`. `session_poke_between_empty_read_and_wait_is_not_lost` and `disconnect_between_idle_check_and_wait_releases_the_client` had the same ordering and use the same seam. **`rpc::grpc_client::tests::subscribe_failure_modes`** (`never connected: Elapsed(())` on macOS). The fixture's connect-state bound was 10 s. Measured on a loaded host, the same handshake took 0.91 s to 14.96 s across concurrent copies, so the bound sat inside the spread. It is now `CONNECT_STATE_BOUND = 60 s` (4x the worst measured), which bounds the whole `wait_conn` family — a genuine regression still reports, it just takes longer to say so. **`index::tests::interactive_resize_during_and_after_startup`** (exit 1 with `future-tui: interrupted during startup` on macOS). The fixture decided startup was over from the mock's command log plus a grace of `unary_delay_ms + 400`, but startup keeps issuing unary calls after its last handshake command (`list_models` follows the session handshake), so at a 400 ms delay the grace and the end of startup were a dead heat and the ctrl+c landed in the startup interrupt arm. `run_interactive` now signals the transition itself through a test-only gate, so the driver waits on the real edge and the host's speed drops out of the assertion. `cli/tests/remote_start_refusal.rs`: on Windows the interrupt helper asserted a successful `AttachConsole`, which also fails when the child has already exited — and the parent can only check liveness *before* spawning the helper, so a child that shuts down on its own in that window made the helper red. Attach is now retried briefly and treated as moot when the child is gone; a live child without a console is still a failure. * fix(desktop): restore the base stylesheet the palette commit dropped #1283 (d4dc86c) replaced the palette section of `styles/globals.css` and, in the same edit, deleted every rule that is not a color: the `:root` base block, two hand-written animation utilities, the rail toolbar's container query and the two `::highlight()` rules. Nothing failed: the stylesheet still compiles, every class is still used, and the palette suites only look at `--color-*`. What that cost, all of it app-wide rather than rail-only: - `-webkit-font-smoothing: antialiased` (and the `-moz-` twin) went with it, so macOS painted subpixel-antialiased glyphs and every label read heavier -- `text-sm font-medium` most visibly, which is the rail's row title. - The font stack fell back to Tailwind's `ui-sans-serif, system-ui`, losing the CJK preferences (PingFang / Microsoft YaHei / Source Han). - `--text-*` stopped multiplying `--app-font-scale`, so the Settings text-size choice reached only the `leading-*` overrides: sizes were dead. - The light `--shadow-*` values vanished, leaving light-theme panels, dialogs and the floating rail flat (the dark ones still lived in `:root.dark`). - `animate-pop-in` and `animate-skill-entry-pulse` lost their keyframes while three components kept the class; the selection toolbar lost its container query, so its labels stopped collapsing; `::highlight(thread-search-*)` stopped painting in-thread search hits. Restored verbatim from d4dc86c^, with a comment on why the smoothing flags matter, and placed in the same order as before (`:root.dark` then `:root` then the palette blocks, which the specificity notes in `globals.css` require). `globals.test.ts` gains a base-rendition suite so this cannot happen quietly again: the type tokens must read `var(--app-font-scale)`, the font stack and both smoothing flags must be declared, light shadows must differ from the dark ones, the base block must sit between `:root.dark` and the palettes, and each hand-written animation keyframe plus the container query and highlight names must exist. Falsified by reverting only the stylesheet: 6 tests red, 20 green; restored, 26 green. The full desktop suite passes (5006 tests), as do `tsc --noEmit`, eslint on the suite and stylelint. Rendered evidence, harness `rail-tree` at 1280x860 before/after: mean ink in the 288px rail column 13.33 -> 11.64, i.e. the rows' strokes are visibly lighter again; the built stylesheet keeps every restored rule, and `.text-sm` still resolves through `var(--text-sm)`, so the text-size setting scales it. * fix(desktop): say "add a conversation" in the Vibe panel's menu The panel menu's add row carried `t("menu.add")` and `t("menu.addHint")`, but `vibe.json` only ever had those strings under `add.*` (`add.title`, `add.footer`). Nothing caught it: the component type-checks, the panel's tests assert the rows they need, and the menu rendered the key itself — measured in the harness with the menu open, the row read `menu.addmenu.addHint`. The empty-state button under the grid asked for the same key and showed `menu.add`. Adds `menu.add` / `menu.addHint` to both locales, phrased the way the add sheet already says it ("adding pins it: it appears here and in the sidebar's pinned section"), and points the empty state's sentence at the label the button now shows. `i18n/localeKeys.test.ts` closes the class: every literal key a component asks for — `ns:key` or the single-argument form matched against every namespace — must exist in every locale, plural suffixes included. Falsified by reverting the two catalogs: the suite then reports exactly the four missing entries (2 keys x 2 languages) and nothing else; with them, 2 tests green. The desktop suite passes (5008 tests), as do tsc, eslint and stylelint. * fix(agent,host,desktop): keep a held Agent lock a yield, not a cancellation Commit 4886036 gave a held instance lock its own `ConnectionError::InstanceBusy` / `host::Error::AgentBusy`, so supervision can wait for the holder instead of reporting a fault. Two callers still assumed the old `StartupBlocked`/`Failed` shape: - `AgentHost` mapped `AgentBusy` to `Stopped` (correct: the host stays restartable) but then dropped the reason: `start` fell through the wait loop into "Agent startup was cancelled", and the Desktop status page substituted the endpoint's transport error. Both now carry the worker's own refusal: the reason is recorded beside `Stopped`, returned from `start` as `AgentBusy`, exposed as `yield_reason` and used by `agent_status`. The `Stopped`-without-a-reason path still reads as a cancellation, which is what the stop-during-startup fixtures assert. - `agent/tests/service_startup.rs` (gated-lock) still asserted `StartupBlocked`. That is the stale half of the pair: the lock gate deliberately reports the yield variant now, as `packages/rpc/src/connection/tests.rs` already asserts. The test's other claims (metadata untouched, no storage created) are unchanged; nothing was loosened. The host's `locked` fixture now also pins the typed error and the recorded reason, so neither can silently regress to a cancellation again. Verified: cargo fmt --all --check; clippy -p future-host/-p future-agent/ -p futureos --all-targets -D warnings; cargo test -p future-agent --test service_startup (15), -p future-rpc --lib (216), -p future-host --lib -- agent_host (22), -p futureos --lib -- agent_supervisor (9), -p future-cli --lib -- headless::agent::block_fixtures (3). * fix(tui): report a clipboard program's exit status, not the broken pipe `run_native` piped the text into the program and returned immediately when that write failed. A program that exits without reading its stdin — `false`, `cmd /c exit 3`, or a clipboard helper rejecting its arguments — makes the write fail with EPIPE, so the caller heard "failed to write: Broken pipe" instead of the reason the copy did not happen, and the exit status and stderr were dropped on the floor. Whether the small payload of a real copy loses that race depends on the host: the macOS runner produced it in `native_runner_reports_a_nonzero_exit_without_stderr` (tui/src/clipboard.rs), i.e. a required check failing on a behaviour nobody intended. Now the write error is held aside, stdin is closed so a program that stopped reading still sees EOF, and the wait decides: a non-zero exit reports its status (or stderr) — the pipe broke because the program had already left — and only a *successful* exit with an undelivered payload is reported as "failed to write", which is the case where the clipboard really does not hold what the caller asked for. That keeps both existing contract tests (`true` with a 1 MB payload still reports the write failure) and makes the exit-status arm deterministic. Added `run_native_prefers_the_exit_status_over_a_broken_stdin_write`: a non-reading program that exits 3 with a 1 MB payload, which forces the broken pipe instead of racing for it. Verified: cargo fmt --all --check; clippy -p future-tui --all-targets -D warnings; cargo test -p future-tui --lib -- clipboard (65 passed); the two non-zero-exit tests 40 consecutive runs, 0 failures. * fix(agent,host,cli,rpc): continue interrupted runs in the Agent, and unbreak three tests Continuation belongs to the Agent, not the desktop. The Agent owns the journal the decision reads, and the instance lock makes it the single trigger. The desktop's one-shot pass sent the same conversation a second continuation when it ran beside it, so it is retired: the call is gone, the module (759 lines with its tests) is deleted, and the replacement is `agent/src/rpc/resume.rs`, which already ran there. The switch moves with the executor: `resumeInterruptedOnStart` in `~/.future/agent/settings.json` is now **on by default**, matching the consent the desktop already recorded (`autoResumeInterrupted`, also on by default), so moving the mechanism does not silently drop a behaviour users rely on. The desktop's Settings toggle writes through to that key, because a switch nothing reads is worse than no switch. Verified end to end with a release binary in an isolated home and a local stub model endpoint: with no settings file at all, `future agent` alone logs `1 conversation(s) checked, 1 continued`, the stub receives one request whose last user message is the continuation prompt ("上一轮运行在 Agent 重启时被中断了" — the Agent's wording, not the retired pass's), and `interruptedRun` clears with `queryCount` 1→2. With `resumeInterruptedOnStart: false` nothing is sent and the run stays interrupted. Three test failures, each with the mechanism identified rather than papered over: - **`models::tests::registry_injects_future_models_from_disk_cache`** flaked in parallel (2 of 10 runs; 0 of 4 when the future-models tests were excluded, which pointed at their background refreshes). Several test modules build a `Registry` without a `TestHome`, so a refresh thread they spawn can publish a different catalog into the process-global memory cache between another test's reset and its assertion. Test builds now serialize reads, resets and publishes through one re-entrant `CACHE_ACCESS` lock (re-entrant so a build reached from inside a build cannot deadlock), and every refresh carries a generation number so one that spans a reset never publishes. 20 runs after the change: no failures. A first attempt inverted the lock order against the existing future-models test lock and deadlocked the suite; the order is stated in the test. - **`grpc::tests::the_public_serve_wrappers…`** failed in a long-path worktree: `$HOME/.future/run/agent.sock` was 113 bytes against the 104-byte `sun_path` limit (78 in the main worktree, which is why it only broke in worktrees). This is a product bug, not just a test one: a deep home made the Agent fail to bind with a bare `Operation not permitted`. Endpoints past the budget now fall back to a short deterministic name in a per-user directory under the temp root, keyed by a hash of the path they wanted (still per-instance). The temp root itself cannot be the parent — the endpoint's lease step chmods its parent to 0700 and macOS refuses that on `$TMPDIR`, which is how the first attempt failed. Short homes keep the documented layout. - **`cli/tests/bin.rs::config_wizard_reports_the_missing_console…`** hung forever. With piped stdin the unix path still let `rpassword` open `/dev/tty`; on a machine where the process has a controlling terminal it blocks there indefinitely, so the "an interactive console is required" error the test asserts never appears. Windows had this guard; unix did not. Non-terminal stdin is now refused before the platform read, on both. `future config` with piped answers exits 1 with that message instead of hanging. `make check-docs` (311 docs), workspace clippy `-D warnings`, host/desktop clippy, and the agent (2479), host (1745), tui (2235), rpc (218) and cli suites all pass.
huichen
added a commit
that referenced
this pull request
Oct 21, 2026
The TUI now runs the Agent in its own process, the way `future headless` and the desktop do. The Agent is no longer a child of the terminal, which removes the whole class of problems a child brought: a terminal signal killing the Agent, a zombie holding the endpoint, pipes that had to be drained so a chatty child never blocked, output that had to be quoted back in a failure report, and — the reason this matters most — the Agent dying whenever the terminal window closed while another client was relying on it. What replaced the sidecar: - `tui/src/agent_host.rs` installs this entry point's Agent driver, shaped like the headless entry's (a short-lived probe runtime, dropped before the service gets one of its own), and starts the service through `future_host`'s process global host. - `agent_supervisor` keeps the policy and loses the process plumbing: attach, wait for whichever process holds the lock (bounded, and it says so), start in process, and rate-limit its own restarts. Every one of those decisions still comes from `future_rpc::supervision`, so the three entry points answer "who owns the Agent" identically. - The exit path stops an Agent this TUI owns, within a bound, on all three ways out (interactive, print mode, `--list-models`). An owned Agent holds the instance lock and the data-directory database; leaving that to process teardown would make the next start report a lock it cannot explain. `future-tui` standalone stays attach-only, and now says why in one place: the Agent re-runs its own executable as the Linux sandbox helper (`--linux-sandbox-helper`) and puts that executable's directory on `PATH` for shell tools, and only the unified `future` binary dispatches that flag. Hosting from the standalone binary would break sandboxed shell commands, so it refuses with the reason and the way out instead. Verified with a release build in isolated homes: a clean home starts the Agent inside the TUI (log shows `embedded Agent ready`, `Agent host finished owned=true`), the instance lock is held by the TUI process itself rather than a child, and the lock is released after the TUI exits. The standalone `future-tui` on an empty home refuses with the sandbox-helper explanation and creates no lock; with an Agent already serving it attaches and answers (`--version`, print mode) while the lock holder stays the same process. Removed with the sidecar: `agent_sidecar_launch.rs` and `agent_sidecar_readiness.rs` (they existed to make the child's failure reporting observable), and the comments in two other tests that referred to that launch path. `future-tui` 2231 lib tests and its integration targets pass; `cargo fmt --check` and clippy for the crate are clean. Not changed, and outside this commit: `host/src/remote/supervisor/state.rs` fails `clippy -D warnings` (`field_reassign_with_default`) at this branch's base commit `7590cbef5`, from PR #1283. It is not touched here, and it is the reason the workspace-wide clippy pass is red independently of this work.
huichen
added a commit
that referenced
this pull request
Oct 21, 2026
…rminal (#1288) * fix(rpc): a deep FUTURE_HOME gets a short endpoint, and says so when it cannot A `FUTURE_HOME` longer than 88 bytes (macOS; 92 on Linux) could not start an Agent at all. The endpoint is `<home>/run/agent.sock`, and `sun_path` holds 104 bytes there, so startup died at "binding the gRPC endpoint" with the message `path must be shorter than SUN_LEN` — which names neither the setting nor a way out. Measured with `UnixListener::bind` at 103/104/106 bytes: `InvalidInput`, `raw_os_error=None` (std refuses before the kernel), so this is neither `EPERM` nor `ENAMETOOLONG`. This is not a rare shape: the repo's own `.worktrees/<name>/target/test-homes/...` reaches 106 bytes. C — a short endpoint, only where the old one cannot exist: - The path is computed as before; it is relocated only when it does not fit the 103-byte limit. Every home that can bind keeps exactly the layout it had, byte for byte (`a_home_that_fits_keeps_the_layout_unchanged`). - The fallback is `/tmp/future-<uid>/<hash16>.sock`, recomputable from `(uid, wanted)` with no randomness or timestamp, so two processes deriving it independently get the same string (`a_home_too_deep_gets_a_recomputable_short_endpoint`). - `/tmp`, never `$TMPDIR`: on macOS `$TMPDIR` is per-session, so a launchd-hosted Agent and a terminal client could compute two different endpoints for one home. `/tmp` is spelled the same way by both (it is a symlink to `/private/tmp`; neither side resolves it). Measured: three different `TMPDIR` values all yield `unix:///tmp/future-501/3913bf89c6031845.sock`. - An explicit `FUTURE_AGENT_SOCKET` is used verbatim and never relocated: silently moving a path somebody named by hand is worse than letting bind refuse it. - Compatibility is structural rather than a probe: the homes that get relocated are exactly the ones the previous release could not bind, so no old Agent can be serving there. A home that fits keeps the old path, so an old Agent still serving it is found as before. Anti-squatting, because `/tmp` is world-writable: `/tmp/future-<uid>` is checked with `lstat` — not a symlink, a directory, owned by our uid, mode 0700 — and any failure refuses startup with the reason instead of repairing it (`chmod`-ing somebody else's directory is the attack, not the fix). Verified live: a pre-created symlink and a 0755 directory are both refused with actionable text ("remove it…" / "run `chmod 700 …`"), and a normal 0700 directory still serves. The check runs in `LocalEndpointReservation::acquire`, which is the path the Agent actually takes — the first attempt put it only in `bind_local_at` and every case passed, because that function was never reached. E — the message: an endpoint that still cannot fit reports its byte count, the limit, and two ways out (shorten `FUTURE_HOME`, or set `FUTURE_AGENT_SOCKET`). Verified end to end with a 103-byte home (old endpoint 118 bytes, so the previous build could not bind it): the Agent listens on `unix:///tmp/future-501/3913bf89c6031845.sock`, `future session list` against that home answers, and the directory is `drwx------`. Unit tests cover the limit boundary, the unchanged short-home layout, the verbatim explicit override, recomputability, per-home distinctness, and each squatting refusal; rpc 221 pass, agent 2479 pass, fmt and clippy clean. Reverting this means restoring the two lines in `local_socket_path_from`. **Stop any Agent running on the new layout first**: an old binary looks only at the in-home path, so it would find the lock held with no visible endpoint and report a failure that looks like the revert itself broke something. * feat(tui): host the Agent in-process, and stop it on exit The TUI now runs the Agent in its own process, the way `future headless` and the desktop do. The Agent is no longer a child of the terminal, which removes the whole class of problems a child brought: a terminal signal killing the Agent, a zombie holding the endpoint, pipes that had to be drained so a chatty child never blocked, output that had to be quoted back in a failure report, and — the reason this matters most — the Agent dying whenever the terminal window closed while another client was relying on it. What replaced the sidecar: - `tui/src/agent_host.rs` installs this entry point's Agent driver, shaped like the headless entry's (a short-lived probe runtime, dropped before the service gets one of its own), and starts the service through `future_host`'s process global host. - `agent_supervisor` keeps the policy and loses the process plumbing: attach, wait for whichever process holds the lock (bounded, and it says so), start in process, and rate-limit its own restarts. Every one of those decisions still comes from `future_rpc::supervision`, so the three entry points answer "who owns the Agent" identically. - The exit path stops an Agent this TUI owns, within a bound, on all three ways out (interactive, print mode, `--list-models`). An owned Agent holds the instance lock and the data-directory database; leaving that to process teardown would make the next start report a lock it cannot explain. `future-tui` standalone stays attach-only, and now says why in one place: the Agent re-runs its own executable as the Linux sandbox helper (`--linux-sandbox-helper`) and puts that executable's directory on `PATH` for shell tools, and only the unified `future` binary dispatches that flag. Hosting from the standalone binary would break sandboxed shell commands, so it refuses with the reason and the way out instead. Verified with a release build in isolated homes: a clean home starts the Agent inside the TUI (log shows `embedded Agent ready`, `Agent host finished owned=true`), the instance lock is held by the TUI process itself rather than a child, and the lock is released after the TUI exits. The standalone `future-tui` on an empty home refuses with the sandbox-helper explanation and creates no lock; with an Agent already serving it attaches and answers (`--version`, print mode) while the lock holder stays the same process. Removed with the sidecar: `agent_sidecar_launch.rs` and `agent_sidecar_readiness.rs` (they existed to make the child's failure reporting observable), and the comments in two other tests that referred to that launch path. `future-tui` 2231 lib tests and its integration targets pass; `cargo fmt --check` and clippy for the crate are clean. Not changed, and outside this commit: `host/src/remote/supervisor/state.rs` fails `clippy -D warnings` (`field_reassign_with_default`) at this branch's base commit `7590cbef5`, from PR #1283. It is not touched here, and it is the reason the workspace-wide clippy pass is red independently of this work. * fix(agent): continue every interrupted conversation, oldest first, with a real concurrency bound The pass took the first three of `list_all`, which orders by `updated_at` descending. That starved the tail rather than merely capping work: the three most recently touched conversations are exactly the ones a user is working in, and so the ones the next restart is most likely to cut off again. They took the whole budget on every pass, and older interrupts waited until those three went quiet. The log looked healthy every time — "checked N, continued 3" said nothing about the debt. Now every eligible conversation is taken, ordered by **oldest interruption first**, so the queue drains on the first pass. What bounds the work is concurrency, not a quota: at most `MAX_IN_FLIGHT` (3) submissions are in flight and the rest queue behind them. That bound has to be ours — the Agent has no cross-session limiter (`GlobalQueueBudget` caps queue depth and bytes, not running sessions), so without it a restart after an outage would fire one model request per interrupted conversation at once. The log now reports the account instead of only the work: `N checked, M interrupted and eligible, X continued (at most 3 at a time), K skipped (older than 7 days, sub-session, streaming, awaiting approval, or no model)`. Tests (and what each would have missed): - `candidates_are_taken_oldest_interruption_first` drives the shipped `candidates_in_order`. The first version re-sorted the fixture itself and passed even with the implementation inverted; reworked, it fails with `left: ["newest", …], right: ["oldest", …]` when the sort is turned back to newest-first. - `at_most_max_in_flight_continuations_run_at_once` runs the same refill-on-free loop over 10 tasks and asserts the peak against a literal 3, not against the constant — comparing the peak with `MAX_IN_FLIGHT` would pass for any value, including one big enough to fire everything at once. Raising the bound to 10 fails it with "saw 10". - `every_eligible_conversation_is_taken_not_just_the_first_few` pins that all ten candidates are taken and that the bound is below the queue size, so the other two tests mean something. - `only_fresh_top_level_sessions_are_candidates` covers the cheap filter (age, sub-session). Both falsifications were run and then reverted. `MAX_AGE` and `run_loop.rs`'s assistant-tail guard are untouched (the latter is the separate D10 change). `future-agent` 2483 lib tests pass; clippy clean. * fix(remote-server): build ConnectionOptions through a setter (pre-existing clippy, from #1259) `DesktopExecutor::connection_options` built the value as `let mut options = ConnectionOptions::default(); options.root_bundle = …`, which `clippy::field_reassign_with_default` rejects. The lint never reached CI because `host`'s `test-support` feature adds a private `loopback_fixture` field: the feature is enabled for the whole graph in the workspace-wide pass (the `cli` and `desktop` dev-dependencies enable it), and with it on the `for_loopback_fixture` shadowing moves the value, which the lint does not look through. With the feature off — `cargo clippy -p future-host --lib` — it fired. Neither struct-literal form works for both configurations: with `test-support` a private field makes the literal (and the `..Default::default()` update syntax) unconstructible from another crate, and without it the same single-field literal is `needless_update`. So `ConnectionOptions` gains `with_root_bundle`, symmetric with the existing `for_loopback_fixture`, and the caller chains both. Behaviour is unchanged: both feature configurations produce the same value, and the fixture path still goes through `for_loopback_fixture()`. Verified: - `cargo clippy -p future-host --lib -- -D warnings` (feature off, the red case): green - `cargo clippy -p future-host --lib --features test-support -- -D warnings`: green - `cargo clippy --workspace --all-targets -- -D warnings`: green - `cargo clippy -p future-remote-server --lib`, `-p future-remote-client --lib`: green - `cargo fmt --all --check`: clean - `cargo test -p future-host --lib remote`: 553 passed * feat(cli): pair and manage remote desktops from the terminal \uture remote peers\ is the client role, the mirror of \uture remote devices\: the machines this one connects out to. future remote peers [list] [--json] future remote peers add <invitation> [--json] future remote peers connect|disconnect <id|#> [--json] future remote peers rename <id|#> <name|--clear> [--json] future remote peers remove <id|#> [--yes] [--json] add runs in the CLI rather than in the Desktop: a pairing is a one-time claim plus a Noise handshake and needs nothing local to be serving, so a machine can be paired before its Desktop is opened. It stores the credential in ~/.future/remote_peers.json and connects once, so a pairing that does not work is reported now. list reads that book; connect, disconnect and remove ask the running Desktop through the same request/reply channel \uture remote devices\ uses, because a live connection and the user's own stopped mark live in that process and nowhere on disk. The host side gained peer-state, peer-connect, peer-disconnect and peer-remove (a peer is named by desktopId, not pairId) and answers each with the list as it stands afterwards. Docs: desktop-headless gains a client-role section (en + zh), and the directory layout now lists remote_peers.json. * feat(agent): continue an interrupted run without a user message D10 step 1 of 3. Restart recovery used to continue an interrupted conversation by submitting a prompt, which lands in the transcript as a user message nobody typed. This adds an accepting path that continues the run in place: the journal gets the new run's `run_started` marker (with `auto_resume_of` naming the interrupted run), and the run goes through accept-before-mutate, the run lease and the broadcaster like any other. The model receives the explanation as request-only context that never enters the transcript or the event stream — no `user_message` event, no user entry, no bubble for a client to draw. The journal is the permission: `continue_interrupted_run` re-reads `unterminated_run_id` at the accepting call and refuses anything else, so `ResumeContext` can only be set from a run the session's own journal still shows as open. This step covers the tail shape that needs no repair — a tool result, which is already a valid request. The assistant-tail guard is untouched, and a call whose result never arrived is not answered yet. Both shapes coexist: when continuing in place is refused (a journal that proves nothing, a provider that cannot take the tail), the pass logs why and falls back to the prompt it used before. * feat(agent): answer a crashed tool call before continuing the run D10 step 2 of 3. A run that died between issuing a tool call and recording its result leaves a transcript that ends on `tool_calls` with nothing answering it, and every provider rejects that request with HTTP 400. The continuation now pairs those calls with a placeholder result first, then appends the directive, so the request is valid. The placeholder says the outcome is *unknown*, not that the tool did not run. The process died in between, so nobody knows; "not executed" is the one guess that invites the model to repeat a side effect that may already have landed. The load-time repair, which writes the same placeholder into a loaded session, said "was not executed" — it now shares this wording, so a model reads the same story whichever path assembled the request. The guard has to distinguish this tail from the one it exists to catch: an assistant turn carrying unanswered tool calls is repairable, a turn that stops on assistant text is not. Only the resuming path is allowed the former, and a plain assistant tail is still refused. * feat(agent): accept an assistant tail when the journal proves the run is open D10 step 3 of 3. A run that died while the model was writing its answer leaves the transcript on an assistant turn, which the loop refused outright — and that is the most common tail a crash leaves. The continuation now accepts it, appends the request-only directive and continues. The relaxation is not "an assistant tail is allowed". `ResumeContext` is the only way in, and it is built by `continue_interrupted_run`, which re-reads `unterminated_run_id` at the accepting call: an assistant tail the session's own journal cannot prove is a still-open run is refused exactly as before. `run_rejects_assistant_last_message` keeps that boundary, and `a_continuation_is_refused_when_the_journal_proves_no_open_run` covers the same edge from the accepting side. The model's interrupted turn is never deleted from the transcript — it was produced, it is history, and the continuation only adds to the tail. * docs(agent): D10 is landed, in three steps The design section said the plan was fixed but the implementation had not started, and the decision table listed D10 as an adopted plan awaiting a separate task. Both are now wrong in the other direction. Update them, and record one thing the plan got wrong: a turn carrying unanswered tool calls is itself an assistant tail, so the guard needed an intermediate shape before the plain-assistant step, and the relaxation has to be conditioned on the journal rather than on the tail's role.
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.
dev-huichen相对main的 40 个提交(25 条非合并提交),主要六件事:feat(desktop)/fix(desktop)/Revert/test(desktop))。feat(desktop))。feat(cli)+fix(cli));--list-models改读 typed payload(fix(tui));fix(tasks)让计划任务最新优先。fix(host)把 web-port pin 收进本 crate 的#[cfg(test)]——正是上一轮Rust check / tui-cli与Rust check / desktop报的 dead code。文档:Agent 启动仲裁与重启后继续的设计(中英),
docs(agents)禁止在主 worktree 改文件。本地已跑(
dev-huichen@4187aca90):cargo fmt --all -- --check;cargo clippy -p future-cli --all-targets -- -D warnings;cargo clippy -p futureos --all-targets -- -D warnings——全绿。pr/huichen是取自dev-huichen@4187aca90的冻结分支(重冻时带上了上一轮修复fix(host): gate the web-port pin);合并方式 squash auto-merge。