@@ -23,13 +23,22 @@ const state = vi.hoisted(() => ({
2323 requests : [ ] as {
2424 action : string ;
2525 environmentId : string ;
26- input : { threadId : string ; orderKey ?: string ; snoozedUntil ?: string ; reason ?: string } ;
26+ input : {
27+ threadId : string ;
28+ orderKey ?: string ;
29+ snoozedUntil ?: string ;
30+ reason ?: string ;
31+ commandId ?: string ;
32+ } ;
2733 } [ ] ,
2834 dialogs : [ ] as { onConfirm : ( ) => void } [ ] ,
2935 alerts : [ ] as {
3036 title : string ;
37+ message ?: string ;
3138 buttons ?: { text : string ; onPress ?: ( ) => void } [ ] ;
3239 } [ ] ,
40+ titleFailure : null as string | null ,
41+ watchedTitleRequests : [ ] as string [ ] ,
3342 afterRequest : undefined as ( ( ) => void ) | undefined ,
3443} ) ) ;
3544
@@ -48,8 +57,8 @@ vi.mock("expo-haptics", () => ({
4857 ImpactFeedbackStyle : { Light : "light" } ,
4958} ) ) ;
5059vi . mock ( "../../components/ui/Dialog" , ( ) => ( {
51- alert : ( title : string , _message : string , buttons ?: { text : string ; onPress ?: ( ) => void } [ ] ) =>
52- state . alerts . push ( { title, buttons } ) ,
60+ alert : ( title : string , message : string , buttons ?: { text : string ; onPress ?: ( ) => void } [ ] ) =>
61+ state . alerts . push ( { title, message , buttons } ) ,
5362 confirm : ( dialog : { onConfirm : ( ) => void } ) => state . dialogs . push ( dialog ) ,
5463} ) ) ;
5564vi . mock ( "../archive/useArchivedThreadSnapshots" , ( ) => ( {
@@ -121,7 +130,10 @@ vi.mock("../../state/thread-order", () => ({
121130} ) ) ;
122131vi . mock ( "../../lib/uuid" , ( ) => ( { uuidv4 : ( ) => "command" } ) ) ;
123132vi . mock ( "../../state/threads" , ( ) => ( {
124- watchThreadTitleRegeneration : ( ) => ( { failure : Promise . resolve ( null ) , cancel : ( ) => { } } ) ,
133+ watchThreadTitleRegeneration : ( _ref : unknown , requestId : string ) => {
134+ state . watchedTitleRequests . push ( requestId ) ;
135+ return { failure : Promise . resolve ( state . titleFailure ) , cancel : ( ) => { } } ;
136+ } ,
125137 environmentThreadShells : {
126138 threadShellsAtom : "thread-shells" ,
127139 navigationThreadShellsAtom : "thread-shells" ,
@@ -201,6 +213,8 @@ beforeEach(() => {
201213 state . shells = [ ] ;
202214 state . dialogs = [ ] ;
203215 state . alerts = [ ] ;
216+ state . titleFailure = null ;
217+ state . watchedTitleRequests = [ ] ;
204218 state . afterRequest = undefined ;
205219} ) ;
206220
@@ -244,6 +258,23 @@ describe("thread list operation permissions", () => {
244258 } ) ;
245259} ) ;
246260
261+ describe ( "thread title regeneration" , ( ) => {
262+ it ( "alerts why the request it dispatched kept the title" , async ( ) => {
263+ state . titleFailure = "Claude CLI command failed: OAuth session expired" ;
264+
265+ await useThreadListActions ( ) . regenerateThreadTitle ( makeThread ( ) ) ;
266+ await Promise . resolve ( ) ;
267+
268+ expect ( state . watchedTitleRequests ) . toEqual ( [ state . requests [ 0 ] ?. input . commandId ] ) ;
269+ expect ( state . alerts ) . toEqual ( [
270+ expect . objectContaining ( {
271+ title : "Could not regenerate title" ,
272+ message : "Claude CLI command failed: OAuth session expired" ,
273+ } ) ,
274+ ] ) ;
275+ } ) ;
276+ } ) ;
277+
247278describe ( "pinned thread operation permissions" , ( ) => {
248279 it ( "checks every materialization target before writing any keys" , async ( ) => {
249280 const moved = makeThread ( { pinnedAt : "2026-09-02T00:00:00.000Z" } ) ;
0 commit comments