@@ -63,6 +63,7 @@ import {
6363 OrchestrationV2ThreadLaunchError ,
6464 type OrchestrationProjectShell ,
6565 type OrchestrationV2ShellSnapshot ,
66+ type ApplicationStoredEvent ,
6667 type ProjectEntriesFailure ,
6768 type ProjectFileFailure ,
6869 type ProjectFileOperation ,
@@ -132,6 +133,7 @@ import {
132133 shellStreamItemFromThreadShell ,
133134 shellStreamItemsFromInitialSnapshot ,
134135 shellStreamItemsFromResumeSnapshot ,
136+ shouldPublishShellApplicationEvent ,
135137 skipUnchangedThreadShells ,
136138 toShellApplicationEvent ,
137139 type ShellApplicationEvent ,
@@ -983,6 +985,9 @@ export const subscribeOrchestrationV2Shell = Effect.fn("ws.orchestrationV2.subsc
983985 const projects = yield * ProjectStore . ProjectStoreV2 ;
984986 const projectService = yield * ProjectService . ProjectService ;
985987 const projectEnrichment = yield * ProjectEnrichmentService . ProjectEnrichmentService ;
988+ let subagentThreadIds = new Set < string > ( ) ;
989+ const filterSubagentTranscript = ( stored : ApplicationStoredEvent ) =>
990+ shouldPublishShellApplicationEvent ( stored , subagentThreadIds ) ;
986991
987992 const enrichmentChanges = yield * projectEnrichment . subscribeChanges ;
988993 const loadProjectMetadataSnapshot = Effect . fn ( "ws.orchestrationV2.loadProjectMetadataSnapshot" ) (
@@ -1009,6 +1014,11 @@ export const subscribeOrchestrationV2Shell = Effect.fn("ws.orchestrationV2.subsc
10091014 latestSequence : applicationEvents . latestApplicationSequence ,
10101015 } ) ,
10111016 ) ;
1017+ subagentThreadIds = new Set (
1018+ base . threads
1019+ . filter ( ( thread ) => thread . lineage . relationshipToParent === "subagent" )
1020+ . map ( ( thread ) => thread . id ) ,
1021+ ) ;
10121022 const enriched = yield * enrichProjectShells ( base . projects ) ;
10131023 return {
10141024 snapshot : { ...base , projects : enriched . projects } as OrchestrationV2ShellSnapshot ,
@@ -1071,6 +1081,7 @@ export const subscribeOrchestrationV2Shell = Effect.fn("ws.orchestrationV2.subsc
10711081 applicationEvents . streamProjectedApplicationEvents ( {
10721082 afterSequence,
10731083 project : toShellApplicationEvent ,
1084+ filter : filterSubagentTranscript ,
10741085 } ) ,
10751086 ) ,
10761087 ) ;
@@ -1161,16 +1172,25 @@ export const subscribeOrchestrationV2Shell = Effect.fn("ws.orchestrationV2.subsc
11611172 } ) ;
11621173 }
11631174
1175+ const currentShell = yield * threadManagement . getShellSnapshot ( { location : "active" } ) ;
1176+ subagentThreadIds = new Set (
1177+ currentShell . threads
1178+ . filter ( ( thread ) => thread . lineage . relationshipToParent === "subagent" )
1179+ . map ( ( thread ) => thread . id ) ,
1180+ ) ;
1181+
11641182 const loaded = yield * loadProjectMetadataSnapshot ( highWater ) ;
11651183 const replay = toShellStream (
1166- applicationEvents . readApplicationEvents ( {
1167- afterSequence : input . afterSequence ,
1168- throughSequence : highWater ,
1169- // A row a newer build wrote (e.g. after a downgrade) must not fail
1170- // every shell resubscribe. The live tail below resumes from
1171- // highWater, so a dropped row never hides later events.
1172- skipUnknownEventTypes : true ,
1173- } ) ,
1184+ applicationEvents
1185+ . readApplicationEvents ( {
1186+ afterSequence : input . afterSequence ,
1187+ throughSequence : highWater ,
1188+ // A row a newer build wrote (e.g. after a downgrade) must not fail
1189+ // every shell resubscribe. The live tail below resumes from
1190+ // highWater, so a dropped row never hides later events.
1191+ skipUnknownEventTypes : true ,
1192+ } )
1193+ . pipe ( Stream . filter ( filterSubagentTranscript ) ) ,
11741194 ) ;
11751195 return composeShellStreamWithEnrichment ( {
11761196 initial : initialEnrichmentItems ( loaded ) ,
0 commit comments