@@ -704,6 +704,36 @@ function toPullRequestHeadRemoteInfo(pr: {
704704 } ;
705705}
706706
707+ export const readProjectSettings = Effect . fnUntraced ( function * ( input : {
708+ readonly cwd : string ;
709+ readonly threadId ?: ThreadId | undefined ;
710+ readonly projectId ?: ProjectId | undefined ;
711+ } ) {
712+ const serverSettingsService = yield * ServerSettings . ServerSettingsService ;
713+ const settings = yield * serverSettingsService . getSettings ;
714+ if ( ! hasProjectSettingsOverrides ( settings ) ) {
715+ return { settings, projectId : input . projectId ?? null } ;
716+ }
717+ // Source-control helpers also run without orchestration in the CLI and focused tests.
718+ const threads = yield * Effect . serviceOption ( ProjectionStore . ProjectionStoreV2 ) ;
719+ const projects = yield * Effect . serviceOption ( ProjectStore . ProjectStoreV2 ) ;
720+ let projectId = input . projectId ?? null ;
721+ if ( input . projectId === undefined ) {
722+ if ( input . threadId !== undefined && Option . isSome ( threads ) ) {
723+ projectId = yield * threads . value . getThreadShell ( input . threadId ) . pipe (
724+ Effect . map ( ( thread ) => thread ?. projectId ?? null ) ,
725+ Effect . orElseSucceed ( ( ) => null ) ,
726+ ) ;
727+ } else if ( input . threadId === undefined && Option . isSome ( projects ) ) {
728+ projectId = yield * projects . value . findActiveByWorkspaceRoot ( input . cwd ) . pipe (
729+ Effect . map ( ( project ) => Option . getOrNull ( project ) ?. projectId ?? null ) ,
730+ Effect . orElseSucceed ( ( ) => null ) ,
731+ ) ;
732+ }
733+ }
734+ return { settings : resolveProjectSettings ( settings , projectId ) . settings , projectId } ;
735+ } ) ;
736+
707737export const make = Effect . gen ( function * ( ) {
708738 const gitCore = yield * GitVcsDriver . GitVcsDriver ;
709739 const sourceControlProviders = yield * SourceControlProviderRegistry . SourceControlProviderRegistry ;
@@ -719,24 +749,15 @@ export const make = Effect.gen(function* () {
719749 const serverSettingsService = yield * ServerSettings . ServerSettingsService ;
720750 const threads = yield * ProjectionStore . ProjectionStoreV2 ;
721751 const projects = yield * ProjectStore . ProjectStoreV2 ;
722- const projectSettingsFor = Effect . fnUntraced ( function * ( input : {
752+ const projectSettingsFor = ( input : {
723753 readonly cwd : string ;
724754 readonly threadId ?: ThreadId | undefined ;
725- } ) {
726- const settings = yield * serverSettingsService . getSettings ;
727- if ( ! hasProjectSettingsOverrides ( settings ) )
728- return { settings, projectId : null as ProjectId | null } ;
729- const projectId : ProjectId | null = yield * input . threadId !== undefined
730- ? threads . getThreadShell ( input . threadId ) . pipe (
731- Effect . map ( ( thread ) => thread ?. projectId ?? null ) ,
732- Effect . orElseSucceed ( ( ) => null ) ,
733- )
734- : projects . findActiveByWorkspaceRoot ( input . cwd ) . pipe (
735- Effect . map ( ( project ) => Option . getOrNull ( project ) ?. projectId ?? null ) ,
736- Effect . orElseSucceed ( ( ) => null ) ,
737- ) ;
738- return { settings : resolveProjectSettings ( settings , projectId ) . settings , projectId } ;
739- } ) ;
755+ } ) =>
756+ readProjectSettings ( { cwd : input . cwd , threadId : input . threadId } ) . pipe (
757+ Effect . provideService ( ServerSettings . ServerSettingsService , serverSettingsService ) ,
758+ Effect . provideService ( ProjectionStore . ProjectionStoreV2 , threads ) ,
759+ Effect . provideService ( ProjectStore . ProjectStoreV2 , projects ) ,
760+ ) ;
740761 const readWorktreesDirectory = serverSettingsService . getSettings . pipe (
741762 Effect . map ( ( settings ) => settings . worktreesDirectory ) ,
742763 Effect . orElseSucceed ( ( ) => "" ) ,
0 commit comments