The best way to control Claude Code, Codex and more from any computer or phone
perf(web): the index route compiles with the React Compiler (#20580)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 22:04 UTC
2814dc9c48851e0fb016b34a290ed978db7abace
1 file changed
+10
-14
apps/web/src/routes/_chat.index.tsx
+10
-14
@@ -2,7 +2,7 @@ import { RefreshIcon } from "~/components/ui/refresh-icon";
2
import { scopeProjectRef } from "@t3tools/client-runtime/environment";
3
import { createFileRoute, Link, useRouter } from "@tanstack/react-router";
4
import { LinkIcon, PlusIcon } from "lucide-react";
5
-import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
5
+import { useEffect, useEffectEvent, useRef, useState } from "react";
6
7
import { isLocalEnvironmentDisabled } from "../localEnvironment";
8
import { isElectron } from "../env";
@@ -44,39 +44,35 @@ function IndexDraftLanding() {
44
// Read at effect time: this page stays mounted while a navigation away from
45
// "/" is still loading, but the router already points at the new location.
46
const isStillOnIndex = useEffectEvent(() => router.state.location.pathname === "/");
47
- const startingRef = useRef(false);
47
+ // One start per attempt; a retry request opens the next attempt.
48
+ const startedAttemptRef = useRef<number | null>(null);
49
const [startState, setStartState] = useState({ failed: false, retryRequest: 0 });
50
50
- const mostRecentProject = useMemo(
51
- () =>
52
- bootstrapped
53
- ? (sortScopedProjectsForSidebar(projects, threads, "updated_at")[0] ?? null)
54
- : null,
55
- [bootstrapped, projects, threads],
56
- );
51
+ const mostRecentProject = bootstrapped
52
+ ? (sortScopedProjectsForSidebar(projects, threads, "updated_at")[0] ?? null)
53
+ : null;
54
+ const attempt = startState.retryRequest;
55
56
useEffect(() => {
57
// Starting a draft after the user has left would replace the page they picked.
60
- if (mostRecentProject === null || startingRef.current || !isStillOnIndex()) {
58
+ if (mostRecentProject === null || startedAttemptRef.current === attempt || !isStillOnIndex()) {
59
return;
60
}
61
const projectRef = scopeProjectRef(mostRecentProject.environmentId, mostRecentProject.id);
62
if (readProject(projectRef) === null) {
63
return;
64
}
67
- startingRef.current = true;
65
+ startedAttemptRef.current = attempt;
66
void handleNewThread(projectRef, { replace: true })
67
.then((opened) => {
68
if (opened === null) {
71
- startingRef.current = false;
69
setStartState((state) => ({ ...state, retryRequest: state.retryRequest + 1 }));
70
}
71
})
72
.catch(() => {
76
- startingRef.current = false;
73
setStartState((state) => ({ ...state, failed: true }));
74
});
79
- }, [handleNewThread, mostRecentProject, startState.retryRequest]);
75
+ }, [attempt, handleNewThread, mostRecentProject]);
76
77
if (!bootstrapped) {
78
return null;