Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Require base branch before first send in worktree mode

Julius Marminge2da82900409f
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 95ab08d6c..ea9e11ed2 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -1424,6 +1424,19 @@ export default function ChatView({ threadId }: ChatViewProps) {
},
]);
+ // In worktree mode, require an explicit base branch so we don't silently
+ // fall back to local execution when branch selection is missing.
+ const shouldCreateWorktree =
+ activeThread.messages.length === 0 && envMode === "worktree" && !activeThread.worktreePath;
+ if (shouldCreateWorktree && !activeThread.branch) {
+ dispatch({
+ type: "SET_ERROR",
+ threadId: activeThread.id,
+ error: "Select a base branch before sending in New worktree mode.",
+ });
+ return;
+ }
+
setThreadError(threadIdForSend, null);
promptRef.current = "";
setPrompt("");
@@ -1449,11 +1462,20 @@ export default function ChatView({ threadId }: ChatViewProps) {
branch: result.worktree.branch,
worktreePath: result.worktree.path,
});
+ // Keep local thread state in sync immediately so terminal drawer opens
+ // with the worktree cwd/env instead of briefly using the project root.
+ dispatch({
+ type: "SET_THREAD_BRANCH",
+ threadId: activeThread.id,
+ branch: result.worktree.branch,
+ worktreePath: result.worktree.path,
+ });
const setupScript = setupProjectScript(activeProject.scripts);
if (setupScript) {
- void runProjectScript(setupScript, {
+ await runProjectScript(setupScript, {
cwd: result.worktree.path,
worktreePath: result.worktree.path,
+ preferNewTerminal: true,
rememberAsLastInvoked: false,
});
}