Skip to content

fix(desktop): keep a taken-over remote conversation named, and close its writes - #1340

Merged
huichen merged 1 commit into
mainfrom
fix/remote-standby-reading
Oct 24, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/remote-standby-reading

Conversation

@huichen

@huichen huichen commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator

另一台设备接管某台电脑后,桌面端正打开着的那条远程会话会失去名字、却仍显示成可写。这条分支补上桌面端缺的两半:留名,和关掉写入口。

现象与链路

useRemotePeers 在 standby 状态下不再收到该主机的 catalogue 快照,于是该主机所有会话行消失(这是对的:standby 设备本就不该收到快照)。而桌面端的标题只有一个来源——AppShell 从 catalogue 行取 session.title,取不到就退化成 sessionId:

  • 标题栏变成 20261022-164713-ea5b…,工作区限定名一起消失;
  • 正文还在(走 useRemoteTimeline 的窗口级快照,不依赖 catalogue 行);
  • 发送按钮仍可按、审批卡仍可答、fork/Retry 仍在——点下去必被 host 以 superseded 拒绝。

即「只读又半失效」:读得下去,但不知道自己在读哪条;写不进去,但界面不说为什么。

改动

1. 标题按 desktopId + sessionId 记住 —— 新模块 remoteConversationIdentity.ts

catalogue 仍是权威(改名要能落地),但最后见到的 title / workspaceName 会按「主机 + 会话」记住(同一 session id 在另一台主机上是另一条会话,所以键要带 desktopId)。读顺序:catalogue 行 → 记住的名字 → sessionId(从未见过标题的会话仍退化成 id,而不是空标题)。

2. 会话内横幅 + 取回入口 —— 新组件 RemoteStandbyNotice.tsx

control === "standby" 时在 composer 上方画一行提示(复用 AgentThread 的 ConnectionNotice 同一套 warning 配色与右置按钮),写明「本机已被 <谁> 接管、从这里发出的内容不会送达」,并给「接管回来」按钮。该按钮走的是设备选择器/远程页同一个 takeover 命令(AppShell 里抽出的 takeOverRemotePeer),成功后重读主机。

放在审批卡之前:卡里那个人等着回答的决定,是读者第一眼要去点的地方,得先看到「点不了」这句。

3. 写入口一律关闭并给出原因

  • RemoteComposer:发送(含 Enter 路径,守卫放在两条路径汇合处)、附件暂存、粘贴文件、/compact(直接从斜杠菜单里去掉,而不是画成灰的——斜杠菜单是「你能要什么」的清单);
  • RemoteConversationView:fork / continue、审批卡的 allow/deny(卡仍保留,只是按钮关掉并在旁边写原因——决定仍然欠着,藏起来会让人以为 run 无缘无故停了)。

判定只读 control,不读 peerHeld:决定这件事的是 host 自己的 control(它在被别的设备持有时拒绝业务命令),链路此刻通不通是另一个问题。太旧、不报 control 的 host 视为自己在用,与全仓其他地方一致。

不采用「自动退出会话」

状态可逆,为一时的读不到而清空阅读位置不划算;且仓里已有「不按 catalogue 缺失判断」的先例(forgetRemoteConversation 的注释专门写了这点,因为网络抖动时 catalogue 也会缺);手机端 StandbyNotice.tsx 早就选择了留在会话里。

回归

  • catalogue 短暂缺失(网络抖动)不得触发任何退出、不得清空阅读位置,也不得把标题改写成 id——这条用 AppShell.test.tsx 的用例锁住,是上面那个先例要防的东西;
  • control 缺失(旧 host)不得关闭任何写入口;
  • standby 下各写入口的关闭各有用例;横幅只在 chrome === "full" 下出现(面板格子里没有 composer)。

范围

纯 desktop TS,无 Rust、无 cargo/make build。手机端已有 StandbyNotice,本次不动;若手机端也存在「standby 时按钮仍可按」的问题,另开单。

i18n 新增 heldTitle / heldTitleUnknown / heldCannotSend / heldSendBlocked / heldApprovalBlocked(en + zh)。

…its writes

Another paired device taking a machine over is a reversible state, not the end
of the conversation: the transcript had already been read, and taking control
back restores everything. What was wrong was what the state did to the screen.

The header lost its title. A conversation is named by the host's catalogue, and
a standby client is sent no snapshots and is refused every read, so every row of
that host leaves the catalogue — `useRemotePeers` drops them, and has to — and
the title fell back to the session id, turning a conversation the reader was in
the middle of into `20261022-164713-ea5b…`. The last title and workspace name
seen are now remembered per desktop+session (`remoteConversationIdentity`) and
read back when the catalogue no longer carries them: display only, the
catalogue still wins whenever it has a row, and a conversation never seen still
falls back to its id. The same memory covers a failed read, which empties the
rows for a round and must not rename anything either.

What the state did not do was say so, or stop the writes. The phone put that
sentence beside its composer long ago; the desktop offered a send button that
ended in the host's own `superseded` refusal. So the conversation now draws the
notice (holder's name, "nothing sent from here will arrive", and the takeover
the device picker already sends), and the writes it would have lost are closed
before they are sent: send, attachment staging, `/compact`, fork, continue and
the approval buttons, each with the reason beside it.

Nothing exits the conversation: a catalogue that blinks, or a machine someone
else holds, keeps the reader's place, which is the rule the delete path already
followed (`forgetRemoteConversation`).
@huichen
huichen merged commit e2fbfbf into main Oct 24, 2026
10 checks passed
@huichen
huichen deleted the fix/remote-standby-reading branch October 26, 2026 07:45
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