Skip to content
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
1d6940f
fix(cli): keep model switches session-scoped
zjunothing Jul 9, 2026
77da2b8
Merge branch 'main' into fix/model-session-default
wenshao Jul 10, 2026
c044a02
fix(cli): add model command translations
zjunothing Jul 10, 2026
bf724cc
Merge branch 'main' into fix/model-session-default
wenshao Jul 10, 2026
a6e995d
Merge branch 'main' into fix/model-session-default
wenshao Jul 10, 2026
b6e9b58
Merge branch 'main' into fix/model-session-default
wenshao Jul 11, 2026
a36e33d
Merge branch 'main' into fix/model-session-default
wenshao Jul 11, 2026
4044ff7
Merge branch 'main' into fix/model-session-default
wenshao Jul 12, 2026
60cc536
Merge branch 'main' into fix/model-session-default
wenshao Jul 12, 2026
0a01d89
Merge branch 'main' into fix/model-session-default
wenshao Jul 18, 2026
d57bdf0
Merge branch 'main' into fix/model-session-default
wenshao Jul 23, 2026
7b7cb51
Merge branch 'main' into fix/model-session-default
wenshao Jul 23, 2026
02b23fc
Merge branch 'main' into fix/model-session-default
wenshao Jul 23, 2026
d6e7252
merge(main): combine --default and --image flags in model command
qwen-code-dev-bot Jul 26, 2026
ff7e91d
Merge branch 'main' into fix/model-session-default
wenshao Jul 26, 2026
1adfab3
fix(cli): preserve model command persistence semantics
zjunothing Jul 29, 2026
d1c23dc
Merge branch 'main' into fix/model-session-default
wenshao Jul 30, 2026
ded4336
fix(cli): address review feedback on /model --default (#6579)
Aug 1, 2026
6e81163
chore(cli): merge main into fix/model-session-default
Aug 1, 2026
9cbc430
Merge branch 'main' into fix/model-session-default
qwen-code-dev-bot Aug 1, 2026
fdac9fd
test(cli): cover resolved config baseUrl in default model picker
qwen-code-dev-bot Aug 1, 2026
f893109
fix(cli): restrict --default flag parsing to leading positions (#6579)
qwen-code-ci-bot Aug 1, 2026
991395a
test(cli): cover selectedType persistence for --default with explicit…
qwen-code-ci-bot Aug 1, 2026
5b12caf
test(cli): cover --voice and --vision in --default mutual-exclusion g…
qwen-code-ci-bot Aug 1, 2026
db59eb8
test(cli): cover --default --global direct-switch and trailing-flag f…
qwen-code-ci-bot Aug 1, 2026
78df51b
fix(cli): show inline-prompt rejection before scope guard in /model (…
qwen-code-ci-bot Aug 2, 2026
ed0ac4f
fix(cli): point inline-prompt rejection hint at working --default com…
qwen-code-ci-bot Aug 2, 2026
9246bbf
fix(cli): address review feedback on --default model persistence (#6579)
qwen-code-ci-bot Aug 2, 2026
237b2ed
fix(cli): align model persistence docs and locales (#6579)
zjunothing Aug 3, 2026
44be9d7
fix(cli): detect trailing --default after whitespace runs and aux fla…
qwen-code-ci-bot Aug 3, 2026
a90f499
Merge branch 'main' into fix/model-session-default
qwen-code-ci-bot Aug 3, 2026
c50a114
Merge remote-tracking branch 'origin/main' into fix/model-session-def…
qwen-code-ci-bot Aug 3, 2026
56d62ff
Merge branch 'main' into fix/model-session-default
qwen-code-dev-bot Aug 3, 2026
5152271
fix(cli): align --default docs and rejections with persistence behavi…
qwen-code-ci-bot Aug 3, 2026
7e9cc4d
Merge branch 'fix/model-session-default' of https://github.com/zjunot…
qwen-code-dev-bot Aug 3, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/cli/src/i18n/locales/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -1496,6 +1496,8 @@ export default {
'Switch the model for this session (--fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).',
'Switch the model for this session (--fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).':

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 237b2ed. I removed both unreferenced description variants from en, zh, and zh-TW, leaving only the full --default + --compaction + --image key used by modelCommand. npm run check-i18n passes.

'Switch the model for this session (--fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).',
'Switch the model for this session (--default to persist the main model for future sessions, --fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).':
'Switch the model for this session (--default to persist the main model for future sessions, --fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).',
"Inline one-shot override isn't supported in this mode — run '/model {{model}}' first, then send your prompt.":
"Inline one-shot override isn't supported in this mode — run '/model {{model}}' first, then send your prompt.",
"Inline one-shot override can't switch providers. '{{model}}' belongs to a different provider — run '/model {{model}}' first, then send your prompt.":
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/i18n/locales/zh-TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,6 +1322,8 @@ export default {
'切換此會話的模型(--fast 建議模型,--voice 語音轉寫模型,--vision 視覺橋接模型,--project 持久化到專案設定,--global 持久化到使用者設定,[model-id] 立即切換,或用 [model-id] [prompt] 在另一個模型上執行一次性提示;內聯提示按原文發送,不展開 @file)',
'Switch the model for this session (--fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).':
'切換此會話的模型(--fast 建議模型,--voice 語音轉寫模型,--vision 視覺橋接模型,--image 圖像生成模型,--project 持久化到專案設定,--global 持久化到使用者設定,[model-id] 立即切換,或用 [model-id] [prompt] 在另一個模型上執行一次性提示;內聯提示按原文發送,不展開 @file)',
'Switch the model for this session (--default to persist the main model for future sessions, --fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).':
'切換此會話的模型(--default 將主模型持久化為未來會話預設值,--fast 建議模型,--voice 語音轉寫模型,--vision 視覺橋接模型,--image 圖像生成模型,--project 持久化到專案設定,--global 持久化到使用者設定,[model-id] 立即切換,或用 [model-id] [prompt] 在另一個模型上執行一次性提示;內聯提示按原文發送,不展開 @file)',
"Inline one-shot override isn't supported in this mode — run '/model {{model}}' first, then send your prompt.":
"此模式不支援內聯一次性覆寫——請先執行 '/model {{model}}',再發送你的提示。",
"Inline one-shot override can't switch providers. '{{model}}' belongs to a different provider — run '/model {{model}}' first, then send your prompt.":
Expand Down
2 changes: 2 additions & 0 deletions packages/cli/src/i18n/locales/zh.js
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,8 @@ export default {
'切换此会话的模型(--fast 建议模型,--voice 语音转写模型,--vision 视觉桥接模型,--project 持久化到项目设置,--global 持久化到用户设置,[model-id] 立即切换,或用 [model-id] [prompt] 在另一个模型上运行一次性提示;内联提示按原文发送,不展开 @file)',
'Switch the model for this session (--fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).':
'切换此会话的模型(--fast 建议模型,--voice 语音转写模型,--vision 视觉桥接模型,--image 图像生成模型,--project 持久化到项目设置,--global 持久化到用户设置,[model-id] 立即切换,或用 [model-id] [prompt] 在另一个模型上运行一次性提示;内联提示按原文发送,不展开 @file)',
'Switch the model for this session (--default to persist the main model for future sessions, --fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).':
'切换此会话的模型(--default 将主模型持久化为未来会话默认值,--fast 建议模型,--voice 语音转写模型,--vision 视觉桥接模型,--image 图像生成模型,--project 持久化到项目设置,--global 持久化到用户设置,[model-id] 立即切换,或用 [model-id] [prompt] 在另一个模型上运行一次性提示;内联提示按原文发送,不展开 @file)',
"Inline one-shot override isn't supported in this mode — run '/model {{model}}' first, then send your prompt.":
"此模式不支持内联一次性覆盖——请先运行 '/model {{model}}',再发送你的提示。",
"Inline one-shot override can't switch providers. '{{model}}' belongs to a different provider — run '/model {{model}}' first, then send your prompt.":
Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/ui/AppContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1368,6 +1368,7 @@ export const AppContainer = (props: AppContainerProps) => {
isVisionModelMode,
isImageModelMode,
modelDialogPersistScope,
modelDialogPersistDefault,
openModelDialog,
closeModelDialog,
} = useModelCommand();
Expand Down Expand Up @@ -4212,6 +4213,7 @@ export const AppContainer = (props: AppContainerProps) => {
isVisionModelMode,
isImageModelMode,
modelDialogPersistScope,
modelDialogPersistDefault,
isTrustDialogOpen,
activeArenaDialog,
isPermissionsDialogOpen,
Expand Down Expand Up @@ -4356,6 +4358,7 @@ export const AppContainer = (props: AppContainerProps) => {
isVisionModelMode,
isImageModelMode,
modelDialogPersistScope,
modelDialogPersistDefault,
isTrustDialogOpen,
activeArenaDialog,
isPermissionsDialogOpen,
Expand Down
221 changes: 194 additions & 27 deletions packages/cli/src/ui/commands/modelCommand.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('modelCommand', () => {
it('should have the correct name and description', () => {
expect(modelCommand.name).toBe('model');
expect(modelCommand.description).toBe(
'Switch the model for this session (--fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).',
'Switch the model for this session (--default to persist the main model for future sessions, --fast for suggestion model, --voice for voice transcription model, --vision for the vision bridge model, --image for the image generation model, --project to persist to project settings, --global to persist to user settings, [model-id] to switch immediately, or [model-id] [prompt] to run a one-off prompt on another model; the inline prompt is sent verbatim without @file expansion).',
);
});

Expand Down Expand Up @@ -174,7 +174,7 @@ describe('modelCommand', () => {
});
});

it('should switch the main model directly in interactive mode when args are provided', async () => {
it('should switch the main model directly in interactive mode without persisting', async () => {
const setValue = vi.fn();
const switchModel = vi.fn().mockResolvedValue(undefined);
mockContext = createMockCommandContext({
Expand All @@ -196,6 +196,48 @@ describe('modelCommand', () => {

const result = await modelCommand.action!(mockContext, 'qwen-max');

expect(switchModel).toHaveBeenCalledWith(

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requested cases are reasonable coverage suggestions, but the repository review rules classify missing tests as Suggestion-level unless the untested path is itself the defect. This round adds regression coverage for the two reproduced user-visible blockers: the silently dropped --default inline intent and scoped image routing. The remaining coverage requests are deferred because the PR has already been reviewed across 15 distinct commits, so this Critical severity is over-classified rather than an unresolved correctness blocker.

中文说明

这些用例作为测试覆盖建议是合理的,但仓库评审规则明确规定:除非未测试路径本身就是缺陷,否则缺少测试属于 Suggestion。本轮已经为两个已复现的用户可见阻断问题补充了回归覆盖:静默丢弃 --default 的内联提示路径,以及带作用域的图像模型路由。其余覆盖建议留待后续,因为该 PR 已经跨 15 个不同提交接受评审;因此这里的 Critical 严重度属于过度分类,而不是仍未解决的正确性阻断。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Partially addressed this round: added tests for --default --fast rejection, --default --image rejection, and bare /model --default opening the dialog with persistDefault: true. Remaining coverage requests (--default --voice, --default --vision, auth-qualified model paths) are deferred to a follow-up per the repository's review-round policy.

中文说明

本轮已部分处理:新增了 --default --fast 拒绝、--default --image 拒绝、以及裸 /model --default 打开带 persistDefault: true 对话框的测试。剩余覆盖请求(--default --voice、--default --vision、带认证限定的模型路径)按仓库审查轮次规则延期至后续处理。

AuthType.QWEN_OAUTH,
'qwen-max',
undefined,
);
expect(setValue).not.toHaveBeenCalled();
expect(result).toEqual({
type: 'message',
messageType: 'info',
content: 'Model: qwen-max',
});
});

it('persists the main model only with --default', async () => {
const setValue = vi.fn();
const switchModel = vi.fn().mockResolvedValue(undefined);
mockContext = createMockCommandContext({
invocation: {
raw: '/model --default qwen-max',
name: 'model',
args: '--default qwen-max',
},
services: {
config: {
getContentGeneratorConfig: vi.fn().mockReturnValue({
model: 'qwen-plus',
authType: AuthType.QWEN_OAUTH,
}),
getAvailableModelsForAuthType: vi
.fn()
.mockReturnValue([{ id: 'qwen-max', label: 'Qwen Max' }]),
switchModel,
},
settings: createMockSettings(setValue),
},
});

const result = await modelCommand.action!(
mockContext,
'--default qwen-max',
);

expect(switchModel).toHaveBeenCalledWith(
AuthType.QWEN_OAUTH,
'qwen-max',
Expand All @@ -206,9 +248,6 @@ describe('modelCommand', () => {
'model.name',
'qwen-max',
);
// `/model <id>` is an id-only switch, so any baseUrl disambiguator left by
// a previous model-picker selection must be cleared (empty-string tombstone)
// to avoid resolving to a different provider on next launch.
expect(setValue).toHaveBeenCalledWith(
expect.any(String),
'model.baseUrl',
Expand All @@ -217,7 +256,7 @@ describe('modelCommand', () => {
expect(result).toEqual({
type: 'message',
messageType: 'info',
content: 'Model: qwen-max',
content: 'Model: qwen-max (default)',
});
});

Expand Down Expand Up @@ -260,6 +299,45 @@ describe('modelCommand', () => {
});
});

it('rejects --default with an inline prompt', async () => {
const setValue = vi.fn();
const switchModel = vi.fn().mockResolvedValue(undefined);
mockContext = createMockCommandContext({
invocation: {
raw: '/model --default qwen-max explain this code',
name: 'model',
args: '--default qwen-max explain this code',
},
services: {
config: {
getContentGeneratorConfig: vi.fn().mockReturnValue({
model: 'qwen-plus',
authType: AuthType.QWEN_OAUTH,
}),
getAvailableModelsForAuthType: vi
.fn()
.mockReturnValue([{ id: 'qwen-max', label: 'Qwen Max' }]),
switchModel,
},
settings: createMockSettings(setValue),
},
});

const result = await modelCommand.action!(
mockContext,
'--default qwen-max explain this code',
);

expect(switchModel).not.toHaveBeenCalled();
expect(setValue).not.toHaveBeenCalled();
expect(result).toEqual({
type: 'message',
messageType: 'error',
content:
"Cannot combine --default with an inline prompt. Run '/model --default qwen-max' first, then send your prompt.",
});
});

it('rejects an inline prompt when the model id is not available', async () => {
const switchModel = vi.fn();
mockContext = createMockCommandContext({
Expand Down Expand Up @@ -634,16 +712,7 @@ describe('modelCommand', () => {
'gpt-4',
undefined,
);
expect(setValue).toHaveBeenCalledWith(
expect.any(String),
'security.auth.selectedType',
AuthType.USE_OPENAI,
);
expect(setValue).toHaveBeenCalledWith(
expect.any(String),
'model.name',
'gpt-4',
);
expect(setValue).not.toHaveBeenCalled();
expect(result).toEqual({
type: 'message',
messageType: 'info',
Expand Down Expand Up @@ -1791,11 +1860,7 @@ describe('modelCommand', () => {
'--fast-model',
undefined,
);
expect(setValue).toHaveBeenCalledWith(
expect.any(String),
'model.name',
'--fast-model',
);
expect(setValue).not.toHaveBeenCalled();
expect(result).toEqual({
type: 'message',
messageType: 'info',
Expand Down Expand Up @@ -2221,22 +2286,44 @@ describe('modelCommand', () => {
return mockContext;
}

it('should include persistScope in dialog return for /model --project', async () => {
it('should reject /model --project without --default', async () => {
const ctx = setupContext();
const result = await modelCommand.action!(ctx, '--project');
expect(result).toMatchObject({
type: 'message',
messageType: 'error',
content: expect.stringContaining('--default'),
});
});

it('should reject /model --global without --default', async () => {
const ctx = setupContext();
const result = await modelCommand.action!(ctx, '--global');
expect(result).toMatchObject({
type: 'message',
messageType: 'error',
content: expect.stringContaining('--default'),
});
});

it('should include persistScope in dialog return for /model --default --project', async () => {
const ctx = setupContext();
const result = await modelCommand.action!(ctx, '--default --project');
expect(result).toEqual({
type: 'dialog',
dialog: 'model',
persistDefault: true,
persistScope: 'workspace',
});
});

it('should include persistScope in dialog return for /model --global', async () => {
it('should include persistScope in dialog return for /model --default --global', async () => {
const ctx = setupContext();
const result = await modelCommand.action!(ctx, '--global');
const result = await modelCommand.action!(ctx, '--default --global');
expect(result).toEqual({
type: 'dialog',
dialog: 'model',
persistDefault: true,
persistScope: 'user',
});
});
Expand Down Expand Up @@ -2377,7 +2464,7 @@ describe('modelCommand', () => {
expect(setValue).not.toHaveBeenCalled();
});

it('should show scope suffix in main model confirmation', async () => {
it('should persist and show scope suffix for --default main model confirmation', async () => {
const setValue = vi.fn();
const settings = {
...createMockSettings(setValue),
Expand All @@ -2400,10 +2487,13 @@ describe('modelCommand', () => {
{ id: 'qwen-max', voiceOnly: false, fastOnly: false },
]);
cfg.switchModel = vi.fn().mockResolvedValue(mockGenerator);
const result = await modelCommand.action!(ctx, '--project qwen-max');
const result = await modelCommand.action!(
ctx,
'--default --project qwen-max',
);
expect(result).toMatchObject({
type: 'message',
content: expect.stringContaining('(this project)'),
content: expect.stringContaining('(this project default)'),
});
expect(setValue).toHaveBeenCalledWith(
SettingScope.Workspace,
Expand All @@ -2420,5 +2510,82 @@ describe('modelCommand', () => {
dialog: 'model',
});
});

it('should reject --default combined with --fast', async () => {
const ctx = setupContext();
const result = await modelCommand.action!(ctx, '--default --fast');
expect(result).toMatchObject({
type: 'message',
messageType: 'error',
content: expect.stringContaining(
'--default only applies to the main model',
),
});
});

it('should reject --default combined with --image', async () => {
const ctx = setupContext();
const result = await modelCommand.action!(ctx, '--default --image');
expect(result).toMatchObject({
type: 'message',
messageType: 'error',
content: expect.stringContaining(
'--default only applies to the main model',
),
});
});

it('should not reject --default when prompt text contains --vision', async () => {
const setValue = vi.fn();
const settings = {
...createMockSettings(setValue),
_merged: {},
computeMergedSettings: vi.fn(),
isTrusted: true,
} as unknown as LoadedSettings;
const ctx = setupContext();
ctx.services.settings = settings;
const cfg = ctx.services.config as unknown as Partial<Config> & {
[key: string]: unknown;
};
cfg.getAvailableModelsForAuthType = vi
.fn()
.mockReturnValue([
{ id: 'qwen-max', voiceOnly: false, fastOnly: false },
]);
cfg.switchModel = vi.fn().mockResolvedValue(undefined);
const result = await modelCommand.action!(
ctx,
'--default qwen-max what does --vision do',
);
expect(result).toMatchObject({
type: 'message',
messageType: 'error',
content: expect.stringContaining('Cannot combine --default'),
});
});

it('should reject bare --default in non-interactive mode', async () => {
const ctx = setupContext();
ctx.executionMode = 'non_interactive';
const result = await modelCommand.action!(ctx, '--default');
expect(result).toMatchObject({
type: 'message',
messageType: 'error',
content: expect.stringContaining(
'--default requires a model ID in non-interactive mode',
),
});
});

it('should open model picker with persistDefault for bare /model --default', async () => {
const ctx = setupContext();
const result = await modelCommand.action!(ctx, '--default');
expect(result).toEqual({
type: 'dialog',
dialog: 'model',
persistDefault: true,
});
});
});
});
Loading
Loading