Skip to content

Commit b28aa51

Browse files
committed
Fix: scope terminal event handler to setup terminals only
The onEvent handler unconditionally called ensureTerminal and setTerminalLaunchContext for every started/restarted terminal event, not just server-initiated setup terminals. This caused the drawer to force-open for all terminal events and set worktreePath: null for non-setup terminals, creating stale launch context entries that the ChatView cleanup effect could not clear. Guard the handler to only fire for setup terminals (IDs starting with 'setup-'), and since we now know it's a setup terminal, always use event.snapshot.cwd as the worktreePath instead of conditionally returning null.
1 parent 033be30 commit b28aa51

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

apps/web/src/routes/__root.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,12 +223,15 @@ function EventRouter() {
223223
domainEventFlushThrottler.maybeExecute();
224224
});
225225
const unsubTerminalEvent = api.terminal.onEvent((event) => {
226-
if (event.type === "started" || event.type === "restarted") {
226+
if (
227+
(event.type === "started" || event.type === "restarted") &&
228+
event.terminalId.startsWith("setup-")
229+
) {
227230
const threadId = ThreadId.makeUnsafe(event.threadId);
228231
ensureTerminal(threadId, event.terminalId, { open: true, active: true });
229232
setTerminalLaunchContext(threadId, {
230233
cwd: event.snapshot.cwd,
231-
worktreePath: event.terminalId.startsWith("setup-") ? event.snapshot.cwd : null,
234+
worktreePath: event.snapshot.cwd,
232235
});
233236
}
234237
const hasRunningSubprocess = terminalRunningSubprocessFromEvent(event);

0 commit comments

Comments
 (0)