Repository navigation
feat(settings): 可信位置设置页 (#2207) - #2255
Merged
Merged
Conversation
设置 › 构建、执行、部署新增“可信位置”页:按保存顺序列出可信文件夹, 添加和删除先进草稿,由 Core 的 toolchains.editCatalog 预演并在应用时 原子写入本机工具链目录;与工具链页共用同一个目录文件,写入互相标记过期。
pump 只重画已失效的区域,直接改页面后截到的仍是目录页,列表截图与目录截图字节相同。改为通过 openBuildChild 切页,并等到列表的第一个文件夹出现在画面上再截图;重新生成列表和草稿截图。
xiaoyumuxi
marked this pull request as ready for review
November 21, 2026 03:49
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
toolchains.editCatalog可以单独添加和删除可信位置,拒绝把文件系统根目录设为可信位置)PR 类型 / Type
改动说明 / What changes
背景 / Why
#2201 的“信任并打开项目”对话框可以勾选“信任父文件夹”,Core 把这个文件夹记进本机工具链目录(偏好目录的
toolchains/global.json)的trustedLocations,此后这个文件夹里任意层级的项目都直接以信任方式打开。但用户看不到这个列表,也没法删掉一个已经不该信任的文件夹,只能手改 JSON。Core #144 已经让
toolchains.editCatalog能单独添加和删除可信位置,并且拒绝文件系统根目录(plugin.toolchain.rootLocation)和超过 256 项(plugin.toolchain.trustListFull)。本 PR 在设置 › 构建、执行、部署下加了“可信位置”页,对齐 IntelliJ IDEA 的 Settings › Build, Execution, Deployment › Trusted Locations:改动 / Changes
Core 固定版本
scripts/desktop/build-desktop-core.sh:PINNED_CORE_REVISION从94408ca升到 Core main7c1cd55(包含 继续优化 macOS 界面细节与更新了单文件编辑器体验 #143 的 Unix socket 对端账户检查合并,和 【功能建议】win端允许应用内部检查更新 #144 的可信位置编辑)。Core 客户端(
desktop/internal/core/toolchain_catalog.go)ToolchainCatalog补上 Core 返回的DistrustedWorkspaces和TrustedLocations。ToolchainTrustedLocationsEdit{Add, Remove}和EditToolchainTrustedLocations:调用toolchains.editCatalog的trustedLocations编辑,只返回结果文档,不写文件。工具链适配器(
desktop/internal/toolchain/catalog.go)TrustedLocations(列表加上读取时的文件快照)、LocationChange{Folder, Add}和ReadTrustedLocations。Preview把草稿逐项交给 Core 预演,返回结果列表,不写任何文件。失败时用LocationChangeError{Index, Err}指出是哪一项被拒,界面只撤掉这一项。Save按读取时的字节做冲突检查(文件被别处改过就返回ErrPinConflict),然后原子写入。改动互相抵消、结果与原列表相同时不写文件。catalogSource.verify和catalogSource.replace,工具链默认值、信任对话框和可信位置三处共用。设置窗口(
desktop/internal/settingswindow)model.go:新增pageTrustedLocations,归在“构建、执行、部署”下,并补上标题和搜索关键词。trusted_locations_view.go(新):trusted_locations_state.go(新):toolchains_state.go:catalogWritten、trustWritten);busy()包括可信位置的请求,保证同一时间只有一个写入;plugin.toolchain.rootLocation和plugin.toolchain.trustListFull映射为界面文案。build_apply.go:build_directory_view.go、build_style.go:目录页新增“可信位置”一行,橙色图块加盾牌图标,描述显示“N 个可信文件夹”或“没有可信文件夹”。window_view.go:侧栏的“可信位置”有草稿时显示圆点;页面路由。controller.go:新增TrustedLocationsLoader接口(读取、预演、写入),由工具链加载器选择性实现;没有实现时不显示这个页面。工作台(
desktop/internal/workbench/settings_toolchains.go)LoadTrustedLocations、PreviewTrustedLocations、SaveTrustedLocations。写入成功后,打开的项目按新的信任状态进入或离开安全模式(reloadProjectTrust),因安全模式没启动的语言服务器重新尝试启动,然后重新读取列表。写入成功但重新读取失败时返回ErrPinCommitted,界面会重新读取,不会把已写入的草稿再写一次。recordFailure记录(toolchain_settings_trusted_locations_load/preview/save),写入记为toolchain.trustedLocations.save按钮操作。文案、矩阵与 Note
shared/i18n/features/trusted-locations.json:新增 15 条中英词条,已生成shared.generated.go;SettingsMessages.TrustedLocations读取页标题。shared/platform-feature-matrix/features/workspace-trusted-locations.json(新):两端都是implemented,验证状态保持pending,已写证据路径和验收动作。workspace-trust.json的说明改为指向这个条目。.agents/notes/implemented/feature/2026-10-15-macos-settings-hierarchy.md:“构建、执行、部署”一行加上“可信位置”。.agents/notes/implemented/feature/2026-11-19-workspace-trust-and-safe-mode.md:记下可信位置页的决策(草稿、逐项预演、拒绝码、撤销语义、应用顺序、互相标记过期、写入后重试读取),更新过时的后果描述,补充验证命令。测试与截图
desktop/internal/toolchain/trusted_locations_test.go(新):用真实 Core 测预演不写文件、写入后嵌套项目以信任打开、过期写入返回冲突、互相抵消的改动不写文件、拒绝根目录并指出第几项、偏好目录缺失时读取失败。desktop/internal/settingswindow/trusted_locations_view_test.go(新):用假加载器在无头窗口里测草稿标记、撤销、应用、拒绝后保留其他草稿、过期列表先重读再写、写入后重新读取,以及目录页的计数和跳转。desktop/internal/settingswindow/trusted_locations_visual_test.go(新,vivahead && lithevisual)和docs/assets/trusted-locations/:12 张无头截图和 README。不在本 PR 范围内 / Out of scope
distrustedWorkspaces)的列表和管理:IDEA 也没有这个页面,用户在安全模式提示条里可以重新信任。类型专属:feat
多平台对齐
filepath.FromSlash,Windows 显示反斜杠;根目录和路径身份(Windows 不区分大小写)由 Core 按平台判断。platform-specific),理由:范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/workspace-trusted-locations.json:两端的实现状态为implemented,没有做实机验收,验证状态保持pending;证据路径、owner、验证动作已如实填写./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(220 项能力校验通过)和./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;新增词条都是宿主的可信位置页文案UI 验证 / UI evidence
LITHE_VISUAL_OUTPUT_DIR="$(pwd)/docs/assets/trusted-locations",在desktop/下运行../scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/settingswindow -run '^TestVisualTrustedLocations$' -count=1 -timeout 180s;场景是目录页、已保存的列表、草稿与拒绝提示,覆盖深浅主题与中英文,用设置窗口默认尺寸。路径都是虚构的统一日志系统 / Structured logging
settingsToolchains.recordFailure各记一次,写入经performedIn记为按钮操作;目录选择器出错走已有的MarketplaceError;没有print或直接写 stderrlog-exempt注明原因)error,不单独记录文件夹列表或目录文件内容;没有记录凭据或环境变量值界面文案 / i18n
shared/i18n/features/trusted-locations.json,已运行node scripts/i18n/generate-i18n.mjs并提交生成结果node scripts/i18n/verify-app-language-localization.mjs(中英各 11949/11949 条)和node scripts/i18n/generate-i18n.mjs --check逻辑归属 / Logic placement
性能与内存 / Performance and memory
设置 / Settings
toolchains/global.json的真实trustedLocations;打开页面不创建也不改写文件;应用时按读取时的字节检查冲突后原子写入,并重新读取;写入失败保留草稿;没有敏感字段插件契约 / Plugin contract
N/A:Core #144 只改了宿主调用的
toolchains.editCatalog(rust/contracts/rust-core-api.md、toolchain-global-v1.schema.json),没有改插件契约、能力版本或插件函数协议,也没有新增宿主方法。发行包与资源 / Bundle and resources
toolchains/global.json(已有文件,归平台存储 adapter 管理),不向 app bundle 或安装目录写入;已运行./scripts/desktop/verify/verify-runtime-bundle-immutability.sh无用代码与重构 / Dead code and refactoring
SaveCatalog和saveWorkspaceTrust里重复的冲突检查和写回抽成catalogSource.verify、replace,没有留下重复代码验证 / Verification
../scripts/desktop/desktop-go.sh test ./...(换 pin 前,Core 检出已含 #144)../scripts/desktop/desktop-go.sh test -race(可信位置涉及的包)../scripts/desktop/desktop-go.sh vet和test ./internal/toolchain ./internal/core ./internal/settingswindow ./internal/workbench(固定 Core7c1cd55后)./.agents/skills/write-stable-tests/scripts/test-stability-macos.sh --package ./internal/toolchain --package ./internal/settingswindow --filter 'TrustedLocations'./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/mainTestVisualTrustedLocations(vivahead,lithevisual)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/desktop/verify/verify-runtime-bundle-immutability.shdevelop-lithe第三节插件归属自查命令未能执行的检查和原因:
filepath.VolumeName(folder)+Separator,Windows 上也成立。提交前确认 / Final checks
main创建,已变基到最新origin/main;目标分支main.build/、target/、dist/、.artifacts/等产物,截图里的路径都是虚构的t.Cleanup关闭,没有进程残留