The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 16:00 UTC
Recover bootstrap thread from snapshot when IDs are missing
- Fetch orchestration snapshot when bootstrap project/thread IDs are absent - Resolve project by current workspace and choose latest non-deleted thread - Continue auto-navigation and expansion using resolved fallback IDs
Julius Marminge committed
Feb 26, 2026 at 20:43 UTC
0b299246488b90cea223dd86ce516116270b1215
1 file changed
+31
-5
apps/web/src/routes/__root.tsx
+31
-5
@@ -198,26 +198,52 @@ function EventRouter() {
198
return;
199
}
200
201
- if (!payload.bootstrapProjectId || !payload.bootstrapThreadId) {
201
+ const fallbackSnapshot =
202
+ payload.bootstrapProjectId && payload.bootstrapThreadId
203
+ ? null
204
+ : await api.orchestration.getSnapshot().catch(() => null);
205
+ if (disposed) {
206
+ return;
207
+ }
208
+
209
+ const bootstrapProjectId =
210
+ payload.bootstrapProjectId ??
211
+ fallbackSnapshot?.projects.find(
212
+ (project) => project.workspaceRoot === payload.cwd && project.deletedAt === null,
213
+ )?.id;
214
+ if (!bootstrapProjectId) {
215
return;
216
}
217
dispatch({
218
type: "SET_PROJECT_EXPANDED",
206
- projectId: payload.bootstrapProjectId,
219
+ projectId: bootstrapProjectId,
220
expanded: true,
221
});
222
+
223
+ const bootstrapThreadId =
224
+ payload.bootstrapThreadId ??
225
+ fallbackSnapshot?.threads
226
+ .filter((thread) => thread.projectId === bootstrapProjectId && thread.deletedAt === null)
227
+ .toSorted((a, b) => {
228
+ const byDate = new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
229
+ if (byDate !== 0) return byDate;
230
+ return b.id.localeCompare(a.id);
231
+ })[0]?.id;
232
+ if (!bootstrapThreadId) {
233
+ return;
234
+ }
235
if (pathnameRef.current !== "/") {
236
return;
237
}
212
- if (handledBootstrapThreadIdRef.current === payload.bootstrapThreadId) {
238
+ if (handledBootstrapThreadIdRef.current === bootstrapThreadId) {
239
return;
240
}
241
await navigate({
242
to: "/$threadId",
217
- params: { threadId: payload.bootstrapThreadId },
243
+ params: { threadId: bootstrapThreadId },
244
replace: true,
245
});
220
- handledBootstrapThreadIdRef.current = payload.bootstrapThreadId;
246
+ handledBootstrapThreadIdRef.current = bootstrapThreadId;
247
})().catch(() => undefined);
248
});
249
const unsubServerConfigUpdated = onServerConfigUpdated((payload) => {