diff --git a/apps/web/src/components/DiffPanel.tsx b/apps/web/src/components/DiffPanel.tsx
index afda09800..cc94d03a1 100644
--- a/apps/web/src/components/DiffPanel.tsx
+++ b/apps/web/src/components/DiffPanel.tsx
@@ -5,11 +5,10 @@ import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
import { ThreadId, type TurnId } from "@okcode/contracts";
import { CheckIcon, ChevronDownIcon, Columns2Icon, Rows3Icon, TextWrapIcon } from "lucide-react";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
-import { RawPatchViewer } from "~/components/pr-review/RawPatchViewer";
import { gitBranchesQueryOptions } from "~/lib/gitReactQuery";
import { checkpointDiffQueryOptions } from "~/lib/providerReactQuery";
import { cn } from "~/lib/utils";
-import { useFileViewNavigation } from "~/hooks/useFileViewNavigation";
+import { useCodeViewerStore } from "../codeViewerStore";
import { parseDiffRouteSearch, stripDiffSearchParams } from "../diffRouteSearch";
import { useTheme } from "../hooks/useTheme";
import { buildPatchCacheKey } from "../lib/diffRendering";
@@ -23,7 +22,6 @@ import {
} from "../lib/diffFileReviewState";
import { resolveDiffThemeName } from "../lib/diffRendering";
import { useTurnDiffSummaries } from "../hooks/useTurnDiffSummaries";
-import { useI18n } from "../i18n/useI18n";
import { useStore } from "../store";
import { useAppSettings } from "../appSettings";
import { formatShortTimestamp } from "../timestampFormat";
@@ -208,7 +206,7 @@ function DiffFileSection(props: {
{hasNonZeroStat(stats) && (
@@ -270,7 +269,6 @@ export { DiffWorkerPoolProvider } from "./DiffWorkerPoolProvider";
export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
const navigate = useNavigate();
const { resolvedTheme } = useTheme();
- const { resolvedLocale } = useI18n();
const { settings } = useAppSettings();
const [diffRenderMode, setDiffRenderMode] = useState("stacked");
const [diffWordWrap, setDiffWordWrap] = useState(settings.diffWordWrap);
@@ -489,7 +487,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
target?.scrollIntoView({ block: "nearest" });
}, [selectedFilePath, renderableFiles]);
- const openFileInCodeViewer = useFileViewNavigation();
+ const openFileInCodeViewer = useCodeViewerStore((state) => state.openFile);
const openDiffFileInCodeViewer = useCallback(
(filePath: string) => {
if (!activeCwd) return;
@@ -527,23 +525,21 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
},
[updateActiveReviewState],
);
+
const latestSelectedTurnId = orderedTurnDiffSummaries[0]?.turnId ?? null;
- const selectTurn = useCallback(
- (turnId: TurnId) => {
- if (!activeThread) return;
- void navigate({
- to: "/$threadId",
- params: { threadId: activeThread.id },
- search: (previous) => {
- const rest = stripDiffSearchParams(previous);
- return { ...rest, diff: "1", diffTurnId: turnId };
- },
- });
- },
- [activeThread, navigate],
- );
- const selectWholeConversation = useCallback(() => {
+ const selectTurn = (turnId: TurnId) => {
+ if (!activeThread) return;
+ void navigate({
+ to: "/$threadId",
+ params: { threadId: activeThread.id },
+ search: (previous) => {
+ const rest = stripDiffSearchParams(previous);
+ return { ...rest, diff: "1", diffTurnId: turnId };
+ },
+ });
+ };
+ const selectWholeConversation = () => {
if (!activeThread) return;
void navigate({
to: "/$threadId",
@@ -553,7 +549,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
return { ...rest, diff: "1" };
},
});
- }, [activeThread, navigate]);
+ };
const turnSelectValue = selectedTurnId ?? "all";
const handleTurnSelectChange = useCallback(
(value: string | null) => {
@@ -574,26 +570,14 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
{selectedTurnId === null
? "All changes"
: selectedTurn?.turnId === latestSelectedTurnId
- ? `Latest • ${formatShortTimestamp(
- selectedTurn.completedAt,
- settings.timestampFormat,
- resolvedLocale,
- )}`
+ ? `Latest • ${formatShortTimestamp(selectedTurn.completedAt, settings.timestampFormat)}`
: `Change ${
selectedTurn?.checkpointTurnCount ??
(selectedTurn
? inferredCheckpointTurnCountByTurnId[selectedTurn.turnId]
: null) ??
"?"
- } • ${
- selectedTurn
- ? formatShortTimestamp(
- selectedTurn.completedAt,
- settings.timestampFormat,
- resolvedLocale,
- )
- : ""
- }`}
+ } • ${selectedTurn ? formatShortTimestamp(selectedTurn.completedAt, settings.timestampFormat) : ""}`}
All changes
@@ -610,11 +594,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
}`}
- {formatShortTimestamp(
- summary.completedAt,
- settings.timestampFormat,
- resolvedLocale,
- )}
+ {formatShortTimestamp(summary.completedAt, settings.timestampFormat)}
@@ -686,7 +666,10 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
) : (
<>
-
+
{checkpointDiffError && !renderablePatch && (
{checkpointDiffError}
@@ -706,11 +689,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
)
) : renderablePatch.kind === "files" ? (
) : (
-
+
+
+
{renderablePatch.reason}
+
+ {renderablePatch.text}
+
+
+
)}
>