@@ -620,8 +620,8 @@ const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerminalDra
620620 const openTerminal = useAtomCommand ( terminalEnvironment . open , "terminal open" ) ;
621621 const writeTerminal = useAtomCommand ( terminalEnvironment . write , "terminal write" ) ;
622622 const closeTerminalMutation = useAtomCommand ( terminalEnvironment . close , "terminal close" ) ;
623- const serverThread = useThread ( threadRef ) ;
624623 const draftThread = useComposerDraftStore ( ( store ) => store . getDraftThreadByRef ( threadRef ) ) ;
624+ const serverThread = useThread ( threadRef , { waitForShell : draftThread !== null } ) ;
625625 const projectRef = serverThread
626626 ? scopeProjectRef ( serverThread . environmentId , serverThread . projectId )
627627 : draftThread
@@ -976,8 +976,8 @@ const PersistentThreadTerminalPanel = memo(function PersistentThreadTerminalPane
976976 newShortcutLabel,
977977 closeShortcutLabel,
978978} : PersistentThreadTerminalPanelProps ) {
979- const serverThread = useThread ( threadRef ) ;
980979 const draftThread = useComposerDraftStore ( ( store ) => store . getDraftThreadByRef ( threadRef ) ) ;
980+ const serverThread = useThread ( threadRef , { waitForShell : draftThread !== null } ) ;
981981 const projectRef = serverThread
982982 ? scopeProjectRef ( serverThread . environmentId , serverThread . projectId )
983983 : draftThread
@@ -1181,7 +1181,7 @@ function ChatViewContent(props: ChatViewProps) {
11811181 ) ;
11821182 const composerDraftTarget : ScopedThreadRef | DraftId =
11831183 routeKind === "server" ? routeThreadRef : props . draftId ;
1184- const serverThread = useThread ( routeThreadRef ) ;
1184+ const serverThread = useThread ( routeThreadRef , { waitForShell : routeKind === "draft" } ) ;
11851185 const markThreadVisited = useUiStateStore ( ( store ) => store . markThreadVisited ) ;
11861186 const activeThreadLastVisitedAt = useUiStateStore (
11871187 ( store ) => store . threadLastVisitedAtById [ routeThreadKey ] ,
0 commit comments