Skip to content
Closed
Changes from 1 commit
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
29 changes: 28 additions & 1 deletion apps/web/src/components/DiffPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ import { FileDiff, type FileDiffMetadata, Virtualizer } from "@pierre/diffs/reac
import { useQuery } from "@tanstack/react-query";
import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
import { ThreadId, type TurnId } from "@t3tools/contracts";
import { ChevronLeftIcon, ChevronRightIcon, Columns2Icon, Rows3Icon } from "lucide-react";
import {
ChevronLeftIcon,
ChevronRightIcon,
Columns2Icon,
Rows3Icon,
WrapTextIcon,
} from "lucide-react";
import {
type WheelEvent as ReactWheelEvent,
useCallback,
Expand All @@ -30,6 +36,7 @@ import { DiffPanelLoadingState, DiffPanelShell, type DiffPanelMode } from "./Dif
import { ToggleGroup, Toggle } from "./ui/toggle-group";

type DiffRenderMode = "stacked" | "split";
type DiffOverflowMode = "scroll" | "wrap";
type DiffThemeType = "light" | "dark";

const DIFF_PANEL_UNSAFE_CSS = `
Expand Down Expand Up @@ -162,6 +169,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
const { resolvedTheme } = useTheme();
const { settings } = useAppSettings();
const [diffRenderMode, setDiffRenderMode] = useState<DiffRenderMode>("stacked");
const [diffOverflowMode, setDiffOverflowMode] = useState<DiffOverflowMode>("scroll");
const patchViewportRef = useRef<HTMLDivElement>(null);
const turnStripRef = useRef<HTMLDivElement>(null);
const [canScrollTurnStripLeft, setCanScrollTurnStripLeft] = useState(false);
Expand Down Expand Up @@ -509,6 +517,24 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
<Columns2Icon className="size-3" />
</Toggle>
</ToggleGroup>
<ToggleGroup
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not a group with just one item. use Toggle without wrapper

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I’ve changed it to use Toggle directly.

className="shrink-0 [-webkit-app-region:no-drag]"
variant="outline"
size="xs"
value={[diffOverflowMode]}
onValueChange={(value) => {
const next = value[0];
if (next === "wrap") {
setDiffOverflowMode("wrap");
} else {
setDiffOverflowMode("scroll");
}
}}
>
<Toggle aria-label="Toggle line wrapping" value="wrap">
<WrapTextIcon className="size-3" />
</Toggle>
</ToggleGroup>
</>
);

Expand Down Expand Up @@ -584,6 +610,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
lineDiffType: "none",
theme: resolveDiffThemeName(resolvedTheme),
themeType: resolvedTheme as DiffThemeType,
overflow: diffOverflowMode === "wrap" ? "wrap" : "scroll",
unsafeCSS: DIFF_PANEL_UNSAFE_CSS,
}}
/>
Expand Down