@@ -2,6 +2,7 @@ import { useRenderer } from '@opentui/react'
22import React , { useCallback , useEffect , useMemo , useRef } from 'react'
33import { useShallow } from 'zustand/react/shallow'
44
5+ import { AgentModeToggle } from './components/agent-mode-toggle'
56import { MultilineInput } from './components/multiline-input'
67import { Separator } from './components/separator'
78import { StatusIndicator , useHasStatus } from './components/status-indicator'
@@ -104,6 +105,8 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
104105 setActiveSubagents,
105106 isChainInProgress,
106107 setIsChainInProgress,
108+ agentMode,
109+ toggleAgentMode,
107110 } = useChatStore (
108111 useShallow ( ( store ) => ( {
109112 inputValue : store . inputValue ,
@@ -126,6 +129,8 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
126129 setActiveSubagents : store . setActiveSubagents ,
127130 isChainInProgress : store . isChainInProgress ,
128131 setIsChainInProgress : store . setIsChainInProgress ,
132+ agentMode : store . agentMode ,
133+ toggleAgentMode : store . toggleAgentMode ,
129134 } ) ) ,
130135 )
131136
@@ -397,7 +402,9 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
397402 )
398403
399404 const sendMessageRef =
400- useRef < ( content : string , onComplete ?: ( ) => void ) => Promise < void > > ( )
405+ useRef <
406+ ( content : string , params : { agentMode : 'FAST' | 'MAX' } ) => Promise < void >
407+ > ( )
401408
402409 const {
403410 queuedMessages,
@@ -411,7 +418,8 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
411418 setCanProcessQueue,
412419 setIsStreaming,
413420 } = useMessageQueue (
414- ( content : string ) => sendMessageRef . current ?.( content ) ?? Promise . resolve ( ) ,
421+ ( content : string ) =>
422+ sendMessageRef . current ?.( content , { agentMode } ) ?? Promise . resolve ( ) ,
415423 isChainInProgressRef ,
416424 activeAgentStreamsRef ,
417425 )
@@ -444,14 +452,14 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
444452 const timeout = setTimeout ( ( ) => {
445453 logger . info ( { prompt : initialPrompt } , 'Auto-submitting initial prompt' )
446454 if ( sendMessageRef . current ) {
447- sendMessageRef . current ( initialPrompt )
455+ sendMessageRef . current ( initialPrompt , { agentMode } )
448456 }
449457 } , 100 )
450458
451459 return ( ) => clearTimeout ( timeout )
452460 }
453461 return undefined
454- } , [ initialPrompt ] )
462+ } , [ initialPrompt , agentMode ] )
455463
456464 const hasStatus = useHasStatus ( isWaitingForResponse , clipboardMessage )
457465
@@ -473,7 +481,7 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
473481 return
474482 }
475483
476- sendMessage ( trimmed )
484+ sendMessage ( trimmed , { agentMode } )
477485
478486 setTimeout ( ( ) => {
479487 scrollToLatest ( )
@@ -500,6 +508,7 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
500508 setCollapsedAgents,
501509 navigateUp,
502510 navigateDown,
511+ toggleAgentMode,
503512 } )
504513
505514 const { tree : messageTree , topLevelMessages } = useMemo (
@@ -637,6 +646,11 @@ export const App = ({ initialPrompt }: { initialPrompt?: string } = {}) => {
637646 </ text >
638647 </ >
639648 ) }
649+ < AgentModeToggle
650+ mode = { agentMode }
651+ theme = { theme }
652+ onToggle = { toggleAgentMode }
653+ />
640654 < Separator theme = { theme } width = { renderer . width } />
641655 { slashContext . active && slashSuggestionItems . length > 0 ? (
642656 < SuggestionMenu
0 commit comments