@@ -25,6 +25,7 @@ function deferred<T>() {
2525
2626const state = vi . hoisted ( ( ) => ( {
2727 serverConfig : { shellThreadFamilies : false } ,
28+ familyLookupFails : false ,
2829 scopes : new Map < string , Set < string > > ( ) ,
2930 threads : [ ] as {
3031 environmentId : EnvironmentId ;
@@ -78,7 +79,9 @@ vi.mock("../state/use-atom-command", () => ({
7879vi . mock ( "../state/use-atom-query-runner" , ( ) => ( {
7980 useAtomQueryRunner : ( family : unknown ) => async ( environmentId : string ) =>
8081 family === "threadFamily"
81- ? AsyncResult . success ( { threads : state . familyThreads } )
82+ ? state . familyLookupFails
83+ ? AsyncResult . failure ( Cause . fail ( new Error ( "Family lookup failed" ) ) )
84+ : AsyncResult . success ( { threads : state . familyThreads } )
8285 : state . sessionLookupFails
8386 ? AsyncResult . failure ( Cause . fail ( new Error ( "Session lookup failed" ) ) )
8487 : AsyncResult . success ( {
@@ -249,6 +252,7 @@ const operations = [
249252
250253beforeEach ( ( ) => {
251254 state . serverConfig . shellThreadFamilies = false ;
255+ state . familyLookupFails = false ;
252256 state . familyThreads = [ ] ;
253257 state . scopes = new Map ( [
254258 [ primary , new Set ( [ AuthOrchestrationOperateScope ] ) ] ,
@@ -366,6 +370,16 @@ describe("thread action permissions", () => {
366370 ) ;
367371 expect ( state . localEffects ) . not . toContain ( "clear-draft:fork" ) ;
368372 expect ( state . localEffects ) . not . toContain ( "clear-draft:other-side-chat" ) ;
373+
374+ // The family read only finds drafts to clear; it never blocks the delete.
375+ state . familyLookupFails = true ;
376+ state . requests = [ ] ;
377+ state . localEffects = [ ] ;
378+ expect ( ( await actions . deleteThread ( target ) ) . _tag ) . toBe ( "Success" ) ;
379+ expect ( state . requests ) . toEqual ( [
380+ expect . objectContaining ( { action : "delete" , environmentId : secondary } ) ,
381+ ] ) ;
382+ expect ( state . localEffects ) . toContain ( "clear-draft:thread" ) ;
369383 } ) ;
370384
371385 it ( "stops before delete and local cleanup when permission is revoked during session stop" , async ( ) => {
0 commit comments