Skip to content

Commit b003595

Browse files
committed
Fix bootstrap IDs missing on reuse and pathname-driven effect re-subscription
- wsServer.ts: Assign welcomeBootstrapProjectId/ThreadId in the else branch when an existing thread is found, so the welcome payload always includes bootstrap IDs when autoBootstrapProjectFromCwd is enabled. - __root.tsx: Move pathname into a ref so route changes don't tear down and re-create WebSocket subscriptions, preventing latestSequence reset and redundant snapshot syncs on every navigation.
1 parent 861a786 commit b003595

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

apps/server/src/wsServer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,9 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return<
387387
});
388388
welcomeBootstrapProjectId = bootstrapProjectId;
389389
welcomeBootstrapThreadId = threadId;
390+
} else {
391+
welcomeBootstrapProjectId = bootstrapProjectId;
392+
welcomeBootstrapThreadId = existingThread.id;
390393
}
391394
}
392395

apps/web/src/routes/__root.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ function EventRouter() {
125125
const queryClient = useQueryClient();
126126
const navigate = useNavigate();
127127
const pathname = useRouterState({ select: (state) => state.location.pathname });
128+
const pathnameRef = useRef(pathname);
129+
pathnameRef.current = pathname;
128130
const lastConfigIssuesSignatureRef = useRef<string | null>(null);
129131
const handledBootstrapThreadIdRef = useRef<string | null>(null);
130132

@@ -187,7 +189,7 @@ function EventRouter() {
187189
projectId: payload.bootstrapProjectId,
188190
expanded: true,
189191
});
190-
if (pathname !== "/") {
192+
if (pathnameRef.current !== "/") {
191193
return;
192194
}
193195
if (handledBootstrapThreadIdRef.current === payload.bootstrapThreadId) {
@@ -249,7 +251,7 @@ function EventRouter() {
249251
unsubWelcome();
250252
unsubServerConfigUpdated();
251253
};
252-
}, [dispatch, navigate, pathname, queryClient]);
254+
}, [dispatch, navigate, queryClient]);
253255

254256
return null;
255257
}

0 commit comments

Comments
 (0)