@@ -47,6 +47,10 @@ import { appAtomRegistry } from "../../state/atom-registry";
4747import { activeNewTaskProjectKeyAtom } from "../../state/active-new-task" ;
4848import { useProjects } from "../../state/entities" ;
4949import { environmentServerConfigsAtom } from "../../state/server" ;
50+ import {
51+ pendingThreadCreationOutcomesAtom ,
52+ selectThreadCreationDetail ,
53+ } from "../../state/pending-thread-creation" ;
5054import { threadOutboxManager } from "../../state/thread-outbox" ;
5155import { workspaceConnections } from "../../state/workspace" ;
5256import { environmentThreadShells } from "../../state/threads" ;
@@ -533,21 +537,25 @@ function AdaptiveWorkspaceLayoutContent(
533537 const environmentId = first ( params ?. environmentId ) ;
534538 const threadId = first ( params ?. threadId ) ;
535539 // The index includes subagent threads, which the navigation list leaves out. A thread whose
536- // creation is still queued is not indexed yet , so its queued creation names the project.
540+ // creation is queued or failed is not indexed, so its pending creation names the project.
537541 const threadProjectId = ( ( ) => {
538542 if ( ! environmentId || ! threadId ) return undefined ;
539543 const ref = {
540544 environmentId : EnvironmentId . make ( environmentId ) ,
541545 threadId : ThreadId . make ( threadId ) ,
542546 } ;
543- const queued = appAtomRegistry . get ( threadOutboxManager . queuedMessagesByThreadKeyAtom ) ;
547+ const { pendingCreation } = selectThreadCreationDetail ( {
548+ threadRef : ref ,
549+ threadKey : scopedThreadKey ( ref . environmentId , ref . threadId ) ,
550+ queuedMessagesByThreadKey : appAtomRegistry . get (
551+ threadOutboxManager . queuedMessagesByThreadKeyAtom ,
552+ ) ,
553+ outcomes : appAtomRegistry . get ( pendingThreadCreationOutcomesAtom ) ,
554+ } ) ;
544555 return (
545556 appAtomRegistry
546557 . get ( environmentThreadShells . environmentThreadIndexAtom ( ref . environmentId ) )
547- . get ( ref . threadId ) ?. projectId ??
548- queued [ scopedThreadKey ( ref . environmentId , ref . threadId ) ] ?. find (
549- ( message ) => message . creation ,
550- ) ?. creation ?. projectId
558+ . get ( ref . threadId ) ?. projectId ?? pendingCreation ?. message . creation ?. projectId
551559 ) ;
552560 } ) ( ) ;
553561 // An open draft's route may not name the project it shows, so read the draft's selection.
0 commit comments