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.

Run setup script after promoting local draft threads

Julius Marminge9e04bad0a504
diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx
index 437cad931..af023f741 100644
--- a/apps/web/src/components/ChatView.tsx
+++ b/apps/web/src/components/ChatView.tsx
@@ -940,10 +940,12 @@ export default function ChatView({ threadId }: ChatViewProps) {
worktreePath?: string | null;
preferNewTerminal?: boolean;
rememberAsLastInvoked?: boolean;
+ allowLocalDraftThread?: boolean;
},
) => {
const api = readNativeApi();
- if (!api || !activeThreadId || !activeProject || !activeThread || !isServerThread) return;
+ if (!api || !activeThreadId || !activeProject || !activeThread) return;
+ if (!isServerThread && !options?.allowLocalDraftThread) return;
if (options?.rememberAsLastInvoked !== false) {
setLastInvokedScriptByProjectId((current) => {
if (current[activeProject.id] === script.id) return current;
@@ -1787,14 +1789,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
worktreePath: result.worktree.path,
});
}
- const setupScript = setupProjectScript(activeProject.scripts);
- if (setupScript && isServerThread) {
- await runProjectScript(setupScript, {
- cwd: result.worktree.path,
- worktreePath: result.worktree.path,
- rememberAsLastInvoked: false,
- });
- }
}
const titleSeed =
@@ -1819,6 +1813,18 @@ export default function ChatView({ threadId }: ChatViewProps) {
createdServerThreadForLocalDraft = true;
}
+ const setupScript = baseBranchForWorktree
+ ? setupProjectScript(activeProject.scripts)
+ : null;
+ if (setupScript && (isServerThread || createdServerThreadForLocalDraft)) {
+ await runProjectScript(setupScript, {
+ worktreePath: nextThreadWorktreePath,
+ rememberAsLastInvoked: false,
+ allowLocalDraftThread: createdServerThreadForLocalDraft,
+ ...(nextThreadWorktreePath ? { cwd: nextThreadWorktreePath } : {}),
+ });
+ }
+
// Auto-title from first message
if (isFirstMessage && isServerThread) {
await api.orchestration.dispatchCommand({