77 ProviderInstanceId ,
88 RunId ,
99 ThreadId ,
10+ type ThreadTitleRegenerationOutcome ,
1011} from "@t3tools/contracts" ;
1112import * as Cause from "effect/Cause" ;
1213import { AsyncResult } from "effect/reactivity" ;
@@ -18,6 +19,7 @@ const state = vi.hoisted(() => ({
1819 dropBusy : false ,
1920 holdingRows : false ,
2021 failedAction : null as string | null ,
22+ titleOutcome : null as ThreadTitleRegenerationOutcome | null ,
2123 archivedRefreshes : [ ] as string [ ] ,
2224 scopes : new Map < string , Set < string > > ( ) ,
2325 shells : [ ] as EnvironmentThreadShell [ ] ,
@@ -156,7 +158,7 @@ vi.mock("../../state/threads", () => ({
156158 if ( action === state . failedAction )
157159 return AsyncResult . failure ( Cause . fail ( new Error ( "Server rejected action" ) ) ) ;
158160 state . afterRequest ?.( ) ;
159- return AsyncResult . success ( undefined ) ;
161+ return AsyncResult . success ( action === "regenerateTitle" ? state . titleOutcome : undefined ) ;
160162 } ,
161163 ] ) ,
162164 ) ,
@@ -193,6 +195,7 @@ const mutationCases = [
193195beforeEach ( ( ) => {
194196 state . connectedEnvironmentIds = [ primaryEnvironmentId , otherEnvironmentId ] ;
195197 state . failedAction = null ;
198+ state . titleOutcome = null ;
196199 state . archivedRefreshes = [ ] ;
197200 state . pendingOrder = null ;
198201 state . dropBusy = false ;
@@ -215,6 +218,16 @@ afterEach(() => {
215218 vi . unstubAllEnvs ( ) ;
216219} ) ;
217220
221+ it ( "reports a failed title generation as unsuccessful and allows another request" , async ( ) => {
222+ const actions = useThreadListActions ( ) ;
223+ const thread = makeThread ( ) ;
224+ state . titleOutcome = { status : "failed" , message : "Model unavailable" } ;
225+ expect ( await actions . regenerateThreadTitle ( thread ) ) . toBe ( false ) ;
226+
227+ state . titleOutcome = { status : "renamed" } ;
228+ expect ( await actions . regenerateThreadTitle ( thread ) ) . toBe ( true ) ;
229+ } ) ;
230+
218231describe ( "thread list operation permissions" , ( ) => {
219232 it . each ( mutationCases ) (
220233 "%s rejects a retained callback after its environment loses permission" ,
0 commit comments