authorgravatar for julius0216@outlook.comJulius Marminge <julius0216@outlook.com> 2026-03-01 20:00:58-08:00
committergravatar for jmarminge@gmail.comJulius Marminge <jmarminge@gmail.com> 2026-03-01 22:36:35-08:00
log9e04bad0a504dafbf19182fb0ec361c55018c780
treeb9c01db9a86696e5d073e9c78af91deae18a3d04
parenta574d9c936adcf0a8ccc9b10d8f65e0127d13adc

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

1 files changed, 15 insertions(+), 9 deletions(-)

apps/web/src/components/ChatView.tsx+15-9
......@@ -940,10 +940,12 @@ export default function ChatView({ threadId }: ChatViewProps) {
940940 worktreePath?: string | null;
941941 preferNewTerminal?: boolean;
942942 rememberAsLastInvoked?: boolean;
943 allowLocalDraftThread?: boolean;
943944 },
944945 ) => {
945946 const api = readNativeApi();
946 if (!api || !activeThreadId || !activeProject || !activeThread || !isServerThread) return;
947 if (!api || !activeThreadId || !activeProject || !activeThread) return;
948 if (!isServerThread && !options?.allowLocalDraftThread) return;
947949 if (options?.rememberAsLastInvoked !== false) {
948950 setLastInvokedScriptByProjectId((current) => {
949951 if (current[activeProject.id] === script.id) return current;
......@@ -1787,14 +1789,6 @@ export default function ChatView({ threadId }: ChatViewProps) {
17871789 worktreePath: result.worktree.path,
17881790 });
17891791 }
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 }
17981792 }
17991793
18001794 const titleSeed =
......@@ -1819,6 +1813,18 @@ export default function ChatView({ threadId }: ChatViewProps) {
18191813 createdServerThreadForLocalDraft = true;
18201814 }
18211815
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
18221828 // Auto-title from first message
18231829 if (isFirstMessage && isServerThread) {
18241830 await api.orchestration.dispatchCommand({