@@ -204,6 +204,11 @@ export function deleteSession(projectId: string, sessionId: string): boolean {
204204export interface ChatEventSink {
205205 /** Streamed text delta from the model. */
206206 text ?: ( delta : string ) => void ;
207+ /** Streamed delta from the model's reasoning block (Anthropic/MiniMax
208+ * thinking). Provider-agnostic — never called for providers that don't
209+ * expose thinking. The chat panel streams these into a live "Thinking…"
210+ * block so the reasoning phase doesn't feel like dead air. */
211+ thinking ?: ( delta : string ) => void ;
207212 /** A tool call is about to execute. */
208213 toolStart ?: ( name : string , args : unknown ) => void ;
209214 /** A tool call has finished. `ok=false` carries the model's error message. */
@@ -218,6 +223,7 @@ const noop = () => undefined;
218223/** ponytail: zero-config sink that swallows every event. */
219224const NOOP_SINK : Required < ChatEventSink > = {
220225 text : noop ,
226+ thinking : noop ,
221227 toolStart : noop ,
222228 toolEnd : noop ,
223229 error : noop ,
@@ -323,6 +329,7 @@ export async function runChat(
323329
324330 const agentSink = {
325331 text : ( delta : string ) => emit . text ( delta ) ,
332+ thinking : ( delta : string ) => emit . thinking ( delta ) ,
326333 toolStart : ( name : string , args : unknown ) => {
327334 emit . toolStart ( name , args ) ;
328335 void editsAllowed ;
@@ -572,44 +579,6 @@ function emptyDocumentForTextOnly(projectId: string): AxcutDocument {
572579 return createEmptyDocument ( { title : "Untitled project" , projectId } ) ;
573580}
574581
575- // ponytail: legacy single-session compatibility for the simpler ChatPanel
576- // consumers. Picks the most recent session (or auto-creates one) so a stale
577- // caller keeps working. The multi-session UI is the supported path.
578- function getOrCreateDefaultSession ( projectId : string ) : ChatSession {
579- const m = getProjectSessions ( projectId ) ;
580- if ( m . size > 0 ) {
581- const arr = Array . from ( m . values ( ) ) . sort ( ( a , b ) => b . createdAt . localeCompare ( a . createdAt ) ) ;
582- return arr [ 0 ] ;
583- }
584- const created = createSession ( projectId ) ;
585- const s = m . get ( created . id ) ;
586- if ( ! s ) throw new Error ( "Chat session unavailable." ) ;
587- return s ;
588- }
589-
590- export async function runChatDefault (
591- projectId : string ,
592- message : string ,
593- llmConfig : LlmConfigStore ,
594- sink ?: ChatEventSink ,
595- ) : Promise < AiEditionChatResult > {
596- const session = getOrCreateDefaultSession ( projectId ) ;
597- return runChat ( projectId , session . id , message , llmConfig , undefined , sink ) ;
598- }
599-
600- export function getDefaultChatHistory ( projectId : string ) : AiEditionChatMessage [ ] {
601- const m = sessionsByProject . get ( projectId ) ;
602- if ( ! m || m . size === 0 ) return [ ] ;
603- const arr = Array . from ( m . values ( ) ) . sort ( ( a , b ) => b . createdAt . localeCompare ( a . createdAt ) ) ;
604- return [ ...arr [ 0 ] . messages ] ;
605- }
606-
607- export function clearDefaultChatHistory ( projectId : string ) : void {
608- const m = sessionsByProject . get ( projectId ) ;
609- if ( ! m ) return ;
610- for ( const s of m . values ( ) ) s . messages = [ ] ;
611- }
612-
613582// --- Compaction (P3.7) ---------------------------------------------------
614583
615584export interface SessionBudgetSnapshot {
0 commit comments