Skip to content

Commit a6cb1dd

Browse files
SunkenInTimedevin-ai-integration[bot]juliusmarmingeclaude
authored
fix(mobile): keep the source worktree when starting a thread on a branch (pingdotgg#12623)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Julius Marminge <[email protected]> Co-authored-by: Claude Fable 5 <[email protected]>
1 parent a4bc7de commit a6cb1dd

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎apps/mobile/src/features/threads/new-task-flow-provider.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -873,12 +873,20 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
873873

874874
useEffect(() => {
875875
if (
876+
!selectedProjectDraftKey ||
876877
!defaultWorkspaceModeSettled ||
877878
workspaceMode !== "worktree" ||
878879
selectedBranchName !== null
879880
) {
880881
return;
881882
}
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+
}
882890
// The default may only exist as origin/<default> (isRemote), which
883891
// availableBranches filters out — search the unfiltered refs for it.
884892
const preferredBranch =
@@ -894,6 +902,7 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) {
894902
defaultWorkspaceModeSettled,
895903
selectBranch,
896904
selectedBranchName,
905+
selectedProjectDraftKey,
897906
workspaceMode,
898907
]);
899908

0 commit comments

Comments
 (0)