@devries-cameron20 / t3code Mirror · read-only / commits / 346247bf1a
Fork 0

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 23, 14:15 UTC

fix(web): leaving the home page while the app loads no longer bounces you to a new draft (#18672)

Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

shivam committed Oct 13, 2026 at 08:12 UTC 346247bf1a461d200209b3f33f2bb7f148987b1f
1 file changed +8 -3
apps/web/src/routes/_chat.index.tsx
+8 -3
@@ -1,8 +1,8 @@
1 import { RefreshIcon } from "~/components/ui/refresh-icon";
2 import { scopeProjectRef } from "@t3tools/client-runtime/environment";
3 -import { createFileRoute, Link } from "@tanstack/react-router";
3 +import { createFileRoute, Link, useRouter } from "@tanstack/react-router";
4 import { LinkIcon, PlusIcon } from "lucide-react";
5 -import { useEffect, useMemo, useRef, useState } from "react";
5 +import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
6
7 import { isLocalEnvironmentDisabled } from "../localEnvironment";
8 import { isElectron } from "../env";
@@ -44,6 +44,10 @@ function IndexDraftLanding() {
44 const threads = useThreadShells();
45 const bootstrapped = useAllEnvironmentShellsBootstrapped();
46 const handleNewThread = useNewThreadHandler();
47 + const router = useRouter();
48 + // Read at effect time: this page stays mounted while a navigation away from
49 + // "/" is still loading, but the router already points at the new location.
50 + const isStillOnIndex = useEffectEvent(() => router.state.location.pathname === "/");
51 const startingRef = useRef(false);
52 const [startState, setStartState] = useState({ failed: false, retryRequest: 0 });
53
@@ -56,7 +60,8 @@ function IndexDraftLanding() {
60 );
61
62 useEffect(() => {
59 - if (mostRecentProject === null || startingRef.current) {
63 + // Starting a draft after the user has left would replace the page they picked.
64 + if (mostRecentProject === null || startingRef.current || !isStillOnIndex()) {
65 return;
66 }
67 startingRef.current = true;