Merge pull request #16600 from NousResearch/austin/fix/model-provider

fix(models): consolidate provider and model into /model command
This commit is contained in:
Austin Pickett 2026-04-27 08:14:27 -07:00 committed by GitHub
commit 60f2415a4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 92 additions and 34 deletions

View file

@ -10,6 +10,7 @@ import type {
VoiceToggleResponse
} from '../../../gatewayTypes.js'
import { fmtK } from '../../../lib/text.js'
import { TUI_SESSION_MODEL_FLAG } from '../../../domain/slash.js'
import type { PanelSection } from '../../../types.js'
import { patchOverlayState } from '../../overlayStore.js'
import { patchUiState } from '../../uiStore.js'
@ -17,12 +18,32 @@ import type { SlashCommand } from '../types.js'
const GLOBAL_MODEL_FLAG_RE = /(?:^|\s)--global(?:\s|$)/
const TUI_SESSION_MODEL_RE = new RegExp(`(?:^|\\s)${TUI_SESSION_MODEL_FLAG}(?:\\s|$)`)
const TUI_SESSION_STRIP_RE = new RegExp(`\\s*${TUI_SESSION_MODEL_FLAG}\\b\\s*`, 'g')
const persistedModelArg = (arg: string) => {
const trimmed = arg.trim()
return !trimmed || GLOBAL_MODEL_FLAG_RE.test(trimmed) ? trimmed : `${trimmed} --global`
}
const stripTuiSessionFlag = (trimmed: string) =>
trimmed.replace(TUI_SESSION_STRIP_RE, ' ').replace(/\s+/g, ' ').trim()
const modelValueForConfigSet = (arg: string) => {
const trimmed = arg.trim()
if (!trimmed) {
return trimmed
}
if (TUI_SESSION_MODEL_RE.test(trimmed)) {
return stripTuiSessionFlag(trimmed)
}
return persistedModelArg(trimmed)
}
export const sessionCommands: SlashCommand[] = [
{
aliases: ['bg', 'btw'],
@ -60,7 +81,7 @@ export const sessionCommands: SlashCommand[] = [
}
ctx.gateway
.rpc<ConfigSetResponse>('config.set', { key: 'model', session_id: ctx.sid, value: persistedModelArg(arg) })
.rpc<ConfigSetResponse>('config.set', { key: 'model', session_id: ctx.sid, value: modelValueForConfigSet(arg) })
.then(
ctx.guarded<ConfigSetResponse>(r => {
if (!r.value) {

View file

@ -655,7 +655,7 @@ export function useMainApp(gw: GatewayClient) {
const onModelSelect = useCallback((value: string) => {
patchOverlayState({ modelPicker: false })
slashRef.current(`/model ${value} --global`)
slashRef.current(`/model ${value}`)
}, [])
const hasReasoning = useTurnSelector(state => Boolean(state.reasoning.trim()))