@@ -51,6 +51,7 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
5151 const [ showHelp , setShowHelp ] = useState ( false ) ;
5252 const [ showWallet , setShowWallet ] = useState ( false ) ;
5353 const [ balance , setBalance ] = useState ( walletBalance ) ;
54+ const [ thinkingText , setThinkingText ] = useState ( '' ) ;
5455 // Key handler for picker + esc + abort
5556 const isPickerOrEsc = mode === 'model-picker' || ( mode === 'input' && ready && ! input ) || ! ready ;
5657 useInput ( ( ch , key ) => {
@@ -151,6 +152,9 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
151152 setStatusMsg ( 'Conversation cleared' ) ;
152153 setTimeout ( ( ) => setStatusMsg ( '' ) , 3000 ) ;
153154 return ;
155+ case '/compact' :
156+ onSubmit ( '/compact' ) ;
157+ return ;
154158 default :
155159 setStatusMsg ( `Unknown command: ${ cmd } . Try /help` ) ;
156160 setTimeout ( ( ) => setStatusMsg ( '' ) , 3000 ) ;
@@ -161,6 +165,7 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
161165 setInput ( '' ) ;
162166 setStreamText ( '' ) ;
163167 setThinking ( false ) ;
168+ setThinkingText ( '' ) ;
164169 setTools ( new Map ( ) ) ;
165170 setReady ( false ) ;
166171 setWaiting ( true ) ;
@@ -184,6 +189,11 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
184189 case 'thinking_delta' :
185190 setWaiting ( false ) ;
186191 setThinking ( true ) ;
192+ setThinkingText ( prev => {
193+ // Keep last 500 chars of thinking for display
194+ const updated = prev + event . text ;
195+ return updated . length > 500 ? updated . slice ( - 500 ) : updated ;
196+ } ) ;
187197 break ;
188198 case 'capability_start' :
189199 setWaiting ( false ) ;
@@ -239,9 +249,9 @@ function RunCodeApp({ initialModel, workDir, walletAddress, walletBalance, chain
239249 } ) , _jsx ( Text , { children : " " } ) ] } ) ) ;
240250 }
241251 // ── Normal Mode ──
242- return ( _jsxs ( Box , { flexDirection : "column" , children : [ statusMsg && ( _jsx ( Box , { marginLeft : 2 , children : _jsx ( Text , { color : "green" , children : statusMsg } ) } ) ) , showHelp && ( _jsxs ( Box , { flexDirection : "column" , marginLeft : 2 , marginTop : 1 , marginBottom : 1 , children : [ _jsx ( Text , { bold : true , children : "Commands" } ) , _jsx ( Text , { children : " " } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/model" } ) , " [name] Switch model (picker if no name)" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/wallet" } ) , " Show wallet address & balance" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/cost" } ) , " Session cost & savings" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/clear" } ) , " Clear conversation display" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/help" } ) , " This help" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/exit" } ) , " Quit" ] } ) , _jsx ( Text , { children : " " } ) , _jsx ( Text , { dimColor : true , children : " Shortcuts: sonnet, opus, gpt, gemini, deepseek, flash, free, r1, o4, nano, mini, haiku" } ) ] } ) ) , showWallet && ( _jsxs ( Box , { flexDirection : "column" , marginLeft : 2 , marginTop : 1 , marginBottom : 1 , children : [ _jsx ( Text , { bold : true , children : "Wallet" } ) , _jsx ( Text , { children : " " } ) , _jsxs ( Text , { children : [ " Chain: " , _jsx ( Text , { color : "magenta" , children : chain } ) ] } ) , _jsxs ( Text , { children : [ " Address: " , _jsx ( Text , { color : "cyan" , children : walletAddress } ) ] } ) , _jsxs ( Text , { children : [ " Balance: " , _jsx ( Text , { color : "green" , children : balance } ) ] } ) ] } ) ) , Array . from ( tools . values ( ) ) . map ( ( tool , i ) => ( _jsx ( Box , { marginLeft : 1 , children : tool . done ? ( tool . error
252+ return ( _jsxs ( Box , { flexDirection : "column" , children : [ statusMsg && ( _jsx ( Box , { marginLeft : 2 , children : _jsx ( Text , { color : "green" , children : statusMsg } ) } ) ) , showHelp && ( _jsxs ( Box , { flexDirection : "column" , marginLeft : 2 , marginTop : 1 , marginBottom : 1 , children : [ _jsx ( Text , { bold : true , children : "Commands" } ) , _jsx ( Text , { children : " " } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/model" } ) , " [name] Switch model (picker if no name)" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/wallet" } ) , " Show wallet address & balance" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/cost" } ) , " Session cost & savings" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/compact" } ) , " Compress conversation history" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/clear" } ) , " Clear conversation display" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/help" } ) , " This help" ] } ) , _jsxs ( Text , { children : [ " " , _jsx ( Text , { color : "cyan" , children : "/exit" } ) , " Quit" ] } ) , _jsx ( Text , { children : " " } ) , _jsx ( Text , { dimColor : true , children : " Shortcuts: sonnet, opus, gpt, gemini, deepseek, flash, free, r1, o4, nano, mini, haiku" } ) ] } ) ) , showWallet && ( _jsxs ( Box , { flexDirection : "column" , marginLeft : 2 , marginTop : 1 , marginBottom : 1 , children : [ _jsx ( Text , { bold : true , children : "Wallet" } ) , _jsx ( Text , { children : " " } ) , _jsxs ( Text , { children : [ " Chain: " , _jsx ( Text , { color : "magenta" , children : chain } ) ] } ) , _jsxs ( Text , { children : [ " Address: " , _jsx ( Text , { color : "cyan" , children : walletAddress } ) ] } ) , _jsxs ( Text , { children : [ " Balance: " , _jsx ( Text , { color : "green" , children : balance } ) ] } ) ] } ) ) , Array . from ( tools . values ( ) ) . map ( ( tool , i ) => ( _jsx ( Box , { marginLeft : 1 , children : tool . done ? ( tool . error
243253 ? _jsxs ( Text , { color : "red" , children : [ " \u2717 " , tool . name , " " , _jsxs ( Text , { dimColor : true , children : [ tool . elapsed , "ms" ] } ) ] } )
244- : _jsxs ( Text , { color : "green" , children : [ " \u2713 " , tool . name , " " , _jsxs ( Text , { dimColor : true , children : [ tool . elapsed , "ms \u2014 " , tool . preview . slice ( 0 , 60 ) , tool . preview . length > 60 ? '...' : '' ] } ) ] } ) ) : ( _jsxs ( Text , { color : "cyan" , children : [ " " , _jsx ( Spinner , { type : "dots" } ) , " " , tool . name , "..." ] } ) ) } , i ) ) ) , thinking && ( _jsx ( Box , { marginLeft : 1 , children : _jsxs ( Text , { color : "magenta" , children : [ " " , _jsx ( Spinner , { type : "dots" } ) , " thinking..." ] } ) } ) ) , waiting && ! thinking && tools . size === 0 && ( _jsx ( Box , { marginLeft : 1 , children : _jsxs ( Text , { color : "yellow" , children : [ " " , _jsx ( Spinner , { type : "dots" } ) , " " , _jsx ( Text , { dimColor : true , children : currentModel } ) ] } ) } ) ) , streamText && ( _jsx ( Box , { marginTop : 0 , marginBottom : 0 , children : _jsx ( Text , { children : streamText } ) } ) ) , ready && ( turnTokens . input > 0 || turnTokens . output > 0 ) && streamText && ( _jsx ( Box , { marginLeft : 1 , marginTop : 0 , children : _jsxs ( Text , { dimColor : true , children : [ turnTokens . input . toLocaleString ( ) , " in / " , turnTokens . output . toLocaleString ( ) , " out" , totalCost > 0 ? ` · $${ totalCost . toFixed ( 4 ) } session` : '' ] } ) } ) ) , ready && ( _jsx ( InputBox , { input : input , setInput : setInput , onSubmit : handleSubmit , model : currentModel , balance : balance , focused : mode === 'input' } ) ) ] } ) ) ;
254+ : _jsxs ( Text , { color : "green" , children : [ " \u2713 " , tool . name , " " , _jsxs ( Text , { dimColor : true , children : [ tool . elapsed , "ms \u2014 " , tool . preview . slice ( 0 , 60 ) , tool . preview . length > 60 ? '...' : '' ] } ) ] } ) ) : ( _jsxs ( Text , { color : "cyan" , children : [ " " , _jsx ( Spinner , { type : "dots" } ) , " " , tool . name , "..." ] } ) ) } , i ) ) ) , thinking && ( _jsxs ( Box , { flexDirection : "column" , marginLeft : 1 , children : [ _jsxs ( Text , { color : "magenta" , children : [ " " , _jsx ( Spinner , { type : "dots" } ) , " thinking..." ] } ) , thinkingText && ( _jsxs ( Text , { dimColor : true , wrap : "truncate-end" , children : [ " " , thinkingText . split ( '\n' ) . pop ( ) ?. slice ( 0 , 80 ) ] } ) ) ] } ) ) , waiting && ! thinking && tools . size === 0 && ( _jsx ( Box , { marginLeft : 1 , children : _jsxs ( Text , { color : "yellow" , children : [ " " , _jsx ( Spinner , { type : "dots" } ) , " " , _jsx ( Text , { dimColor : true , children : currentModel } ) ] } ) } ) ) , streamText && ( _jsx ( Box , { marginTop : 0 , marginBottom : 0 , children : _jsx ( Text , { children : streamText } ) } ) ) , ready && ( turnTokens . input > 0 || turnTokens . output > 0 ) && streamText && ( _jsx ( Box , { marginLeft : 1 , marginTop : 0 , children : _jsxs ( Text , { dimColor : true , children : [ turnTokens . input . toLocaleString ( ) , " in / " , turnTokens . output . toLocaleString ( ) , " out" , totalCost > 0 ? ` · $${ totalCost . toFixed ( 4 ) } session` : '' ] } ) } ) ) , ready && ( _jsx ( InputBox , { input : input , setInput : setInput , onSubmit : handleSubmit , model : currentModel , balance : balance , focused : mode === 'input' } ) ) ] } ) ) ;
245255}
246256export function launchInkUI ( opts ) {
247257 let resolveInput = null ;
0 commit comments