authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-02-26 18:29:10-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-02-26 20:51:29-08:00
log2da82900409fe231fb913df2c61b580f1a453924
tree91a4b2cfaf701e6b1075ebb4e2d30f76cf0e39e9
parent4d6e8e1ca5a7c81f5c56b05fa20b80254ad423d9

Require base branch before first send in worktree mode

- show an explicit error when New worktree mode has no base branch selected - sync thread branch/worktree path immediately after creation - run setup script in the new worktree terminal before continuing Co-authored-by: codex <codex@users.noreply.github.com>

1 files changed, 23 insertions(+), 1 deletions(-)

apps/web/src/components/ChatView.tsx+23-1
......@@ -1424,6 +1424,19 @@ export default function ChatView({ threadId }: ChatViewProps) {
14241424 },
14251425 ]);
14261426
1427 // In worktree mode, require an explicit base branch so we don't silently
1428 // fall back to local execution when branch selection is missing.
1429 const shouldCreateWorktree =
1430 activeThread.messages.length === 0 && envMode === "worktree" && !activeThread.worktreePath;
1431 if (shouldCreateWorktree && !activeThread.branch) {
1432 dispatch({
1433 type: "SET_ERROR",
1434 threadId: activeThread.id,
1435 error: "Select a base branch before sending in New worktree mode.",
1436 });
1437 return;
1438 }
1439
14271440 setThreadError(threadIdForSend, null);
14281441 promptRef.current = "";
14291442 setPrompt("");
......@@ -1449,11 +1462,20 @@ export default function ChatView({ threadId }: ChatViewProps) {
14491462 branch: result.worktree.branch,
14501463 worktreePath: result.worktree.path,
14511464 });
1465 // Keep local thread state in sync immediately so terminal drawer opens
1466 // with the worktree cwd/env instead of briefly using the project root.
1467 dispatch({
1468 type: "SET_THREAD_BRANCH",
1469 threadId: activeThread.id,
1470 branch: result.worktree.branch,
1471 worktreePath: result.worktree.path,
1472 });
14521473 const setupScript = setupProjectScript(activeProject.scripts);
14531474 if (setupScript) {
1454 void runProjectScript(setupScript, {
1475 await runProjectScript(setupScript, {
14551476 cwd: result.worktree.path,
14561477 worktreePath: result.worktree.path,
1478 preferNewTerminal: true,
14571479 rememberAsLastInvoked: false,
14581480 });
14591481 }