@devries-cameron20 / t3code-1 / commits / 8da8f613ff
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

refactor(web): ChatView's right panel lives in its own component (#22700)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

Julius Marminge committed Oct 21, 2026 at 01:36 UTC 8da8f613ffdaaed6f3b01bf6d461f34e40b8b859
3 files changed +66 -69
apps/web/src/components/ChatView.tsx
+14 -68
@@ -212,7 +212,6 @@ import { settleAndAdvance } from "../settleAndAdvance";
212 import { subscribeSnapShotComposerFocus } from "../lib/desktopSnapShot";
213 import { useMediaQuery } from "../hooks/useMediaQuery";
214 import { FileMetadataThreadProvider } from "../hooks/FileMetadataThreadProvider";
215 -import { usePreviewPanelInlineSize } from "../hooks/usePreviewPanelInlineSize";
215 import {
216 RIGHT_PANEL_INLINE_LAYOUT_MEDIA_QUERY,
217 type ThreadPanelPresentation,
@@ -247,7 +246,6 @@ import {
246 usePreviewMiniPlayerStore,
247 } from "../previewMiniPlayerStore";
248 import { threadPullRequestPanelTarget } from "./pullRequest/pullRequestDetail.logic";
250 -import { RightPanelTabs } from "./RightPanelTabs";
249 import { LinkPullRequestDialogHost } from "./pullRequest/LinkPullRequestDialog";
250 import { useDeviceState } from "~/state/device";
251 import { BranchToolbar, type BranchToolbarHandle } from "./BranchToolbar";
@@ -509,7 +507,6 @@ import {
507 retryAttachmentUpload,
508 startAttachmentUpload,
509 } from "../lib/attachmentUploadQueue";
512 -import { RightPanelSheet } from "./RightPanelSheet";
510 import { previewEnvironment } from "../state/preview";
511 import { clampFileAttachmentUploadBytes } from "@t3tools/client-runtime/state/attachments";
512 import { appAtomRegistry } from "../rpc/atomRegistry";
@@ -544,6 +541,7 @@ import {
541 import { observeResize } from "~/lib/observeResize";
542 import { ThreadVisitWatermark } from "./chat/ThreadVisitWatermark";
543 import { ChatTerminalDrawers } from "./chat/ChatTerminalDrawers";
544 +import { ChatRightPanel } from "./chat/ChatRightPanel";
545 import { useDraftHeroLayoutTransition } from "./chat/useDraftHeroLayoutTransition";
546 import { useLocalDispatchState } from "./chat/useLocalDispatchState";
547 import {
@@ -1209,10 +1207,6 @@ export default function ChatView(props: ChatViewProps) {
1207 activeThreadRef?.environmentId ?? null,
1208 );
1209 const browserAvailable = isPreviewSupportedInRuntime() || activeEnvironmentServerBrowser;
1212 - const previewPanelInlineSize = usePreviewPanelInlineSize(undefined, {
1213 - container: workspaceLayoutElement,
1214 - widthStorageKey: `t3code:preview-panel-width:${activeThreadKey}`,
1215 - });
1210 const activeThreadShell = serverThread;
1211 const timelineThreadError =
1212 serverRuntime?.status === "failed" &&
@@ -8405,14 +8399,22 @@ export default function ChatView(props: ChatViewProps) {
8399 />
8400 </div>
8401
8408 - {rightPanelPresent && !shouldUsePlanSidebarSheet && activeThreadRef ? (
8409 - <RightPanelTabs
8410 - mode="inline"
8402 + {rightPanelPresent && activeThreadRef ? (
8403 + <ChatRightPanel
8404 + sheet={shouldUsePlanSidebarSheet}
8405 + workspaceLayoutElement={workspaceLayoutElement}
8406 + widthStorageKey={`t3code:preview-panel-width:${activeThreadKey}`}
8407 + sheetAnimationDurationMs={panelAnimationsActive ? panelAnimationDurationMs : 0}
8408 + onCloseSheet={closePreviewPanelStable}
8409 open={rightPanelOpen}
8410 keybindings={keybindings}
8411 getShortcutContext={getShortcutContextStable}
8412 maximized={rightPanelMaximized}
8415 - inlineSize={previewPanelInlineSize}
8413 + layoutControls={
8414 + rightPanelOpen ? (
8415 + <div className="mr-px flex items-center">{panelToggleControls}</div>
8416 + ) : null
8417 + }
8418 surfaces={renderedRightPanelSurfaces}
8419 environmentId={activeThreadRef.environmentId}
8420 activeSurfaceId={renderedRightPanelSurface?.id ?? null}
@@ -8449,63 +8451,7 @@ export default function ChatView(props: ChatViewProps) {
8451 deviceAvailable={activeThreadRef !== null}
8452 >
8453 {rightPanelContent}
8452 - </RightPanelTabs>
8453 - ) : null}
8454 - {rightPanelPresent && shouldUsePlanSidebarSheet && activeThreadRef ? (
8455 - <RightPanelSheet
8456 - animationDurationMs={panelAnimationsActive ? panelAnimationDurationMs : 0}
8457 - open={rightPanelOpen}
8458 - onClose={closePreviewPanelStable}
8459 - >
8460 - <RightPanelTabs
8461 - mode="sheet"
8462 - open={rightPanelOpen}
8463 - keybindings={keybindings}
8464 - getShortcutContext={getShortcutContextStable}
8465 - inlineSize={previewPanelInlineSize}
8466 - layoutControls={
8467 - rightPanelOpen ? (
8468 - <div className="mr-px flex items-center">{panelToggleControls}</div>
8469 - ) : null
8470 - }
8471 - surfaces={renderedRightPanelSurfaces}
8472 - environmentId={activeThreadRef.environmentId}
8473 - activeSurfaceId={renderedRightPanelSurface?.id ?? null}
8474 - pendingSurfaceIds={pendingFileSurfaceIds}
8475 - previewSessions={activePreviewState.sessions}
8476 - desktopByTabId={activePreviewState.desktopByTabId}
8477 - previewRuntimeTabId={resolvePreviewRuntimeTabId}
8478 - terminalLabelsById={activeTerminalLabelsById}
8479 - onActivate={activateRightPanelSurfaceStable}
8480 - onCloseSurface={closeRightPanelSurfaceStable}
8481 - onRenameDevice={(surfaceId, title) => {
8482 - if (activeThreadRef)
8483 - useRightPanelStore.getState().renameDevice(activeThreadRef, surfaceId, title);
8484 - }}
8485 - onCloseOtherSurfaces={closeOtherRightPanelSurfacesStable}
8486 - onCloseSurfacesToRight={closeRightPanelSurfacesToRightStable}
8487 - onCloseAllSurfaces={closeAllRightPanelSurfacesStable}
8488 - onMoveSurface={moveRightPanelSurfaceStable}
8489 - onCopyFilePath={copyRightPanelFilePathStable}
8490 - onAddBrowser={() => createBrowserSurface()}
8491 - onAddBrowserInProfile={createBrowserSurfaceStable}
8492 - onAddTerminal={addTerminalSurfaceStable}
8493 - onAddDiff={addDiffSurfaceStable}
8494 - onAddFiles={addFilesSurfaceStable}
8495 - onAddPullRequest={addPullRequestSurfaceStable}
8496 - onAddPullRequests={addPullRequestsSurfaceStable}
8497 - onAddDevice={addDeviceSurfaceStable}
8498 - browserAvailable={canOperatePreview && browserAvailable}
8499 - terminalAvailable={activeProject !== null && canOperateTerminal}
8500 - diffAvailable={isServerThread && isGitRepo}
8501 - filesAvailable={activeProject !== null}
8502 - pullRequestAvailable={pullRequestSurfaceAvailable}
8503 - pullRequestsAvailable={pullRequestsSurfaceAvailable}
8504 - deviceAvailable={activeThreadRef !== null}
8505 - >
8506 - {rightPanelContent}
8507 - </RightPanelTabs>
8508 - </RightPanelSheet>
8454 + </ChatRightPanel>
8455 ) : null}
8456
8457 <RevertConfirmHost threadKey={routeThreadKey} onConfirm={onConfirmRevertStable} />
apps/web/src/components/RightPanelTabs.tsx
+1 -1
@@ -93,7 +93,7 @@ import { resolvePullRequestState } from "./pullRequest/pullRequestPresentation";
93 import { PullRequestGlyph } from "~/components/pullRequest/pullRequestIcons";
94 import { observeResize } from "~/lib/observeResize";
95
96 -interface RightPanelTabsProps {
96 +export interface RightPanelTabsProps {
97 mode: PreviewPanelMode;
98 maximized?: boolean;
99 open?: boolean;
apps/web/src/components/chat/ChatRightPanel.tsx new
+51
@@ -0,0 +1,51 @@
1 +import { usePreviewPanelInlineSize } from "../../hooks/usePreviewPanelInlineSize";
2 +import { RightPanelSheet } from "../RightPanelSheet";
3 +import { RightPanelTabs, type RightPanelTabsProps } from "../RightPanelTabs";
4 +
5 +type ChatRightPanelProps = Omit<RightPanelTabsProps, "mode" | "inlineSize" | "maximized"> & {
6 + readonly sheet: boolean;
7 + readonly maximized: boolean;
8 + readonly workspaceLayoutElement: HTMLElement | null;
9 + readonly widthStorageKey: string;
10 + readonly sheetAnimationDurationMs: number;
11 + readonly onCloseSheet: () => void;
12 +};
13 +
14 +/**
15 + * The right panel, inline beside the chat column or as a sheet on narrow
16 + * layouts. Its width follows a resize drag every frame, so the width state
17 + * lives here rather than in ChatView.
18 + */
19 +export function ChatRightPanel(props: ChatRightPanelProps) {
20 + const {
21 + sheet,
22 + workspaceLayoutElement,
23 + widthStorageKey,
24 + sheetAnimationDurationMs,
25 + onCloseSheet,
26 + maximized,
27 + layoutControls,
28 + ...tabs
29 + } = props;
30 + const inlineSize = usePreviewPanelInlineSize(undefined, {
31 + container: workspaceLayoutElement,
32 + widthStorageKey,
33 + });
34 + if (!sheet) {
35 + return <RightPanelTabs {...tabs} mode="inline" maximized={maximized} inlineSize={inlineSize} />;
36 + }
37 + return (
38 + <RightPanelSheet
39 + animationDurationMs={sheetAnimationDurationMs}
40 + open={tabs.open === true}
41 + onClose={onCloseSheet}
42 + >
43 + <RightPanelTabs
44 + {...tabs}
45 + mode="sheet"
46 + inlineSize={inlineSize}
47 + layoutControls={layoutControls}
48 + />
49 + </RightPanelSheet>
50 + );
51 +}