diff --git a/apps/web/src/components/ChatView.tsx b/apps/web/src/components/ChatView.tsx index fd94dfff9385b0eff8c2c86ae54da7d7845bfcd8..4a374b6d67f08521cda82cdd6a053e1dca5e5a01 100644 --- a/apps/web/src/components/ChatView.tsx +++ b/apps/web/src/components/ChatView.tsx @@ -36,7 +36,7 @@ import { projectSearchEntriesQueryOptions } from "~/lib/projectReactQuery"; import { serverConfigQueryOptions, serverQueryKeys } from "~/lib/serverReactQuery"; import { isElectron } from "../env"; -import { parseDiffRouteSearch } from "../diffRouteSearch"; +import { parseDiffRouteSearch, stripDiffSearchParams } from "../diffRouteSearch"; import { buildBootstrapInput } from "../historyBootstrap"; import { type ComposerTriggerKind, @@ -1967,12 +1967,7 @@ export default function ChatView({ threadId }: ChatViewProps) { to: "/$threadId", params: { threadId }, search: (previous) => { - const { - diff: _diff, - diffTurnId: _diffTurnId, - diffFilePath: _diffFilePath, - ...rest - } = previous; + const rest = stripDiffSearchParams(previous); return diffOpen ? rest : { ...rest, diff: "1" }; }, }); @@ -1983,12 +1978,7 @@ export default function ChatView({ threadId }: ChatViewProps) { to: "/$threadId", params: { threadId }, search: (previous) => { - const { - diff: _diff, - diffTurnId: _diffTurnId, - diffFilePath: _diffFilePath, - ...rest - } = previous; + const rest = stripDiffSearchParams(previous); return filePath ? { ...rest, diff: "1", diffTurnId: turnId, diffFilePath: filePath } : { ...rest, diff: "1", diffTurnId: turnId }; @@ -2828,11 +2818,16 @@ const MessagesTimeline = memo(function MessagesTimeline({ row.message.id, ); if (!turnSummary) return null; - const checkpointFilesState = turnCheckpointFilesByTurnId.get(turnSummary.turnId); + const checkpointFilesState = turnCheckpointFilesByTurnId.get( + turnSummary.turnId, + ); const checkpointFiles = checkpointFilesState?.files ?? []; const summaryStat = checkpointFiles.reduce( (acc, file) => { - if (typeof file.additions !== "number" || typeof file.deletions !== "number") { + if ( + typeof file.additions !== "number" || + typeof file.deletions !== "number" + ) { return acc; } return { @@ -2843,7 +2838,9 @@ const MessagesTimeline = memo(function MessagesTimeline({ { additions: 0, deletions: 0 }, ); const changedFileCountLabel = - checkpointFilesState?.status === "ready" ? String(checkpointFiles.length) : "..."; + checkpointFilesState?.status === "ready" + ? String(checkpointFiles.length) + : "..."; return (
Waiting for checkpoint metadata...
diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx index 6510cea7ee3ca999660b8447c360dde862b7f352..33149c5088a7f5082a821512302c953f4295a4a1 100644 --- a/apps/web/src/components/DiffPanel.tsx +++ b/apps/web/src/components/DiffPanel.tsx @@ -1,16 +1,12 @@ import { parsePatchFiles } from "@pierre/diffs"; -import { - FileDiff, - type FileDiffMetadata, - Virtualizer, -} from "@pierre/diffs/react"; +import { FileDiff, type FileDiffMetadata, Virtualizer } from "@pierre/diffs/react"; import { useQuery } from "@tanstack/react-query"; import { useNavigate, useParams, useSearch } from "@tanstack/react-router"; import { Columns2Icon, Rows3Icon } from "lucide-react"; import { useEffect, useMemo, useRef, useState } from "react"; import { checkpointDiffQueryOptions } from "~/lib/providerReactQuery"; import { cn } from "~/lib/utils"; -import { parseDiffRouteSearch } from "../diffRouteSearch"; +import { parseDiffRouteSearch, stripDiffSearchParams } from "../diffRouteSearch"; import { isElectron } from "../env"; import { useNativeApi } from "../hooks/useNativeApi"; import { useTheme } from "../hooks/useTheme"; @@ -101,7 +97,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { useTurnDiffSummaries(activeThread); const selectedTurnId = diffSearch.diffTurnId ?? null; - const selectedFilePath = selectedTurnId !== null ? diffSearch.diffFilePath ?? null : null; + const selectedFilePath = selectedTurnId !== null ? (diffSearch.diffFilePath ?? null) : null; const selectedTurn = selectedTurnId === null ? undefined @@ -205,12 +201,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { to: "/$threadId", params: { threadId: activeThread.id }, search: (previous) => { - const { - diff: _diff, - diffTurnId: _diffTurnId, - diffFilePath: _diffFilePath, - ...rest - } = previous; + const rest = stripDiffSearchParams(previous); return { ...rest, diff: "1", diffTurnId: turnId }; }, }); @@ -221,12 +212,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) { to: "/$threadId", params: { threadId: activeThread.id }, search: (previous) => { - const { - diff: _diff, - diffTurnId: _diffTurnId, - diffFilePath: _diffFilePath, - ...rest - } = previous; + const rest = stripDiffSearchParams(previous); return { ...rest, diff: "1" }; }, }); diff --git a/apps/web/src/diffRouteSearch.ts b/apps/web/src/diffRouteSearch.ts index 1b1ccded2427f9a07e213f16554b91b7c2d45cf1..fd3d6cae7087bb84286b5dfa75009a330c4541cd 100644 --- a/apps/web/src/diffRouteSearch.ts +++ b/apps/web/src/diffRouteSearch.ts @@ -12,6 +12,13 @@ function normalizeSearchString(value: unknown): string | undefined { return normalized.length > 0 ? normalized : undefined; } +export function stripDiffSearchParams