@@ -24,7 +24,7 @@ import {
2424 ThreadId ,
2525} from "@t3tools/contracts" ;
2626import { sanitizeNewRefName } from "@t3tools/shared/git" ;
27- import { resolveProjectSettings } from "@t3tools/shared/projectSettings" ;
27+ import { resolveNewThreadEnvMode , resolveProjectSettings } from "@t3tools/shared/projectSettings" ;
2828import { parseT3ProjectFile } from "@t3tools/shared/t3ProjectFile" ;
2929import * as Arr from "effect/Array" ;
3030import { pipe } from "effect/Function" ;
@@ -487,7 +487,8 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
487487 const attachments = selectedProjectDraft . attachments ;
488488 // Default mode until the user picks one explicitly — same resolution web
489489 // uses for new draft threads: per-project setting, then the repo's
490- // checked-in t3.json, then the server's configured default.
490+ // checked-in t3.json, then the server's configured default (which a new
491+ // project with no threads yet replaces with its checkout).
491492 const fileAccessSession = useEnvironmentQuery (
492493 selectedProject !== null && selectedProject . workspaceRoot !== ""
493494 ? environmentSession . sessionStateAtom ( selectedProject . environmentId )
@@ -535,8 +536,20 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
535536 // A thread without a project runs in a plain folder, so worktree mode
536537 // would leave it unsendable: it is always local and offers no choice.
537538 const canChooseWorkspace = ! isScratchDraft ;
539+ const selectedProjectHasThreads =
540+ selectedProject !== null &&
541+ threads . some (
542+ ( thread ) =>
543+ thread . environmentId === selectedProject . environmentId &&
544+ thread . projectId === selectedProject . id ,
545+ ) ;
538546 const defaultWorkspaceMode : WorkspaceMode = canChooseWorkspace
539- ? projectSettings . settings . defaultThreadEnvMode
547+ ? resolveNewThreadEnvMode ( {
548+ projectSettings,
549+ workspaceRoot : selectedProject ?. workspaceRoot ?? null ,
550+ newProjectsRoot : selectedEnvironmentServerConfig ?. newProjectsRoot ,
551+ projectHasThreads : selectedProjectHasThreads ,
552+ } )
540553 : "local" ;
541554 // While the file read is pending and nothing above it decided, the
542555 // resolved default is provisional. Nothing may write it into the draft
0 commit comments