Bootstrap default thread on server welcome and simplify dev runner behavior #101
Mergedjuliusmarmingemerged 6 commits into
main fromcodething/ad120d1fmerged by juliusmarminge View on GitHub- apps/server/src/wsServer.ts line 389OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -353,2 +369,21 @@369+ }370+371+ const existingThread = snapshot.threads.find(372+ (thread) => thread.projectId === bootstrapProjectId && thread.deletedAt === null,373+ );374+ if (!existingThread) {375+ const createdAt = new Date().toISOString();376+ const threadId = ThreadId.makeUnsafe(crypto.randomUUID());377+ yield* orchestrationEngine.dispatch({378+ type: "thread.create",379+ commandId: CommandId.makeUnsafe(crypto.randomUUID()),380+ threadId,381+ projectId: bootstrapProjectId,382+ title: "New thread",383+ model: bootstrapProjectDefaultModel,384+ branch: null,385+ worktreePath: null,353386 createdAt,354387 });388+ welcomeBootstrapProjectId = bootstrapProjectId;389+ welcomeBootstrapThreadId = threadId;apps/web/src/routes/__root.tsx line 252OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -221,4 +249,4 @@221249 unsubWelcome();222250 unsubServerConfigUpdated();223251 };224- }, [dispatch, queryClient]);252+ }, [dispatch, navigate, pathname, queryClient]);
- apps/server/src/wsServer.ts lines 371 to 390OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -353,3 +370,21 @@370+371+ const existingThread = snapshot.threads.find(372+ (thread) => thread.projectId === bootstrapProjectId && thread.deletedAt === null,373+ );374+ if (!existingThread) {375+ const createdAt = new Date().toISOString();376+ const threadId = ThreadId.makeUnsafe(crypto.randomUUID());377+ yield* orchestrationEngine.dispatch({378+ type: "thread.create",379+ commandId: CommandId.makeUnsafe(crypto.randomUUID()),380+ threadId,381+ projectId: bootstrapProjectId,382+ title: "New thread",383+ model: bootstrapProjectDefaultModel,384+ branch: null,385+ worktreePath: null,353386 createdAt,354387 });388+ welcomeBootstrapProjectId = bootstrapProjectId;389+ welcomeBootstrapThreadId = threadId;355390 }apps/web/src/routes/__root.tsx lines 194 to 223Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -175 +183,21 @@183+ return;184+ }185+ dispatch({186+ type: "SET_PROJECT_EXPANDED",187+ projectId: payload.bootstrapProjectId,188+ expanded: true,189+ });190+ if (pathname !== "/") {191+ return;192+ }193+ if (handledBootstrapThreadIdRef.current === payload.bootstrapThreadId) {194+ return;195+ }196+ handledBootstrapThreadIdRef.current = payload.bootstrapThreadId;197+ await navigate({198+ to: "/$threadId",199+ params: { threadId: payload.bootstrapThreadId },200+ replace: true,201+ });202+ })().catch(() => undefined);175203 });
- @@ -174,0 +184,21 @@184+ if (!payload.bootstrapProjectId || !payload.bootstrapThreadId) {185+ return;186+ }187+ dispatch({188+ type: "SET_PROJECT_EXPANDED",189+ projectId: payload.bootstrapProjectId,190+ expanded: true,191+ });192+ if (pathnameRef.current !== "/") {193+ return;194+ }195+ if (handledBootstrapThreadIdRef.current === payload.bootstrapThreadId) {196+ return;197+ }198+ handledBootstrapThreadIdRef.current = payload.bootstrapThreadId;199+ await navigate({200+ to: "/$threadId",201+ params: { threadId: payload.bootstrapThreadId },202+ replace: true,203+ });204+ })().catch(() => undefined);
juliusmarminge merged thisa1f208f
juliusmarminge closed this
Sign in to join this conversation.



No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between ae4e353322be0a178c11a469b53769bf5ae4b761 and 8effcf380afe007abf39444db659b777456aae8d.
📒 Files selected for processing (6)
apps/server/src/wsServer.test.tsapps/server/src/wsServer.tsapps/web/src/routes/__root.tsxapps/web/src/store.tsapps/web/src/wsNativeApi.test.tspackages/contracts/src/ws.ts🚧 Files skipped from review as they are similar to previous changes (1)
Walkthrough#
Adds server auto-bootstrap that finds or creates a project and thread on connect, includes their IDs in
serverWelcome, and updates the web client to expand the project and navigate to the bootstrapped thread; tests and contract schema updated accordingly.Changes#
apps/server/src/wsServer.tswelcomeBootstrapProjectId/welcomeBootstrapThreadId, and includes optionalbootstrapProjectId/bootstrapThreadIdinserverWelcomepushes.apps/server/src/wsServer.test.tsmakeSqlitePersistenceLivealongside in-memory persistence; snapshots and assertions extended to expect bootstrap IDs inwelcome.data; new test added for reuse of bootstrap IDs.apps/web/src/routes/__root.tsxonServerWelcomemade async: awaits snapshot sync, dispatchesSET_PROJECT_EXPANDEDfor bootstrap project, and navigates to the bootstrap thread when at root; adds refs to avoid duplicate handling and tracks pathname.apps/web/src/store.tsSET_PROJECT_EXPANDEDaction variant and reducer case to set a project'sexpandedflag byprojectId.apps/web/src/wsNativeApi.test.tsexpect.objectContainingforserverWelcomepayloads and adds a test verifying preservation ofbootstrapProjectId/bootstrapThreadId.packages/contracts/src/ws.tsWsWelcomePayloadschema to include optionalbootstrapProjectIdandbootstrapThreadId(importsProjectId,ThreadId).Sequence Diagram(s)#
Estimated code review effort#
🎯 4 (Complex) | ⏱️ ~60 minutes
🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (2 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands and usage tips.