@devries-cameron20 / t3code Mirror · read-only / commits / 9e04bad0a5
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 25, 11:00 UTC

Run setup script after promoting local draft threads

- allow `runProjectScript` for local draft threads when explicitly enabled - move setup script execution to run after server thread creation - gate setup script on worktree/base-branch availability and pass resolved worktree cwd

Julius Marminge committed Mar 1, 2026 at 20:00 UTC 9e04bad0a504dafbf19182fb0ec361c55018c780
1 file changed +15 -9
apps/web/src/components/ChatView.tsx
+15 -9
@@ -940,10 +940,12 @@ export default function ChatView({ threadId }: ChatViewProps) {
940 worktreePath?: string | null;
941 preferNewTerminal?: boolean;
942 rememberAsLastInvoked?: boolean;
943 + allowLocalDraftThread?: boolean;
944 },
945 ) => {
946 const api = readNativeApi();
946 - if (!api || !activeThreadId || !activeProject || !activeThread || !isServerThread) return;
947 + if (!api || !activeThreadId || !activeProject || !activeThread) return;
948 + if (!isServerThread && !options?.allowLocalDraftThread) return;
949 if (options?.rememberAsLastInvoked !== false) {
950 setLastInvokedScriptByProjectId((current) => {
951 if (current[activeProject.id] === script.id) return current;
@@ -1787,14 +1789,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
1789 worktreePath: result.worktree.path,
1790 });
1791 }
1790 - const setupScript = setupProjectScript(activeProject.scripts);
1791 - if (setupScript && isServerThread) {
1792 - await runProjectScript(setupScript, {
1793 - cwd: result.worktree.path,
1794 - worktreePath: result.worktree.path,
1795 - rememberAsLastInvoked: false,
1796 - });
1797 - }
1792 }
1793
1794 const titleSeed =
@@ -1819,6 +1813,18 @@ export default function ChatView({ threadId }: ChatViewProps) {
1813 createdServerThreadForLocalDraft = true;
1814 }
1815
1816 + const setupScript = baseBranchForWorktree
1817 + ? setupProjectScript(activeProject.scripts)
1818 + : null;
1819 + if (setupScript && (isServerThread || createdServerThreadForLocalDraft)) {
1820 + await runProjectScript(setupScript, {
1821 + worktreePath: nextThreadWorktreePath,
1822 + rememberAsLastInvoked: false,
1823 + allowLocalDraftThread: createdServerThreadForLocalDraft,
1824 + ...(nextThreadWorktreePath ? { cwd: nextThreadWorktreePath } : {}),
1825 + });
1826 + }
1827 +
1828 // Auto-title from first message
1829 if (isFirstMessage && isServerThread) {
1830 await api.orchestration.dispatchCommand({