@@ -2159,7 +2159,7 @@ async function runCliSingle(p) {
21592159 ? [ 'View' , 'GlobTool' , 'GrepTool' , 'ListDir' , 'ReadNotebook' , ...mcpTools ]
21602160 : [ 'Bash' , 'View' , 'GlobTool' , 'GrepTool' , 'ReadNotebook' , 'NotebookEditCell' , 'ListDir' , 'SearchReplace' , 'Write' , ...mcpTools ] ;
21612161 const effectiveMaxTurns = maxTurns || 30 ;
2162- let fullText = '' , newCid = claudeSessionId , chunkCount = 0 ;
2162+ let fullText = '' , fullThinking = '' , newCid = claudeSessionId , chunkCount = 0 ;
21632163 let currentPrompt = prompt ;
21642164 let continueCount = 0 ;
21652165 // First invocation carries attachments; subsequent auto-continues do not
@@ -2183,7 +2183,7 @@ async function runCliSingle(p) {
21832183 try { stmts . setPartialText . run ( fullText , sessionId ) ; } catch { }
21842184 }
21852185 } )
2186- . onThinking ( t => { ws . send ( JSON . stringify ( { type :'thinking' , text :t , ...( tabId ? { tabId } : { } ) } ) ) ; } )
2186+ . onThinking ( t => { fullThinking += t ; ws . send ( JSON . stringify ( { type :'thinking' , text :t , ...( tabId ? { tabId } : { } ) } ) ) ; } )
21872187 . onTool ( ( name , inp ) => {
21882188 if ( name === 'ask_user' || name === 'notify_user' || name === 'set_ui_state' ) {
21892189 try { stmts . addMsg . run ( sessionId , 'assistant' , 'tool' , ( inp || '' ) . substring ( 0 , 500 ) , name , null , null , null ) ; } catch { }
@@ -2287,6 +2287,7 @@ async function runCliSingle(p) {
22872287 }
22882288
22892289 // Persist final text and clean up
2290+ try { if ( fullThinking ) stmts . addMsg . run ( sessionId , 'assistant' , 'thinking' , fullThinking , null , null , null , null ) ; } catch { }
22902291 try { if ( fullText ) stmts . addMsg . run ( sessionId , 'assistant' , 'text' , fullText , null , null , null , null ) ; } catch { }
22912292 try { stmts . setPartialText . run ( null , sessionId ) ; } catch { }
22922293 return { cid : newCid , completed : lastResult ?. subtype === 'success' } ;
@@ -2303,7 +2304,7 @@ async function runSshSingle(p) {
23032304 ? [ 'View' , 'GlobTool' , 'GrepTool' , 'ListDir' , 'ReadNotebook' , ...mcpTools ]
23042305 : [ 'Bash' , 'View' , 'GlobTool' , 'GrepTool' , 'ListDir' , 'SearchReplace' , 'Write' , ...mcpTools ] ;
23052306 const effectiveMaxTurns = maxTurns || 30 ;
2306- let fullText = '' , newCid = claudeSessionId , chunkCount = 0 ;
2307+ let fullText = '' , fullThinking = '' , newCid = claudeSessionId , chunkCount = 0 ;
23072308 let currentPrompt = prompt ;
23082309 let continueCount = 0 ;
23092310 let currentContentBlocks = Array . isArray ( userContent ) ? userContent : null ;
@@ -2325,7 +2326,7 @@ async function runSshSingle(p) {
23252326 try { stmts . setPartialText . run ( fullText , sessionId ) ; } catch { }
23262327 }
23272328 } )
2328- . onThinking ( t => { ws . send ( JSON . stringify ( { type :'thinking' , text :t , ...( tabId ? { tabId } : { } ) } ) ) ; } )
2329+ . onThinking ( t => { fullThinking += t ; ws . send ( JSON . stringify ( { type :'thinking' , text :t , ...( tabId ? { tabId } : { } ) } ) ) ; } )
23292330 . onTool ( ( name , inp ) => {
23302331 if ( name === 'ask_user' || name === 'notify_user' || name === 'set_ui_state' ) {
23312332 try { stmts . addMsg . run ( sessionId , 'assistant' , 'tool' , ( inp || '' ) . substring ( 0 , 500 ) , name , null , null , null ) ; } catch { }
@@ -2398,6 +2399,7 @@ async function runSshSingle(p) {
23982399 currentContentBlocks = null ;
23992400 }
24002401
2402+ try { if ( fullThinking ) stmts . addMsg . run ( sessionId , 'assistant' , 'thinking' , fullThinking , null , null , null , null ) ; } catch { }
24012403 try { if ( fullText ) stmts . addMsg . run ( sessionId , 'assistant' , 'text' , fullText , null , null , null , null ) ; } catch { }
24022404 try { stmts . setPartialText . run ( null , sessionId ) ; } catch { }
24032405 return { cid : newCid , completed : lastResult ?. subtype === 'success' } ;
0 commit comments