@@ -68,7 +68,7 @@ const auth = {
6868 sessionCookieName : "t3_session" ,
6969} ;
7070
71- const serverConfig : ServerConfig = {
71+ const baseServerConfig : ServerConfig = {
7272 ...Schema . decodeUnknownSync ( ServerConfig ) ( {
7373 environment : descriptor ,
7474 auth,
@@ -106,6 +106,11 @@ const serverConfig: ServerConfig = {
106106 } ) ,
107107 keybindings : DEFAULT_RESOLVED_KEYBINDINGS ,
108108} ;
109+ // A server only leaves threads out of the shell when it serves their families.
110+ const serverConfig = ( ) : ServerConfig =>
111+ threads . some ( ( thread ) => thread . olderSettled )
112+ ? { ...baseServerConfig , shellThreadFamilies : true }
113+ : baseServerConfig ;
109114
110115const project : OrchestrationProjectShell = {
111116 id : PROJECT_ID ,
@@ -189,6 +194,8 @@ function run(threadId: ThreadId, id: RunId, ordinal: number, userMessageId: stri
189194export interface FakeThread {
190195 /** Makes this a side chat of that thread. */
191196 readonly sideChatOf ?: ThreadId ;
197+ /** Makes this an older settled thread the shell leaves out; only its family read returns it. */
198+ readonly olderSettled ?: true ;
192199 readonly id : ThreadId ;
193200 readonly title : string ;
194201 readonly runs : ReadonlyArray < OrchestrationV2Run > ;
@@ -253,8 +260,8 @@ function shellOf(thread: FakeThread): OrchestrationV2ThreadShell {
253260 createdAt : AT ,
254261 updatedAt : AT ,
255262 archivedAt : null ,
256- settledOverride : null ,
257- settledAt : null ,
263+ settledOverride : thread . olderSettled ? "settled" : null ,
264+ settledAt : thread . olderSettled ? AT : null ,
258265 lastVisitedAt : AT ,
259266 deletedAt : null ,
260267 } ;
@@ -290,8 +297,8 @@ function projectionOf(thread: FakeThread): OrchestrationV2ThreadProjection {
290297 createdAt : AT ,
291298 updatedAt : AT ,
292299 archivedAt : null ,
293- settledOverride : null ,
294- settledAt : null ,
300+ settledOverride : shell . settledOverride ,
301+ settledAt : shell . settledAt ,
295302 lastVisitedAt : AT ,
296303 deletedAt : null ,
297304 } ,
@@ -363,7 +370,7 @@ const handlers: Record<string, (input: never) => unknown> = {
363370 schemaVersion : 1 ,
364371 snapshotSequence : sequence ,
365372 projects : [ project ] ,
366- threads : threads . map ( shellOf ) ,
373+ threads : threads . filter ( ( thread ) => ! thread . olderSettled ) . map ( shellOf ) ,
367374 archivedThreads : [ ] ,
368375 } ,
369376 } ,
@@ -387,6 +394,16 @@ const handlers: Record<string, (input: never) => unknown> = {
387394 } ,
388395 ) ;
389396 } ,
397+ [ ORCHESTRATION_V2_WS_METHODS . getThreadFamily ] : ( input : { readonly threadId : ThreadId } ) => {
398+ const rootOf = ( thread : FakeThread ) => thread . sideChatOf ?? thread . id ;
399+ const requested = threads . find ( ( candidate ) => candidate . id === input . threadId ) ;
400+ return Effect . succeed ( {
401+ snapshotSequence : sequence ,
402+ threads : requested
403+ ? threads . filter ( ( thread ) => rootOf ( thread ) === rootOf ( requested ) ) . map ( shellOf )
404+ : [ ] ,
405+ } ) ;
406+ } ,
390407 [ WS_METHODS . subscribeVcsStatus ] : ( ) =>
391408 subscribe < VcsStatusStreamEvent > ( [ ] , ( queue ) => {
392409 vcsStatusSubscriber = queue ;
@@ -395,7 +412,7 @@ const handlers: Record<string, (input: never) => unknown> = {
395412 } ;
396413 } ) ,
397414 [ WS_METHODS . subscribeServerConfig ] : ( ) =>
398- subscribe ( [ { version : 1 as const , type : "snapshot" as const , config : serverConfig } ] ) ,
415+ subscribe ( [ { version : 1 as const , type : "snapshot" as const , config : serverConfig ( ) } ] ) ,
399416} ;
400417
401418// Unanswered calls stay pending, like a server that has not replied yet.
@@ -410,9 +427,9 @@ const client = new Proxy(handlers, {
410427
411428const session : EnvironmentConnectionLease [ "session" ] = {
412429 client : client as unknown as WsRpcProtocolClient ,
413- initialConfig : Effect . succeed ( serverConfig ) ,
430+ initialConfig : Effect . sync ( serverConfig ) ,
414431 subscribeServerConfig : ( ) =>
415- subscribe ( [ { version : 1 as const , type : "snapshot" as const , config : serverConfig } ] ) ,
432+ subscribe ( [ { version : 1 as const , type : "snapshot" as const , config : serverConfig ( ) } ] ) ,
416433 ready : Effect . void ,
417434 probe : Effect . void ,
418435 inboundFrames : Effect . succeed ( 0 ) ,
0 commit comments