| ... | ... | @@ -873,12 +873,20 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) { |
| 873 | 873 | |
| 874 | 874 | useEffect(() => { |
| 875 | 875 | if ( |
| 876 | !selectedProjectDraftKey || |
| 876 | 877 | !defaultWorkspaceModeSettled || |
| 877 | 878 | workspaceMode !== "worktree" || |
| 878 | 879 | selectedBranchName !== null |
| 879 | 880 | ) { |
| 880 | 881 | return; |
| 881 | 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 | } |
| 882 | 890 | // The default may only exist as origin/<default> (isRemote), which |
| 883 | 891 | // availableBranches filters out — search the unfiltered refs for it. |
| 884 | 892 | const preferredBranch = |
| ... | ... | @@ -894,6 +902,7 @@ export function NewTaskFlowProvider(props: React.PropsWithChildren) { |
| 894 | 902 | defaultWorkspaceModeSettled, |
| 895 | 903 | selectBranch, |
| 896 | 904 | selectedBranchName, |
| 905 | selectedProjectDraftKey, |
| 897 | 906 | workspaceMode, |
| 898 | 907 | ]); |
| 899 | 908 | |