diff --git a/packages/cli/src/tui/app.tsx b/packages/cli/src/tui/app.tsx index 832a187..9effec4 100644 --- a/packages/cli/src/tui/app.tsx +++ b/packages/cli/src/tui/app.tsx @@ -25,8 +25,8 @@ export function TuiApp({ gatewayUrl, conversationId, sessionCookie, - initialModel: _initialModel, - initialProvider: _initialProvider, + initialModel, + initialProvider, }: TuiAppProps) { const { exit } = useApp(); const gitInfo = useGitInfo(); @@ -36,6 +36,8 @@ export function TuiApp({ gatewayUrl, sessionCookie, initialConversationId: conversationId, + initialModel, + initialProvider, }); const conversations = useConversations({ gatewayUrl, sessionCookie }); @@ -72,11 +74,14 @@ export function TuiApp({ const handleDeleteConversation = useCallback( (id: string) => { - void conversations.deleteConversation(id).then((ok) => { - if (ok && id === socket.conversationId) { - socket.clearMessages(); - } - }); + void conversations + .deleteConversation(id) + .then((ok) => { + if (ok && id === socket.conversationId) { + socket.clearMessages(); + } + }) + .catch(() => {}); }, [conversations, socket], ); @@ -95,12 +100,15 @@ export function TuiApp({ } // Ctrl+N: create new conversation and switch to it if (key.ctrl && ch === 'n') { - void conversations.createConversation().then((conv) => { - if (conv) { - socket.switchConversation(conv.id); - appMode.setMode('chat'); - } - }); + void conversations + .createConversation() + .then((conv) => { + if (conv) { + socket.switchConversation(conv.id); + appMode.setMode('chat'); + } + }) + .catch(() => {}); } // Ctrl+K: toggle search mode if (key.ctrl && ch === 'k') { diff --git a/packages/cli/src/tui/hooks/use-socket.ts b/packages/cli/src/tui/hooks/use-socket.ts index 47cc60c..7ce9d55 100644 --- a/packages/cli/src/tui/hooks/use-socket.ts +++ b/packages/cli/src/tui/hooks/use-socket.ts @@ -41,6 +41,8 @@ export interface UseSocketOptions { gatewayUrl: string; sessionCookie?: string; initialConversationId?: string; + initialModel?: string; + initialProvider?: string; } export interface UseSocketReturn { @@ -78,7 +80,7 @@ const EMPTY_USAGE: TokenUsage = { }; export function useSocket(opts: UseSocketOptions): UseSocketReturn { - const { gatewayUrl, sessionCookie, initialConversationId } = opts; + const { gatewayUrl, sessionCookie, initialConversationId, initialModel, initialProvider } = opts; const [connected, setConnected] = useState(false); const [connecting, setConnecting] = useState(true); @@ -227,6 +229,8 @@ export function useSocket(opts: UseSocketOptions): UseSocketReturn { socketRef.current.emit('message', { conversationId, content, + ...(initialProvider ? { provider: initialProvider } : {}), + ...(initialModel ? { modelId: initialModel } : {}), }); }, [conversationId, isStreaming], diff --git a/packages/types/src/chat/events.ts b/packages/types/src/chat/events.ts index 074c96e..0cf999d 100644 --- a/packages/types/src/chat/events.ts +++ b/packages/types/src/chat/events.ts @@ -62,6 +62,8 @@ export interface ErrorPayload { export interface ChatMessagePayload { conversationId?: string; content: string; + provider?: string; + modelId?: string; } /** Session info pushed when session is created or model changes */