Repository navigation
feat(desktop): 关闭远程工作区时确认远端进程,可保留在主机上并在下次连接接回 (#2231) - #2291
Merged
Merged
Conversation
- 关闭窗口、标签、项目,退出 Lithe 或切换工作区时,主机上还有 Lithe 启动的终端或进程就询问: 取消 / 保留在远端并关闭 / 结束并关闭(默认);正文原样列出类型、名称、命令和已运行时长; “记住我的选择”带 ⓘ,记住后只能在 设置 › 工具 › 远程工作区 修改 - 保留:先把恢复凭据按连接存入系统密钥存储(每连接最多 8 条,适配 Windows 凭据管理器 2560 字节), 再让 Core 经 remote.disconnect programs=keep 保留主机会话;存不下或主机拒绝时改为结束并提示 - 下次经同一连接或 WSL 发行版连接时带上最新凭据接回,打开文件夹后列出上次保留的进程, 可经 remote.endPrograms 只结束它们或继续运行;接回后没打开工作区就再保留一次 - 设置 › 工具 › 远程工作区 新增“关闭工作区”卡片:关闭时的远端进程(每次询问/结束/保留在远端)、 常驻会话的空闲超时(只读,来自 Core closing.idleTimeoutSeconds) - Core 客户端新增 RemoteRunningPrograms、RemoteEndPrograms、RemoteDisconnect 的 programs 参数与 resume; 固定 Core 到 a81ad08(Core Draft #160) - 日志只记 remote.close.* / remote.kept.* 动作与失败操作名,不记命令、进程名、主机或令牌 - 中英词条、功能矩阵、Agent Note、无头截图(docs/assets/remote-close、remote-settings)
This was referenced Nov 21, 2026
xiaoyumuxi
marked this pull request as ready for review
November 22, 2026 01:15
This was referenced Nov 22, 2026
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.
关联 Issue / Linked issue
ac80382df327579a92dba105abd9fddceef29a29(含 [Bug] 双击左侧文件栏目中的文件会卡住 #159、【bug】mac上的一些页面优化建议 #160、【bug】mac上卡顿问题 #161)PR 类型 / Type
改动说明 / What changes
背景 / Why
原来关闭远程工作区(“断开并关闭”、关窗口、退出 Lithe)时会直接结束主机会话。用户在主机终端里跑着的构建、
npm run dev等进程会被悄悄结束。Issue #2231 要求关闭前先确认:可以每次询问,也可以记住选择,记住后在设置里改。保留在远端的进程,下次连接时要能看到并结束。改动 / Changes
关闭确认(
desktop/internal/workbench/remote_close.go,新文件)remote.runningPrograms读主机上 Lithe 为这个工作区启动的进程和终端:remote.editPreferences(closePrograms)写入remote/preferences.json。之后关闭时直接按设置结束或保留。remote.disconnect(programs=keep)保留主机会话。remote.endPrograms只结束列出的进程,不动这次新开的;保留会话的存储(
desktop/internal/remoteconn/kept.go,新文件)@host/remote-sessions,每个连接一项。账户名是连接 id 的 SHA-256 前 128 位,所以密钥存储的列表里看不出主机或发行版名。设置 › 工具 › 远程工作区(
settingswindow/remote_workspace_view.go、remote_preferences_state.go)选择是草稿,“应用”后经
remote.editPreferences写入,再读回显示。closing.idleTimeoutSeconds(10 分钟),ⓘ 说明断线且没人保留的会话多久后由主机结束。Core 客户端与接线
core/remote_session.go:RemoteRunningPrograms和RemoteEndPrograms;RemoteDisconnect新增programs参数,返回RemoteDisconnectResult{Kept};RemoteConnectRequest.Resume和RemoteSession新增SessionKey、SessionToken、Resumed、KeptPrograms字段。core/remote_preferences.go:新增ClosePrograms和RemoteClosing{Source, Programs, IdleTimeoutSeconds}。workbench/app.go:Kernel接口跟着改;requestCloseProject在本机退出确认之后调用confirmRemoteClose;remoteKeptSecrets替身。workbench/window_sessions.go:新标签页继承remoteKeptSecrets。workbench/remote_browse.go和remote_workspace.go:连接时取最新的保留凭据作为resume,记下会话的Resume();打开工作区后提示保留的进程;连接被放弃时交还会话。workbench/remote_preferences.go:抽出remotePreferenceState,供重连间隔和关闭选择共用。workbench/pluginprompt.go:通用询问框的“记住”复选框旁可以带一个 ⓘ(checkHelp)。scripts/desktop/build-desktop-core.sh:PINNED_CORE_REVISION升到 Core mainac80382(【bug】mac上的一些页面优化建议 #160 已合入;同时带上 【bug】mac上卡顿问题 #161 的远程运行配置计划,本 PR 不使用)。文案、矩阵、Note、截图
shared/i18n/features/remote-connections.json和remote-settings.json补齐中英词条,并重新生成shared.generated.go。remote-workspace.json更新了以下内容:.agents/notes/implemented/feature/2026-11-22-remote-workspace-close-keeps-host-programs.md:写为什么先存凭据再保留,以及被否的方案。docs/assets/remote-close/的截图(6 张);重拍docs/assets/remote-settings/的截图,因为页面多了关闭卡片,并新增“关闭时保留”草稿截图。不在本 PR 范围内 / Out of scope
类型专属:feat
多平台对齐
范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/remote-workspace.json:两端证据加入remote_close.go、remoteconn/kept.go(macOS 另有测试文件),验证动作和 notes 如实写,验证状态保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(validated 221 platform capabilities)和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD(通过).artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;没有写插件的构建步骤或资源路径pluginPrompt只多了一个可选的checkHelp,不设置时外观和行为不变,不影响已发布插件UI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=… scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual -count=1 -run 'TestVisualRemoteClose$' ./internal/workbench/LITHE_VISUAL_OUTPUT_DIR=… scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual -count=1 -run 'TestVisualRemoteWorkspace$' ./internal/settingswindow/关闭时询问(列出终端和进程、命令原样显示;“记住我的选择”带 ⓘ;默认“结束并关闭”)
选“保留在远端并关闭”后的通知
下次连接打开文件夹后列出上次保留的进程
设置 › 工具 › 远程工作区:自动值(新增“关闭工作区”卡片)
设置:关闭时“保留在远端”的草稿
统一日志系统 / Structured logging
performed:remote.close.cancel/keep/end、remote.kept.end/keep。backgroundFailed、operationFailed、operationRejected:remote_close_programs、remote_close_preferences、remote_close_remember、remote_keep_programs、remote_kept_sessions。记住选择写不进去时另外通知用户。print,也没有直接写 stderr。log-exempt注释说明后直接返回。remoteLogError、documentLogError)。界面文案 / i18n
shared/i18n/features/remote-connections.json和remote-settings.json补齐了中英词条:对话框、按钮、复选框与 ⓘ、类型、时长、通知、设置行。已运行node scripts/i18n/generate-i18n.mjs并提交生成结果;Viva 代码通过i18n.Shared、i18n.SharedFormat读取。node scripts/i18n/verify-app-language-localization.mjs(通过)和node scripts/i18n/generate-i18n.mjs --check(en-US、zh-CN 12398/12398)逻辑归属 / Logic placement
以下规则都在 Rust Core(【bug】mac上的一些页面优化建议 #160):
server.keep);桌面端只做询问、通知、系统密钥存储的读写和呈现。
[N/A] 没有修改平台层已有的可共享逻辑
没有按工具名加分支
性能与内存 / Performance and memory
remote.runningPrograms往返,在后台运行,超时同remoteDisconnectTimeout。连接时读一次系统密钥存储,也在后台。没有新增轮询、缓存或常驻进程。保留会话列表每个连接最多 8 条。设置 / Settings
remote.preferences;remote/preferences.json,并重新读取;2026-10-15-macos-settings-hierarchy.md确定插件契约 / Plugin contract
N/A:只依赖 Core 的远程 API,不涉及插件契约、能力版本或宿主方法。用到的 API 有:
remote.runningPrograms、remote.endPrograms;remote.disconnect的programs;remote.connect的resume;remote.preferences的closing和closePrograms。发行包与资源 / Bundle and resources
保留会话的凭据写在系统密钥存储(命名空间
@host/remote-sessions),由本机用户拥有:它不在 app bundle 或安装目录里,不影响代码签名或 Sparkle 增量包,生命周期写在
remoteconn/kept.go的注释和 Agent Note 里。已运行./scripts/desktop/verify/verify-runtime-bundle-immutability.sh,通过。[N/A] 没有新增下载、解压或缓存资源
无用代码与重构 / Dead code and refactoring
remotePreferenceState验证 / Verification
scripts/desktop/desktop-go.sh test ./internal/workbench ./internal/remoteconn ./internal/settingswindow ./internal/core -count=1scripts/desktop/desktop-go.sh test ./internal/workbench ./internal/remoteconn ./internal/settingswindow -run 'RemoteClose|Kept|RemoteWorkspace' -count=1:remote_close_test.go7 个测试、kept_test.go3 个测试、TestRemoteWorkspace*5 个测试scripts/desktop/desktop-go.sh vet ./internal/workbench ./internal/remoteconn ./internal/settingswindow ./internal/coreTestVisualRemoteClose、TestVisualRemoteWorkspace无头截图node scripts/i18n/generate-i18n.mjs --check、node scripts/i18n/verify-app-language-localization.mjs./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh、verify-platform-feature-matrix-change.sh origin/main HEAD./scripts/agent-notes/verify-agent-notes.sh./scripts/desktop/verify/verify-runtime-bundle-immutability.shgofmt -l(改动的包)rg未能执行的检查和原因:
main合进本分支(merge,不改写历史):远程工作区设置页同时保留“端口转发”卡片(反向转发)和“关闭工作区”卡片,Core 客户端的偏好结构同时带allowReverseForwarding和closePrograms;功能矩阵合并两边的说明,设置页测试数改为 6 个;截图重新生成。提交前确认 / Final checks
main(994b67331)创建,目标分支main