@@ -31,6 +31,7 @@ const state = vi.hoisted(() => ({
3131 projectId : ProjectId ;
3232 title : string ;
3333 worktreePath : string | null ;
34+ lineage : { parentThreadId : ThreadId | null ; sideChat ?: boolean } ;
3435 session : { status : "ready" | "stopped" } | null ;
3536 latestTurn : null ;
3637 } [ ] ,
@@ -119,7 +120,8 @@ vi.mock("../components/Sidebar.logic", () => ({
119120vi . mock ( "../composerDraftStore" , ( ) => ( {
120121 useComposerDraftStore : ( select : ( store : unknown ) => unknown ) =>
121122 select ( {
122- clearDraftThread : ( ) => state . localEffects . push ( "clear-draft" ) ,
123+ clearDraftThread : ( ref : ScopedThreadRef ) =>
124+ state . localEffects . push ( `clear-draft:${ ref . threadId } ` ) ,
123125 clearProjectDraftThreadById : ( ) => state . localEffects . push ( "clear-project-draft" ) ,
124126 } ) ,
125127} ) ) ;
@@ -139,7 +141,8 @@ vi.mock("../lib/archivedThreadsState", () => ({
139141 refreshArchivedThreadsForEnvironment : ( ) => state . localEffects . push ( "refresh-archive" ) ,
140142} ) ) ;
141143vi . mock ( "../lib/composerDraftUploads" , ( ) => ( {
142- releaseComposerDraftUploads : ( ) => state . localEffects . push ( "release-uploads" ) ,
144+ releaseComposerDraftUploads : ( ref : ScopedThreadRef ) =>
145+ state . localEffects . push ( `release-uploads:${ ref . threadId } ` ) ,
143146} ) ) ;
144147vi . mock ( "../localApi" , ( ) => ( {
145148 readLocalApi : ( ) => ( { dialogs : { confirm : state . confirm } } ) ,
@@ -238,6 +241,7 @@ beforeEach(() => {
238241 projectId : ProjectId . make ( "project" ) ,
239242 title : "Thread" ,
240243 worktreePath : null ,
244+ lineage : { parentThreadId : null } ,
241245 session : null ,
242246 latestTurn : null ,
243247 } ,
@@ -348,6 +352,24 @@ describe("thread action permissions", () => {
348352 expect ( threadPanelStatePresence ( target ) ) . toEqual ( panelStateCleared ) ;
349353 } ) ;
350354
355+ it ( "clears the drafts of the side chats deleted with it" , async ( ) => {
356+ state . scopes . get ( secondary ) ! . add ( AuthOrchestrationOperateScope ) ;
357+ const parent = state . threads [ 0 ] ! ;
358+ state . threads . push (
359+ {
360+ ...parent ,
361+ id : ThreadId . make ( "side-chat" ) ,
362+ lineage : { parentThreadId : parent . id , sideChat : true } ,
363+ } ,
364+ { ...parent , id : ThreadId . make ( "fork" ) , lineage : { parentThreadId : parent . id } } ,
365+ ) ;
366+ expect ( ( await useThreadActions ( ) . deleteThread ( target ) ) . _tag ) . toBe ( "Success" ) ;
367+ expect ( state . localEffects ) . toEqual (
368+ expect . arrayContaining ( [ "release-uploads:side-chat" , "clear-draft:side-chat" ] ) ,
369+ ) ;
370+ expect ( state . localEffects ) . not . toContain ( "clear-draft:fork" ) ;
371+ } ) ;
372+
351373 it ( "does not request worktree removal after its grant is revoked during delete" , async ( ) => {
352374 state . scopes
353375 . get ( secondary ) !
0 commit comments