Skip to content

Commit 0ea9e96

Browse files
aorwallclaude
andauthored
feat: add a split-screen-horizontally toggle for the right panel (pingdotgg#41)
* feat: add a split-screen-horizontally toggle for the right panel Adds a third toggle beside the terminal-drawer and right-panel buttons that moves the right panel under the chat column instead of beside it, splitting the screen into top and bottom the way the terminal drawer already does. Splitting is a placement change rather than an open/close one, so every press has to leave a panel on screen: pressing from a closed panel opens it at the bottom, and pressing while maximized un-maximizes first, since maximizing hides the chat entirely — the opposite of a split. The panel gains a row-resize handle on its top edge. Height persists under its own key, separate from width, so flipping orientation restores the size that orientation last had. Orientation itself is a per-browser preference like the panel's width, not thread state. Which surface owns the window's top-right follows the panel: its tab bar when it sits beside the chat, the chat header when it is split off the bottom or closed. Supporting changes: - useResizableWidth -> useResizableSize, now driving height as well via an "top" edge, with the pointer math extracted as a pure, tested function. - ChatHeader's rightPanelOpen prop -> hostsLayoutControls, which is all it ever meant; the split makes the old name wrong. - New rebindable command rightPanel.toggleHorizontalSplit, mod+alt+0. Co-Authored-By: Claude Opus 5 <[email protected]> * docs(fork): record the split-screen delta, and give the inventory an upstream to check against The split-screen toggle adds a delta to ten upstream files, so it needs a Fork Inventory row, a delta section, Path Policy rows and a convergence watch entry. Eight of the ten were byte-identical to upstream before it. The fork owns no file in that row except one: useResizableWidth.ts is renamed to useResizableSize.ts, so upstream's edits to the hook will arrive as a modify/delete conflict rather than a mergeable hunk. Recorded rather than reversed, with the cheaper shape written beside it. Two corrections found while verifying ownership against upstream, which a sandbox can now do — the fork's clone is shallow and has no upstream remote, but adding pingdotgg/t3code and fetching --depth=1 takes seconds, so both commands go in Path Policy: - .plans/** was marked ours while upstream owns 32 of its 35 files. That blanket ours would have discarded every upstream plan edit, which is the failure the paragraph above the table describes. Row split. - messageOrigin.ts is confirmed absent upstream, clearing the caveat the previous log entry left on it. The other twelve ours paths verify clean too. Co-Authored-By: Claude Opus 5 <[email protected]> * refactor(web): keep the split-screen delta additive, per AGENTS.md AGENTS.md asks for fork changes that upstream merges cheaply: put the code on a path upstream does not have, reach it from upstream files through the smallest hook, and prefer a branch above upstream's to a rewrite of it. Three parts of this branch did the opposite. useResizableWidth.ts was renamed to useResizableSize.ts, which deletes a path upstream owns and edits — every future upstream change to that hook would have landed as a modify/delete conflict. Upstream's hook is restored byte for byte, and the vertical axis moves to a fork-only sibling, apps/web/src/fork/useResizablePanelHeight.ts, which also owns the max-height helper and its tests. The orientation preference was appended to upstream's rightPanelLayout.ts; it moves to apps/web/src/fork/rightPanelOrientation.ts, leaving that file byte-identical to upstream again. ChatHeader's rightPanelOpen prop was renamed to hostsLayoutControls. It keeps upstream's name and meaning now, with an optional layoutControlsOverHeader beside it for the case the split introduces. PreviewPanelShell keeps every upstream line as upstream wrote it: the stacked classes are appended after upstream's own and resolved by twMerge, and the width path is untouched. Net effect on merges: eight upstream files with additive hunks, three fork-only modules, no renamed or deleted upstream paths. Behaviour is unchanged. Verification scoped to the change, per AGENTS.md: web typecheck, lint on the touched files, fmt, and vp test run over apps/web/src/fork, apps/web/src/components/preview and rightPanelStore — 24 files, 128 tests. Model: Claude Opus 5. Harness: Claude Code. Co-Authored-By: Claude Opus 5 <[email protected]> * docs: fork code lives where the code it works with lives apps/web/src/fork/ was reading as a ghetto for anything fork-authored, which makes the tree look like a fork rather than like the app it is. AGENTS.md said to put fork code there; it now says to write a new file and put that file where it belongs, named for what it does. A path upstream does not have merges for free wherever it sits, so the merge argument was never a reason for an odd home. fork/ keeps only what is about being a fork: the surface-gating registry and the mobile modules. Two rules go with it. Mark fork code where someone will look — a line in the module's doc comment, a short // Fork: on a hunk inside an upstream file — so a merge can see what it is holding without diffing against upstream. And never rename, move or delete an upstream file for a fork reason, which is the lesson the useResizableWidth rename in this branch taught. The split-screen modules move accordingly: rightPanelOrientation.ts next to upstream's rightPanelLayout.ts, useResizablePanelHeight.ts next to upstream's useResizableWidth.ts. Imports and the fork inventory follow. Behaviour is unchanged. Verification: web typecheck, lint on the touched files, fmt --check, and vp test run over apps/web/src/hooks and apps/web/src/components/preview — 25 files, 87 tests. Model: Claude Opus 5. Harness: Claude Code. Co-Authored-By: Claude Opus 5 <[email protected]> * docs: trim the fork-change rules back to what they need to say The placement rule arrived with two extra bullets and a paragraph of justification aimed at the mistake that prompted it. Folded back into the three bullets that were already there: where a new file goes and how it says it is ours, the additive hook, and upstream's file keeping its name and shape. The inventory and the log entry lose the same padding. Model: Claude Opus 5. Harness: Claude Code. Co-Authored-By: Claude Opus 5 <[email protected]> * docs: fork code says so in the file Dropped the placement bullet from AGENTS.md — where a file sits is a judgement call, not a rule worth spending lines on. What replaces it is the part that pays off at merge time: a fork-only module says it is ours in its doc comment, and a fork hunk inside an upstream file carries a short // Fork: above it, so a merge can see what it is holding without diffing against upstream first. Applied to this branch's own hunks: ChatView's two split derivations, RightPanelTabs' orientation prop, PanelLayoutControls' third toggle, and the two keybindings entries. The two fork-only modules already said it. Model: Claude Opus 5. Harness: Claude Code. Co-Authored-By: Claude Opus 5 <[email protected]> --------- Co-authored-by: Claude Opus 5 <[email protected]>
1 parent fd3b851 commit 0ea9e96

14 files changed

Lines changed: 578 additions & 64 deletions

‎AGENTS.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ So most of what upstream's product is built around is not this fork's product. T
1616

1717
Upstream owns most files here and works in them steadily, and every line of ours inside one of their files is a conflict we pay for at each merge. So make fork changes surgically:
1818

19-
- **Put the code somewhere upstream does not have.** `apps/web/src/fork/`, `docs/fork/`, a new module beside the upstream one. A fork-only path merges for free.
20-
- **Reach it from upstream files through the smallest hook you can find.** A call, a gate read from `apps/web/src/fork/features.ts`, one element in a list — additive, and never re-indenting an upstream block, because a re-indented block turns a nearby upstream edit into a conflict.
21-
- **Prefer a toggle to a rewrite.** Something the fork must not show gets hidden by a flag, not deleted. Something it must do differently gets a branch above upstream's, leaving upstream's path intact.
19+
- **Say in the file that it is ours.** A line in a fork-only module's doc comment, a short `// Fork:` above a hunk inside an upstream file. A merge should be able to see what it is holding without diffing against upstream first.
20+
- **Reach it from upstream files through the smallest hook you can find.** A call, a gate read from `apps/web/src/fork/features.ts`, one element in a list, one optional prop — additive, and never re-indenting an upstream block, because a re-indented block turns a nearby upstream edit into a conflict.
21+
- **Prefer a toggle to a rewrite.** Something the fork must not show gets hidden by a flag, not deleted. Something it must do differently gets a branch above upstream's, and their file keeps its name, its exports and its shape.
2222
- **Write the delta down so it can be re-stated, not re-merged.** The inventory records behavior that must survive; the point is to reapply it on top of an upstream rewrite, not to defend our version of their file.
2323
- **Shrink the delta when upstream catches up.** The convergence watch list says what to drop when upstream ships an equivalent.
2424

‎apps/web/src/components/ChatView.tsx‎

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ import { isCommandPaletteOpen } from "../commandPaletteBus";
117117
import { buildTemporaryWorktreeBranchName } from "@t3tools/shared/git";
118118
import { useMediaQuery } from "../hooks/useMediaQuery";
119119
import { RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY } from "../rightPanelLayout";
120+
import { useRightPanelOrientation } from "../rightPanelOrientation";
120121
import {
121122
selectActiveRightPanel,
122123
selectActiveRightPanelSurface,
@@ -1303,6 +1304,7 @@ function ChatViewContent(props: ChatViewProps) {
13031304
const [pendingUserInputQuestionIndexByRequestId, setPendingUserInputQuestionIndexByRequestId] =
13041305
useState<Record<string, number>>({});
13051306
const shouldUsePlanSidebarSheet = useMediaQuery(RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY);
1307+
const [rightPanelOrientation, setRightPanelOrientation] = useRightPanelOrientation();
13061308
// Tracks whether the user explicitly dismissed the sidebar for the active turn.
13071309
const planSidebarDismissedForTurnRef = useRef<string | null>(null);
13081310
// When set, the thread-change reset effect will open the sidebar instead of closing it.
@@ -1556,7 +1558,15 @@ function ChatViewContent(props: ChatViewProps) {
15561558
const canMaximizeRightPanel = rightPanelOpen && !shouldUsePlanSidebarSheet;
15571559
const rightPanelMaximized =
15581560
canMaximizeRightPanel && maximizedRightPanelThreadKey === routeThreadKey;
1559-
const inlineRightPanelOwnsTitleBar = rightPanelOpen && !shouldUsePlanSidebarSheet;
1561+
// Fork: a maximized panel covers the whole area, so it has no orientation left
1562+
// to honour — only an open, un-maximized inline panel can sit under the chat.
1563+
const screenSplitHorizontally =
1564+
rightPanelOpen &&
1565+
!shouldUsePlanSidebarSheet &&
1566+
!rightPanelMaximized &&
1567+
rightPanelOrientation === "bottom";
1568+
const inlineRightPanelOwnsTitleBar =
1569+
rightPanelOpen && !shouldUsePlanSidebarSheet && !screenSplitHorizontally;
15601570

15611571
useEffect(() => {
15621572
if (!activeThreadRef) return;
@@ -3304,6 +3314,25 @@ function ChatViewContent(props: ChatViewProps) {
33043314
}
33053315
useRightPanelStore.getState().toggleVisibility(activeThreadRef);
33063316
}, [activeThreadRef, closePlanSidebar, closePreviewPanel, planSidebarOpen, rightPanelOpen]);
3317+
// Splitting is a placement change, not an open/close one: every press has to
3318+
// leave a panel on screen, so a press from a closed panel opens it in the
3319+
// requested spot the way the terminal button opens the drawer at the bottom.
3320+
const toggleHorizontalSplit = useCallback(() => {
3321+
if (!activeThreadRef || shouldUsePlanSidebarSheet) return;
3322+
if (screenSplitHorizontally) {
3323+
setRightPanelOrientation("right");
3324+
} else {
3325+
setRightPanelOrientation("bottom");
3326+
// Maximized hides the chat entirely, which is the opposite of a split.
3327+
setMaximizedRightPanelThreadKey(null);
3328+
}
3329+
useRightPanelStore.getState().show(activeThreadRef);
3330+
}, [
3331+
activeThreadRef,
3332+
screenSplitHorizontally,
3333+
setRightPanelOrientation,
3334+
shouldUsePlanSidebarSheet,
3335+
]);
33073336
const toggleRightPanelMaximized = useCallback(() => {
33083337
if (!canMaximizeRightPanel) return;
33093338
setMaximizedRightPanelThreadKey((threadKey) =>
@@ -4413,6 +4442,13 @@ function ChatViewContent(props: ChatViewProps) {
44134442
return;
44144443
}
44154444

4445+
if (command === "rightPanel.toggleHorizontalSplit") {
4446+
event.preventDefault();
4447+
event.stopPropagation();
4448+
toggleHorizontalSplit();
4449+
return;
4450+
}
4451+
44164452
if (command === "terminal.split") {
44174453
event.preventDefault();
44184454
event.stopPropagation();
@@ -4508,6 +4544,7 @@ function ChatViewContent(props: ChatViewProps) {
45084544
keybindings,
45094545
onToggleDiff,
45104546
toggleRightPanel,
4547+
toggleHorizontalSplit,
45114548
toggleTerminalVisibility,
45124549
composerRef,
45134550
]);
@@ -5653,8 +5690,15 @@ function ChatViewContent(props: ChatViewProps) {
56535690
rightPanelAvailable={activeProject !== null}
56545691
rightPanelOpen={rightPanelOpen}
56555692
rightPanelShortcutLabel={shortcutLabelForCommand(keybindings, "rightPanel.toggle")}
5693+
horizontalSplitAvailable={activeProject !== null && !shouldUsePlanSidebarSheet}
5694+
horizontalSplit={screenSplitHorizontally}
5695+
horizontalSplitShortcutLabel={shortcutLabelForCommand(
5696+
keybindings,
5697+
"rightPanel.toggleHorizontalSplit",
5698+
)}
56565699
onToggleTerminal={toggleTerminalVisibility}
56575700
onToggleRightPanel={toggleRightPanel}
5701+
onToggleHorizontalSplit={toggleHorizontalSplit}
56585702
/>
56595703
);
56605704
const panelLayoutControls = (
@@ -5668,6 +5712,11 @@ function ChatViewContent(props: ChatViewProps) {
56685712
{panelToggleControls}
56695713
</div>
56705714
);
5715+
// Fork: the controls float over whichever surface owns the top of the window —
5716+
// the right panel's tab bar when it sits beside the chat, the chat header when
5717+
// the panel is closed or split off the bottom. In the sheet layout they ride
5718+
// along inside the sheet instead.
5719+
const chatHeaderHostsLayoutControls = !rightPanelOpen || screenSplitHorizontally;
56715720
const rightPanelContent = activeThreadRef ? (
56725721
activeRightPanelSurface?.kind === "preview" ? (
56735722
<Suspense fallback={null}>
@@ -5744,8 +5793,14 @@ function ChatViewContent(props: ChatViewProps) {
57445793
) : null;
57455794

57465795
return (
5747-
<div className="relative flex min-h-0 min-w-0 flex-1 overflow-hidden bg-background">
5748-
{rightPanelOpen && !shouldUsePlanSidebarSheet ? panelLayoutControls : null}
5796+
<div
5797+
className={cn(
5798+
"relative flex min-h-0 min-w-0 flex-1 overflow-hidden bg-background",
5799+
screenSplitHorizontally && "flex-col",
5800+
)}
5801+
data-chat-split={screenSplitHorizontally ? "horizontal" : "vertical"}
5802+
>
5803+
{inlineRightPanelOwnsTitleBar ? panelLayoutControls : null}
57495804
<div
57505805
className={cn(
57515806
"flex min-h-0 min-w-0 flex-col overflow-x-hidden",
@@ -5769,7 +5824,7 @@ function ChatViewContent(props: ChatViewProps) {
57695824
COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS,
57705825
)}
57715826
>
5772-
{!rightPanelOpen ? panelLayoutControls : null}
5827+
{chatHeaderHostsLayoutControls ? panelLayoutControls : null}
57735828
<ChatHeader
57745829
activeThreadEnvironmentId={activeThread.environmentId}
57755830
activeThreadId={activeThread.id}
@@ -5785,6 +5840,7 @@ function ChatViewContent(props: ChatViewProps) {
57855840
keybindings={keybindings}
57865841
availableEditors={availableEditors}
57875842
rightPanelOpen={rightPanelOpen}
5843+
layoutControlsOverHeader={screenSplitHorizontally}
57885844
gitCwd={gitCwd}
57895845
onNewThreadInProject={handleNewThreadInActiveProject}
57905846
onRunProjectScript={runProjectScript}
@@ -6134,6 +6190,7 @@ function ChatViewContent(props: ChatViewProps) {
61346190
<RightPanelTabs
61356191
threadRef={activeThreadRef}
61366192
mode="inline"
6193+
orientation={screenSplitHorizontally ? "bottom" : "right"}
61376194
maximized={rightPanelMaximized}
61386195
surfaces={rightPanelState.surfaces}
61396196
activeSurfaceId={activeRightPanelSurface?.id ?? null}

‎apps/web/src/components/RightPanelTabs.tsx‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
} from "react";
1313

1414
import { isElectron } from "~/env";
15+
import type { RightPanelOrientation } from "~/rightPanelOrientation";
1516
import type { RightPanelSurface } from "~/rightPanelStore";
1617
import { cn } from "~/lib/utils";
1718
import { readLocalApi } from "~/localApi";
@@ -28,6 +29,14 @@ import { RightPanelDisabledState } from "./sandbox/RightPanelDisabledState";
2829

2930
interface RightPanelTabsProps {
3031
mode: PreviewPanelMode;
32+
/**
33+
* Fork: inline only — whether the panel sits beside the chat column or under
34+
* it.
35+
* When it sits beside, its tab bar doubles as the window title bar and has to
36+
* leave room for the floating layout controls; stacked under the chat, the
37+
* chat header keeps them.
38+
*/
39+
orientation?: RightPanelOrientation;
3140
maximized?: boolean;
3241
layoutControls?: ReactNode;
3342
surfaces: readonly RightPanelSurface[];
@@ -139,9 +148,7 @@ function RightPanelEmptyState(props: {
139148
<div className="w-full max-w-xl">
140149
<div className="mb-5 text-center">
141150
<h3 className="text-sm font-medium text-foreground">Open a surface</h3>
142-
<p className="mt-1 text-xs text-muted-foreground">
143-
Choose what to show in the right panel.
144-
</p>
151+
<p className="mt-1 text-xs text-muted-foreground">Choose what to show in the panel.</p>
145152
</div>
146153
<div className="grid grid-cols-2 gap-2">
147154
{actions.map((action) => {
@@ -281,7 +288,8 @@ function SurfaceIcon({
281288
}
282289

283290
export function RightPanelTabs(props: RightPanelTabsProps) {
284-
const ownsDesktopTitleBar = isElectron && props.mode === "inline";
291+
const ownsTitleBar = props.mode === "inline" && props.orientation !== "bottom";
292+
const ownsDesktopTitleBar = isElectron && ownsTitleBar;
285293
const { resolvedTheme } = useTheme();
286294
const tabListRef = useRef<HTMLDivElement>(null);
287295
const surfaceDisabledReason =
@@ -369,15 +377,16 @@ export function RightPanelTabs(props: RightPanelTabsProps) {
369377
return (
370378
<PreviewPanelShell
371379
mode={props.mode}
380+
{...(props.orientation !== undefined ? { orientation: props.orientation } : {})}
372381
{...(props.maximized !== undefined ? { maximized: props.maximized } : {})}
373382
>
374383
<div
375384
className={cn(
376385
"workspace-topbar gap-1 pl-2",
377386
!ownsDesktopTitleBar && "[--workspace-topbar-height:--spacing(11)]",
378-
props.mode === "inline" ? "pr-28" : "pr-3",
387+
ownsTitleBar ? "pr-28" : "pr-3",
379388
ownsDesktopTitleBar && "wco:pr-[calc(var(--workspace-native-controls-inset)+6rem)]",
380-
props.mode === "inline" && props.maximized && COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS,
389+
ownsTitleBar && props.maximized && COLLAPSED_SIDEBAR_TITLEBAR_INSET_CLASS,
381390
)}
382391
data-right-panel-tabbar
383392
>

‎apps/web/src/components/chat/ChatHeader.tsx‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ interface ChatHeaderProps {
3434
keybindings: ResolvedKeybindingsConfig;
3535
availableEditors: ReadonlyArray<EditorId>;
3636
rightPanelOpen: boolean;
37+
/**
38+
* Fork: with the screen split horizontally the right panel is open but sits
39+
* under the chat, so the floating layout controls stay over this header and
40+
* the actions still have to stop short of them.
41+
*/
42+
layoutControlsOverHeader?: boolean;
3743
gitCwd: string | null;
3844
onNewThreadInProject: () => void;
3945
onRunProjectScript: (script: ProjectScript) => void;
@@ -70,6 +76,7 @@ export const ChatHeader = memo(function ChatHeader({
7076
keybindings,
7177
availableEditors,
7278
rightPanelOpen,
79+
layoutControlsOverHeader,
7380
gitCwd,
7481
onNewThreadInProject,
7582
onRunProjectScript,
@@ -138,7 +145,7 @@ export const ChatHeader = memo(function ChatHeader({
138145
data-chat-header-actions
139146
className={cn(
140147
"flex shrink-0 items-center justify-end gap-2 @3xl/header-actions:gap-3",
141-
rightPanelOpen ? "pr-0" : "pr-16",
148+
rightPanelOpen && !layoutControlsOverHeader ? "pr-0" : "pr-16",
142149
)}
143150
>
144151
{activeProjectScripts && FEATURES.projectScripts && (

‎apps/web/src/components/chat/PanelLayoutControls.tsx‎

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { Maximize2Icon, Minimize2Icon, PanelBottomIcon, PanelRightIcon } from "lucide-react";
1+
import {
2+
Maximize2Icon,
3+
Minimize2Icon,
4+
PanelBottomIcon,
5+
PanelRightIcon,
6+
Rows2Icon,
7+
} from "lucide-react";
28
import { memo } from "react";
39

410
import { Toggle } from "../ui/toggle";
@@ -11,8 +17,13 @@ interface PanelLayoutControlsProps {
1117
rightPanelAvailable: boolean;
1218
rightPanelOpen: boolean;
1319
rightPanelShortcutLabel: string | null;
20+
// Fork: the third toggle, for the panel placement upstream does not have.
21+
horizontalSplitAvailable: boolean;
22+
horizontalSplit: boolean;
23+
horizontalSplitShortcutLabel: string | null;
1424
onToggleTerminal: () => void;
1525
onToggleRightPanel: () => void;
26+
onToggleHorizontalSplit: () => void;
1627
}
1728

1829
export const PanelLayoutControls = memo(function PanelLayoutControls({
@@ -22,9 +33,16 @@ export const PanelLayoutControls = memo(function PanelLayoutControls({
2233
rightPanelAvailable,
2334
rightPanelOpen,
2435
rightPanelShortcutLabel,
36+
horizontalSplitAvailable,
37+
horizontalSplit,
38+
horizontalSplitShortcutLabel,
2539
onToggleTerminal,
2640
onToggleRightPanel,
41+
onToggleHorizontalSplit,
2742
}: PanelLayoutControlsProps) {
43+
const horizontalSplitLabel = horizontalSplit
44+
? "Split screen vertically"
45+
: "Split screen horizontally";
2846
return (
2947
<div
3048
className="flex h-full shrink-0 items-center gap-1 [-webkit-app-region:no-drag]"
@@ -74,6 +92,28 @@ export const PanelLayoutControls = memo(function PanelLayoutControls({
7492
: "Right panel is unavailable"}
7593
</TooltipPopup>
7694
</Tooltip>
95+
<Tooltip>
96+
<TooltipTrigger
97+
render={
98+
<Toggle
99+
className="shrink-0 [-webkit-app-region:no-drag]"
100+
pressed={horizontalSplit}
101+
onPressedChange={onToggleHorizontalSplit}
102+
aria-label={horizontalSplitLabel}
103+
variant="ghost"
104+
size="sm"
105+
disabled={!horizontalSplitAvailable}
106+
>
107+
<Rows2Icon className="size-3.5" />
108+
</Toggle>
109+
}
110+
/>
111+
<TooltipPopup side="bottom">
112+
{horizontalSplitAvailable
113+
? `${horizontalSplitLabel}${horizontalSplitShortcutLabel ? ` (${horizontalSplitShortcutLabel})` : ""}`
114+
: "Splitting the screen is unavailable"}
115+
</TooltipPopup>
116+
</Tooltip>
77117
</div>
78118
);
79119
});

‎apps/web/src/components/preview/PreviewPanelShell.tsx‎

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { type ReactNode, useEffect, useState } from "react";
22

33
import { isElectron } from "~/env";
4+
import { useResizablePanelHeight } from "~/hooks/useResizablePanelHeight";
45
import { useResizableWidth } from "~/hooks/useResizableWidth";
56
import { cn } from "~/lib/utils";
7+
import type { RightPanelOrientation } from "~/rightPanelOrientation";
68

79
import { RightPanelResizeHandle } from "./RightPanelResizeHandle";
810

@@ -25,6 +27,8 @@ export function getPreviewPanelMaxWidth(viewportWidth: number): number {
2527
*/
2628
export function PreviewPanelShell(props: {
2729
mode: PreviewPanelMode;
30+
/** Fork: inline only — whether the panel sits beside the chat or under it. */
31+
orientation?: RightPanelOrientation;
2832
maximized?: boolean;
2933
children: ReactNode;
3034
}) {
@@ -38,6 +42,10 @@ export function PreviewPanelShell(props: {
3842
maxWidth,
3943
edge: "left",
4044
});
45+
// Fork: the other placement. Maximized takes the whole area, so it has no
46+
// edge left to drag and no orientation left to honour.
47+
const { height, handlers: heightHandlers } = useResizablePanelHeight();
48+
const stacked = isInline && !props.maximized && props.orientation === "bottom";
4149

4250
return (
4351
<div
@@ -48,12 +56,28 @@ export function PreviewPanelShell(props: {
4856
? "flex-1 border-l border-border"
4957
: "shrink-0 border-l border-border"
5058
: "w-full",
59+
// Fork: under the chat the panel spans the width, and its border and
60+
// its size run the other way.
61+
stacked && "h-auto w-full border-t border-l-0 border-border",
5162
)}
52-
style={isInline && !props.maximized ? { width: `${width}px` } : undefined}
63+
style={
64+
isInline && !props.maximized
65+
? stacked
66+
? { height: `${height}px` }
67+
: { width: `${width}px` }
68+
: undefined
69+
}
5370
data-preview-panel-mode={props.mode}
71+
data-preview-panel-orientation={stacked ? "bottom" : "right"}
5472
data-preview-panel-maximized={props.maximized ? "true" : "false"}
5573
>
56-
{isInline && !props.maximized ? <RightPanelResizeHandle handlers={handlers} /> : null}
74+
{isInline && !props.maximized ? (
75+
stacked ? (
76+
<RightPanelResizeHandle edge="top" handlers={heightHandlers} />
77+
) : (
78+
<RightPanelResizeHandle handlers={handlers} />
79+
)
80+
) : null}
5781
{useDragRegion ? <div className="electron-drag-region h-0 w-full" aria-hidden /> : null}
5882
{props.children}
5983
</div>

0 commit comments

Comments
 (0)