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