-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(cli): use target dir for ACP core settings #9897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5691,6 +5691,27 @@ class QwenAgent implements Agent { | |
| }; | ||
| } | ||
|
|
||
| private resolveCoreSettingsCwd( | ||
| params: Record<string, unknown>, | ||
| requestedCwd: string | undefined, | ||
| ): string { | ||
| if (requestedCwd) { | ||
| return requestedCwd; | ||
| } | ||
| const sessionId = | ||
| typeof params['sessionId'] === 'string' ? params['sessionId'] : undefined; | ||
| if (sessionId) { | ||
| const sessionTargetDir = this.sessions | ||
| .get(sessionId) | ||
| ?.getConfig() | ||
| .getTargetDir(); | ||
| if (sessionTargetDir) { | ||
| return sessionTargetDir; | ||
| } | ||
| } | ||
| return this.config.getTargetDir(); | ||
| } | ||
|
|
||
| private syncLivePermissionManagers( | ||
| before: PermissionRuleSet, | ||
| after: PermissionRuleSet, | ||
|
|
@@ -11138,9 +11159,13 @@ class QwenAgent implements Agent { | |
| return { newSessionId, title, displayName: title }; | ||
| } | ||
| case 'qwen/settings/getCore': { | ||
| const settings = loadSettings(cwd); | ||
| const coreSettingsCwd = this.resolveCoreSettingsCwd( | ||
| params, | ||
| requestedCwd, | ||
| ); | ||
| const settings = loadSettings(coreSettingsCwd); | ||
| this.settings = settings; | ||
| return this.buildCoreSettings(settings, cwd); | ||
| return this.buildCoreSettings(settings, coreSettingsCwd); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Suggestion] The diff changes four sites ( expect(vi.mocked(ExtensionManager)).toHaveBeenCalledWith(
expect.objectContaining({ workspaceDir: targetDir }),
);中文说明本次改动修改了四处(每个 handler 中的 — qwen3.8-max via Qwen Code /review (v0.22.0) |
||
| } | ||
| case 'qwen/settings/setCoreValue': { | ||
| const key = params['key']; | ||
|
|
@@ -11153,7 +11178,11 @@ class QwenAgent implements Agent { | |
| 'Unsupported Qwen setting key', | ||
| ); | ||
| } | ||
| const settings = loadSettings(cwd); | ||
| const coreSettingsCwd = this.resolveCoreSettingsCwd( | ||
| params, | ||
| requestedCwd, | ||
| ); | ||
| const settings = loadSettings(coreSettingsCwd); | ||
| const settingKey = key as QwenCoreSettingKey; | ||
| const normalizedValue = normalizeCoreSettingValue( | ||
| settingKey, | ||
|
|
@@ -11183,7 +11212,7 @@ class QwenAgent implements Agent { | |
| // `setValue` already persisted to disk and recomputed the in-memory | ||
| // merged view, so reloading from disk here is redundant I/O. | ||
| this.settings = settings; | ||
| return this.buildCoreSettings(settings, cwd); | ||
| return this.buildCoreSettings(settings, coreSettingsCwd); | ||
| } | ||
| case 'qwen/settings/setMcpServer': { | ||
| const name = params['name']; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Suggestion] The
requestedCwd ||half of this fallback is pinned by zero tests: all 11getCore/setCoreValuecall sites in the suite omitcwd, andloadSettingsis mocked to return the same object regardless of argument. The mutationrequestedCwd || this.config.getTargetDir()→this.config.getTargetDir()survives the entire settings suite (probe-verified:Tests 25 passed | 440 skipped). Since the desktop client always sends an explicitcwd, that regression would silently redirect desktop settings calls to the config target dir while the suite stays green. Add a variant per method in which the explicitcwdmust win:中文说明
这个 fallback 中
requestedCwd ||的一半没有任何测试覆盖:套件中全部 11 处getCore/setCoreValue调用都省略了cwd,且loadSettings被 mock 为无论参数如何都返回同一对象。变异requestedCwd || this.config.getTargetDir()→this.config.getTargetDir()在整个 settings 套件中存活(已通过探针验证:Tests 25 passed | 440 skipped)。由于 desktop 客户端总是显式传入cwd,这种回归会在套件全绿的情况下悄悄把 desktop 的 settings 调用重定向到 config target dir。建议为每个方法补一个"显式cwd必须优先"的变体测试(代码见上)。— qwen3.8-max via Qwen Code /review (v0.22.0)