Repository navigation
feat(desktop): 可信位置页按连接列出并删除远程工作区的信任记录 (#2231) - #2284
Merged
Merged
Conversation
设置 › 工具 › 可信位置新增“远程工作区”卡片,按连接列出已信任、安全模式和可信位置记录; 删除是草稿,底栏应用时经 Core 撤销命令一次写入,冲突后重新读取并保留仍存在的删除。 顺带修正 workbench/git.go 的 gofmt 对齐。
xiaoyumuxi
marked this pull request as ready for review
November 21, 2026 12:44
1 task done
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
#2283 起,打开远程工作区时会按连接询问是否信任,Core 把决定写进偏好目录的
toolchains/remote-trust.json。用户之前没有办法查看这些记录,也撤销不了“已信任”或“保持安全模式”的选择,只能手动删文件。Zed 远程安全设计 S04 要求信任记录能看到、能撤销。本 PR 在“设置 › 工具 › 可信位置”页加了一张“远程工作区”卡片:按连接列出记录,可以逐条删除。删除先记为草稿,点底栏的“应用”或“确定”才写入。改动 / Changes
Core 调用封装(
desktop/internal/core/remote_helpers.go)RemoteWorkspaceTrustDocument和RemoteWorkspaceTrustTarget,对应 Core 信任文档的结构(version、targets、label、三个列表)。Target保留原始 JSON,用来原样回传给 Core。RemoteWorkspaceTrustTarget.Place()从 hops 拼出主机显示文本,例如dev@devbox:2222、lab → docker:web,用户名、端口、容器按层级显示。RemoteTrustTrustedWorkspaces、RemoteTrustDistrustedWorkspaces、RemoteTrustTrustedLocations。RemoteWorkspaceTrustRevoke和Client.RevokeRemoteWorkspaceTrust,调用 Core 已有的撤销命令(固定版本 a73d60f 已包含)。撤销不需要打开会话;撤销不存在的条目不写文件;目标被清空时由 Core 删除。Decisions字段。远程信任读写(
desktop/internal/remoteconn/trust.go)Trust.Revoke:一次请求把多条撤销串起来,最后只写一次文件。文件在读取之后被别处修改过时返回ErrConflict;没有实际变化时不写文件。publish和trustEditError,“决定”和“撤销”共用同一套冲突与错误分类;新增errNoTrustDocument。设置窗口(
desktop/internal/settingswindow/)remote_trust_state.go,保存卡片状态:读取、按连接分组、草稿(删除和撤销删除)、写入,以及冲突后重新读取。冲突后只保留仍然对应现有记录的删除草稿。trusted_locations_view.go新增“远程工作区”卡片:toolchains_state.go、window_view.go:只有 loader 实现了远程信任接口时才显示这张卡片,草稿数计入底栏的“应用”。build_apply.go:底栏“应用”多了一个写入远程信任撤销的步骤,失败时提示放在卡片上,底栏显示失败。项目窗口接线(
desktop/internal/workbench/)settings_toolchains.go新增LoadRemoteTrust和SaveRemoteTrust,读写全局偏好目录的远程信任记录。失败通过recordFailure记录,事件为remote_trust_settings_load和remote_trust_settings_save,只记命令和错误码,不记主机路径。保存操作标记为remote.workspaceTrust.revoke。app.go:kernel 接口新增RevokeRemoteWorkspaceTrust。git.go:修正 feat(desktop): 远程工作区信任后在主机上运行 Git,安全模式与信任询问在项目窗口生效 (#2231) #2283 留下的err error字段的 gofmt 对齐。只调整格式,行为不变。文案(
shared/i18n/features/trusted-locations.json)remoteFailed带reason参数。desktop/internal/i18n/shared.generated.go。功能矩阵(
shared/platform-feature-matrix/features/workspace-trusted-locations.json)截图(
docs/assets/trusted-locations/)不在本 PR 范围内 / Out of scope
类型专属:feat
多平台对齐
范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/workspace-trusted-locations.json。远程部分的两端验证状态如实保持原状,没有声称已做原生验收。./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
UI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR=… ../scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/settingswindow -run '^TestVisualTrustedLocations$' -count=1。场景为列表和删除草稿,覆盖明暗主题和中英文。列表(深色,中文)
删除草稿(浅色,中文):第二条记录标“待删除”,底栏出现“应用”
List (light, English)
Drafts (dark, English)
统一日志系统 / Structured logging
recordFailure和documentLogError。没有新增事件 ID,也没有print或直接写 stderr。界面文案 / i18n
shared/i18n/features/trusted-locations.json,中英文齐全,已重新生成并提交生成文件,通过i18n.Shared用字面量键读取node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,都通过,没有放宽脚本逻辑归属 / Logic placement
性能与内存 / Performance and memory
设置 / Settings
插件契约 / Plugin contract
N/A:没有改插件契约、能力版本或宿主方法。用的是 Core 远程模块已有的撤销命令,不属于插件 API。
发行包与资源 / Bundle and resources
globalToolchainRoot())下的toolchains/remote-trust.json,不写 app bundle 或安装目录。已运行./scripts/desktop/verify/verify-runtime-bundle-immutability.sh,通过无用代码与重构 / Dead code and refactoring
workbench/git.go的 gofmt 对齐,是格式问题,没有发现需要建单的债务验证 / Verification
../scripts/desktop/desktop-go.sh vet ./internal/...../scripts/desktop/desktop-go.sh test ./internal/settingswindow ./internal/remoteconn ./internal/core../scripts/desktop/desktop-go.sh test ./internal/workbench -count=1test-stability-macos.sh --package ./internal/settingswindow -- --filter 'TestRemoteTrust'test-stability-macos.sh --package ./internal/remoteconn -- --filter 'TestRemoteTrust'TestVisualTrustedLocations(vivahead,lithevisual)node scripts/i18n/generate-i18n.mjs --checknode scripts/i18n/verify-app-language-localization.mjsscripts/platform-feature-matrix/verify-platform-feature-matrix.shscripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEADscripts/desktop/verify/verify-runtime-bundle-immutability.shrg新增测试:
remoteconn/trust_test.go的TestRemoteTrustRevokeRemovesRecordsWithoutAConnection用真实 Core 覆盖以下行为:ErrConflict。settingswindow/remote_trust_state_test.go:TestRemoteTrustRecordsAreListedDraftedAndApplied。TestRemoteTrustConflictReadsAgainAndKeepsTheListedRemovals。TestRemoteTrustCardShowsOnlyWithALoader。未能执行的检查和原因:
提交前确认 / Final checks
main(010ee2945)创建,目标分支main*.example.com、devbox、lab),没有凭据或个人路径