Skip to content

fix(history): start a first page at its question; complete and weigh a whole walk - #1633

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

huichen merged 6 commits into
mainfrom
pr/huichen

Conversation

@huichen

@huichen huichen commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

The first page of a conversation was cut against a row/byte bound without regard for where a turn begins, so a page whose newest turn is taller than the bound arrived as that turn's tail — a reply with no question above it. The projection builds a turn from its question, so such a page projected to no turns and the conversation opened blank. This branch makes one invariant hold for every page: a page either is the whole conversation or it begins at a question — and makes the walk that reaches that question correct for an unbounded read, and linear in the rows it carries.

Measured on this machine's store (332 first pages read through read_page_with, 2026-11-17): 7 conversations opened blank and 121 more began mid-turn; after the change, 0 blank, every cut lands on a user row, and the 98 pages still over a bound are single indivisible turns.

Commits

  • 23493944b fix(history): start a first page at its question, not at a reply's tail
    • the page is cut at exchange boundaries only; the row bound yields to the page's question (it is a render bound, the question is what makes the page readable)
    • an exchange is indivisible: the 512 KiB byte bound drops whole older exchanges, and a turn larger than it is served whole
    • a page that begins mid-run is walked up to its question (bounded by 8 MiB, and only while the window holds no question at all), then cut at the first question it holds; truncated is set only when neither is possible
    • ExchangeStart::Anywhere is untouched: the terminal's switch and page-up still take what the agent cut, unbounded
    • the desktop reads the truncated flag the host already sent — SessionHistoryPage carries it, the thread state keeps it, and the transcript says the page starts mid-turn instead of drawing a reply with nothing above it
  • ead7fdef8 fix(history): walk to the question without a backstop when the page has no bound
    • read_page (the CLI's page read, the terminal's backward walk, and the agent's own paging contract test) asks for the whole exchange, so its budget is PageBudget::UNBOUNDED; the completion walk still stopped at COMPLETION_WALK_BYTES (8 MiB), a first paint's backstop, so a single exchange heavier than that came back as its own tail
    • PageBudget::walk_limit now returns usize::MAX for UNBOUNDED and COMPLETION_WALK_BYTES otherwise: the backstop belongs to a first paint, and a page with no bound keeps walking until it holds a question
  • c4d44de32 fix(history): weigh each row once per read, not once per walked slice
    • the walk re-weighed and re-scanned its whole accumulated window after every fetched slice, and the host's weight is a serialization of the row, so a page that walked twenty slices serialized every row it held twenty times — a history-dense page-up read was quadratic in the rows it carried
    • the running weight and the "has a question" fact are now accumulated from the rows as they arrive; the new test pins the property by counting weigh calls (a page assembled from 20 slices asks about each row once, not 21 times)

Verification

At the frozen tip 5a21fb328 (tree clean, pinned rustc 1.99.1, ulimit -n 8192):

  • cargo fmt --all -- --check — clean
  • cargo check -p future-rpc --all-targets — clean (3.6 s)
  • cargo test -p future-rpc --lib — 286 passed, 0 failed

At the earlier tip f82c1c891 (first commit only), the full set the original body carried:

  • cargo fmt --all -- --check — clean; cargo check -p future-rpc --all-targets — clean (8.6 s); cargo clippy -p future-rpc --all-targets -- -D warnings — clean (3.2 s); cargo test -p future-rpc --lib — 284 passed, 0 failed
  • cargo check -p future-host --all-targets — clean (8.5 s, the crate that reads read_page_with)
  • desktop npx tsc --noEmit — clean; npx eslint on the 8 changed TS/TSX files — clean
  • npx vitest run src/features/agent — 99 files / 1422 tests passed; npx vitest run src/i18n — 9 passed; npx vitest run --config ../packages/markdown/vitest.config.ts — 33 files / 754 tests passed

CI note: the previous head's run had its three Rust <OS> test / agent lanes killed at the 60-minute job cap with no logs. A dedicated investigation ran the agent suite nine times at both heads under four configurations, including the CI entry point scripts/ci/rust-checks.mjs test; no test hung — the longest full-suite round was 113 s and the per-test 480 s cap never fired. The one real failure it found (agent/src/session/history/paging_tests.rs:234, an assertion, not a hang) fails only on f82c1c891 and passes on this tip, where ead7fdef8 fixed it.

User-visible changes

  • Opening a conversation whose newest turn is bigger than the first-paint row bound: before, the page could arrive as a reply with no question and the conversation drew blank (7 of 332 measured pages), or began mid-turn (121 more). After, a first page either is the whole conversation or begins at a question, so those conversations open at their question. Revert 23493944b.
  • Page size: the 300-row bound now yields when honoring it would begin the page mid-turn, and the 512 KiB byte bound drops whole older exchanges instead of splitting one — a single turn larger than 512 KiB is served whole. Revert 23493944b.
  • A page that still cannot reach a question is marked truncated, and the desktop transcript says the page starts mid-turn (new agent.json string in both locales) instead of showing a reply with nothing above it. Revert 23493944b.
  • An unbounded read (the CLI page read and the terminal's backward walk) of a single exchange heavier than 8 MiB: before, the walk gave up at 8 MiB and served that turn's tail; after, it keeps walking to the question. Revert ead7fdef8.
  • Performance: a history-dense page-up no longer re-weighs its whole window once per fetched slice (quadratic in the rows carried); each row is weighed once. No default or bound changed. Revert c4d44de32.
  • Unchanged: the terminal's history switch and page-up (ExchangeStart::Anywhere) take the agent's cut, unbounded.

A first page whose newest turn is longer than the 300-row bound was cut to its
last 300 rows, and those rows are the reply — no user row among them. The
projection builds a turn from its question (`turnFromAcc` returns null without
`acc.userMessage`), so the page projected to no turns and the conversation
opened blank. Measured on this machine's store (332 first pages read through
`read_page_with`, 2026-11-17): 7 conversations opened blank and 121 more began
mid-turn.

Three changes, one invariant — a page either is the whole conversation or begins
at a question:

* the page is cut at exchange boundaries only, and the row bound yields to the
  question (it is a render bound; the question is what makes the page readable);
* an exchange is indivisible: the byte bound drops whole older exchanges and
  never splits the one the page lands in. A turn larger than 512 KiB is served
  whole, which is the case the reply lane chunks
  (`a_page_larger_than_one_reply_arrives_intact`); splitting it either drops the
  question or leaves a hole no cursor can reach;
* a page that begins mid-run is walked up to its question (bounded by 8 MiB, and
  only while the window holds no question at all), then cut at the first
  question it holds; `truncated` is set only when neither is possible.

`ExchangeStart::Anywhere` is untouched: the terminal's switch and page-up take
what the agent cut, unbounded — pinned by
`a_page_that_may_begin_anywhere_is_not_trimmed`.

The desktop now reads the flag the host already sent: `SessionHistoryPage`
carries `truncated`, the thread state keeps it, and the transcript says the page
starts mid-turn instead of drawing a reply with nothing above it.

After, on the same 332 pages: 0 blank, every cut lands on a user row, and the 98
pages still over a bound are single indivisible turns.
@huichen
huichen enabled auto-merge (squash) November 17, 2026 02:22
…as no bound

`read_page` (the CLI's page read, the terminal's backward walk, and the
Agent's own paging contract test) asks for the whole exchange, so its
budget is `PageBudget::UNBOUNDED`. The walk that completes a backward page
to its question was still stopped at `COMPLETION_WALK_BYTES` (8 MiB), a
first paint's backstop: when a single exchange weighed more than that, the
walk returned a window with no question in it, and the trim below — which
has no bound to cut against either — served the turn's tail.

That is the same blank conversation the parent commit removed for a
bounded page, one layer down:
`a_backward_exchange_larger_than_the_budget_is_complete_before_projection`
(a 12 MiB turn read through `read_page`) came back with an assistant row
first where its question belongs.

The backstop belongs to a first paint, so it now applies only to a bounded
budget: `PageBudget::walk_limit` returns `usize::MAX` for `UNBOUNDED` and
`COMPLETION_WALK_BYTES` otherwise. A page with no bound keeps walking
until it holds a question — which is what its caller asked for.
@huichen huichen changed the title fix(history): start a first page at its question, not at a reply's tail fix(history): start a first page at its question; complete and weigh a whole walk Nov 17, 2026
@huichen
huichen merged commit 53b5484 into main Nov 17, 2026
60 of 62 checks passed
@huichen
huichen deleted the pr/huichen branch November 17, 2026 05:19
tallcode pushed a commit that referenced this pull request Nov 17, 2026
…a whole walk (#1633)

* fix(history): start a first page at its question, not at a reply's tail

A first page whose newest turn is longer than the 300-row bound was cut to its
last 300 rows, and those rows are the reply — no user row among them. The
projection builds a turn from its question (`turnFromAcc` returns null without
`acc.userMessage`), so the page projected to no turns and the conversation
opened blank. Measured on this machine's store (332 first pages read through
`read_page_with`, 2026-11-17): 7 conversations opened blank and 121 more began
mid-turn.

Three changes, one invariant — a page either is the whole conversation or begins
at a question:

* the page is cut at exchange boundaries only, and the row bound yields to the
  question (it is a render bound; the question is what makes the page readable);
* an exchange is indivisible: the byte bound drops whole older exchanges and
  never splits the one the page lands in. A turn larger than 512 KiB is served
  whole, which is the case the reply lane chunks
  (`a_page_larger_than_one_reply_arrives_intact`); splitting it either drops the
  question or leaves a hole no cursor can reach;
* a page that begins mid-run is walked up to its question (bounded by 8 MiB, and
  only while the window holds no question at all), then cut at the first
  question it holds; `truncated` is set only when neither is possible.

`ExchangeStart::Anywhere` is untouched: the terminal's switch and page-up take
what the agent cut, unbounded — pinned by
`a_page_that_may_begin_anywhere_is_not_trimmed`.

The desktop now reads the flag the host already sent: `SessionHistoryPage`
carries `truncated`, the thread state keeps it, and the transcript says the page
starts mid-turn instead of drawing a reply with nothing above it.

After, on the same 332 pages: 0 blank, every cut lands on a user row, and the 98
pages still over a bound are single indivisible turns.

* fix(history): walk to the question without a backstop when the page has no bound

`read_page` (the CLI's page read, the terminal's backward walk, and the
Agent's own paging contract test) asks for the whole exchange, so its
budget is `PageBudget::UNBOUNDED`. The walk that completes a backward page
to its question was still stopped at `COMPLETION_WALK_BYTES` (8 MiB), a
first paint's backstop: when a single exchange weighed more than that, the
walk returned a window with no question in it, and the trim below — which
has no bound to cut against either — served the turn's tail.

That is the same blank conversation the parent commit removed for a
bounded page, one layer down:
`a_backward_exchange_larger_than_the_budget_is_complete_before_projection`
(a 12 MiB turn read through `read_page`) came back with an assistant row
first where its question belongs.

The backstop belongs to a first paint, so it now applies only to a bounded
budget: `PageBudget::walk_limit` returns `usize::MAX` for `UNBOUNDED` and
`COMPLETION_WALK_BYTES` otherwise. A page with no bound keeps walking
until it holds a question — which is what its caller asked for.

* fix(history): weigh each row once per read, not once per walked slice
tallcode added a commit that referenced this pull request Nov 18, 2026
…1637)

* fix(benchmark): recover terminal runs and schedule provider routes

* fix(benchmark): cap retries and mark failed second attempts

* fix(benchmark): separate technical retries from capability scoring

* feat(benchmark): run Fusion campaigns with frozen settings

* feat(fusion): allow five concurrent consultations

* fix(benchmark): retry terminal unconfirmed model responses

* fix(benchmark): retain answers after rejected Fusion inputs

* fix(benchmark): back off Fusion campaigns during upstream outages

* fix(benchmark): collect Fusion input type rejection receipts

* fix(benchmark): defer terminal provider stream errors

* fix(benchmark): wait for cancellation ledger persistence

* fix(benchmark): retain confirmed host interruptions for makeup

* fix(benchmark): recover confirmed persistence failures for makeup

* fix(agent): time out LLM streams on content inactivity

* fix(benchmark): allow rolling technical makeups

* fix(fusion): recover long-running discussions and consult before solving

* fix(agent): keep the Fusion first-action reminder in the task text

* fix(fusion): carry discussion decisions through execution and delivery

* fix(fusion): enforce consultation routing and preserve task delivery

* fix(history): start a first page at its question; complete and weigh a whole walk (#1633)

* fix(history): start a first page at its question, not at a reply's tail

A first page whose newest turn is longer than the 300-row bound was cut to its
last 300 rows, and those rows are the reply — no user row among them. The
projection builds a turn from its question (`turnFromAcc` returns null without
`acc.userMessage`), so the page projected to no turns and the conversation
opened blank. Measured on this machine's store (332 first pages read through
`read_page_with`, 2026-11-17): 7 conversations opened blank and 121 more began
mid-turn.

Three changes, one invariant — a page either is the whole conversation or begins
at a question:

* the page is cut at exchange boundaries only, and the row bound yields to the
  question (it is a render bound; the question is what makes the page readable);
* an exchange is indivisible: the byte bound drops whole older exchanges and
  never splits the one the page lands in. A turn larger than 512 KiB is served
  whole, which is the case the reply lane chunks
  (`a_page_larger_than_one_reply_arrives_intact`); splitting it either drops the
  question or leaves a hole no cursor can reach;
* a page that begins mid-run is walked up to its question (bounded by 8 MiB, and
  only while the window holds no question at all), then cut at the first
  question it holds; `truncated` is set only when neither is possible.

`ExchangeStart::Anywhere` is untouched: the terminal's switch and page-up take
what the agent cut, unbounded — pinned by
`a_page_that_may_begin_anywhere_is_not_trimmed`.

The desktop now reads the flag the host already sent: `SessionHistoryPage`
carries `truncated`, the thread state keeps it, and the transcript says the page
starts mid-turn instead of drawing a reply with nothing above it.

After, on the same 332 pages: 0 blank, every cut lands on a user row, and the 98
pages still over a bound are single indivisible turns.

* fix(history): walk to the question without a backstop when the page has no bound

`read_page` (the CLI's page read, the terminal's backward walk, and the
Agent's own paging contract test) asks for the whole exchange, so its
budget is `PageBudget::UNBOUNDED`. The walk that completes a backward page
to its question was still stopped at `COMPLETION_WALK_BYTES` (8 MiB), a
first paint's backstop: when a single exchange weighed more than that, the
walk returned a window with no question in it, and the trim below — which
has no bound to cut against either — served the turn's tail.

That is the same blank conversation the parent commit removed for a
bounded page, one layer down:
`a_backward_exchange_larger_than_the_budget_is_complete_before_projection`
(a 12 MiB turn read through `read_page`) came back with an assistant row
first where its question belongs.

The backstop belongs to a first paint, so it now applies only to a bounded
budget: `PageBudget::walk_limit` returns `usize::MAX` for `UNBOUNDED` and
`COMPLETION_WALK_BYTES` otherwise. A page with no bound keeps walking
until it holds a question — which is what its caller asked for.

* fix(history): weigh each row once per read, not once per walked slice

* perf(host,desktop): take the history read off the main thread; count catalogue packets at publish (#1634)

* perf: stop the empty-session sweep and take the history read off the main thread

Two independent causes of slow conversation opening, both measured on
2026-11-17 against a 4.3 GB / 1918-session store.

The discovery pass read every session it could not place in a conversation, so
the 639 sessions a CLI run had created on 2026-11-05 — each holding nothing but
its birth `session_info` entry, none with a thread — cost one 250-row read every
60 s forever: 15 697 reads an hour, 654 of them per pass. `list_sessions`
already answered the question that read was asked: `query_count == 0` with no
name means the agent has never seen a user prompt for the session, so the pass
now classifies it without reading. The wait stays lossless — the first prompt is
picked up by the next pass, exactly as an unreadable journal already was.
Measured after the change: 654 reads per pass down to 4.

`read_session_history_transfer` was a synchronous `tauri::command`, which Tauri
runs on the main thread, and the reader calls it once per 64 KiB — 25 times
back to back for a 1.5 MB conversation. Each one then waited behind whatever the
UI was painting: the same 64 KiB chunk cost 7.7 ms on an idle window and
70–128 ms on a busy one, and one 1.57 MB read spent 3.2 s end to end of which
the backend read was 80 ms. It is now async, so the copy and the cache lock land
on the runtime instead of in a frame.

Both cases are covered by tests that fail without the fix: the sweep case
asserts the absence of the read (disabling the guard makes it fail on an
unexpected request), and the transfer cases were updated for the awaited call.

* fix(host): count a catalogue packet before it reaches the wire

`catalogue_delta_lane_carries_only_what_changed` failed on CI (run
44016274423, lane `Rust Linux test / host-remote`) at

    a published packet is counted: 0

after the fixture had already handed back the first full packet. The two
observables are not the same event: `client.publish` only queues the bytes,
so the write and the fixture's record of it complete in a task of the
transport's own, while the count was taken after the publish returned. There
is no ordering between "a reader can see this packet" and "this packet is
counted", so the counter could trail the wire — and on that run it did.

Status is the wrong place to trail the wire: the field exists to answer "how
much has this connection been sent?" and it should never answer with a number
lower than what the client can already hold. Count first, and take the count
back when the endpoint did not take the packet (no key yet, or a transport
failure): the record may then lead the wire by the one packet in flight,
never lag it.

Reproduced deterministically by widening the window the CI run hit — the same
100 ms between the publish and the count turns the test red with exactly the
CI message, and the same 100 ms before the publish (or between the count and
the publish, after this change) leaves it green.

Assertions are unchanged; no threshold, retry or ignore was added.

* fix(fusion): preserve supported answers through final delivery

* feat: clean archived run logs and auto-archive idle conversations (#1635)

* fix(mobile): a workspace delete counts the conversations its heading counted

The workspace list drew every heading with the connected desktop's id
(`withMachine`), while a conversation read from the single-machine catalogue
carried no machine at all (`listTargets` answers `null`, because there is only
one it could be). Comparing those two spellings directly read them as different
machines, so a workspace whose badge said it held a conversation matched none of
them and its confirmation reported "0 conversations will be deleted".

The same confirmation was wrong on the archived shelf for a second reason: it
counted from the batch list, which is empty by design while the shelf is
showing, and which has the shelved rows filtered out everywhere else. Deleting a
shelved workspace therefore always counted zero — and a workspace holding only
shelved conversations counted zero on the workspace list too.

Both halves of a workspace are now read from the catalogue the screen is drawing
(`listTargets(merged, remote.sessions)`), the machine comparison reads the
missing spelling as the connected desktop, and the half that goes is still
chosen below it, so each page keeps reporting only its own side. The batch list
is untouched: its job is deciding what a selection may hold, not what a delete
will take.

`onSameMachine` names the rule once; `sessionsInWorkspace` (the workspace's
"select all") compared the same two spellings and had the same fault.

The shared i18n mock in the tests answered `title` before `count`, so no test
could see the number this dialog was telling the reader. It now appends the
count when both are given, and the three existing confirmations assert their
real numbers.

Co-Authored-By: Claude Opus 4.8 <[email protected]>

* fix(desktop): a queued prompt stays above the reply that answers it

Reported: ask a question, and while the first round is still only *thinking*
(nothing written yet) queue a second prompt. When everything settles the
question renders BELOW the reply it produced — a "7s thinking" bubble, then the
question, then the queued run's bubble — and the wrong order survives switching
conversations, though a full reload shows it correctly. Waiting until the first
round had written some text avoided it.

Two halves, and the reload observation is what separates them: the stored
transcript is right (a full reload reads it and renders correctly), so the order
was wrong only in the in-memory array the thread switch restores from its warm
snapshot.

A prompt is placed above its own reply by matching run ids
(`upsertUserMessage`). But `applyRunMetadata` *withholds* an in-flight reply's
`runId` so the live bubble keeps growing after a mid-run reload rather than the
frozen partial taking over — and the withheld stamp was the only link between
reply and prompt. With it gone the prompt matched nothing and was appended past
its own answer.

- `AgentMessage.inFlightRunId` carries the identity while `runId` is withheld;
  `applyRunMetadata` moves the stamp there instead of dropping it, clears it when
  the run settles and `runId` is restored, and keeps such a reply out of the
  positional legacy fallback (it still has a known owner — that was already the
  intent, and it is now explicit).
- `upsertUserMessage` pairs on `runId ?? inFlightRunId`.

Tests: a mid-run partial keeps its owner and the queued prompt is placed above
it (desktop), and the pairing itself (thread-projection). The desktop test is
what pins the bug — with only the pairing half reverted it fails.

* fix(desktop): a queued prompt is never wedged between two halves of its answer

Second half of the reported bug, found by reading the dev journal for the
conversation: the stored transcript is right (user, reply, queued user, reply)
and a full reload renders it right — so only the in-memory array was wrong, and
the screenshot showed why: TWO reply bubbles for one run ("5s · 380 tokens" then,
below the question, a fresh one). The agent persists a partial snapshot mid-run,
a reload projects it into the array as a settled-looking reply, and the live
bubble for the same run is drawn beside it.

Placing the prompt before its run's bubble then put it *between* the two halves
of its own answer, and because that array is what the warm snapshot keeps, the
wrong order outlived a thread switch — while reloading from the journal fixed it.

`upsertUserMessage` now swallows the stale fragment: the contiguous replies
directly above the matched reply, with no prompt between them, which carry no run
of their own (the shape `applyRunMetadata` leaves when it withholds a stamp so
the live bubble keeps ownership). Only that run is touched — an older exchange
above it is left exactly as it was.

Tests: the prompt lands above the single surviving reply, and an earlier
exchange is untouched. Without the swallow the first one produces the reported
`[stale reply, prompt, live reply]`.

* fix(desktop): one reply is drawn once, however many reloads happened during it

Third report on the same conversation, and the decisive one: the answer appeared
TWICE on screen (a settled "49s · 2,557 tokens" copy, then the same text under
"✓ 13 · 思考 11 次"), with a third starting below the question. Switching
conversations left two; Ctrl+R showed one. The dev journal for that conversation
holds one reply per run, and `history_display` is in the right order — so again
only the in-memory array was wrong, and this time the defect is the duplication
itself, not where the prompt went.

The agent saves a partial snapshot after every model call, so a reload *during*
a run projects that snapshot into the array as a settled-looking reply carrying
no run of its own; the live bubble writing the same run is a second copy beside
it. Each further reload added another, and nothing collapsed them: the live
writers only ever looked at the trailing assistant.

- `collapseReplyDuplicates` (thread-projection) keeps one bubble per turn: a
  later bubble carrying a run replaces an earlier one carrying the same run
  (`runId` or the withheld `inFlightRunId`), and an unidentified reply directly
  above an identified one — nothing but replies between them, so the same turn —
  is the earlier copy of that answer. A prompt between two replies is a new
  turn, and nothing crosses it.
- Every live-bubble writer starts from that array (`streamingBubbleBase`), so a
  duplicate cannot survive a reattach, a reload merge or a settle.
- `upsertUserMessage` uses the same collapse before it places the prompt, which
  replaces the narrower swallow from the previous fix with the general rule.

Tests: 7 cases for the rule (one copy out of three, newest wins, withheld stamp
counts as the run, never across a prompt, older exchange untouched, identity
returned when nothing moved).

* fix(desktop,host): switching approval on an existing conversation takes effect

Reported: an older conversation was on automatic approval; picking a different
level changed nothing — the option stayed on the old one. Two facts made that
invisible rather than merely delayed:

- the chip draws the tier the conversation's *Agent session* reports, not the
  stored default (deliberately: rendering the default claimed a tier the gate was
  not enforcing);
- that session tier was only pushed to the Agent immediately before the next
  prompt, and picking a level wrote the settings store alone. So the control the
  reader pressed wrote somewhere the control does not read, and nothing on screen
  moved.

Model and thinking level already propagate the moment they are chosen
(`update_thread_model` / `update_thread_thinking_level`). The approval tier now
does the same:

- host: `application::threads::update_thread_approval_tier` stores the choice and
  applies it to that conversation's session over the same path a prompt uses
  (`set_agent_sandbox_policy_tier`, so an unavailable sandbox is downgraded to
  manual rather than claimed), then answers with the tier the machine accepted.
  Best-effort for the session, like its siblings: an unreachable Agent must not
  fail the preference the next prompt sends anyway.
- desktop: `update_thread_approval_tier` command, `applyThreadApprovalTier` in the
  agent client, and the shell's `changeApprovalTier` — which passes the accepted
  tier back to the store and revalidates the conversation's cached Agent state so
  the chip moves at once. A conversation with no session yet just writes the
  default, which is what its session will be created with.

Tests: the host case asserts the choice reaches the stored default a later prompt
sends (`update_thread_approval_tier_applies_to_the_session_now`).

* fix(host,desktop): an old conversation's approval chip names a real mode

Reported: several older conversations show "按会话" / "Per session" in the
approval chip, and no such mode exists to pick. It was the chip's *unknown*
state: a conversation created before the desktop ever pushed an approval tier
reports none, and the composer drew a fifth label for that instead of one of the
four modes — a name a reader can only read as a mode they cannot select.

The chip was deliberately not falling back to the app-wide default, because a
session that was genuinely running on another tier (a CLI-created one) would then
be described by a value the gate was not enforcing. That concern is about a
mismatch, and a mismatch has a better answer than a phantom mode: settle it.

- host: `get_thread_agent_state` now heals the conversation it is reading. When
  the session reports no tier, it pushes the stored default over the same path a
  prompt uses (so an unavailable sandbox is downgraded, not claimed) and answers
  with the tier the machine accepted. That is what the next prompt sends anyway,
  so the chip can name a real mode; the push is best-effort, so an Agent too old
  to take a policy keeps answering as before.
- desktop: the label for the remaining unknown case (an Agent that cannot be
  reached at all) says "未知" / "Unknown" rather than offering a mode that does
  not exist.

Tests: `get_thread_agent_state_settles_a_session_that_reports_no_tier` asserts the
payload ends up carrying the accepted tier and that it is one of the four modes;
the composer test now expects "Unknown".

* fix(desktop): the approval chip changes when it is clicked, not on the next message

Reported after the host started applying the switch: the choice did work — the
next message ran under the newly picked mode — but the chip kept showing the old
one until that message was sent.

The chip draws the conversation's cached Agent state, which only moved once the
machine reported a new tier, and that happened at the next prompt. So the
control looked dead for exactly as long as the reader was looking at it.

`changeApprovalTier` now writes the chosen tier into that cache first, so the
mode changes under the reader's finger; the host's answer then corrects it when
the machine kept something else (an unenforceable sandbox is downgraded to manual
rather than claimed), and the revalidation at the end still converges on the
machine's own state. A round trip that fails leaves the choice showing: it is
stored, and the next prompt applies it.

Same reason a stale dev build shows the old behaviour: the chip updated only via
the state read, so a build without the new command looked unchanged.

* fix(desktop): the approval chip keeps the mode the reader picked

My own bug, from the previous commit: the optimistic write was immediately undone
by the state re-read after it.

The order was: write the choice into the cached Agent state (so the chip moves),
call the host, then force-revalidate. When the host call failed — a dev build
without the new command, or an Agent that refused the policy — the re-read asked
the machine what tier it was on and got the OLD one, replacing the whole cached
snapshot with it. The chip went back to where it started, which is why it still
looked like a dead control.

The re-read now happens only after the host has actually been told, so its answer
agrees with the choice. On failure the choice stays on the chip (it is stored, and
the next prompt sends it), and nothing asks the machine for a snapshot that would
contradict it.

* fix: stop the Windows sandbox revoke from failing a Desktop exit

A Desktop close could end in an error dialog titled "Cleanup failed" reading
"Agent shutdown deadline exceeded during Windows sandbox permissions; instance
ownership retained" — twice — followed by "更新、重置和重启已阻止". Nothing had
broken: the exit dialog was reporting a deferred housekeeping step as a failure,
and the deferral made it look unrecoverable.

Measured 2026-11-09 on a real machine: a stop entered the sandbox stage at
08:37:49.86 and the deadline watcher fired at 08:37:54.35, exactly the
five-second budget. The same two records were revoked by the next startup in
under a millisecond, so the time was not spent walking the trees the state file
names — the step is simply the one place where an unbounded platform call can
land anywhere, and nothing about it is safe to run on the thread whose verdict
it can then decide.

- `service/shutdown.rs`: run the revoke on its own thread and wait a fixed
  500 ms for the result. The drain no longer enters the stage at all, so the
  deadline watcher can never catch it there; past the budget the ACEs stay and
  the next startup revokes them, which is safe because they only grant
  FutureOS's own capability SID access to paths it already owns.
- `sandbox/windows/runner.rs`: check the deadline between revoke targets, so a
  bounded caller stops walking records instead of being carried to the end.
  `SANDBOX_RESET_BUDGET` promised this before but only covered the locks.
- `service/mod.rs`: a cleanup error the host error already names is no longer
  appended again — one deferred step was reaching the user as two problems.
- `agent_supervisor.rs`: the failed-exit dialog now says what is true (the app
  is closing, one housekeeping step moved to the next start, conversations and
  settings are unaffected) and keeps the diagnostic on its own line for a bug
  report. It is a warning, not an error.
- The two layout strings drop "已阻止 / blocked" for "暂不可用 / stay blocked
  until then", and the status gate leads with the same reassurance.

Tests: the drain reports Stopped when the revoke is stalled, the duplicate
error is collapsed, a distinct cleanup error still survives, and the dialog
wording is pinned.

* fix(desktop): the approval chip reads the setting the click just wrote

* fix(mobile): the model-visibility list stops jumping when a switch is flipped

* feat(mobile): archive a batch of conversations, as the desktop already can

Reported: selecting several conversations on the phone offers only delete —
the desktop's "Select chats" batch has had archive beside it since archiving
shipped, so clearing a shelf on the phone meant opening each conversation's own
menu.

The batch toolbar now carries an archive button next to the delete, with the
same rules that already govern the delete:

- offered while at least one machine in the batch answers `archive_v1`, refused
  only when none does (a machine too old to archive keeps its rows selected
  rather than failing them one by one);
- one machine at a time, one conversation at a time, so a desktop is not flooded
  and a failure leaves that row ticked for a retry;
- a batch holding conversations that are still running asks once, naming the
  count, and archives after stopping them — the same "stop and archive" answer
  the single-conversation and workspace archives use, with the retry window that
  covers the host settling its own run row.

Strings: "归档所选会话" / "Archive selected conversations", plus the partial
failure and running-batch confirmations.

* fix(desktop,mobile): sync the approval write, and reset the pending overlay during render

* docs: design archive log cleanup and auto archiving

* feat: clean archived run logs and idle conversations

* fix: add offers choice to desktop schema migration

* feat(desktop): show a file's folder from the transcript and the file tree

Both file menus could open a file and copy its path, but neither could answer
"where is this file on disk?". The transcript's file link and the right panel's
row menu (`...`) now offer "Show in folder" / 「在文件夹中显示」, which reveals the
file in the OS file manager with the item selected:

- Windows: `explorer /select,<path>`
- macOS: `open -R`
- Linux: the containing folder, since no portable "select this item" exists

New `reveal_in_file_manager` command. It is deliberately not `open_path`: that
launches the file's default application, which is a different question from
finding the file, and the menu already offers it as "Open". Built from
`explorer`/`open` with the path as one argument rather than through a shell, so a
path carrying `&`, `^` or `%VAR%` cannot be reinterpreted. It carries the same
credential guard as `open_path`.

A failure is swallowed on both surfaces: the entry exists so a user can locate a
file, and a folder window that will not open is not worth replacing their
message — or their tree — with an error.

Tests: the reveal command validates and blocks credentials before reaching the
OS; the transcript menu exposes six items and calls `reveal_in_file_manager`
rather than `open_path`; the row menu does the same for files and directories,
and a failed reveal leaves the tree intact.

* fix(desktop): keep archive settings on the general page

Move the run-log cleanup and automatic-archive switches into Settings -> General and drop the standalone archive tab, so archiving settings sit with the rest of the general preferences.

Rename the block to 'Conversation auto-archive', drop the cleanup-interaction row, and state the schedule without describing fork trees. Add a help icon beside the idle days that explains what counts as idle and that restoring restarts the period.

* fix(desktop): shorten the auto-archive copy and cover pinned exclusion

Drop the auto-archive sub-line and the workspace-scope sentence from the archive settings block, leaving one heading and the row descriptions.

Add host regressions proving a pinned conversation is never an automatic-archive candidate and that the shipped default keeps a pass from archiving anything.

* chore(store): renumber archive migrations after contract 7

Main adopted runs.offers_choice as contract 7, so the unreleased archive-cleanup steps become 8 and 9. Update the SQL headers to match and drop the superseded duplicate ALTER that contract 7 now owns.

* fix(desktop): hide cleared run logs from the runs panel

Archiving a conversation clears its Shell output but leaves the run records in the store, so the Runs panel kept listing every command of an archived conversation. Filter rows whose run was purged as well as rows whose run was archived, and explain the empty list as cleared run logs.

The transcript is unaffected: its 'Ran' rows come from the Agent's own messages and still open a detail view that reports the logs were cleared.

* fix(store): adopt the interim migration ledger instead of refusing it

Contracts 7-9 were renumbered after an unreleased build had already written databases with the first ordering (cleanup 7, restore 8, choice mark 9). Those databases hold every column the steps add, but their ledger carries checksums that no longer match, so admission refused them and the desktop would not start.

Recognise that exact ledger, verify the columns its steps added are present, and rewrite only the three labels to the current numbering. A database missing those columns is still refused rather than silently marked migrated.

* fix(desktop): the link context menu keeps its own font weight

The transcript's file-link menu drew every row bold whenever the link came from
bold prose. The agent writes a document reference as `**中文设计文档**`, so the
anchor sits inside `<strong className="font-semibold">`; the menu is positioned
`fixed` but inherits through the DOM, so the row labels followed the weight of
the sentence the menu was opened from. A menu is chrome — its weight belongs to
the menu, not to the text behind it.

`font-normal` on the panel. The regression is pinned by mounting `FileLink`
inside a `font-semibold` `<strong>` and asserting the panel carries its own
weight, which is the shape the report showed.

* fix(desktop): stop calling a purged run list archived

Restoring a conversation does not restore its cleared run logs, so the empty Runs panel kept telling a reader the conversation was archived after it had been restored. Drop that claim and say plainly that the logs were cleared, that restoring does not bring them back, and that new turns are unaffected.

* fix(cli): document the archive settings in the desktop help

Adding the archive run-log cleanup and automatic-archive settings left four keys out of future desktop --help, and the check that every settable key is documented failed on CI.

---------

Co-authored-by: Claude Opus 4.8 <[email protected]>

* fix(fusion): preserve user settings and bound failure recovery

* fix: align lazy journal fixtures and retire replaced remote subscriptions

* fix(host): restrict subscription assertion helper to unit test builds

* fix(remote): confirm command subscription retirement before replacement readiness

* fix(remote): remove failed replacement generations before retrying handoff

* fix(remote): fence retirement within relay permissions and isolate broker fixtures

* fix(fusion): validate versioned evidence references and expose source availability

* fix(fusion): distinguish optional evidence and check every structured citation

* fix(desktop): render versioned Fusion evidence citations alongside legacy references

* fix(fusion): require objection dispositions and inherit reopened decisions

* fix(fusion): retain reused invocation links and refresh scoped evidence

* fix(fusion): honor recovery content progress and repair all quote errors

* fix(fusion): reconcile objection dispositions with delivered conclusions

* fix(fusion): admit conclusion reconciliation in a fresh moderator step

* fix(fusion): project final checks as moderator activity

* refactor(fusion): deliver audited synthesis without a separate final check

* fix(test): keep desktop download fixture transport responsive

---------

Co-authored-by: Hui Chen <[email protected]>
Co-authored-by: jiangzhuqing000 <[email protected]>
Co-authored-by: Claude Opus 4.8 <[email protected]>
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