Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions apps/web/src/routes/_chat.$threadId.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ThreadId } from "@t3tools/contracts";
import { createFileRoute, retainSearchParams, useNavigate } from "@tanstack/react-router";
import { Suspense, lazy, type ReactNode, useCallback, useEffect, useState } from "react";
import { Suspense, lazy, type ReactNode, useCallback, useEffect, useRef } from "react";

import ChatView from "../components/ChatView";
import { DiffWorkerPoolProvider } from "../components/DiffWorkerPoolProvider";
Expand Down Expand Up @@ -176,7 +176,7 @@ function ChatThreadRouteView() {
const shouldUseDiffSheet = useMediaQuery(DIFF_INLINE_LAYOUT_MEDIA_QUERY);
// TanStack Router keeps active route components mounted across param-only navigations
// unless remountDeps are configured, so this stays warm across thread switches.
const [hasOpenedDiff, setHasOpenedDiff] = useState(diffOpen);
const hasOpenedDiffRef = useRef(diffOpen);
const closeDiff = useCallback(() => {
void navigate({
to: "/$threadId",
Expand All @@ -195,11 +195,7 @@ function ChatThreadRouteView() {
});
}, [navigate, threadId]);

useEffect(() => {
if (diffOpen) {
setHasOpenedDiff(true);
}
}, [diffOpen]);
if (diffOpen) hasOpenedDiffRef.current = true;

useEffect(() => {
if (!threadsHydrated) {
Expand All @@ -216,7 +212,7 @@ function ChatThreadRouteView() {
return null;
}

const shouldRenderDiffContent = diffOpen || hasOpenedDiff;
const shouldRenderDiffContent = diffOpen || hasOpenedDiffRef.current;

if (!shouldUseDiffSheet) {
return (
Expand Down