@@ -35,6 +35,7 @@ import * as Fiber from "effect/Fiber";
3535import * as Layer from "effect/Layer" ;
3636import * as Queue from "effect/Queue" ;
3737import * as Ref from "effect/Ref" ;
38+ import * as Result from "effect/Result" ;
3839import * as Schema from "effect/Schema" ;
3940import * as Stream from "effect/Stream" ;
4041
@@ -3912,7 +3913,21 @@ describe("OrchestratorMcpService thread list", () => {
39123913 Layer . mock ( ProviderAdapterRegistry . ProviderAdapterRegistryV2 ) ( {
39133914 list : ( ) => Effect . succeed ( [ ] ) ,
39143915 } ) ,
3915- Layer . mock ( ProjectService . ProjectService ) ( { } ) ,
3916+ Layer . mock ( ProjectService . ProjectService ) ( {
3917+ getById : ( id ) =>
3918+ shells . some ( ( thread ) => thread . projectId === id )
3919+ ? Effect . succeedSome ( {
3920+ id,
3921+ title : id ,
3922+ workspaceRoot : `/projects/${ id } ` ,
3923+ defaultModelSelection : null ,
3924+ scripts : [ ] ,
3925+ createdAt : "2026-10-18T00:00:00.000Z" ,
3926+ updatedAt : "2026-10-18T00:00:00.000Z" ,
3927+ deletedAt : null ,
3928+ } )
3929+ : Effect . succeedNone ,
3930+ } ) ,
39163931 Layer . mock ( SecretRequests . SecretRequests ) ( { } ) ,
39173932 Layer . mock ( RemoteDelegation . RemoteDelegation ) ( { } ) ,
39183933 Layer . mock ( ScheduledTaskService . ScheduledTaskService ) ( { } ) ,
@@ -3939,6 +3954,20 @@ describe("OrchestratorMcpService thread list", () => {
39393954 } ) . pipe ( Effect . provide ( service ) ) ,
39403955 ) ;
39413956
3957+ it . effect ( "refuses a projectId that names no project" , ( ) =>
3958+ Effect . gen ( function * ( ) {
3959+ const mcp = yield * OrchestratorMcpService . OrchestratorMcpService ;
3960+ const listed = yield * mcp
3961+ . listThreads ( client , { projectId : ProjectId . make ( "project:missing" ) } )
3962+ . pipe ( Effect . result ) ;
3963+ if ( Result . isSuccess ( listed ) ) {
3964+ assert . fail ( `listed threads for a missing project: ${ JSON . stringify ( listed . success ) } ` ) ;
3965+ }
3966+ assert . equal ( listed . failure . code , "invalid_request" ) ;
3967+ assert . include ( listed . failure . message , "not found" ) ;
3968+ } ) . pipe ( Effect . provide ( service ) ) ,
3969+ ) ;
3970+
39423971 it . effect ( "counts a thread holding awaited background work as live in the status filter" , ( ) =>
39433972 Effect . gen ( function * ( ) {
39443973 const mcp = yield * OrchestratorMcpService . OrchestratorMcpService ;
0 commit comments