fix(session): save default model settings in the background

This commit is contained in:
Yichen Jiang committed 2026-09-24 19:48:49 +08:00
1 parent c8631b2064
commit 86331673d9
18 files changed
+136 -29

No files matched your search

@@ -144,9 +144,9 @@ export class SessionCommandController {
}
/**
* Validate and install one Session-local model selection.
* Validate and install one Session-local model selection; save the default in the background.
* @param request - Session identity and requested model selection.
* @returns the normalized selection installed for the Session.
* @returns the normalized selection installed for the Session, without waiting for default persistence.
*/
async selectModel(request: SessionSelectModelRequest): Promise<SessionSelectModelValue> {
const agent = await this.resolveAgent(request.sessionId)
@@ -168,13 +168,11 @@ export class SessionCommandController {
: { reasoningEffort: resolved.reasoningEffort }),
}
this.agents.selectForNextRequest(agent, selected)
try {
await this.ctx.agentDefaultModel.saveSelection(selected)
} catch (error) {
void this.ctx.agentDefaultModel.saveSelection(selected).catch((error: unknown) => {
this.ctx.logger.warn(
`session-controller: model selection changed for the Session but the default was not saved: ${String(error)}`,
)
}
})
return { selected: { ...selected } }
} catch (error) {
if (remoteErrorOf(error) !== undefined) throw error
+2 -2
View File
@@ -275,9 +275,9 @@ export class SessionController extends TypertRemoteService {
}
/**
* Select one Session-local model after explicitly resuming the Session.
* Select one Session-local model after explicitly resuming the Session; save the default in the background.
* @param request - Session identity and requested model selection.
* @returns the normalized selection installed for the Session.
* @returns the normalized selection installed for the Session, without waiting for default persistence.
*/
@Remote('selectModel')
selectModel(request: SessionSelectModelRequest): Promise<SessionSelectModelValue> {