Skip to content

feat: 新增 Mosh 远程 workspace 传输方式 - #48

Open
kchen0x wants to merge 3 commits into
iAmCorey:mainfrom
kchen0x:feat/mosh-workspace
Open

feat: 新增 Mosh 远程 workspace 传输方式#48
kchen0x wants to merge 3 commits into
iAmCorey:mainfrom
kchen0x:feat/mosh-workspace

Conversation

@kchen0x

@kchen0x kchen0x commented Jul 31, 2026

Copy link
Copy Markdown

概述

在现有 SSH 远程 workspace 的基础上,新增 Mosh 传输方式。菜单项 File → New SSH Workspace… 改为 New Remote Workspace…,可在 SSH 与 Mosh 之间选择。Mosh 提供在高延迟、休眠、漫游和短暂断网下依然可用的响应式终端。

主要特性

  • 独立的 SSH 控制平面:Mosh 终端通过一条独立、非阻塞的 SSH 控制通道来同步可重放的 Agent 状态、远端 cwd、文件上传与清理。TCP/认证中断时,状态会显示 connected/stale/auth-required,但不会停止或重启 Mosh 终端;交互式凭据(密码/OTP/硬件密钥)全程由 OpenSSH 在应用内显式终端中处理。
  • 安全的远端运行时:使用私有的、token 作用域隔离的目录、有界协议、原子快照、经身份校验的清理,以及崩溃后持久化的尽力回收租约。网络静默永远不会触发 kill。
  • 向后兼容:持久化时对 Mosh 目标做双写,旧版本 Kooky 打开已保存的 Mosh workspace 时会安全降级为 SSH。

简体中文本地化

跟随 v0.47.0 新增的简体中文本地化,将本次新增的全部 Mosh UI 接入同一 .kookyResources 资源包,随 app 语言切换:

  • 创建面板(New Remote Workspace):传输方式 / UDP / 本地预测选择器、高级选项(SSH 端口、身份密钥文件、mosh-server、孤儿超时)、mosh 未安装警告与安装帮助链接。
  • OpenSSH 认证面板:标题、认证到 %@、凭据说明文案。
  • 状态 pill:完整标签(如 mosh · 状态已过期 N 秒)、短后缀(如 · 待认证)与重连 tooltip;传输名与主机名保持原样。
  • 设置 → 远程工作区 分区,以及 SSH 上传失败、远程启动被拒绝等失败文案。
  • 新增对应 zh-Hans 译文;英文回退到源串,无需 en.lproj 条目。

测试

  • swift build:0 警告
  • swift test:839 通过 / 0 失败(8 个环境条件跳过)
  • 新增专项测试:RemoteControlChannelTestsRemoteRuntimeProtocolTestsRemoteRuntimeScriptsTestsRemoteNetworkRecoveryMonitorTestsWorkspaceTransportTests

@kchen0x
kchen0x force-pushed the feat/mosh-workspace branch from b0fd5dd to 569cef0 Compare July 31, 2026 11:22
kchen0x and others added 2 commits July 31, 2026 19:43
Extend Remote Workspaces to support Mosh alongside SSH. File → New SSH
Workspace… becomes New Remote Workspace… with an SSH/Mosh choice.

- Mosh terminals run over an independent, non-blocking SSH control plane
  for replayable Agent state, remote cwd, uploads, and cleanup. TCP/auth
  drops surface connected/stale/auth-required status without stopping or
  relaunching the Mosh terminal; interactive credentials stay inside an
  OpenSSH PTY.
- Remote runtimes use private token-scoped directories, bounded
  protocols, atomic snapshots, identity-verified cleanup, and
  crash-persisted best-effort reap leases. Network silence never kills.
- Persistence dual-writes Mosh destinations so older Kooky releases
  safely downgrade a saved Mosh workspace to SSH.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
v0.47.0 added Simplified Chinese localization; wire the new Mosh UI into
the same `.kookyResources` bundle so it follows the app language.

- New Remote Workspace sheet, Mosh advanced options, and the OpenSSH
  authentication sheet now resolve every user-facing string through
  String(localized:) / LocalizedStringKey.
- Status pill label, its stale/auth/failed suffix, and the reconnect
  tooltip localize their copy; the transport token and host stay verbatim.
- Add zh-Hans translations for all of the above plus the SSH-upload and
  remote-launch failure messages.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kchen0x
kchen0x force-pushed the feat/mosh-workspace branch from 07a20e2 to 53e88b8 Compare July 31, 2026 11:43
@kchen0x

kchen0x commented Aug 1, 2026

Copy link
Copy Markdown
Author

Mosh orphan/busy-loop 修复已完成并推送,commit: b728472

主要改动:

  • 新增 detached remote reaper,作为 runtime 唯一清理执行者;PTY 删除、leader 退出或显式 SHUTDOWN 时,对登记的 agent PGID 执行身份校验后的 TERM → grace → KILL。
  • wrapper 通过继承的已打开 FD 非阻塞发送 REG/UNREG;UNREG 仅撤销登记,不清理正常退出后留下的后台任务。
  • SSH cleanup 优先路由到 reaper,reaper 不存在时使用带 KILL 升级的 direct fallback。
  • App 退出改为统一 deadline 等待 pending remote cleanup,不再固定等待 1 秒。
  • 最终核查补上关键事故竞态:wrapper 若先被 PTY hangup 杀死,reaper 会使用记录的 SID + PGID 验证并回收仍存活的 Codex 进程组。

安全说明:保留 7 天默认 MOSH_SERVER_NETWORK_TMOUT。reaper capability 只能在远端 bootstrap 阶段探测,而 timeout 在此之前已注入 mosh-server,无法按主机动态回退;全局降至 24 小时会让不支持 reaper 的主机更早暴露 PTY-death 风险。

验证:

  • swift test: 850 tests,0 failures,8 个 opt-in benchmarks skipped。
  • RemoteReaperTests: 11 个测试,覆盖 SHUTDOWN 路由、TERM→KILL、身份不匹配拒绝、UNREG、leader death,以及 wrapper 先死但同 SID/PGID agent 仍存活的回收路径。
  • 先前完成的 oc-jpa Linux 真机验证:reaper SID/PGID 脱离、deleted PTY 后约 1 秒回收、真实 cleanupCommand → reaper 端到端成功。

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