Repository navigation
fix(desktop): 允许关闭虚拟或干净文档并跳过工作区外最近文件记录 - #2099
Merged
Merged
Conversation
1lck
marked this pull request as ready for review
November 17, 2026 10:25
1lck
force-pushed
the
fix/virtual-external-document-close
branch
from
November 17, 2026 10:38
33ecd32 to
e121889
Compare
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
SpringApplication.java: 无法检查文件的外部变化且编辑标签页与窗口无法关闭,诊断日志同时记录了跨盘符调用filepath.Rel导致的editor_recent failed)PR 类型 / Type
改动说明 / What changes
背景 / Why
在 Windows 上跳转到外部依赖或虚拟源码类文件时存在两个关联缺陷:
saveBeforeClose只跳过了d.scratch,没有跳过d.virtual,因此仍调用checkBeforeClose→scheduleDocumentChecks对虚拟 URI 执行本地磁盘读取,引发desktop.document.externalReadFailed并置位d.checkFailed = true阻塞关闭。unwatchDocument、drainDocumentWatch、scheduleDocumentChecks与saveProjectPass也未全面跳过d.virtual。!d.dirty() && !d.view.IsComposing() && !d.conflicted),只要磁盘读取检查报非os.ErrNotExist错误(d.checkFailed = true),scheduleDocumentChecks也会无条件向checkWaiters回调done(false),导致无未保存修改的标签页和 IDE 窗口被锁死无法关闭。noteRecentFile直接调用filepath.Rel(p.root, d.path);当工作区位于D:盘而插件解压的只读依赖源码位于C:盘(AppData\Local)时,filepath.Rel跨盘符必定失败并弹出editor_recent failed(同盘符工作区外路径也会把../...写入最近文件记录)。openFile/openFileAt/openFileAtPosition/openStepDestination未对传入路径做filepath.Clean,在 Windows 上来自 URI 解码的斜杠路径可能导致位置映射键不一致。改动 / Changes
desktop/internal/workbench/documents.goopenFile、openFileAt、openFileAtPosition入口拦截空路径并执行filepath.Clean(path)。saveBeforeClose对d.virtual直接回调done(true)返回,不再触发checkBeforeClose。saveProjectPass在遍历未校验文档时跳过candidate.virtual。desktop/internal/workbench/navigation_history.goopenStepDestination先对destination.Document执行filepath.Clean,与openFile和p.docs.locations键保持一致。desktop/internal/workbench/document_observation.gounwatchDocument、drainDocumentWatch忽略d.virtual。scheduleDocumentChecks跳过d.virtual文档的磁盘检查,并在循环结束后释放其挂起的checkWaiters(done(true))。scheduleDocumentChecks后台校验回调仅在d.conflicted(含已删除文件的conflictMissing保护)或(d.dirty() || d.view.IsComposing()) && d.checkFailed时拒绝关闭(done(false));干净且未冲突的文档不因d.checkFailed阻断关闭。desktop/internal/workbench/recent_files.gonoteRecentFile改用projectRelative(p.root, d.path);位于工作区外的文档直接返回,不写入最近文件也不触发recentFailed。desktop/internal/workbench/document_observation_test.goTestVirtualDocumentClosesWithoutExternalCheckOrError、TestCleanDocumentClosesWhenExternalReadFails。desktop/internal/workbench/editor_essentials_test.goTestEditorEssentialsOutsideProjectFileDoesNotFailRecentFiles。shared/platform-feature-matrix/features/workspace-document-sync.json、shared/platform-feature-matrix/features/editor-recent-files.jsonverificationStatus保持pending)。不在本 PR 范围内 / Out of scope
类型专属:fix
复现与根因
D:盘工程),通过虚拟文档打开.classURI(如jdt://...)或使一个干净本地文件的后台外部读取检查失败,随后点击关闭标签页或关闭项目;修复前会提示无法检查文件的外部变化。且标签页/项目无法关闭;修复后虚拟文档跳过磁盘读取并正常关闭,干净未冲突文档不受读取失败锁死(已删除文档和带未保存改动的脏文档仍受保护)。../...路径记入最近文件(在 Windows 跨盘符时触发filepath.Rel错误);修复后静默跳过且不污染最近文件列表。git log -S查):0faecba49(Epic(0.7.0): 基于 Viva 框架的跨平台方案的迁移(#1794) #1799)迁移 Viva 桌面端时引入checkBeforeClose与scheduleDocumentChecks,未跳过d.virtual且在d.checkFailed时无条件拒绝checkWaiters。10385ee0a(feat(desktop): 补齐六项 IDE 本体编辑能力并附无头测试截图 #1852)引入noteRecentFile,直接使用filepath.Rel(p.root, d.path)而未用projectRelative过滤工作区外路径。desktop/internal/workbench)。检查项
desktop/internal/workbench/document_observation_test.go(TestVirtualDocumentClosesWithoutExternalCheckOrError修复前输出virtual document ran disk check: readCalls=1 checkFailed=true;TestCleanDocumentClosesWhenExternalReadFails修复前输出clean document could not be closed after external read error; notice="clean.txt: 无法检查文件的外部变化。")desktop/internal/workbench/editor_essentials_test.go(TestEditorEssentialsOutsideProjectFileDoesNotFailRecentFiles修复前输出outside file leaked into recent files)openFile/openFileAt/openFileAtPosition、openStepDestination、saveBeforeClose、saveProjectPass、noteRecentFile、unwatchDocument、drainDocumentWatch、scheduleDocumentChecks的所有工作台调用方均已核对;p.docs.opening与p.docs.locations全部读写点已检查。desktop/internal/workbench实现,一并修复。.agents/notes/implemented/bug-fix/记录:.agents/notes/implemented/bug-fix/2026-09-15-external-document-changes-and-guarded-save.md已记录“文件被删除时保留内容”和“虚拟文档不套用本地文件保证”约束,本次实现是使代码符合既有约束。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/workspace-document-sync.json与shared/platform-feature-matrix/features/editor-recent-files.json的说明与测试证据,Windows 验证状态仍保持pending。node scripts/platform-feature-matrix/generate-platform-feature-matrix.mjs、./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh(197 项通过)与./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 或 Skill。UI 验证 / UI evidence
N/A:纯桌面工作台文档生命周期与路径处理逻辑修复,无布局、控件、样式或文案改动。
统一日志系统 / Structured logging
N/A:未新增、修改或删除日志事件、字段或级别;保留既有
editor.document.open_failed与app.notification.operation_failed目录事件。界面文案 / i18n
shared/i18n/。node scripts/i18n/verify-app-language-localization.mjs与node scripts/i18n/generate-i18n.mjs --check(11412/11412 通过)。逻辑归属 / Logic placement
projectRelative封装 OSfilepath.Rel/filepath.IsAbs、filepath.Clean处理原生路径分隔符、document_observation.go/documents.go编排原生目录监听与editorview关闭异步回调;共享文档状态转移仍由 Coredocument.lifecycle与editor.recent负责。性能与内存 / Performance and memory
N/A:未新增后台线程、缓存、队列或轮询;虚拟文档与工作区外最近文件改为提前返回,反而减少了无效后台 I/O。
设置 / Settings
N/A:未涉及设置项、设置页或工具配置读写。
插件契约 / Plugin contract
N/A:未涉及 Rust Core 插件契约、能力版本或宿主方法。
发行包与资源 / Bundle and resources
N/A:未新增或修改运行时资源、缓存、下载物或打包步骤。
无用代码与重构 / Dead code and refactoring
验证 / Verification
./scripts/desktop/desktop-go.sh vet ./internal/workbench./scripts/desktop/desktop-go.sh test ./internal/workbench -run 'TestVirtualDocumentClosesWithoutExternalCheckOrError|TestCleanDocumentClosesWhenExternalReadFails|TestEditorEssentialsOutsideProjectFileDoesNotFailRecentFiles'./.agents/skills/write-stable-tests/scripts/test-stability-macos.sh --package ./internal/workbench -- --filter 'TestVirtualDocumentClosesWithoutExternalCheckOrError|TestCleanDocumentClosesWhenExternalReadFails|TestEditorEssentialsOutsideProjectFileDoesNotFailRecentFiles'./scripts/desktop/desktop-go.sh test ./internal/workbench./.agents/skills/write-stable-tests/scripts/verify-test-stability.sh --base origin/mainnode scripts/i18n/verify-app-language-localization.mjs && node scripts/i18n/generate-i18n.mjs --check./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh && ./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEADrg自查未能执行的检查和原因:
origin/main(05f9958a7)前曾运行全包./scripts/desktop/desktop-go.sh test ./...(除既有的internal/localshellbash 终端挂断两条测试失败外全部通过)与./scripts/desktop/desktop-go.sh test -race ./internal/workbench(通过,305.556s);变基后仅补充了navigation_history.go的filepath.Clean与功能矩阵 JSON,并在新基线上运行了vet、test ./internal/workbench与稳定性计时检查。提交前确认 / Final checks
main创建;目标分支:main.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图