@@ -8418,8 +8418,11 @@ export default function ChatView(props: ChatViewProps) {
84188418 // The composer is already cleared, so until the draft is marked promoting
84198419 // new-thread flows would treat it as an empty draft and reuse it while
84208420 // the worktree is still being prepared.
8421- if ( isLocalDraftThread ) {
8422- markPromotedDraftThreadByRef ( scopeThreadRef ( activeThread . environmentId , threadIdForSend ) ) ;
8421+ const sentDraftThreadRef = isLocalDraftThread
8422+ ? scopeThreadRef ( activeThread . environmentId , threadIdForSend )
8423+ : null ;
8424+ if ( sentDraftThreadRef ) {
8425+ markPromotedDraftThreadByRef ( sentDraftThreadRef ) ;
84238426 }
84248427 if ( backgroundThreadRef ) {
84258428 try {
@@ -8457,12 +8460,15 @@ export default function ChatView(props: ChatViewProps) {
84578460 releaseDraftAttachments ( composerAttachmentsSnapshot ) ;
84588461 }
84598462 acknowledgeActiveThreadWoke ( ) ;
8460- if ( backgroundThreadRef ) {
8463+ // A draft still on screen finalizes once its thread route takes over.
8464+ if ( sentDraftThreadRef ) {
84618465 if ( backgroundDraftOpened || currentRouteThreadKeyRef . current !== routeThreadKey ) {
8462- finalizePromotedDraftThreadByRef ( backgroundThreadRef ) ;
8466+ finalizePromotedDraftThreadByRef ( sentDraftThreadRef ) ;
84638467 } else {
8464- clearBackgroundDraftSubmissionByRef ( backgroundThreadRef ) ;
8468+ clearBackgroundDraftSubmissionByRef ( sentDraftThreadRef ) ;
84658469 }
8470+ }
8471+ if ( backgroundThreadRef ) {
84668472 if ( backgroundDraftOpened ) {
84678473 toastManager . add (
84688474 stackedThreadToast ( {
0 commit comments