Skip to content

The agent that grows with you

refactor(tui): the deferred-pick ask and the idle refusal share one model confirmation dialog

Teknium337afeb588de
diff --git a/ui-tui/src/app/createGatewayEventHandler.ts b/ui-tui/src/app/createGatewayEventHandler.ts
index fb0252bf4b7..ebf0c12ebae 100644
--- a/ui-tui/src/app/createGatewayEventHandler.ts
+++ b/ui-tui/src/app/createGatewayEventHandler.ts
@@ -47,7 +47,7 @@ import { markBubbleShown, newlyStartedRows } from './pendingBubbles.js'
import { flashGoodVibes, flashPet } from './petFlashStore.js'
import { forgetServerRequest } from './serverRequestStore.js'
import { noteCanonicalCompletion } from './slash/canonicalSessionCommands.js'
-import { mutateCanonicalSession } from './slash/canonicalSessionControls.js'
+import { mutateCanonicalSession, openModelConfirmation } from './slash/canonicalSessionControls.js'
import { loadSlashCatalog } from './slashCatalog.js'
import { reportStartupLatency } from './startupLatency.js'
import { markNextSubmitVoice } from './submissionCore.js'
@@ -617,26 +617,18 @@ function applyDeferredPickOutcome(
// The confirmed resend is the same selection: its level commits with the model.
const arg = `${pick.model ?? ''}${pick.provider ? ` --provider ${pick.provider}` : ''}${pick.reasoning ? ` --reasoning ${pick.reasoning}` : ''}`
- patchOverlayState({
- confirm: {
- cancelLabel: t('slashCmd.session.model.cancel'),
- confirmLabel: t('slashCmd.session.model.switchAnyway'),
- danger: true,
- detail: (update.confirm_message as string | undefined) || t('slashCmd.session.model.expensiveDetail'),
- onConfirm: () =>
- void mutateCanonicalSession(gw, sid, 'model', arg, undefined, update.confirm as string).then(
- mutation => {
- // Refused again (a queued turn or another pick moved the session first): say so once,
- // never re-ask in a loop.
- if (mutation?.result.status === 'confirmation_required') {
- sys(t('slashCmd.session.model.confirmStale'))
- }
- },
- (error: unknown) => sys(`error: ${error instanceof Error ? error.message : String(error)}`)
- ),
- title: t('slashCmd.session.model.confirmTitle', String(update.target_model ?? pick.model ?? ''))
- }
- })
+ openModelConfirmation(update.confirm_message as string | undefined, String(update.target_model ?? pick.model ?? ''), () =>
+ void mutateCanonicalSession(gw, sid, 'model', arg, undefined, update.confirm as string).then(
+ mutation => {
+ // Refused again (a queued turn or another pick moved the session first): say so once,
+ // never re-ask in a loop.
+ if (mutation?.result.status === 'confirmation_required') {
+ sys(t('slashCmd.session.model.confirmStale'))
+ }
+ },
+ (error: unknown) => sys(`error: ${error instanceof Error ? error.message : String(error)}`)
+ )
+ )
}
}
diff --git a/ui-tui/src/app/slash/canonicalSessionControls.ts b/ui-tui/src/app/slash/canonicalSessionControls.ts
index 2b4d26c270d..367fef8991c 100644
--- a/ui-tui/src/app/slash/canonicalSessionControls.ts
+++ b/ui-tui/src/app/slash/canonicalSessionControls.ts
@@ -190,14 +190,21 @@ function askModelConfirmation(refusal: ModelConfirmation, arg: string, ctx: Slas
throw new Error(`${refusal.confirm_message ?? ''}\n\n${t('slashCmd.session.model.confirmStale')}`.trim())
}
+ openModelConfirmation(refusal.confirm_message, refusal.target_model ?? arg.trim().split(/\s+/)[0] ?? '', () =>
+ void runCanonicalSessionControl('model', arg, ctx, refusal.confirm)
+ )
+}
+
+/** The guarded-model dialog: an idle pick's refusal and a deferred pick's boundary ask share it. */
+export function openModelConfirmation(detail: string | undefined, target: string, onConfirm: () => void) {
patchOverlayState({
confirm: {
cancelLabel: t('slashCmd.session.model.cancel'),
confirmLabel: t('slashCmd.session.model.switchAnyway'),
danger: true,
- detail: refusal.confirm_message || t('slashCmd.session.model.expensiveDetail'),
- onConfirm: () => void runCanonicalSessionControl('model', arg, ctx, refusal.confirm),
- title: t('slashCmd.session.model.confirmTitle', refusal.target_model ?? arg.trim().split(/\s+/)[0] ?? '')
+ detail: detail || t('slashCmd.session.model.expensiveDetail'),
+ onConfirm,
+ title: t('slashCmd.session.model.confirmTitle', target)
}
})
}