Skip to content

refactor(cli)!: 入口 headless 更名 future host 且按需配对;桌面远程设备/工作区键盘选择与撤销配对修复;定时任务独立时区 - #1292

Merged
huichen merged 25 commits into
mainfrom
pr/huichen
Oct 21, 2026

Conversation

@huichen

@huichen huichen commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Squash-merges dev-huichen (21 commits, 11 non-merge, 117 files) into main.

What is in here

CLI / host

  • refactor(cli)!: rename the headless entry to future host and pair only on request
  • feat(cli): take a remote desktop back from the terminal
  • fix(host): stop naming a revoked pairing instead of waiting for one — a revoked credential now ends the run (CredentialRevoked) instead of dropping the pairing and spinning in "no device is paired yet"

Desktop remote

  • feat(desktop): pick the machine for a new conversation with the arrows and Enter
  • feat(desktop): switch the rail's view, device and composer pickers from the keyboard
  • feat(desktop): let a remote draft pick a workspace or a plain chat
  • fix(desktop): line the device picker's entries up in one column
  • fix(desktop): 设备选择弹窗里本机与远程机器的名称对齐
  • fix(desktop): leave fullscreen when the vibe panel closes
  • fix(desktop): push a row's activity stamp so an external run refreshes the rail

Other

  • chore(skills): bump the skills submodule for the CLI coverage audit
  • docs renamed to docs/guide/desktop-host.md to match future host

Local checks before opening

  • cargo fmt --all -- --check clean (Rust 1.97.0, the CI toolchain)
  • cargo clippy -p future-cli -p future-host -p future-remote-server -p future-rpc -p future-tui -p future-agent --all-targets -- -D warnings clean
  • cargo test -p future-cli --lib — 1377 passed
  • cargo test -p future-cli --test headless_cli — 12 passed (the revoked-pairing test was red on this branch and is what the fix above resolves)
  • desktop npm run lint (eslint + tsc --noEmit) clean

Earlier in this sweep the branch failed a_revoked_pairing_stops_the_run_with_the_reason_and_drops_the_credential (300s hang); that was handed to a repair session and is fixed on the branch, not asserted away.

huichen and others added 21 commits October 22, 2026 00:23
`future remote peers` could pair, connect and disconnect a remote desktop,
but not take one back from the device driving it — the one action the window
and the phone both offer when a machine answers while another device holds
it. A standby peer is connected on the wire and refuses every command
(`superseded`), so the terminal's only story was a row saying "connected"
over a machine nothing could be done with.

`future remote peers takeover <id|#>` asks the running Desktop for the move,
over the same request/reply channel connect/disconnect use, and the Desktop
sends the same `takeover` command a phone sends on the `list` lane. Its
answer says whether control actually moved; a machine this one already drove
answers `changed: false`, printed as the result it is rather than as a
refusal. `--json` prints `{desktopRunning, answered, tookOver, peers}`.

`list` now draws that state instead of hiding it: `PeerSummary.control` /
`.holder` reach the STATE column as "taken over" / "taken over by <name>",
and `--json` carries `control` and `holder` beside the fields it already
printed, with the same null-means-nobody-answered rule.

Co-Authored-By: FutureAgent <[email protected]>
futuregene/future-skills#101 documents session prune, the remote group,
headless, relay, future data and future run's own flags, so an agent asked to
clean up conversations, pair a device or back the record up no longer has to
rediscover them from --help.
…nly on request

`future headless` described what the process lacks, not what the user gets: the
command turns this machine into the host its phone (or another computer)
connects to. The name is now `future host`, and `headless` stays a hidden alias
so existing service units and scripts keep starting the same entry point — it
appears in no help output or message. `make run-headless` still works the same
way.

Launching it no longer mints a pairing invitation. The entry serves the devices
already in the pairing book (`enable` rather than `start`) and prints no code of
its own; `future remote devices add` is what mints one, and it prints the QR code
together with the complete link in the terminal that asked. Consequences:

* an unpaired machine comes up serving nothing and keeps running, naming the
  command that pairs a device instead of the code it used to print;
* only the platform login needs an interactive terminal now — pairing does not,
  so a host can run under a process manager while it is still unpaired;
* an emptied book (last device removed) reads "on, serving nothing", not a
  reason to exit.

Docs in both languages follow the new name and flow; `desktop-headless.md`
becomes `desktop-host.md`.
「在哪台电脑上新建对话」里本机用 16px 线条图标、远程机器用 emoji,字形宽
度不同,两行名称各自从自己的 x 开始,读起来像两列。给两种标记同一个 20px
固定槽位并居中,名称左边缘与标记中线都对齐。
The panel is the only surface that offers fullscreen (its bar icon, its menu row and vibe.fullscreen are all registered with it), so closing it while fullscreen left the reader with no way back: Windows draws no title bar in fullscreen, and Esc closes the panel rather than leaving fullscreen. Every exit path now calls exitNativeFullscreen, centrally in AppShell so onClose, vibe.toggle and the three 'open it in the shell' routes cannot drift apart.
…s and Enter

The device dialog is what Ctrl+N opens, so it is answered with the keys that
opened it: the list takes the caret when it appears (on this machine, which can
always take the work), the arrows walk the rows -- skipping a machine that
cannot take the work instead of landing on a refused row -- and Enter opens the
row the caret is on.

Closing the dialog hands the caret back to the composer on the machine that was
picked, through the same focus-composer event the terminal panel and Vibe use.
A draft the dialog re-opens is already on screen, so nothing remounts and the
mount-time autofocus never runs again; without the event, Enter in the dialog
left the field unfocused and swallowed the question typed next.
The picker mixes two kinds of mark: "all devices" and "this computer" are 14px
line icons, while a paired machine carries an emoji the user picked, whose
advance is wider than a line icon's box at the same font size. Each entry sized
its slot by its own glyph, so the names started at 86, 86, 91 and 92 CSS px in
the harness — the list read as two columns, with the emoji hanging into the
first one, and the trigger drew its mark at 14px in a row set at 12px.

Reserve one centred 16px slot for every mark, in the entries and in the
trigger, so every name begins at the same x whatever glyph it follows. The
screenshot scenario measures both columns now instead of trusting the class
list: its four entries report one slot width and one name position.
…om the keyboard

Adds one command per pair, all rebindable and listed in Settings and the cheat
sheet:

- rail.view.recent / rail.view.workspace (mod+alt+1 / mod+alt+2)
- rail.device.next (mod+shift+d): the device picker's ring, all -> this machine
  -> each paired machine
- composer.model / thinking / approval previous+next (mod+alt+{m,t,a})
- thread.usage (mod+alt+u): the header's receipt, enabled only when a
  conversation has an agent session

The pickers step their value instead of opening a menu because a SelectMenu has
no roving focus; the approval ring skips tiers this account and host cannot
offer, using the same predicate as the menu's disabled rows.
A new conversation on a paired machine now asks the question this machine's own new-conversation screen asks before the first prompt: a workspace on that computer, or a plain chat. The remote draft used to open in a workspace only when it was started from that workspace's heading, and the plain 'new conversation' path made a chat without offering the choice at all.

The footer under the composer is the local one's row, drawn with that host's own workspace list (name and path, because two folders there can share a name) and handed to the host as an id when the first prompt creates the session. Opening a workspace hands over to the host's create form, whose path is typed rather than browsed — this machine has no picker for another machine's disk. A draft with no host, or a conversation that already exists, has no such row: neither can still choose where it lives.

The chooser's read is lifted to the shell so the draft's header can name its workspace (it has no catalogue row yet) and so a workspace created from its own menu is in the list immediately. The remote placeholder now points at '#' for referencing another conversation, and the local new-conversation placeholder says the same, in both languages.

Verified in the screenshot harness: a new remote-draft-workspace scenario drives the row (workspace -> chat -> another workspace) and asserts the header badge follows it, and remote-slash-menu's stale menu-order assertion is corrected — the '#' hand-off leads that menu now, as the composer builds it, not the compact request.
…s the rail

A run driven from outside the GUI (CLI, scheduler, another machine) writes
threads.last_message_at once a second but announced nothing to the webview:
record_message_activity persisted the value and stopped there, so the rail's
age labels and its ordering (both read lastMessageAt) kept the value from
before the run until some unrelated event happened to reload the whole store.

The observer now emits one light event carrying the value it wrote, and the
thread store patches that row's lastMessageAt instead of re-listing every
conversation (a full refresh once a second would rebuild the list under the
reader). Emission rides the observation throttle that already guards the
store write, so a streaming reply announces about once a second, never per
token; prompts and terminals still flush. record_thread_message_activity now
reports whether the row actually moved, so a deleted thread or a replayed
older event announces nothing.
A `future host` whose stored pairing the platform revokes kept running
forever. `establish_slots` forgot the refused credential and, because the
entry now serves its book without minting an invitation (`enable`, not
`start`), the start ended with an empty book and no error code at all. The
projection read that as `Enabled` — "on, serving nothing", the answer an
unpaired machine gives — so the entry printed "No device is paired yet …
this entry keeps running" and never exited. Measured on the arm that covers
it: `a_revoked_pairing_stops_the_run_with_the_reason_and_drops_the_credential`
timed out at `wait_for_exit`'s 300 s budget, twice, where the same run used
to finish in three seconds.

Revocation is terminal, and this is the fix rather than the test's
expectation, for three reasons. It is how every other reading of the same
event already behaves: a revocation noticed mid-run stops its bridge with
`revoked` and the status reports `Revoked` with `CredentialRevoked`, which is
the handling page the window shows. It is the only state the operator must
act on — the credential is gone for good, nothing on this machine can serve
it, and "wait for a phone to claim an invitation" names neither the reason
nor a remedy. And the emptied book of a *removal* is a different thing
entirely: the user's own `remove` is answered with an invitation on request,
so it stays "on, serving nothing" and the entry keeps running — that is the
behaviour `b90438ec1` introduced, and it is untouched.

So the start fails with the error it acted on when a revocation leaves it
nothing to serve and it will not mint an invitation. `start_failure`'s
existing classification then names it, both entry points stop on it, and a
legacy credential dropped on upgrade keeps its waiting behaviour because
nothing was revoked.

Also documents the distinction in the host guide (both languages) and adds a
supervisor-level test that fails on the old code with
`phase: Enabled, reason: None` and pins the new one: `Revoked`, no invitation
requested of the platform, the credential dropped.
@huichen
huichen enabled auto-merge (squash) October 21, 2026 17:52
A schedule stores wall-clock times (`daily 09:00`), but which instant that is
depended on the machine running the tick: the kernel read every time through
`chrono::Local`, so the same task meant 09:00 in whatever zone the host
happened to sit in — and moving the task to another machine silently moved the
run.

- `tasks.timezone` (migration + schema) stores an IANA name, `None` for a row
  written before the setting. `future_tasks::timezone` resolves a task's zone,
  with the host's own zone as the default and **Asia/Shanghai** when that cannot
  be read (an unreadable zone must not silently mean UTC).
- The kernel computes daily/weekly/monthly/yearly/once candidates in that zone
  (including its DST rules), renders the envelope's `due=` on it and states
  `timezone=` in the run's settings line.
- CLI: `future task add|edit --timezone IANA`, canonicalized and validated; a
  typo is an error, not a silent fallback. An edit that changes the zone
  re-resolves `next_due_at`. `show`/`list`/`runs` print times on the task's
  clock and name the zone.
- Desktop task form: a Time zone picker (`Intl` zone list, plus "this machine's
  zone" = resolved on write); the detail panel shows it and next-due times are
  rendered in it. The remote panel and the phone editor carry the field through
  their payloads, and the remote host validates it the same way.
- Docs: the tasks architecture pair and `future task --help`.

Time-zone options the phone offers are a short list plus free text because the
phone cannot enumerate the desktop's zone database; a name the desktop cannot
resolve comes back as a save error.
…clearing it

`refresh_bails_when_already_in_flight` failed intermittently on Linux CI
(2497-test run, 1 failed) while macOS and Windows stayed green, and it never
reproduced locally: `agent/src/models/future.rs` is unchanged on the branch, so
the red check is a test-isolation race, not a regression in the code under test.

The single-flight slot was an `AtomicBool` that any finishing refresh thread
cleared with `store(false)`. A background refresh spawned by some other test
(`Registry::new()` in the models/auth tests) can still be in flight when this
test stores `true` and calls `spawn_future_models_refresh_unlocked`; if that
thread finished inside that window, its unconditional store handed the caller a
free slot, the spawn succeeded, and the assertion failed. Only `future_test_lock`
serializes the *other future-models tests*, so it cannot order foreign threads.

The slot is now a ticket (`0` = idle, otherwise the owner's ticket). Acquiring
takes a fresh ticket from a counter; releasing is a compare-exchange on that
ticket, so an owner that has been superseded — by a test reset or a newer
refresh — is a no-op instead of freeing somebody else's slot.

Tests now take the slot for real (a ticket-owning guard) instead of faking the
bool, and `stale_refresh_owner_cannot_free_a_newer_slot` pins the discipline
(it fails if the release goes back to a plain store).

Verified: cargo fmt -p future-agent --check; cargo clippy -p future-agent
--all-targets -- -D warnings; models::future 10x green (53 passed); full
`cargo test -p future-agent --lib` 3x green (2497 passed).
@huichen huichen changed the title refactor(cli)!: 入口 headless 更名 future host 且仅按需配对;桌面端远程设备/工作区键盘选择与撤销配对修复 refactor(cli)!: 入口 headless 更名 future host 且按需配对;桌面远程设备/工作区键盘选择与撤销配对修复;定时任务独立时区 Oct 21, 2026
@huichen
huichen merged commit 3f369b0 into main Oct 21, 2026
67 of 70 checks passed
@huichen
huichen deleted the pr/huichen branch October 21, 2026 19:26
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