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 24, 21:30 UTC
Allow preview panel to grow on wide displays (#4044)
Olivier Melcher committed
Jul 17, 2026 at 13:40 UTC
a7f6d97b94d2e12b10081760063768f715f87e96
2 files changed
+19
-4
apps/web/src/components/preview/PreviewPanelShell.test.ts
new
+13
@@ -0,0 +1,13 @@
1
+import { describe, expect, it } from "vite-plus/test";
2
+
3
+import { getPreviewPanelMaxWidth } from "./PreviewPanelShell";
4
+
5
+describe("getPreviewPanelMaxWidth", () => {
6
+ it("allows the panel to use 70% of an ultra-wide viewport without a pixel ceiling", () => {
7
+ expect(getPreviewPanelMaxWidth(6_000)).toBe(4_200);
8
+ });
9
+
10
+ it("rounds fractional CSS pixels down", () => {
11
+ expect(getPreviewPanelMaxWidth(2_001)).toBe(1_400);
12
+ });
13
+});
apps/web/src/components/preview/PreviewPanelShell.tsx
+6
-4
@@ -10,12 +10,14 @@ export type PreviewPanelMode = "inline" | "sheet" | "sidebar" | "embedded";
10
11
const PREVIEW_PANEL_WIDTH_STORAGE_KEY = "t3code:preview-panel-width";
12
const PREVIEW_PANEL_MIN_WIDTH = 360;
13
-/** Hard ceiling so a wide monitor can't yield a panel that swallows the chat. */
14
-const PREVIEW_PANEL_MAX_WIDTH_PX = 1400;
15
-/** Fraction of the viewport allowed; the panel is min(this · vw, MAX_PX). */
13
+/** Fraction of the viewport allowed, preserving the remaining space for chat. */
14
const PREVIEW_PANEL_MAX_WIDTH_FRACTION = 0.7;
15
const PREVIEW_PANEL_DEFAULT_WIDTH = 540;
16
17
+export function getPreviewPanelMaxWidth(viewportWidth: number): number {
18
+ return Math.floor(viewportWidth * PREVIEW_PANEL_MAX_WIDTH_FRACTION);
19
+}
20
+
21
/**
22
* Shell for the preview panel. In inline mode the panel is user-resizable
23
* via a drag handle on the left edge; width persists per browser. In
@@ -82,5 +84,5 @@ function useViewportClampedMaxWidth(): number {
84
if (frame !== 0) window.cancelAnimationFrame(frame);
85
};
86
}, []);
85
- return Math.min(PREVIEW_PANEL_MAX_WIDTH_PX, Math.floor(vw * PREVIEW_PANEL_MAX_WIDTH_FRACTION));
87
+ return getPreviewPanelMaxWidth(vw);
88
}