fix(web): move the new-session chip when the default preset changes

The General row and the preset page already re-read on `settings/changed`, but
the hero chip did not — so changing the default and starting a session without
reloading composed the previous default. That is the one session the setting
claims to govern ("对此后新建的会话生效"), and the chip is what decides it.

A staged pick still wins: `load()` prefers the stage over the refreshed
fallback, so a refresh never overwrites a choice the user just made.
This commit is contained in:
Yichen Jiang
2026-08-07 03:20:49 +08:00
parent 0ab035c748
commit a7ab8b27c5
2 changed files with 56 additions and 2 deletions

View File

@@ -110,6 +110,15 @@ export function apply(ctx: ClientContext): void {
// and either way the chip's pick predates it — so the stage is applied
// when the session arrives, not when it was made.
const stop = scope.sessions.list.subscribe(() => { void seat.apply() })
// The chip opens on the deployment default, so a default changed from
// the settings surface moves it too — otherwise the screen that starts
// the next session keeps offering the previous default until a reload,
// which is exactly the session the setting claims to govern. A staged
// pick survives: `load()` prefers it over the refreshed fallback.
const settingsMoved = scope.on('settings/changed', (ns?: string) => {
if (ns !== undefined && ns !== AGENT_PRESET_SETTINGS_NS) return
void seat.load()
})
const chip = scope.slots.register({
name: 'conversation.hero.agentPreset',
locale: 'settings.agentPreset',
@@ -124,6 +133,7 @@ export function apply(ctx: ClientContext): void {
}, AgentPresetLabel)
return () => {
stop()
settingsMoved()
chip()
label()
}