@@ -20,10 +20,6 @@ import {
2020} from "@t3tools/contracts" ;
2121import { resolveProjectSettings } from "@t3tools/shared/projectSettings" ;
2222import { parseT3ProjectFile } from "@t3tools/shared/t3ProjectFile" ;
23- import {
24- isDefaultThreadEnvModeSettled ,
25- resolveDefaultThreadEnvMode ,
26- } from "@t3tools/shared/threadEnvMode" ;
2723import * as Arr from "effect/Array" ;
2824import { pipe } from "effect/Function" ;
2925
@@ -431,38 +427,35 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
431427 : null ,
432428 ) ;
433429 const t3ProjectFileData = t3ProjectFileQuery . data as ProjectReadFileResult | null ;
434- const t3ProjectFileDefaultMode = useMemo ( ( ) => {
435- if ( t3ProjectFileData === null || t3ProjectFileData . truncated ) return null ;
436- return parseT3ProjectFile ( t3ProjectFileData . contents ) ?. defaultThreadEnvMode ?? null ;
437- } , [ t3ProjectFileData ] ) ;
438- // Environment settings with the project's overrides applied; the
439- // aggregate's own legacy fields still count until the server folds them.
430+ const t3ProjectFile = useMemo (
431+ ( ) =>
432+ t3ProjectFileData === null || t3ProjectFileData . truncated
433+ ? null
434+ : parseT3ProjectFile ( t3ProjectFileData . contents ) ,
435+ [ t3ProjectFileData ] ,
436+ ) ;
437+ // Environment settings with the project's overrides and its t3.json
438+ // applied; the aggregate's own legacy fields still count until the server
439+ // folds them.
440440 const projectSettings = useMemo (
441441 ( ) =>
442442 resolveProjectSettings (
443443 selectedEnvironmentServerConfig ?. settings ?? DEFAULT_SERVER_SETTINGS ,
444444 selectedProject ?. id ?? null ,
445445 selectedProject ,
446+ t3ProjectFile ,
446447 ) ,
447- [ selectedEnvironmentServerConfig ?. settings , selectedProject ] ,
448+ [ selectedEnvironmentServerConfig ?. settings , selectedProject , t3ProjectFile ] ,
448449 ) ;
449- const projectThreadEnvMode =
450- projectSettings . sources . defaultThreadEnvMode === "project"
451- ? projectSettings . settings . defaultThreadEnvMode
452- : undefined ;
453- const defaultWorkspaceMode : WorkspaceMode = resolveDefaultThreadEnvMode ( {
454- projectSetting : projectThreadEnvMode ,
455- projectFile : t3ProjectFileDefaultMode ,
456- globalDefault : projectSettings . settings . defaultThreadEnvMode ,
457- } ) ;
458- // While unsettled the resolved default is provisional. Nothing may write
459- // it into the draft during that window (the auto-branch effect does), or
460- // the frozen interim value beats the t3.json default once it loads.
461- const defaultWorkspaceModeSettled = isDefaultThreadEnvModeSettled ( {
462- explicitMode : selectedProjectDraft . workspaceSelection ?. mode ,
463- projectSetting : projectThreadEnvMode ,
464- projectFilePending : t3ProjectFileQuery . isPending ,
465- } ) ;
450+ const defaultWorkspaceMode : WorkspaceMode = projectSettings . settings . defaultThreadEnvMode ;
451+ // While the file read is pending and nothing above it decided, the
452+ // resolved default is provisional. Nothing may write it into the draft
453+ // during that window (the auto-branch effect does), or the frozen interim
454+ // value beats the t3.json default once it loads.
455+ const defaultWorkspaceModeSettled =
456+ selectedProjectDraft . workspaceSelection ?. mode !== undefined ||
457+ projectSettings . sources . defaultThreadEnvMode !== "environment" ||
458+ ! t3ProjectFileQuery . isPending ;
466459 const workspaceMode = selectedProjectDraft . workspaceSelection ?. mode ?? defaultWorkspaceMode ;
467460 const selectedBranchName = selectedProjectDraft . workspaceSelection ?. branch ?? null ;
468461 const selectedWorktreePath = selectedProjectDraft . workspaceSelection ?. worktreePath ?? null ;
0 commit comments