-
Notifications
You must be signed in to change notification settings - Fork 837
fix(web): composer model switch also updates global default model #1491
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 |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@moonshot-ai/kimi-code": patch | ||
| --- | ||
|
|
||
| web: The composer model switcher switches the active session's model as before and additionally bumps the global default model, so new sessions inherit the choice. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -338,7 +338,27 @@ function openLogin(): void { | |
|
|
||
| async function handleSelectModel(modelId: string): Promise<void> { | ||
| showModelPicker.value = false; | ||
| await client.setModel(modelId); | ||
| // Same semantics as the composer dropdown rows: the overlay is just the | ||
| // "more models" continuation of the same flow, so it must also bump the | ||
| // global default (see handleComposerSelectModel). | ||
| await handleComposerSelectModel(modelId); | ||
| } | ||
|
|
||
| async function handleComposerSelectModel(modelId: string): Promise<void> { | ||
| // Primary action: switch the active session's model via POST /sessions/{id}/profile | ||
| // (same as the model picker overlay). Awaited so the model pill reflects the | ||
| // result and failures surface. In the onboarding draft this just stores the | ||
| // pick for the first session. | ||
| const switched = await client.setModel(modelId); | ||
|
|
||
| // Side effect: also bump the daemon-wide default model via POST /config so | ||
| // new sessions inherit the choice. Fire-and-forget — it must not block the UI | ||
| // or mask the session switch. Only after a confirmed switch (a stale/invalid | ||
| // alias must not become the global default), and skip when it already | ||
| // matches the default. | ||
| if (switched && modelId !== client.defaultModel.value) { | ||
| void client.updateConfig({ defaultModel: modelId }); | ||
| } | ||
| } | ||
|
|
||
| async function handleAddProvider(input: { type: string; apiKey?: string; baseUrl?: string; defaultModel?: string }): Promise<void> { | ||
|
|
@@ -759,7 +779,7 @@ function openPr(url: string): void { | |
| @archive-session="(id) => client.archiveSession(id)" | ||
| @compact="client.compact()" | ||
| @pick-model="openModelPicker()" | ||
| @select-model="client.setModel($event)" | ||
| @select-model="handleComposerSelectModel($event)" | ||
|
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.
When a user opens the composer dropdown and uses “More models”, Useful? React with 👍 / 👎. |
||
| @open-file="openFilePreview($event)" | ||
| @open-media="openMediaPreview($event)" | ||
| @open-thinking="openThinkingPanel($event)" | ||
|
|
||
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.
When a user changes the model in an existing session and immediately starts a new session, this fire-and-forget
POST /configcan still be in flight whilecreateSessionis sent without an explicit model (unless there is a draft pick), so the daemon may create that first new session with the old persisted default even though the UI just accepted the switch. Please either serialize/await the default update before new-session creation or optimistically carry the selected model into the next draft/default path.Useful? React with 👍 / 👎.