Repository navigation
feat(desktop): 远程工作区信任后在主机上运行 Git,安全模式与信任询问在项目窗口生效 (#2231) - #2283
Merged
Merged
Conversation
xiaoyumuxi
marked this pull request as ready for review
November 21, 2026 12:19
This was referenced Nov 21, 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
PR 类型 / Type
改动说明 / What changes
背景 / Why
#2231 接缝④。以前远程工作区打开后一直处于“只能看和改文件”的状态:远程开发窗口里的信任询问(#2279)只决定打开方式,项目窗口里看不出是不是安全模式,也不能在窗口里再信任;Git 在远程工作区里完全不可用,提交窗口和日志都是空的。远程开发也必须能看 diff、提交、追溯。
本 PR 让远程信任在项目窗口里真正生效(Zed 安全设计 S02/S03/S05),并在信任后让 Git 在主机上运行:状态、提交、差异、日志、逐行追溯、排除、搁置、暂存都读写主机上的仓库,主机上 git 目录的变化通过
remote.runWatch推回本机刷新。仍要在主机上跑代码的运行、测试、构建和插件语言服务器在远程工作区里明确拒绝并说明原因,不会在本机占位目录里误跑。改动 / Changes
远程信任在项目窗口生效(S02/S03/S05)
remote_workspace.go:openRemoteFolderNow(dir, trusted)按远程开发窗口里的选择决定项目是安全模式还是已信任,打开后用applyProjectTrust生效;没有决定过的文件夹先显示信任询问(remote_browse.go),询问前不打开工作区。workspace_trust.go:远程工作区的“信任项目…”走 Core 的remote.editWorkspaceTrust(带连接名作为 Label),不写本机可信位置;reloadRemoteTrust从 Core 的remote.workspaceTrust读回结果,remoteTrusted只在ProjectCodeAllowed且状态为 trusted 时视为已信任。remote_trust.go:信任询问的决定写入 Core 后再打开;trustRemoteProject供项目窗口复用;读取或写入失败分别记remote_trust_read、remote_workspace_trust。shell_view.go:编辑器上方的远程横幅区分两种状态:安全模式显示desktop.remote.workspace.safeBanner和“信任项目…”链接;已信任显示desktop.remote.workspace.banner(终端和 Git 在主机上运行,运行、调试、语言服务器暂不可用)。信任后 Git 在主机上运行
core/remote_session.go:新增RemoteCreateDirectory(fs.createDir,递归),供在主机上写 info/exclude 前建目录。remote_git.go(新增):RemoteRunWatch走会话,变化交给和本机项目同一套按路径分类的逻辑(git_observation.go);会话断开或项目关闭时停止,新会话由resumeRemoteGit重新监听并重扫状态。remoteRepositoryAbove:Core 返回的仓库根在占位目录之外(打开的是仓库的子目录)时,Git 和提交窗口说明“仓库从上级目录开始,请打开仓库顶层文件夹”,不显示路径对不上的变更、不记为失败。完整支持在 [Feature] 远程工作区支持从上级目录开始的 Git 仓库(打开 monorepo 子目录时 Git 可用) #2282。appendInfoExclude的主机版本:按期望版本读改写主机上的info/exclude,有大小上限。git_observation.go:远程工作区有会话时启动主机监听而不是本机文件监听;监听失败经p.logError只记命令名和错误码。git_exclude.go:远程工作区的“添加到 .git/info/exclude”写主机上的文件。gitreview.go:逐行追溯读取主机上的文件内容(remoteBlameText),超过读取上限时照常显示注解、不显示行内容;失败原因走远程文档的统一说明。git.go、commit_view.go、gitlog_view.go:新增remoteAbove状态和对应的空状态说明。remoteplaceholder:新增HostPath/LocalPath/HostSuffix,在占位路径和主机路径之间换算,包括 Core 映射到占位目录旁.lithe-remote-host的工作区外路径;Windows 上拒绝含\的主机文件名(否则会指向另一个路径)。工作树
gitworktree.go、gitworktree_view.go、worktree_window.go:远程工作区可以列出、锁定、解锁、移除 Git 工作树,“复制路径”复制主机路径;打开、在新窗口打开、在 Finder 中显示、新建会拒绝并说明(为另一个主机文件夹开会话在后续阶段)。仍要在主机上跑代码的功能明确拒绝
title_run.go、title_run_entrypoints.go、tests.go、build.go:运行、运行当前文件、测试、构建任务在远程工作区经refuseRemote拒绝(title_run、run_current_file、run_start、test_start、build_task),不在占位目录里探测构建系统。pluginbackends.go:远程工作区不启动插件语言服务器。shell_view.go:remoteToolWindow允许项目、通知、终端、查找、Git、提交工具窗口,其余显示remoteLocalOnlyPanel;editor.find、github.parseRemote加入本机命令白名单。文案、测试与截图
shared/i18n/features/remote-connections.json:新增desktop.remote.workspace.safeBanner、desktop.remote.workspace.gitAbove,更新banner、localOnly;已重新生成。remote_git_test.go(新增):信任前询问、信任后 Git 在主机上运行(含主机监听和断线重连恢复)、排除写主机、追溯读主机文件、仓库从上级目录开始、运行/测试/构建/语言服务器被拒绝。remote_workspace_test.go、remote_workspace_visual_test.go:适配信任流程;视觉测试新增信任询问和“仓库从上级目录开始”两个场景,并在 feat(desktop): 远程开发窗口按原型补齐选文件夹、信任、导入页和测试结果 (#2231) #2279 的新界面上重新生成了全部截图。shared/platform-feature-matrix/features/remote-workspace.json:能力描述加“远程信任与主机 Git”,补证据和验证动作。截图 / Screenshots
其余场景(选择文件夹、状态栏菜单、打开文件、保存冲突、终端、搜索、Search Everywhere)在 #2279 的新界面上重新生成了,见
docs/assets/remote-workspace/README.md。不在本 PR 范围内 / Out of scope
类型专属:feat
多平台对齐
改动都在 Viva 共用代码里,两端同一份实现;Windows 实机未验证,矩阵 Windows 验证状态保持
pending(Windows 远端路径问题见 #2264)。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/remote-workspace.json:两端的实现状态和验证状态、证据路径、owner、验证动作都如实填写;没有运行验证的保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh;改了平台实现路径的,还运行了./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;插件的构建步骤、资源路径和补丁没有写进docs/ci-builds.md、Agent Note 或 SkillUI 验证 / UI evidence
TestVisualRemoteWorkspace(-tags vivahead,lithevisual),提交 1d65767,十个场景,浅色英文与深色中文,1200×760docs/assets/remote-workspace/(横幅说明 Git 不可用),改动后横幅区分安全模式和已信任;macOS 原生窗口和真实 SSH 主机整机验收未做统一日志系统 / Structured logging
remote_workspace_trust、git_metadata_watch(远程监听)、git_exclude、git_blame,拒绝记录title_run、run_current_file、run_start、test_start、build_task、git_worktree_open、git_worktree_reveal、git_worktree_create、worktree_open_new_window;没有print、直接写 stderr 或手写事件 IDlog-exempt注明)p.logError只记命令名和错误码(Core 的远程错误消息可能含主机路径),测试断言日志里没有主机和主机路径界面文案 / i18n
shared/i18n/补齐中英词条,运行node scripts/i18n/generate-i18n.mjs并提交生成结果,没有手改生成文件;Viva 代码通过desktop/internal/i18n/的接口读取node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
remoteplaceholder.HostPath/LocalPath是占位目录(桌面端本机 I/O)的路径换算,和 Core 的映射规则对应,不是业务规则性能与内存 / Performance and memory
a.background里设置 / Settings
N/A:没有新增或修改设置项。
插件契约 / Plugin contract
N/A:没有改插件契约、能力版本或宿主方法;使用的
remote.*、fs.createDir是 Core 已合入的客户端接口。发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh:没有新增资源路径,Git 的元数据写在主机上,测试断言占位目录里没有.gitdocs/ci-builds.md:没有新增下载、解压、生成或缓存资源无用代码与重构 / Dead code and refactoring
验证 / Verification
../scripts/desktop/desktop-go.sh vet ./internal/workbench ./internal/core ./internal/remoteplaceholder../scripts/desktop/desktop-go.sh test ./internal/workbench ./internal/core ./internal/remoteplaceholder(变基前全量)../scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestRemote' -count=1(变基到 46586ce 后)test-stability-macos.sh --package ./internal/workbench -- --filter 'TestRemoteWorkspace(AsksToTrust|TrustStartsGit|ExcludesOnTheHost|BlamesTheHostsFile|SaysItsRepositoryStartsAbove|RefusesToRunItsCode)'TestVisualRemoteWorkspace(-tags vivahead,lithevisual)node scripts/i18n/generate-i18n.mjs --check、node scripts/i18n/verify-app-language-localization.mjsverify-platform-feature-matrix.sh、verify-platform-feature-matrix-change.sh origin/main HEADscripts/desktop/verify/verify-runtime-bundle-immutability.sh未能执行的检查和原因: Windows 未运行(共用代码,矩阵保持
pending);没有对真实 SSH 主机做整机验收(测试用替换内核模拟主机);macOS 原生窗口验收未做。提交前确认 / Final checks
main创建;目标分支:feat、fix、docs 为main,release 以发布流程要求为准.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图