Repository navigation
fix(desktop,mobile,host): queued-reply order, approval tier switching, and mobile list/batch defects - #1582
Merged
Conversation
…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]>
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.
…ts 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]`.
…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).
…es 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`).
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".
…e 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.
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.
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.
…y 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.
jiangzhuqing000
enabled auto-merge (squash)
November 10, 2026 09:01
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.
这批改动
桌面端、手机端与 host 的一批缺陷修复,全部来自最近的实测报告。
桌面端 · 队列与转录顺序
applyRunMetadata把暂扣的 run 标记放进inFlightRunId而不是丢掉,upsertUserMessage按runId ?? inFlightRunId配对,collapseReplyDuplicates保证一轮只留一份回答、且不跨过用户消息。桌面端 · 审批模式
update_thread_approval_tier,切换时立刻推给该会话(沙箱不可用照旧降级成手动审批),徽标读“点击写入的那份设置”并乐观更新,不再依赖一次往返。unknown态的文案,而它并不是可选模式。读取会话状态时会用默认值补齐并回报真实等级;真正未知时文案改为「未知 / Unknown」。手机端
useDesktopResource在已有数据时把重拉视为刷新(新增refresh),开关的值先按点击结果显示再交回权威值。pairing.desktops,而forgetUnpaired与onTaskFinished闭包捕获了它/label,导致每台机器的连接被重建一次;重建的 client 没有心跳,于是被判成 standby。两处改为执行时读取当前值。验证
cargo test -p future-host --lib(新增两个用例:审批等级立刻生效、会话无等级时回填)、cargo clippy --all-targets -D warnings、cargo fmt --check、cargo check -p futureos全部通过packages/thread-projection:452 全通过(含 7 个去重用例)tsc --noEmit、eslint干净;vitest 因沙箱拒绝派生子进程(spawn EPERM)未能本地跑,已交由 CI 兜底tsc --noEmit、eslint干净;jest 同上说明
dev-jiangzhuqing000已包含当前main。pr/dev-jiangzhuqing000(dev-jiangzhuqing000仍会继续接收后续任务,那属于下一个 PR)。