The best way to control Claude Code, Codex and more from any computer or phone
fix(mobile): keep the source worktree when starting a thread on a branch (#12623)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Dara Adedeji committed
Sep 21, 2026 at 00:09 UTC
a6cb1dd2054c96c5be41980e63594ea51554a552
1 file changed
+9
apps/mobile/src/features/threads/new-task-flow-provider.tsx
+9
@@ -873,12 +873,20 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
873
874
useEffect(() => {
875
if (
876
+ !selectedProjectDraftKey ||
877
!defaultWorkspaceModeSettled ||
878
workspaceMode !== "worktree" ||
879
selectedBranchName !== null
880
) {
881
return;
882
}
883
+ // The draft screen writes a thread's branch and worktree into the draft in
884
+ // the same commit this effect runs, so the rendered selection above can be
885
+ // stale. Re-read the draft before replacing it.
886
+ const live = getComposerDraftSnapshot(selectedProjectDraftKey).workspaceSelection;
887
+ if (live && (live.mode !== "worktree" || live.branch !== null)) {
888
+ return;
889
+ }
890
// The default may only exist as origin/<default> (isRemote), which
891
// availableBranches filters out — search the unfiltered refs for it.
892
const preferredBranch =
@@ -894,6 +902,7 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
902
defaultWorkspaceModeSettled,
903
selectBranch,
904
selectedBranchName,
905
+ selectedProjectDraftKey,
906
workspaceMode,
907
]);
908