From 72500a650610df6ab412653a2c15d80156273ff5 Mon Sep 17 00:00:00 2001 From: Brennan Benson <79079362+brennanb2025@users.noreply.github.com> Date: Thu, 20 Aug 2026 17:32:39 -0700 Subject: [PATCH] fix(native-chat): narrow the model branch to a string session-option value SessionOptionValue widened to string | boolean for fast mode, so the model branch could index valuesByModel with a boolean and pass one to the persist callback. A boolean there is a malformed command, not a model id. --- src/shared/native-chat-session-option-commands.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/shared/native-chat-session-option-commands.ts b/src/shared/native-chat-session-option-commands.ts index a92ee0548df..e512c0f04d6 100644 --- a/src/shared/native-chat-session-option-commands.ts +++ b/src/shared/native-chat-session-option-commands.ts @@ -121,6 +121,12 @@ function recordCommandApply(args: { } const previousModelId = effectiveModelId if (optionId === 'model') { + // Why: SessionOptionValue widened to string | boolean for fast mode, but a + // model id is always a string - a boolean here is a malformed command, not a + // model, and must not index valuesByModel or reach the persist callback. + if (typeof value !== 'string') { + return false + } if (previousModelId !== value) { // Why: a model command can reset model-scoped state, so an older value // from a prior visit is no longer evidence about this live session.