Skip to content

fix(host,tui): an idempotent Agent channel runtime; one row per keypress - #1366

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

huichen merged 2 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Oct 26, 2026

Copy link
Copy Markdown
Collaborator

Installing the Agent channel runtime twice used to disturb the instance already running; it is now idempotent. Alongside it, a workbench overlay's highlight moves exactly one row per keypress instead of jumping, and the acceptance record for the runtime fix is added under docs/testing/.

Commits

  • fix(host): make the Agent channel runtime install idempotent
  • fix(tui): move an overlay's highlight one row per keypress

Verification

Local self-test at e4763a1db with rustc/clippy 1.99.1 (rustup toolchain; the Homebrew 1.96 install shadows it on PATH), in the main checkout:

  • cargo fmt --all -- --check — clean
  • cargo clippy -p future-host -p future-cli -p future-tui --all-targets -- -D warnings — clean
  • cargo clippy -p futureos --all-targets -- -D warnings — clean
  • cargo test -p future-tui --lib — 1229 passed, 0 failed
  • cargo test -p future-host --lib -- agent_client — 10 passed, 0 failed
  • cargo test -p future-cli --lib -- headless — 27 passed, 0 failed
  • make check-docs — 346 docs OK (placement, bilingual pairing, links, fences); provider matrix 13 rows

The desktop (futureos) library test suite was not run locally because its full lib run poisons a shared Once against the host test support in this environment; clippy --all-targets compiled it, and CI runs the suite.

Notes

  • No migration, feature flag or default-value change.
  • docs/testing/agent-channel-runtime-install-2026-10-26{,.zh-CN}.md is the acceptance record for the runtime fix.

huichen and others added 2 commits October 26, 2026 12:48
Pressing `down` in a list overlay skipped an entry: the state machine advanced
by one, but a record was drawn by wrapping its data, so a real session title
(title) — workspace — id) folded into two rows and the marker travelled two rows
down the screen per press. At a narrower box it could be three.

A record is now composed to occupy exactly one row (`workflows::record_line`):
pieces after the first are dropped whole when they no longer fit — a workspace
cut mid-path reads as a different directory — and only the leading title is
shortened, with a visible ellipsis.

Two more places had the same shape:

* the worktree list used the arrow for the *current* checkout, so the overlay
  had no visible selection at all and `down` looked dead; `●` now marks the
  current one and `›` is only ever the selection;
* the diff navigator drew its arrow from the file whose patch had loaded, which
  is a reload behind the key, so the cursor did not move until the driver came
  back; the arrow follows the cursor and `·` marks the loaded patch.

The regression test asserts the painted marker sits on the row its own hit
region reports and that four presses move it exactly four rows, for all five
list overlays.
Three installers share one process — the Desktop entry, the CLI entry, and the
shared test fixture that `desktop`'s dev-dependencies enable — and all three
registered the process-wide channel driver runtime by `set`ting a `OnceLock`
*and* wrapping the "already configured" error in `expect` inside a `Once` of
their own. The second installer therefore panicked, and because the panic
happened inside its `Once`, that `Once` was poisoned: every later install in
the process then failed for a reason unrelated to the first. One run of the
Desktop suite turned that into 38 failing tests out of 364, and the fixture's
own "is it installed?" guard did not help because it is not atomic with `set`.

`configure_channel_runtime` is replaced by an idempotent port whose two
outcomes are both successes (`RuntimeInstall::Installed` /
`AlreadyInstalled`), so the ordinary second-install case can no longer be
unwrapped into a panic. `CHANNEL_RUNTIME` is the only arbiter: a caller-side
`Once` in front of it was the second state machine that disagreed with it.

`provide_channel_runtime` is the shape every installer now uses, and it owns
the keep/discard pairing the design rests on: the winner parks its runtime on a
thread that never returns (so the shared channel's h2 driver task survives),
and a loser shuts its own down through `Runtime::shutdown_background`, which is
safe in the async contexts the port is reachable from. A losing call does not
even build a runtime.

Production semantics are unchanged: future-host still refuses to construct a
fallback runtime, and `agent_channel_runtime()` still errors when no entry
installed one.

Tests: `the_first_install_wins_and_the_second_reports_already_installed` and
`a_losing_installer_neither_builds_nor_parks_a_runtime` (host, private slot,
deterministic) plus `a_second_installer_is_a_normal_outcome_not_a_panic`
(Desktop entry, real process slot). All three were red against the pre-fix
semantics and are green now. The contract they pin is installation, not thread
scheduling — see docs/testing/agent-channel-runtime-install-2026-10-26.md for
the measurements, the falsification runs and what is deliberately not covered.
@huichen
huichen enabled auto-merge (squash) October 26, 2026 04:56
@huichen
huichen merged commit c43d9c7 into main Oct 26, 2026
21 checks passed
@huichen
huichen deleted the pr/huichen branch October 26, 2026 05:07
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