@@ -40,14 +40,18 @@ export interface TestFixture {
4040 getCodexAcpAgent ( ) : CodexAcpServer ,
4141
4242 onCodexConnectionEvent ( handler : ( event : CodexConnectionEvent ) => void ) : void ,
43- getCodexConnectionDump ( ignoredFields : string [ ] ) : string ,
43+ getCodexConnectionDump ( ignoredFields : string [ ] , options ?: CodexConnectionDumpOptions ) : string ,
4444 clearCodexConnectionDump ( ) : void ,
4545
4646 onAcpConnectionEvent ( handler : ( event : MethodCallEvent ) => void ) : void ,
4747 getAcpConnectionDump ( ignoredFields : string [ ] ) : string ,
4848 clearAcpConnectionDump ( ) : void ,
4949}
5050
51+ export interface CodexConnectionDumpOptions {
52+ placeholderResponseMethods ?: string [ ] ;
53+ }
54+
5155export interface AcpConnectionConfig {
5256 connection : AgentSideConnection ;
5357 events : MethodCallEvent [ ] ;
@@ -86,8 +90,29 @@ export function createBaseTestFixture(config: ConnectionConfig): TestFixture {
8690 getCodexAcpClient ( ) : CodexAcpClient {
8791 return codexAcpClient ;
8892 } ,
89- getCodexConnectionDump ( ignoredFields : string [ ] ) : string {
90- return createArrayDump ( transportEvents , ignoredFields ) ;
93+ getCodexConnectionDump ( ignoredFields : string [ ] , options ?: CodexConnectionDumpOptions ) : string {
94+ const placeholderResponseMethods = new Set ( options ?. placeholderResponseMethods ?? [ ] ) ;
95+ const pendingRequestMethods : string [ ] = [ ] ;
96+
97+ const filteredEvents = transportEvents . flatMap ( ( event ) => {
98+ switch ( event . eventType ) {
99+ case "request" :
100+ pendingRequestMethods . push ( event . method ) ;
101+ break ;
102+ case "response" :
103+ const requestMethod = pendingRequestMethods . shift ( ) ;
104+ if ( requestMethod && placeholderResponseMethods . has ( requestMethod ) ) {
105+ return [ {
106+ eventType : "response" as const ,
107+ placeholder : requestMethod ,
108+ } ] ;
109+ }
110+ break ;
111+ }
112+
113+ return [ event ] ;
114+ } ) ;
115+ return createArrayDump ( filteredEvents , ignoredFields ) ;
91116 } ,
92117 onCodexConnectionEvent ( handler : ( event : CodexConnectionEvent ) => void ) : void {
93118 codexEventHandlers . push ( handler ) ;
0 commit comments