History

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 8 months ago

Commit 822d8df1 parent 7c0b8be1 file · +15 −9Browse files

Unified · Split

apps/web/src/components/ChatView.tsx+15−9
@@ -940,10 +940,12 @@ export default function ChatView({ threadId }: ChatViewProps) { · 939 unmodified lines
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) { · 837 unmodified lines
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) { · 18 unmodified lines
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({

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t