@@ -33,6 +33,7 @@ import {CodexCommands} from "./CodexCommands";
3333import type { QuotaMeta } from "./QuotaMeta" ;
3434import { logger } from "./Logger" ;
3535import { sanitizeMcpServerName } from "./McpServerName" ;
36+ import { createResponseItemHistoryFallbackUpdates } from "./ResponseItemHistoryFallback" ;
3637import {
3738 type LegacyLoadSessionResponse ,
3839 type LegacyNewSessionResponse ,
@@ -44,6 +45,7 @@ import {
4445 LEGACY_SET_SESSION_MODEL_METHOD ,
4546} from "./AcpExtensions" ;
4647import {
48+ createCommandExecutionCompleteUpdate ,
4749 createCommandExecutionUpdate ,
4850 createDynamicToolCallUpdate ,
4951 createFileChangeUpdate ,
@@ -833,17 +835,29 @@ export class CodexAcpServer implements acp.Agent {
833835
834836 private async streamThreadHistory ( sessionId : string , thread : Thread ) : Promise < void > {
835837 const session = new ACPSessionConnection ( this . connection , sessionId ) ;
838+ const sessionState = this . getSessionState ( sessionId ) ;
839+ const responseItemFallbackUpdates = await createResponseItemHistoryFallbackUpdates (
840+ thread ,
841+ sessionState . terminalOutputMode ,
842+ ) ;
843+ if ( responseItemFallbackUpdates ) {
844+ for ( const update of responseItemFallbackUpdates ) {
845+ await session . update ( update ) ;
846+ }
847+ return ;
848+ }
849+
836850 for ( const turn of thread . turns ) {
837851 for ( const item of turn . items ) {
838- const updates = await this . createHistoryUpdates ( item ) ;
852+ const updates = await this . createHistoryUpdates ( item , sessionState ) ;
839853 for ( const update of updates ) {
840854 await session . update ( update ) ;
841855 }
842856 }
843857 }
844858 }
845859
846- private async createHistoryUpdates ( item : ThreadItem ) : Promise < UpdateSessionEvent [ ] > {
860+ private async createHistoryUpdates ( item : ThreadItem , sessionState : SessionState ) : Promise < UpdateSessionEvent [ ] > {
847861 switch ( item . type ) {
848862 case "userMessage" :
849863 return this . createUserMessageUpdates ( item ) ;
@@ -859,8 +873,14 @@ export class CodexAcpServer implements acp.Agent {
859873 return this . createReasoningUpdates ( item ) ;
860874 case "fileChange" :
861875 return [ await createFileChangeUpdate ( item ) ] ;
862- case "commandExecution" :
863- return [ await createCommandExecutionUpdate ( item ) ] ;
876+ case "commandExecution" : {
877+ const updates = [ await createCommandExecutionUpdate ( item ) ] ;
878+ const completeUpdate = createCommandExecutionCompleteUpdate ( item , sessionState . terminalOutputMode ) ;
879+ if ( completeUpdate ) {
880+ updates . push ( completeUpdate ) ;
881+ }
882+ return updates ;
883+ }
864884 case "mcpToolCall" :
865885 return [ await createMcpToolCallUpdate ( item ) ] ;
866886 case "dynamicToolCall" :
0 commit comments