@@ -39,7 +39,11 @@ import { afterEach, describe, expect, it, vi } from "vite-plus/test";
3939
4040import { deriveServerPaths , ServerConfig } from "../../config.ts" ;
4141import { TextGenerationError } from "@t3tools/contracts" ;
42- import { ProviderAdapterRequestError } from "../../provider/Errors.ts" ;
42+ import {
43+ ProviderAdapterRequestError ,
44+ ProviderWorkspaceMissingError ,
45+ type ProviderServiceError ,
46+ } from "../../provider/Errors.ts" ;
4347import { OrchestrationEventStoreLive } from "../../persistence/Layers/OrchestrationEventStore.ts" ;
4448import { OrchestrationCommandReceiptRepositoryLive } from "../../persistence/Layers/OrchestrationCommandReceipts.ts" ;
4549import { SqlitePersistenceMemory } from "../../persistence/Layers/Sqlite.ts" ;
@@ -181,7 +185,7 @@ describe("ProviderCommandReactor", () => {
181185 readonly stopSessionEffect ?: ( ) => Effect . Effect < void , ProviderAdapterRequestError > ;
182186 readonly startSessionEffect ?: (
183187 session : ProviderSession ,
184- ) => Effect . Effect < ProviderSession , ProviderAdapterRequestError > ;
188+ ) => Effect . Effect < ProviderSession , ProviderServiceError > ;
185189 readonly tryHandlePromptCommandEffect ?: ProviderAuthService [ "Service" ] [ "tryHandlePromptCommand" ] ;
186190 } ) {
187191 const now = "2026-01-01T00:00:00.000Z" ;
@@ -1217,6 +1221,58 @@ describe("ProviderCommandReactor", () => {
12171221 } ) ,
12181222 ) ;
12191223
1224+ effectIt . effect ( "shows the missing workspace message without a provider stack trace" , ( ) =>
1225+ Effect . gen ( function * ( ) {
1226+ const attempted = yield * Deferred . make < void > ( ) ;
1227+ const missingCwd = "/missing/project/worktree" ;
1228+ const missingWorkspace = new ProviderWorkspaceMissingError ( {
1229+ threadId : ThreadId . make ( "thread-1" ) ,
1230+ cwd : missingCwd ,
1231+ } ) ;
1232+ const harness = yield * Effect . promise ( ( ) =>
1233+ createHarness ( {
1234+ startSessionEffect : ( ) =>
1235+ Deferred . succeed ( attempted , undefined ) . pipe (
1236+ Effect . andThen ( Effect . fail ( missingWorkspace ) ) ,
1237+ ) ,
1238+ } ) ,
1239+ ) ;
1240+
1241+ yield * harness . engine . dispatch ( {
1242+ type : "thread.turn.start" ,
1243+ commandId : CommandId . make ( "cmd-turn-start-missing-workspace" ) ,
1244+ threadId : ThreadId . make ( "thread-1" ) ,
1245+ message : {
1246+ messageId : asMessageId ( "user-message-missing-workspace" ) ,
1247+ role : "user" ,
1248+ text : "continue" ,
1249+ attachments : [ ] ,
1250+ } ,
1251+ interactionMode : DEFAULT_PROVIDER_INTERACTION_MODE ,
1252+ runtimeMode : "approval-required" ,
1253+ createdAt : "2026-01-01T00:00:00.000Z" ,
1254+ } ) ;
1255+ yield * Deferred . await ( attempted ) ;
1256+ yield * Effect . promise ( ( ) => harness . drain ( ) ) ;
1257+
1258+ const thread = ( yield * Effect . promise ( ( ) => harness . readModel ( ) ) ) . threads . find (
1259+ ( entry ) => entry . id === ThreadId . make ( "thread-1" ) ,
1260+ ) ;
1261+ expect ( thread ?. session ) . toMatchObject ( {
1262+ status : "error" ,
1263+ activeTurnId : null ,
1264+ lastError : missingWorkspace . message ,
1265+ } ) ;
1266+ const failure = thread ?. activities . find (
1267+ ( activity ) => activity . kind === "provider.turn.start.failed" ,
1268+ ) ;
1269+ expect ( failure ?. payload ) . toMatchObject ( { detail : missingWorkspace . message } ) ;
1270+ expect ( harness . runtimeSessions ) . toEqual ( [ ] ) ;
1271+ expect ( harness . sendTurn ) . not . toHaveBeenCalled ( ) ;
1272+ expect ( yield * Effect . promise ( ( ) => harness . readPendingTurnStarts ( ) ) ) . toEqual ( [ ] ) ;
1273+ } ) ,
1274+ ) ;
1275+
12201276 effectIt . effect ( "settles a failed provider startup and allows a clean retry" , ( ) =>
12211277 Effect . gen ( function * ( ) {
12221278 let failStartup = true ;
0 commit comments