The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 25, 07:30 UTC
feat: add word wrapping setting and in-panel button (#1326)
Raphael Lüthy committed
Mar 24, 2026 at 17:34 UTC
d4a7e1ac0b03399376a0acde78b58365715415ae
3 files changed
+88
-20
apps/web/src/appSettings.ts
+1
@@ -56,6 +56,7 @@ export const AppSettingsSchema = Schema.Struct({
56
codexHomePath: Schema.String.check(Schema.isMaxLength(4096)).pipe(withDefaults(() => "")),
57
defaultThreadEnvMode: EnvMode.pipe(withDefaults(() => "local" as const satisfies EnvMode)),
58
confirmThreadDelete: Schema.Boolean.pipe(withDefaults(() => true)),
59
+ diffWordWrap: Schema.Boolean.pipe(withDefaults(() => false)),
60
enableAssistantStreaming: Schema.Boolean.pipe(withDefaults(() => false)),
61
timestampFormat: TimestampFormat.pipe(withDefaults(() => DEFAULT_TIMESTAMP_FORMAT)),
62
customCodexModels: Schema.Array(Schema.String).pipe(withDefaults(() => [])),
apps/web/src/components/DiffPanel.tsx
+58
-20
@@ -3,7 +3,13 @@ import { FileDiff, type FileDiffMetadata, Virtualizer } from "@pierre/diffs/reac
3
import { useQuery } from "@tanstack/react-query";
4
import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
5
import { ThreadId, type TurnId } from "@t3tools/contracts";
6
-import { ChevronLeftIcon, ChevronRightIcon, Columns2Icon, Rows3Icon } from "lucide-react";
6
+import {
7
+ ChevronLeftIcon,
8
+ ChevronRightIcon,
9
+ Columns2Icon,
10
+ Rows3Icon,
11
+ TextWrapIcon,
12
+} from "lucide-react";
13
import {
14
type WheelEvent as ReactWheelEvent,
15
useCallback,
@@ -162,8 +168,10 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
168
const { resolvedTheme } = useTheme();
169
const { settings } = useAppSettings();
170
const [diffRenderMode, setDiffRenderMode] = useState<DiffRenderMode>("stacked");
171
+ const [diffWordWrap, setDiffWordWrap] = useState(settings.diffWordWrap);
172
const patchViewportRef = useRef<HTMLDivElement>(null);
173
const turnStripRef = useRef<HTMLDivElement>(null);
174
+ const previousDiffOpenRef = useRef(false);
175
const [canScrollTurnStripLeft, setCanScrollTurnStripLeft] = useState(false);
176
const [canScrollTurnStripRight, setCanScrollTurnStripRight] = useState(false);
177
const routeThreadId = useParams({
@@ -171,6 +179,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
179
select: (params) => (params.threadId ? ThreadId.makeUnsafe(params.threadId) : null),
180
});
181
const diffSearch = useSearch({ strict: false, select: (search) => parseDiffRouteSearch(search) });
182
+ const diffOpen = diffSearch.diff === "1";
183
const activeThreadId = routeThreadId;
184
const activeThread = useStore((store) =>
185
activeThreadId ? store.threads.find((thread) => thread.id === activeThreadId) : undefined,
@@ -293,6 +302,13 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
302
);
303
}, [renderablePatch]);
304
305
+ useEffect(() => {
306
+ if (diffOpen && !previousDiffOpenRef.current) {
307
+ setDiffWordWrap(settings.diffWordWrap);
308
+ }
309
+ previousDiffOpenRef.current = diffOpen;
310
+ }, [diffOpen, settings.diffWordWrap]);
311
+
312
useEffect(() => {
313
if (!selectedFilePath || !patchViewportRef.current) {
314
return;
@@ -490,25 +506,39 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
506
))}
507
</div>
508
</div>
493
- <ToggleGroup
494
- className="shrink-0 [-webkit-app-region:no-drag]"
495
- variant="outline"
496
- size="xs"
497
- value={[diffRenderMode]}
498
- onValueChange={(value) => {
499
- const next = value[0];
500
- if (next === "stacked" || next === "split") {
501
- setDiffRenderMode(next);
502
- }
503
- }}
504
- >
505
- <Toggle aria-label="Stacked diff view" value="stacked">
506
- <Rows3Icon className="size-3" />
507
- </Toggle>
508
- <Toggle aria-label="Split diff view" value="split">
509
- <Columns2Icon className="size-3" />
509
+ <div className="flex shrink-0 items-center gap-1 [-webkit-app-region:no-drag]">
510
+ <ToggleGroup
511
+ className="shrink-0"
512
+ variant="outline"
513
+ size="xs"
514
+ value={[diffRenderMode]}
515
+ onValueChange={(value) => {
516
+ const next = value[0];
517
+ if (next === "stacked" || next === "split") {
518
+ setDiffRenderMode(next);
519
+ }
520
+ }}
521
+ >
522
+ <Toggle aria-label="Stacked diff view" value="stacked">
523
+ <Rows3Icon className="size-3" />
524
+ </Toggle>
525
+ <Toggle aria-label="Split diff view" value="split">
526
+ <Columns2Icon className="size-3" />
527
+ </Toggle>
528
+ </ToggleGroup>
529
+ <Toggle
530
+ aria-label={diffWordWrap ? "Disable diff line wrapping" : "Enable diff line wrapping"}
531
+ title={diffWordWrap ? "Disable line wrapping" : "Enable line wrapping"}
532
+ variant="outline"
533
+ size="xs"
534
+ pressed={diffWordWrap}
535
+ onPressedChange={(pressed) => {
536
+ setDiffWordWrap(Boolean(pressed));
537
+ }}
538
+ >
539
+ <TextWrapIcon className="size-3" />
540
</Toggle>
511
- </ToggleGroup>
541
+ </div>
542
</>
543
);
544
@@ -582,6 +612,7 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
612
options={{
613
diffStyle: diffRenderMode === "split" ? "split" : "unified",
614
lineDiffType: "none",
615
+ overflow: diffWordWrap ? "wrap" : "scroll",
616
theme: resolveDiffThemeName(resolvedTheme),
617
themeType: resolvedTheme as DiffThemeType,
618
unsafeCSS: DIFF_PANEL_UNSAFE_CSS,
@@ -595,7 +626,14 @@ export default function DiffPanel({ mode = "inline" }: DiffPanelProps) {
626
<div className="h-full overflow-auto p-2">
627
<div className="space-y-2">
628
<p className="text-[11px] text-muted-foreground/75">{renderablePatch.reason}</p>
598
- <pre className="max-h-[72vh] overflow-auto rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90">
629
+ <pre
630
+ className={cn(
631
+ "max-h-[72vh] rounded-md border border-border/70 bg-background/70 p-3 font-mono text-[11px] leading-relaxed text-muted-foreground/90",
632
+ diffWordWrap
633
+ ? "overflow-auto whitespace-pre-wrap wrap-break-word"
634
+ : "overflow-auto",
635
+ )}
636
+ >
637
{renderablePatch.text}
638
</pre>
639
</div>
apps/web/src/routes/_chat.settings.tsx
+29
@@ -252,6 +252,7 @@ function SettingsRouteView() {
252
const changedSettingLabels = [
253
...(theme !== "system" ? ["Theme"] : []),
254
...(settings.timestampFormat !== defaults.timestampFormat ? ["Time format"] : []),
255
+ ...(settings.diffWordWrap !== defaults.diffWordWrap ? ["Diff line wrapping"] : []),
256
...(settings.enableAssistantStreaming !== defaults.enableAssistantStreaming
257
? ["Assistant output"]
258
: []),
@@ -500,6 +501,34 @@ function SettingsRouteView() {
501
}
502
/>
503
504
+ <SettingsRow
505
+ title="Diff line wrapping"
506
+ description="Set the default wrap state when the diff panel opens. The in-panel wrap toggle only affects the current diff session."
507
+ resetAction={
508
+ settings.diffWordWrap !== defaults.diffWordWrap ? (
509
+ <SettingResetButton
510
+ label="diff line wrapping"
511
+ onClick={() =>
512
+ updateSettings({
513
+ diffWordWrap: defaults.diffWordWrap,
514
+ })
515
+ }
516
+ />
517
+ ) : null
518
+ }
519
+ control={
520
+ <Switch
521
+ checked={settings.diffWordWrap}
522
+ onCheckedChange={(checked) =>
523
+ updateSettings({
524
+ diffWordWrap: Boolean(checked),
525
+ })
526
+ }
527
+ aria-label="Wrap diff lines by default"
528
+ />
529
+ }
530
+ />
531
+
532
<SettingsRow
533
title="Assistant output"
534
description="Show token-by-token output while a response is in progress."