Repository navigation
fix(desktop): 立即生效的设置改动重新向后端询问启动答复里的语言服务器配置 - #2320
Merged
Merged
Conversation
1 task done
xiaoyumuxi
marked this pull request as ready for review
November 23, 2026 05:12
8 of 11 tasks
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
有些语言服务器由插件后端决定怎么启动(
launch.kind: "backend"),启动函数的答复可以自带workspaceConfiguration。例如 Python Support 1.0.0 起,答复里有「工具链」解析出的python.pythonPath,还有按设置换算出的 Pyrefly 设置。问题出在设置窗口保存立即生效的设置时。
ApplyLanguageSettings总是把清单里声明的workspaceConfiguration展开,再用lsp.updateWorkspaceConfiguration整体替换服务器配置,于是答复里的配置被丢掉。Pyrefly 因此丢掉解释器路径,直到重新加载项目。答复自带配置、清单却没有声明模板的服务器更糟:设置改动根本不会发给服务器。改动 / Changes
pluginservice/backendlaunch.go:answerBackendLaunch。它返回解码后的计划,以及答复是否自带workspaceConfiguration(answerCarriesConfiguration:字段存在且不是null)。resolveBackendLaunch改为调用它,创建可写路径父目录的逻辑不变。答复自带配置时,backendLaunch.configuration记下这次启动的插件 ID、清单、语言、工作区上下文、四个目录的请求和运行时,类型为新增的launchConfiguration。launchWorkspaceConfiguration:换上新的全局和项目设置,用同一组目录再调用一次启动函数,同样由 Core 解码,只返回计划里的workspaceConfiguration(空或null时返回 nil)。答复的其余部分(参数、环境变量、可执行文件)等下次启动才生效。pluginservice/backends.go:LanguageSession新增launch,StartLanguageServer在由后端决定启动方式时从解析结果填入。pluginservice/settings.go:ApplyLanguageSettings在session.launch不为空时向后端重新取配置,否则仍用 Core 展开声明,后面的发送逻辑不变。workspaceConfiguration时,行为和以前一样,宿主也不会再调用它。Rust Support 的rustAnalyzer.launch可能执行rustup component add,它的答复不带配置,所以不受影响。pluginservice/backendlaunch_configuration_test.go,用契约 fixturefixtures/languages/language-server-backend-launch.plugin.json加一个立即生效的项目设置和声明模板,分两种情况:{"metals":{"checks":"strict"}}。{"metals":{"strict":true}}。reference/domains/languages.md、settings.md和协议更新记录。Core 代码不变,所以本 PR 不升PINNED_CORE_REVISION。不在本 PR 范围内 / Out of scope
immediate只推送配置的定义一致。类型专属:fix
复现与根因
strict = true,再调用ApplyLanguageSettings。期望发出启动函数按新设置给出的{"metals":{"checks":"strict"}},实际发出声明的展开{"metals":{"strict":true}},后端只被调用了一次。0faecba49)的ApplyLanguageSettings只走 Core 的声明式展开,没有考虑后来加入的、由后端决定启动方式且答复自带配置的服务器。desktop/internal/pluginservice,三个平台都有这个问题,本 PR 一并修复。检查项
desktop/internal/pluginservice/backendlaunch_configuration_test.go,在旧版settings.go上的结果是:resolveBackendLaunch只有StartLanguageServer一个调用方。ApplyLanguageSettings的调用方是 workbench 的设置保存路径,不受签名影响。LanguageSession的新字段不导出。.agents/notes/implemented/bug-fix/记录:行为约束写进了 Core 契约(docs(plugins): 写明后端决定启动方式的语言服务器在立即生效的设置变化时重新调用启动函数取配置 Lithe-IDEA/Lithe-core-rust#176),回归测试覆盖两种情况,不再另写 Note。范围检查 / Scope checks
功能矩阵 / Feature matrix
N/A:没有新增宿主的用户可见能力,只修正已有的“立即生效的设置”在由后端决定启动方式的服务器上的行为,跨平台行为一致。
插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空language-server-backend-launch.plugin.json,在内存里加一个设置和声明模板,后端答复由测试的假内核给出shared/i18n/;插件的构建步骤、资源路径和补丁没有写进docs/ci-builds.md、Agent Note 或 SkillUI 验证 / UI evidence
N/A:没有界面变化。
统一日志系统 / Structured logging
N/A:没有新增或改动日志事件。重新调用失败时把错误返回给原来的调用方,由调用方按原来的方式处理。
界面文案 / i18n
N/A:没有新增用户可见文字。
逻辑归属 / Logic placement
plugins.languageServers.decodeLaunch完成,宿主只负责调用插件函数、发送结果性能与内存 / Performance and memory
timeoutMilliseconds。会话多保存一份启动请求(目录、设置、清单的引用),随会话释放设置 / Settings
N/A:没有新增或修改设置项和设置页,只修正立即生效的设置发给语言服务器的内容。
插件契约 / Plugin contract
languageServers0 内的说明补充,只改文档,Core 代码不变)PINNED_CORE_REVISION已升到包含该契约的 Core commit:Core 代码和 fixture 都没有变,不需要升sdk-e2e.mjs:没有改协议字段发行包与资源 / Bundle and resources
N/A:没有新增运行时资源。再次调用启动函数用的是这次启动已经建好的四个目录(
state、workspaceState、log、temporary),都在平台存储里,不写发行目录。无用代码与重构 / Dead code and refactoring
验证 / Verification
scripts/desktop/desktop-go.sh test ./internal/pluginservice/ -run TestImmediateSettingAsksTheBackend -count=1(旧版settings.go)scripts/desktop/desktop-go.sh test -race ./internal/pluginservice/ -count=1scripts/desktop/desktop-go.sh test ./... -count=1make fmt-check(desktop/)、go vet ./internal/pluginservice/未能执行的检查和原因:
提交前确认 / Final checks
main(cc1600283)创建,目标分支main