@@ -24,6 +24,7 @@ import type {
2424 ProviderInteractionMode ,
2525 RuntimeMode ,
2626 RuntimeRequestId ,
27+ ScopedThreadRef ,
2728 ServerConfig as T3ServerConfig ,
2829 ThreadId ,
2930 UsageLimitsReport ,
@@ -155,6 +156,11 @@ export interface ThreadDetailScreenProps {
155156 readonly setupWorkingStartedAt ?: string | null ;
156157 readonly canOperateThread : boolean ;
157158 readonly selectedThread : EnvironmentThreadShell ;
159+ /**
160+ * Read thread details through this, not `selectedThread.id`: it stays null until
161+ * a queued creation reaches the server; see `useThreadSelection`.
162+ */
163+ readonly selectedThreadDetailRef : ScopedThreadRef | null ;
158164 readonly contentPresentation : ThreadContentPresentation ;
159165 readonly screenTone : StatusTone ;
160166 readonly connectionError : string | null ;
@@ -330,10 +336,7 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
330336 const usesNativeWorkspaceColumns = useNativeWorkspaceColumnsSupported ( ) ;
331337 const navigation = useNavigation ( ) ;
332338 const { session : voiceInputSession } = useGlobalVoiceInput ( ) ;
333- const reportedModelSelection = useThreadReportedModelSelection ( {
334- environmentId : props . environmentId ,
335- threadId : props . selectedThread . id ,
336- } ) ;
339+ const reportedModelSelection = useThreadReportedModelSelection ( props . selectedThreadDetailRef ) ;
337340 const deviceState = useEnvironmentQuery (
338341 deviceEnvironment . state ( { environmentId : props . environmentId , input : { } } ) ,
339342 ) ;
@@ -411,14 +414,8 @@ export const ThreadDetailScreen = memo(function ThreadDetailScreen(props: Thread
411414 threadId : props . selectedThread . id ,
412415 } ) ;
413416 const composerError = useAtomValue ( threadComposerErrorsAtom ) [ selectedThreadKey ] ?. message ?? null ;
414- const queuedCount = useThreadQueuedCount ( {
415- environmentId : props . environmentId ,
416- threadId : props . selectedThread . id ,
417- } ) ;
418- const turnSubagents = useThreadTurnSubagents ( {
419- environmentId : props . environmentId ,
420- threadId : props . selectedThread . id ,
421- } ) ;
417+ const queuedCount = useThreadQueuedCount ( props . selectedThreadDetailRef ) ;
418+ const turnSubagents = useThreadTurnSubagents ( props . selectedThreadDetailRef ) ;
422419 const agentsSegment = resolveSubagentPillSegment ( turnSubagents ) ;
423420 const composerEditorRef = useRef < ComposerEditorHandle > ( null ) ;
424421 // A provider-native subagent shows status instead of a composer.
0 commit comments