TypeScript
fix(mobile): keep the source worktree when starting a thread on a branch (#12623)
Dara Adedejia6cb1dd2054c
diff --git a/apps/mobile/src/features/threads/new-task-flow-provider.tsx b/apps/mobile/src/features/threads/new-task-flow-provider.tsxindex 5c74e52cfac..4a912f171a5 100644--- a/apps/mobile/src/features/threads/new-task-flow-provider.tsx+++ b/apps/mobile/src/features/threads/new-task-flow-provider.tsx@@ -873,12 +873,20 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {useEffect(() => {if (+ !selectedProjectDraftKey ||!defaultWorkspaceModeSettled ||workspaceMode !== "worktree" ||selectedBranchName !== null) {return;}+ // The draft screen writes a thread's branch and worktree into the draft in+ // the same commit this effect runs, so the rendered selection above can be+ // stale. Re-read the draft before replacing it.+ const live = getComposerDraftSnapshot(selectedProjectDraftKey).workspaceSelection;+ if (live && (live.mode !== "worktree" || live.branch !== null)) {+ return;+ }// The default may only exist as origin/<default> (isRemote), which// availableBranches filters out — search the unfiltered refs for it.const preferredBranch =@@ -894,6 +902,7 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {defaultWorkspaceModeSettled,selectBranch,selectedBranchName,+ selectedProjectDraftKey,workspaceMode,]);