Repository navigation
feat(desktop): 远程工作区的 Find in Files、Search Everywhere 和 Replace All 搜索主机上的文件 (#2231) - #2278
Merged
Merged
Conversation
…索主机上的文件 (#2231) - 搜索、计数、索引更新与失效、Search Everywhere、替换预览带远程绑定发送,Core 从主机文件夹建索引; 结果在远程编辑器打开主机文件。查找工具窗口在远程工作区可用,Search Everywhere 不再只有“操作”页。 - 主机监听(remote.runWatch)代替本机监听喂给索引:变化路径增量更新,监听开始、丢失变化时重建; 包含生成文件的查询、监听数用尽和会话断开期间每次重建。远程工作区不启动语言服务器做符号搜索。 - Replace All 对未打开的文件经会话读取主机内容、按读取时的内容写回主机,冲突和主机上缺失的文件 用远程文案说明;不写本机占位目录。 - 导航历史的后退/前进在远程工作区不再用本机 os.Stat 判断目标是否存在。 - 远程横幅与“暂不支持”文案改为说明可以搜索;无头截图更新并新增搜索两个场景。 - Core 会话结束后不释放以会话为键的索引,已建单 #2277,并在 releaseProjectSearch 注释说明。
xiaoyumuxi
marked this pull request as ready for review
November 21, 2026 11:02
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
#2274 合入后,远程工作区可以编辑主机上的文件、在主机上运行终端,主机上的修改也会出现在项目树和打开的文档里,但查找工具窗口仍说明“远程工作区暂不支持此功能”,Search Everywhere 只有“操作”页,Replace All 无从谈起。Core 的搜索、计数、索引和替换预览本来就经工作区作用域读取文件,带上远程绑定就会读主机上的文件夹。本 PR 让 Find in Files、Search Everywhere 和 Replace All 带工作区的远程绑定发送,用 #2274 的主机监听代替本机监听维护索引,并让 Replace All 经会话读写主机上未打开的文件。
改动 / Changes
Core 客户端
remote_session.go:workspace.searchPresentation(按传入的路径分组结果)和workspace.replaceText(替换传入的文本)加入payloadOnlyCommands。两者只根据请求内容计算,不读文件,所以不带远程绑定发送(带绑定 Core 会以 not_supported 拒绝),注释说明了原因。搜索走主机(新文件
desktop/internal/workbench/remote_search.go)searchIndex.update/invalidate、searchEverywhere、replacePreview都经a.background(p, …)带工作区的远程绑定发送,Core 从主机文件夹建索引,结果路径相对主机文件夹,在远程编辑器打开。remoteWatching():主机监听已开始、而且没有因监听数用尽漏掉部分文件夹时,主机的变化能到达索引。remoteWatchMisses(generated):包含生成文件的查询会读主机监听跳过的(插件隐藏的)文件夹,这些变化到不了索引,所以每次都重建。remoteSearchChanged(p, names, resync):主机监听报告的变化路径交给 Find in Files 和打开着的 Search Everywhere,下一次查询前增量更新索引;监听开始和主机丢失变化时整个重建;正在显示的查询重新运行。remoteSearchUnwatched(p):监听停止(会话丢失、关闭工作区)或监听数用尽后,每次查询都重建,直到下一个监听开始并重建一次。接线
remote_watch.go:remoteWatch新增partial(监听数用尽);applyRemoteChanges把变化先交给搜索,resyncRemoteWorkspace也重建索引,stopRemoteWatch和监听数用尽时调用remoteSearchUnwatched。search.go:startProjectSearchWatch的注释说明远程工作区由主机监听喂给索引。drainProjectSearchWatch在远程工作区以remoteWatching()判断监听是否可用。queueSearchChanges、projectSearchOutdated,本地监听和主机监听共用(本地行为不变)。runProjectSearch在包含生成文件时每次重建(remoteWatchMisses)。a.kernel.CountWorkspaceSearch(原来直接core.NewClient(),绕过了内核接口,测试无法替换主机)。p.logError。releaseProjectSearch注释引用 [Bug] 远程工作区的会话结束后 Core 不释放以该会话为键的搜索索引,每次重连或重新打开都多留一份 #2277。search_everywhere.go:everywhereActionsOnly只对单独打开的文件成立,远程工作区所有页签都可用。queueSearchChanges,提出everywhereOutdated。p.logError。search_everywhere_lsp.go:远程工作区不发现、不启动语言服务器(语言服务器还不能在主机上运行),符号只有 Core 在主机文件中找到的。search_replace.go:replacePreviewInFile改为注入读和写:本地仍是documentio.ReadFileLimit、WriteGuardedLimit;远程工作区用documentBytesOf(p)经会话读取主机内容,用remoteDocuments.save写回。保存前会重新读主机文件,内容与读取时不同就报告冲突,文件不在了就说明主机上找不到它。remoteDocumentReason)。app.go:Kernel接口新增CountWorkspaceSearch。remote_workspace.go:新增(*project).logError,远程工作区只记命令名和错误码(Core 的远程错误消息可能含主机路径),本地照旧。shell_view.go:查找工具窗口在远程工作区可用;空白编辑区除 Search Everywhere 外也提示 Find in Files。navigation_history.go:后退/前进在远程工作区不再用本机os.Stat判断目标是否存在。占位目录里永远没有文件,原来从搜索结果打开主机文件后再后退会被误判为“目标已不存在”。现在交给远程编辑器打开,文件不在时由它说明。界面文案(
shared/i18n/features/remote-connections.json)测试
remote_search_test.go,4 个测试。测试内核remoteHostSearch模拟 Core 在主机上的索引,记录每个请求带的会话、建索引和增量更新的次数。TestRemoteWorkspaceFindsInTheHostsFiles:README.md第 2 行。NOTES.md变化后只增量更新这一个路径、不重建。TestRemoteSearchBuildsTheIndexAgainWhileTheHostWatchMisses:TestRemoteSearchEverywhereSearchesTheHost:TestRemoteReplaceAllWritesTheHostsFiles:NOTES.md在应用前被删除。另两个照常替换写回主机;通知说明“2 个成功、1 个失败:主机上已没有这个文件”。README.md在预览后被改过,不覆盖,报告冲突。remoteWatchMisses恒为 false、remoteSearchChanged不做任何事、忽略partial,这 5 个变异都有测试失败。remote_workspace_test.go:search字段。search_idea_test.go:跟随replacePreviewInFile的新签名。remote_workspace_visual_test.go:在终端场景后新增“Find in Files 搜索主机”和“Search Everywhere 搜索主机”两个场景。截图与功能矩阵
docs/assets/remote-workspace/:shared/platform-feature-matrix/features/remote-workspace.json:不在本 PR 范围内 / Out of scope
project/corecrate,不在crates/remote,需单独评审。桌面端无法代替 Core 清理(会话结束后带旧会话的请求被拒绝)。类型专属:feat
多平台对齐
改动都在 Viva 共用代码里,两端同一份实现;Windows 实机未验证,矩阵 Windows 验证状态保持
pending。范围检查 / 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
LITHE_VISUAL_OUTPUT_DIR=<仓库>/docs/assets/remote-workspace ../scripts/desktop/desktop-go.sh test -tags vivahead,lithevisual ./internal/workbench -run '^TestVisualRemoteWorkspace$' -count=1,本 PR 的提交,1200×760,浅色英文与深色中文remote-workspace-opened-*.png与本 PR 的同名文件;原生窗口验收未做Find in Files 搜索主机上的文件(浅色英文 / 深色中文):
Search Everywhere 列出主机上的文件名和文本(浅色英文 / 深色中文):
打开远程工作区后的横幅与空白编辑区提示(前:main;后:本 PR):
统一日志系统 / Structured logging
workspace_search、workspace_search_count、workspace_search_everywhere、workspace_replace_preview、project_replace);没有print、直接写 stderr 或手写事件 IDp.logError只记命令名和错误码(Core 的远程错误消息可能含主机路径),测试断言日志里没有主机和主机路径界面文案 / i18n
shared/i18n/features/remote-connections.json更新中英词条desktop.remote.workspace.banner、desktop.remote.workspace.localOnly,运行node scripts/i18n/generate-i18n.mjs并提交生成结果;替换失败的远程原因复用已有的desktop.remote.document.*shared/i18n/node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
性能与内存 / Performance and memory
searchEventLimit);远程工作区不启动语言服务器。Core 的会话索引在会话结束后不释放,是既有问题,见 [Bug] 远程工作区的会话结束后 Core 不释放以该会话为键的搜索索引,每次重连或重新打开都多留一份 #2277设置 / Settings
N/A:没有新增或修改设置项。
插件契约 / Plugin contract
N/A:没有改插件契约、能力版本、插件函数协议或宿主方法。
发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.sh:没有新增资源路径,替换只写主机上的文件无用代码与重构 / Dead code and refactoring
验证 / Verification
gofmt -l+../scripts/desktop/desktop-go.sh vet ./internal/workbench ./internal/core../scripts/desktop/desktop-go.sh test ./internal/workbench -run 'Remote|Search|Replace|Navigation|Everywhere' -count=1../scripts/desktop/desktop-go.sh test ./internal/workbench -run '^(TestRemoteWorkspaceFindsInTheHostsFiles|TestRemoteSearch.*|TestRemoteReplaceAllWritesTheHostsFiles)$' -count=1 -race../scripts/desktop/desktop-go.sh test ./internal/workbench ./internal/core -count=1test-stability-macos.sh --package ./internal/workbench(新增的 4 个测试,单测试计时)TestRemoteSearchEverywhereSearchesTheHost490 ms,其余 130–380 msremoteWatchMisses恒为 false、remoteSearchChanged不做任何事、忽略partial)TestVisualRemoteWorkspace(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.sh.agents/skills/write-stable-tests/scripts/verify-test-stability.sh未能执行的检查和原因:
提交前确认 / Final checks
main创建;目标分支:feat、fix、docs 为main,release 以发布流程要求为准.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图