authorgravatar for 91240327+shivamhwp@users.noreply.github.comshivam <91240327+shivamhwp@users.noreply.github.com> 2026-10-13 08:12:42+05:30
committergravatar for noreply@github.comGitHub <noreply@github.com> 2026-10-13 08:12:42+05:30
log346247bf1a461d200209b3f33f2bb7f148987b1f
tree475dc5a7f05852bb387e331b1af7cab7059c7ac6
parenta143fa3c56be890346b8a7915a6a870529201dda
signature Signed by PGP key B5690EEEBB952194

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>

1 files changed, 8 insertions(+), 3 deletions(-)

apps/web/src/routes/_chat.index.tsx+8-3
...@@ -1,8 +1,8 @@...@@ -1,8 +1,8 @@
1import { RefreshIcon } from "~/components/ui/refresh-icon";1import { RefreshIcon } from "~/components/ui/refresh-icon";
2import { scopeProjectRef } from "@t3tools/client-runtime/environment";2import { scopeProjectRef } from "@t3tools/client-runtime/environment";
3import { createFileRoute, Link } from "@tanstack/react-router";3import { createFileRoute, Link, useRouter } from "@tanstack/react-router";
4import { LinkIcon, PlusIcon } from "lucide-react";4import { LinkIcon, PlusIcon } from "lucide-react";
5import { useEffect, useMemo, useRef, useState } from "react";5import { useEffect, useEffectEvent, useMemo, useRef, useState } from "react";
66
7import { isLocalEnvironmentDisabled } from "../localEnvironment";7import { isLocalEnvironmentDisabled } from "../localEnvironment";
8import { isElectron } from "../env";8import { isElectron } from "../env";
...@@ -44,6 +44,10 @@ function IndexDraftLanding() {...@@ -44,6 +44,10 @@ function IndexDraftLanding() {
44 const threads = useThreadShells();44 const threads = useThreadShells();
45 const bootstrapped = useAllEnvironmentShellsBootstrapped();45 const bootstrapped = useAllEnvironmentShellsBootstrapped();
46 const handleNewThread = useNewThreadHandler();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 === "/");
47 const startingRef = useRef(false);51 const startingRef = useRef(false);
48 const [startState, setStartState] = useState({ failed: false, retryRequest: 0 });52 const [startState, setStartState] = useState({ failed: false, retryRequest: 0 });
4953
...@@ -56,7 +60,8 @@ function IndexDraftLanding() {...@@ -56,7 +60,8 @@ function IndexDraftLanding() {
56 );60 );
5761
58 useEffect(() => {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()) {
60 return;65 return;
61 }66 }
62 startingRef.current = true;67 startingRef.current = true;