From e6abe81eda31f70e64f7a55eebb1e21d164a3573 Mon Sep 17 00:00:00 2001 From: none23 Date: Sun, 30 Aug 2026 21:39:16 +0400 Subject: [PATCH] fix(mobile): default non-git projects to the current checkout The new-task composer let a worktree default (from project settings, t3.json, or the server default) apply to projects that are not git repos, so drafts and queued tasks could carry a worktree mode and branch that cannot exist there. Resolve the workspace selection through one helper that forces local/no-branch/no-worktree whenever the project is not a repo, apply it in the flow provider (live selection and queued-task drain) and the draft screen, and hide the workspace/branch controls for non-git projects. Repo capability comes from the unfiltered branches query, which still answers offline; until it loads, the requested mode is preserved rather than silently rewritten. --- .../features/threads/NewTaskDraftScreen.tsx | 25 ++++++++---- .../threads/new-task-context-presentation.ts | 11 ++++++ .../threads/new-task-flow-provider.tsx | 39 +++++++++++++++---- 3 files changed, 59 insertions(+), 16 deletions(-) diff --git a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx index 8f8cf485f6f8..e44a7d229ec1 100644 --- a/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx +++ b/apps/mobile/src/features/threads/NewTaskDraftScreen.tsx @@ -91,6 +91,7 @@ import { resolveProjectThreadCreationBranch } from "./projectThreadCreationValid import { useCreateProjectThread } from "./use-project-actions"; import { resolveDraftProjectSelection } from "./new-task-project-selection"; import { + applyNonGitWorkspaceFallback, resolveNewTaskBranchLabel, resolveNewTaskWorkspaceLabel, } from "./new-task-context-presentation"; @@ -866,10 +867,18 @@ export function NewTaskDraftScreen(props: { selectedEnvironmentServerConfig, draft.modelSelection ?? null, ) ?? flow.selectedModel; - const workspaceMode = draft.workspaceSelection?.mode ?? flow.workspaceMode; - const selectedBranchName = draft.workspaceSelection?.branch ?? flow.selectedBranchName; - const selectedWorktreePath = - draft.workspaceSelection?.worktreePath ?? flow.selectedWorktreePath; + const workspaceSelection = applyNonGitWorkspaceFallback({ + selection: draft.workspaceSelection, + fallback: { + mode: flow.workspaceMode, + branch: flow.selectedBranchName, + worktreePath: flow.selectedWorktreePath, + }, + isGitRepo: flow.isGitRepo, + }); + const workspaceMode = workspaceSelection.mode; + const selectedBranchName = workspaceSelection.branch; + const selectedWorktreePath = workspaceSelection.worktreePath; const startFromOrigin = draft.workspaceSelection?.startFromOrigin ?? flow.startFromOrigin; const runtimeMode = draft.runtimeMode ?? flow.runtimeMode; const interactionMode = flow.planModeEnabled @@ -1158,8 +1167,8 @@ export function NewTaskDraftScreen(props: { ); - const workspaceControls = ( - + const workspaceControls = flow.isGitRepo ? ( + {flow.submitting && environmentConnected && flow.workspaceMode === "worktree" ? ( )} - ); + ) : null; const composerDock = ( @@ -1219,7 +1228,7 @@ export function NewTaskDraftScreen(props: { /> ) : null} - {workspaceControls} + {workspaceControls}