[建议 / Feature] 远程 detached 模式:桌面端断开后,远端 sessions 继续运行
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 22
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
提交前确认 · Pre-submission checklist
- 我已搜索过现有 issue,确认这不是重复提议 / I searched existing issues and confirmed this isn't a duplicate.
- 我已阅读 CONTRIBUTING.md / I've read CONTRIBUTING.md.
问题类别 · Category
稳定性 / 崩溃 · Stability / Crash
涉及的 Agent 框架 · Agent framework
ZCode Agent(自研)
使用场景 · Use case
用 ZCode Desktop(v3.10.2)远程连接一台 Linux 开发机。桌面端通过 SSH 启动远端运行时:ZCODE_SERVICE_AUTHORITY_MODE="desktop-attached-remote",所有 session(zcode-cli)都是 zcode-server.cjs 的子进程,而 zcode-server 挂在那条 SSH 连接下面,只支持 stdio + 握手(单独启动会直接退出:fatal: Handshake timeout: no hello-ack received within 10s)。
结果:合上笔记本 / 电脑睡眠 / 网络断开时,SSH 通道关闭 → zcode-server 整个被杀 → 全部远端 session 同时停止。正在执行的 turn 全部被取消(日志中大量 Turn was cancelled、v4 session stopped)。重连后 session 能 resume(rehydrate 正常工作),但断线瞬间进行中的工作全部丢失。
单日日志统计:9 次 zcode_protocol.startup(远端服务器进程重启)、6 次干净的 shutdown;每一次都与"桌面端不在了"对应。文档提到可以通过 Remote / Bot Channel 持续查看进度、手机端控制 Agent,但当前架构下 authority 在桌面端一侧,"前端离线后任务继续跑"做不到。
建议方案 · Proposal
增加 detached / 常驻服务器模式,例如:
ZCODE_SERVICE_AUTHORITY_MODE=detached(或提供zcode server install把远端 server 安装为 systemd user service):桌面端断开时 zcode-server 继续运行并保留 resident session runtime,不随 SSH 通道退出;- 断线策略可配置:默认让运行中的 turn 继续执行并把状态写入 session DB(
tasks-index.sqlite已有 rehydrate 基础),或按配置暂停而非取消; - 桌面端重新连接时 attach 回正在运行的 server(一次 authority 交接),而不是重新 spawn 一个新的 stdio server。
预期价值 · Expected value
数小时级别的长任务(多 session、subagent 并行)不再因合盖 / 睡眠 / 断网 / 熄机而中断;与文档中 "Remote / Bot Channel / 手机端控制 Agent" 的定位一致。竞品参照:Cursor 的 Cloud Agents 已实现"本地机器不需要在线"(agent 跑在隔离的云 VM 里),Cursor CLI 也支持把会话交给云端继续跑。
你认为的优先级 · Your perceived priority
高 · High
你使用的 ZCode 版本 / 环境 · ZCode version / environment
v3.10.2 / Desktop 远程连接 → Linux x64 服务器(desktop-attached-remote)
补充材料 · Additional context
idle_timeout的 resident 卸载没有问题(下次使用会自动 rehydrate);问题只在于进程随 SSH 通道一起死亡。- 如需完整日志摘录(
zcode-2026-08-31.jsonl)可以提供。
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with zcode-server.cjs and the existing session rehydrate path backed by tasks-index.sqlite; review CONTRIBUTING.md before running the remote desktop-attached setup. Done means a detached server keeps resident sessions and active turns alive after the SSH client disconnects, then lets the desktop reconnect to those sessions instead of spawning a new stdio server.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, linux
- Domain
- backend, distributed-systems
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100