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 23, 08:00 UTC
refactor(web): move the right panel's surface switch out of ChatView (#20421)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 18:06 UTC
f5cb328aac19302a45a3fe9f7e6864a198cdb1ad
4 files changed
+278
-185
apps/web/reactCompiledFiles.ts
+1
@@ -11,6 +11,7 @@ export const REACT_COMPILED_FILES = [
11
"apps/web/src/components/chat/ChatComposer.tsx",
12
"apps/web/src/components/chat/usePendingThreadRequests.ts",
13
"apps/web/src/components/chat/MessagesTimeline.tsx",
14
+ "apps/web/src/components/chat/RightPanelSurfaceContent.tsx",
15
"apps/web/src/components/chat/composerFocusRedirect.ts",
16
"apps/web/src/components/chat/useChatShortcuts.ts",
17
"apps/web/src/components/chat/useProjectScriptEditing.ts",
apps/web/src/components/ChatView.tsx
+58
-184
@@ -26,6 +26,7 @@ import { useLoadBalancedEnvironment } from "../hooks/useLoadBalancedEnvironment"
26
import { useScratchProject } from "../hooks/useScratchProject";
27
import { useStableCallback } from "../hooks/useStableCallback";
28
import { useProjectScriptEditing } from "./chat/useProjectScriptEditing";
29
+import { RightPanelSurfaceContent } from "./chat/RightPanelSurfaceContent";
30
import { useThreadTerminalActions } from "./terminal/useThreadTerminalActions";
31
import { usePendingThreadRequests } from "./chat/usePendingThreadRequests";
32
import { isScratchProject } from "@t3tools/client-runtime/state/projects";
@@ -141,9 +142,7 @@ import { useAtomValue } from "@effect/atom-react";
142
import { Atom } from "effect/reactivity";
143
import {
144
Fragment,
144
- lazy,
145
type SetStateAction,
146
- Suspense,
146
useEffect,
147
useEffectEvent,
148
useLayoutEffect,
@@ -249,16 +248,9 @@ import {
248
selectThreadPreviewMiniPlayer,
249
usePreviewMiniPlayerStore,
250
} from "../previewMiniPlayerStore";
252
-import {
253
- pullRequestPanelContext,
254
- threadPullRequestPanelTarget,
255
-} from "./pullRequest/pullRequestDetail.logic";
256
-import { PullRequestDetailPanel } from "./pullRequest/PullRequestDetailPanel";
257
-import { PullRequestDetailGhost } from "./pullRequest/PullRequestGhosts";
258
-import { PullRequestsUnavailableState } from "./pullRequest/PullRequestsUnavailableState";
251
+import { threadPullRequestPanelTarget } from "./pullRequest/pullRequestDetail.logic";
252
import { RightPanelTabs } from "./RightPanelTabs";
253
import { LinkPullRequestDialogHost } from "./pullRequest/LinkPullRequestDialog";
261
-import { ThreadPullRequestsPanel } from "./pullRequest/ThreadPullRequestsPanel";
254
import { useDeviceState } from "~/state/device";
255
import { DeviceSetup } from "./device/DeviceSetup";
256
import { Dialog } from "./ui/dialog";
@@ -268,10 +260,7 @@ import { makeWorkspaceFileDropHandlers } from "./chat/workspaceFileDrop";
260
import { isEditableFocused } from "../lib/editableFocus";
261
import { DEFAULT_RESOLVED_KEYBINDINGS } from "@t3tools/shared/keybindings";
262
import { shortcutLabelForCommand } from "../keybindings";
271
-import {
272
- PersistentThreadTerminalDrawer,
273
- PersistentThreadTerminalPanel,
274
-} from "./PersistentThreadTerminals";
263
+import { PersistentThreadTerminalDrawer } from "./PersistentThreadTerminals";
264
import {
265
AlarmClockIcon,
266
CheckCircle2Icon,
@@ -638,14 +627,6 @@ function useDraftHeroLayoutTransition(
627
return { transitionGroupRef, composerAnchorRef, captureComposerRect } as const;
628
}
629
641
-const PreviewPanel = lazy(() =>
642
- import("./preview/PreviewPanel").then((module) => ({ default: module.PreviewPanel })),
643
-);
644
-const DiffPanel = lazy(() => import("./DiffPanel"));
645
-const DevicePanel = lazy(() =>
646
- import("./device/DevicePanel").then((module) => ({ default: module.DevicePanel })),
647
-);
648
-const FilePreviewPanel = lazy(() => import("./files/FilePreviewPanel"));
630
const EMPTY_PENDING_FILE_SURFACE_IDS: ReadonlySet<string> = new Set();
631
type EnvironmentUnavailableState = {
632
readonly environmentId: EnvironmentId;
@@ -7616,6 +7597,13 @@ export default function ChatView(props: ChatViewProps) {
7597
};
7598
const onWorktreeSetupWorkLocallyStable = useStableCallback(onWorktreeSetupWorkLocally);
7599
const onComposerSendStable = useStableCallback(onSend);
7600
+ const sendPreviewAnnotation = (
7601
+ annotation: PreviewAnnotationPayload,
7602
+ image: ComposerImageAttachment | null,
7603
+ ) => {
7604
+ void onSend(undefined, "auto", "foreground", { annotation, image });
7605
+ };
7606
+ const sendPreviewAnnotationStable = useStableCallback(sendPreviewAnnotation);
7607
const onComposerResumeStable = useStableCallback(onResume);
7608
const onComposerCompactContextStable = useStableCallback(onCompactContext);
7609
const queuedRunsControl =
@@ -7768,169 +7756,55 @@ export default function ChatView(props: ChatViewProps) {
7756
}
7757
7758
const rightPanelContent = activeThreadRef ? (
7771
- renderedRightPanelSurface?.kind === "preview" ? (
7772
- <Suspense fallback={null}>
7773
- <PreviewPanel
7774
- mode="embedded"
7775
- threadRef={activeThreadRef}
7776
- tabId={renderedRightPanelSurface.resourceId}
7777
- configuredUrls={configuredPreviewUrls}
7778
- visible={rightPanelOpen}
7779
- onSendAnnotation={(annotation, image) => {
7780
- void onSend(undefined, "auto", "foreground", { annotation, image });
7781
- }}
7782
- />
7783
- </Suspense>
7784
- ) : renderedRightPanelSurface?.kind === "terminal" ? (
7785
- <PersistentThreadTerminalPanel
7786
- visible={rightPanelOpen}
7787
- threadRef={activeThreadRef}
7788
- surface={renderedRightPanelSurface}
7789
- launchContext={activeTerminalLaunchContext ?? null}
7790
- focusRequestId={terminalFocusRequestId}
7791
- keybindings={keybindings}
7792
- onAddTerminalContext={addTerminalContextToDraftStable}
7793
- onSplitTerminal={splitPanelTerminalStable}
7794
- onSplitTerminalVertical={splitPanelTerminalVerticalStable}
7795
- onNewTerminal={addTerminalSurfaceStable}
7796
- onActiveTerminalChange={activatePanelTerminalStable}
7797
- onCloseTerminal={closePanelTerminalStable}
7798
- splitShortcutLabel={splitTerminalShortcutLabel ?? undefined}
7799
- splitVerticalShortcutLabel={splitTerminalVerticalShortcutLabel ?? undefined}
7800
- newShortcutLabel={newTerminalShortcutLabel ?? undefined}
7801
- closeShortcutLabel={closeTerminalShortcutLabel ?? undefined}
7802
- />
7803
- ) : renderedRightPanelSurface?.kind === "diff" ? (
7804
- <Suspense fallback={null}>
7805
- <DiffPanel
7806
- key={activeThreadKey}
7807
- mode="embedded"
7808
- composerDraftTarget={composerDraftTarget}
7809
- workspaceMutationId={workspaceMutationId}
7810
- />
7811
- </Suspense>
7812
- ) : renderedRightPanelSurface?.kind === "pull-request" && !pullRequestsCapabilityKnown ? (
7813
- <PullRequestDetailGhost />
7814
- ) : renderedRightPanelSurface?.kind === "pull-request" && !supportsPullRequests ? (
7815
- <PullRequestsUnavailableState
7816
- title="Pull requests unavailable"
7817
- error="Update this environment's T3 Code server to browse pull requests."
7818
- />
7819
- ) : renderedRightPanelSurface?.kind === "pull-request" ? (
7820
- <PullRequestDetailPanel
7821
- getShortcutContext={getShortcutContextStable}
7822
- shortcutsEnabled={
7823
- rightPanelOpen && activeRightPanelSurface?.id === renderedRightPanelSurface.id
7824
- }
7825
- key={`${renderedRightPanelSurface.host ?? ""}:${renderedRightPanelSurface.repository}#${renderedRightPanelSurface.number}`}
7826
- environmentId={activeThread.environmentId}
7827
- onSelectPullRequest={(reference) => {
7828
- if (activeThreadRef)
7829
- useRightPanelStore.getState().openPullRequest(activeThreadRef, {
7830
- projectId: reference.projectId,
7831
- repository: reference.repository,
7832
- number: reference.number,
7833
- ...(reference.host ? { host: reference.host } : {}),
7834
- });
7835
- }}
7836
- threadRef={activeThreadRef}
7837
- reference={{
7838
- projectId: renderedRightPanelSurface.projectId as ProjectId,
7839
- ...(renderedRightPanelSurface.host ? { host: renderedRightPanelSurface.host } : {}),
7840
- repository: renderedRightPanelSurface.repository,
7841
- number: renderedRightPanelSurface.number,
7842
- }}
7843
- context={pullRequestPanelContext(
7844
- {
7845
- projectId: activeThread.projectId,
7846
- pullRequests: visiblePullRequests,
7847
- linkedPullRequest: linkedThreadPullRequest,
7848
- branchPullRequest:
7849
- activeThreadShell?.branchPullRequest ?? activeThread.branchPullRequest,
7850
- },
7851
- renderedRightPanelSurface,
7852
- )}
7853
- composerDraftTarget={composerDraftTarget}
7854
- onBack={
7855
- activeThreadRef !== null && pullRequestsSurfaceAvailable && visiblePullRequestCount > 1
7759
+ <RightPanelSurfaceContent
7760
+ surface={renderedRightPanelSurface}
7761
+ activeSurfaceId={activeRightPanelSurface?.id ?? null}
7762
+ threadRef={activeThreadRef}
7763
+ environmentId={activeThread.environmentId}
7764
+ visible={rightPanelOpen}
7765
+ composerDraftTarget={composerDraftTarget}
7766
+ keybindings={keybindings}
7767
+ configuredPreviewUrls={configuredPreviewUrls}
7768
+ workspaceMutationId={workspaceMutationId}
7769
+ getShortcutContext={getShortcutContextStable}
7770
+ onSendAnnotation={sendPreviewAnnotationStable}
7771
+ onCloseSurface={closeRightPanelSurface}
7772
+ terminal={{
7773
+ launchContext: activeTerminalLaunchContext ?? null,
7774
+ focusRequestId: terminalFocusRequestId,
7775
+ keybindings,
7776
+ onAddTerminalContext: addTerminalContextToDraftStable,
7777
+ onSplitTerminal: splitPanelTerminalStable,
7778
+ onSplitTerminalVertical: splitPanelTerminalVerticalStable,
7779
+ onNewTerminal: addTerminalSurfaceStable,
7780
+ onActiveTerminalChange: activatePanelTerminalStable,
7781
+ onCloseTerminal: closePanelTerminalStable,
7782
+ splitShortcutLabel: splitTerminalShortcutLabel ?? undefined,
7783
+ splitVerticalShortcutLabel: splitTerminalVerticalShortcutLabel ?? undefined,
7784
+ newShortcutLabel: newTerminalShortcutLabel ?? undefined,
7785
+ closeShortcutLabel: closeTerminalShortcutLabel ?? undefined,
7786
+ }}
7787
+ pullRequest={{
7788
+ capabilityKnown: pullRequestsCapabilityKnown,
7789
+ supported: supportsPullRequests,
7790
+ projectId: activeThread.projectId,
7791
+ pullRequests: visiblePullRequests,
7792
+ linkedPullRequest: linkedThreadPullRequest,
7793
+ branchPullRequest: activeThreadShell?.branchPullRequest ?? activeThread.branchPullRequest,
7794
+ onBack:
7795
+ pullRequestsSurfaceAvailable && visiblePullRequestCount > 1
7796
? addPullRequestsSurfaceStable
7857
- : undefined
7858
- }
7859
- />
7860
- ) : renderedRightPanelSurface?.kind === "pull-requests" && activeThreadRef ? (
7861
- <ThreadPullRequestsPanel threadRef={activeThreadRef} />
7862
- ) : renderedRightPanelSurface?.kind === "device" ? (
7863
- <Suspense fallback={null}>
7864
- <DevicePanel
7865
- mode="embedded"
7866
- threadRef={activeThreadRef}
7867
- key={renderedRightPanelSurface.id}
7868
- surface={renderedRightPanelSurface}
7869
- visible={rightPanelOpen}
7870
- onDismissSetup={() => {
7871
- closeRightPanelSurface(renderedRightPanelSurface);
7872
- useRightPanelStore.getState().show(activeThreadRef);
7873
- }}
7874
- />
7875
- </Suspense>
7876
- ) : (renderedRightPanelSurface?.kind === "files" ||
7877
- renderedRightPanelSurface?.kind === "file") &&
7878
- ((activeProject && activeWorkspaceRoot) ||
7879
- (renderedRightPanelSurface.kind === "file" && renderedRightPanelSurface.attachment)) ? (
7880
- <Suspense fallback={null}>
7881
- <FilePreviewPanel
7882
- key={`${activeThread.environmentId}:${
7883
- renderedRightPanelSurface.kind === "file" && renderedRightPanelSurface.attachment
7884
- ? `attachment:${renderedRightPanelSurface.attachment.id}`
7885
- : activeWorkspaceRoot
7886
- }`}
7887
- environmentId={activeThread.environmentId}
7888
- cwd={activeWorkspaceRoot ?? ""}
7889
- projectName={activeProject?.title ?? ""}
7890
- threadRef={activeThreadRef}
7891
- composerDraftTarget={composerDraftTarget}
7892
- keybindings={keybindings}
7893
- availableEditors={availableEditors}
7894
- relativePath={
7895
- renderedRightPanelSurface.kind === "file"
7896
- ? renderedRightPanelSurface.relativePath
7897
- : null
7898
- }
7899
- {...(renderedRightPanelSurface.kind === "file" && renderedRightPanelSurface.attachment
7900
- ? { attachment: renderedRightPanelSurface.attachment }
7901
- : {})}
7902
- revealLine={
7903
- renderedRightPanelSurface.kind === "file"
7904
- ? (renderedRightPanelSurface.revealLine ?? null)
7905
- : null
7906
- }
7907
- revealRequestId={
7908
- renderedRightPanelSurface.kind === "file"
7909
- ? renderedRightPanelSurface.revealRequestId
7910
- : 0
7911
- }
7912
- onOpenFile={openFileSurfaceStable}
7913
- onNavigateFolder={(relativePath, folderTrail, keepSource) =>
7914
- useRightPanelStore
7915
- .getState()
7916
- .navigateFolder(
7917
- activeThreadRef,
7918
- renderedRightPanelSurface.id,
7919
- relativePath,
7920
- folderTrail,
7921
- keepSource,
7922
- )
7923
- }
7924
- folderTrail={renderedRightPanelSurface.folderTrail}
7925
- onPendingChange={handleFilePendingChangeStable}
7926
- selectedFilePending={
7927
- renderedRightPanelSurface.kind === "file" &&
7928
- pendingFileSurfaceIds.has(renderedRightPanelSurface.id)
7929
- }
7930
- workspaceMutationId={workspaceMutationId}
7931
- />
7932
- </Suspense>
7933
- ) : null
7797
+ : undefined,
7798
+ }}
7799
+ files={{
7800
+ projectName: activeProject?.title ?? null,
7801
+ workspaceRoot: activeWorkspaceRoot,
7802
+ availableEditors,
7803
+ pendingSurfaceIds: pendingFileSurfaceIds,
7804
+ onOpenFile: openFileSurfaceStable,
7805
+ onPendingChange: handleFilePendingChangeStable,
7806
+ }}
7807
+ />
7808
) : null;
7809
const threadDetailsPanelProps: ThreadDetailsPanelProps = {
7810
anchor: threadPanelPopoverAnchorRef,
apps/web/src/components/PersistentThreadTerminals.tsx
+1
-1
@@ -293,7 +293,7 @@ export const PersistentThreadTerminalDrawer = memo(function PersistentThreadTerm
293
);
294
});
295
296
-interface PersistentThreadTerminalPanelProps {
296
+export interface PersistentThreadTerminalPanelProps {
297
visible: boolean;
298
threadRef: ScopedThreadRef;
299
surface: Extract<RightPanelSurface, { kind: "terminal" }>;
apps/web/src/components/chat/RightPanelSurfaceContent.tsx
new
+218
@@ -0,0 +1,218 @@
1
+import type {
2
+ EditorId,
3
+ EnvironmentId,
4
+ PreviewAnnotationPayload,
5
+ ProjectId,
6
+ ResolvedKeybindingsConfig,
7
+ ScopedThreadRef,
8
+ ThreadLinkedPullRequest,
9
+ ThreadPullRequestLink,
10
+} from "@t3tools/contracts";
11
+import { scopedThreadKey } from "@t3tools/client-runtime/environment";
12
+import { lazy, Suspense } from "react";
13
+import type { ComposerImageAttachment, DraftId } from "../../composerDraftStore";
14
+import type { ShortcutMatchContext } from "../../keybindings";
15
+import { type RightPanelSurface, useRightPanelStore } from "../../rightPanelStore";
16
+import {
17
+ PersistentThreadTerminalPanel,
18
+ type PersistentThreadTerminalPanelProps,
19
+} from "../PersistentThreadTerminals";
20
+import { pullRequestPanelContext } from "../pullRequest/pullRequestDetail.logic";
21
+import { PullRequestDetailPanel } from "../pullRequest/PullRequestDetailPanel";
22
+import { PullRequestDetailGhost } from "../pullRequest/PullRequestGhosts";
23
+import { PullRequestsUnavailableState } from "../pullRequest/PullRequestsUnavailableState";
24
+import { ThreadPullRequestsPanel } from "../pullRequest/ThreadPullRequestsPanel";
25
+
26
+const PreviewPanel = lazy(() =>
27
+ import("../preview/PreviewPanel").then((module) => ({ default: module.PreviewPanel })),
28
+);
29
+const DiffPanel = lazy(() => import("../DiffPanel"));
30
+const DevicePanel = lazy(() =>
31
+ import("../device/DevicePanel").then((module) => ({ default: module.DevicePanel })),
32
+);
33
+const FilePreviewPanel = lazy(() => import("../files/FilePreviewPanel"));
34
+
35
+export type RightPanelTerminalProps = Omit<
36
+ PersistentThreadTerminalPanelProps,
37
+ "visible" | "threadRef" | "surface"
38
+>;
39
+
40
+export interface RightPanelPullRequestProps {
41
+ readonly capabilityKnown: boolean;
42
+ readonly supported: boolean;
43
+ readonly projectId: ProjectId | null;
44
+ readonly pullRequests: ReadonlyArray<ThreadPullRequestLink>;
45
+ readonly linkedPullRequest: ThreadLinkedPullRequest | null;
46
+ readonly branchPullRequest: ThreadLinkedPullRequest | null | undefined;
47
+ /** Back to the pull request list; absent when there is no list to go back to. */
48
+ readonly onBack: (() => void) | undefined;
49
+}
50
+
51
+export interface RightPanelFileProps {
52
+ readonly projectName: string | null;
53
+ readonly workspaceRoot: string | undefined;
54
+ readonly availableEditors: ReadonlyArray<EditorId>;
55
+ readonly pendingSurfaceIds: ReadonlySet<string>;
56
+ readonly onOpenFile: (relativePath: string) => void;
57
+ readonly onPendingChange: (relativePath: string, pending: boolean) => void;
58
+}
59
+
60
+/** The body of the thread's right panel for the surface it is showing. */
61
+export function RightPanelSurfaceContent(props: {
62
+ readonly surface: RightPanelSurface | null;
63
+ readonly activeSurfaceId: string | null;
64
+ readonly threadRef: ScopedThreadRef;
65
+ readonly environmentId: EnvironmentId;
66
+ readonly visible: boolean;
67
+ readonly composerDraftTarget: ScopedThreadRef | DraftId;
68
+ readonly keybindings: ResolvedKeybindingsConfig;
69
+ readonly configuredPreviewUrls: ReadonlyArray<string>;
70
+ readonly workspaceMutationId: string | null;
71
+ readonly getShortcutContext: () => ShortcutMatchContext;
72
+ readonly onSendAnnotation: (
73
+ annotation: PreviewAnnotationPayload,
74
+ image: ComposerImageAttachment | null,
75
+ ) => void;
76
+ readonly onCloseSurface: (surface: RightPanelSurface) => void;
77
+ readonly terminal: RightPanelTerminalProps;
78
+ readonly pullRequest: RightPanelPullRequestProps;
79
+ readonly files: RightPanelFileProps;
80
+}) {
81
+ const { surface, threadRef, visible } = props;
82
+ if (surface === null) return null;
83
+ switch (surface.kind) {
84
+ case "preview":
85
+ return (
86
+ <Suspense fallback={null}>
87
+ <PreviewPanel
88
+ mode="embedded"
89
+ threadRef={threadRef}
90
+ tabId={surface.resourceId}
91
+ configuredUrls={props.configuredPreviewUrls}
92
+ visible={visible}
93
+ onSendAnnotation={props.onSendAnnotation}
94
+ />
95
+ </Suspense>
96
+ );
97
+ case "terminal":
98
+ return (
99
+ <PersistentThreadTerminalPanel
100
+ {...props.terminal}
101
+ visible={visible}
102
+ threadRef={threadRef}
103
+ surface={surface}
104
+ />
105
+ );
106
+ case "diff":
107
+ return (
108
+ <Suspense fallback={null}>
109
+ <DiffPanel
110
+ key={scopedThreadKey(threadRef)}
111
+ mode="embedded"
112
+ composerDraftTarget={props.composerDraftTarget}
113
+ workspaceMutationId={props.workspaceMutationId}
114
+ />
115
+ </Suspense>
116
+ );
117
+ case "pull-request": {
118
+ const pullRequest = props.pullRequest;
119
+ if (!pullRequest.capabilityKnown) return <PullRequestDetailGhost />;
120
+ if (!pullRequest.supported) {
121
+ return (
122
+ <PullRequestsUnavailableState
123
+ title="Pull requests unavailable"
124
+ error="Update this environment's T3 Code server to browse pull requests."
125
+ />
126
+ );
127
+ }
128
+ return (
129
+ <PullRequestDetailPanel
130
+ getShortcutContext={props.getShortcutContext}
131
+ shortcutsEnabled={visible && props.activeSurfaceId === surface.id}
132
+ key={`${surface.host ?? ""}:${surface.repository}#${surface.number}`}
133
+ environmentId={props.environmentId}
134
+ onSelectPullRequest={(reference) => {
135
+ useRightPanelStore.getState().openPullRequest(threadRef, {
136
+ projectId: reference.projectId,
137
+ repository: reference.repository,
138
+ number: reference.number,
139
+ ...(reference.host ? { host: reference.host } : {}),
140
+ });
141
+ }}
142
+ threadRef={threadRef}
143
+ reference={{
144
+ projectId: surface.projectId as ProjectId,
145
+ ...(surface.host ? { host: surface.host } : {}),
146
+ repository: surface.repository,
147
+ number: surface.number,
148
+ }}
149
+ context={pullRequestPanelContext(
150
+ {
151
+ projectId: pullRequest.projectId,
152
+ pullRequests: pullRequest.pullRequests,
153
+ linkedPullRequest: pullRequest.linkedPullRequest,
154
+ branchPullRequest: pullRequest.branchPullRequest,
155
+ },
156
+ surface,
157
+ )}
158
+ composerDraftTarget={props.composerDraftTarget}
159
+ onBack={pullRequest.onBack}
160
+ />
161
+ );
162
+ }
163
+ case "pull-requests":
164
+ return <ThreadPullRequestsPanel threadRef={threadRef} />;
165
+ case "device":
166
+ return (
167
+ <Suspense fallback={null}>
168
+ <DevicePanel
169
+ mode="embedded"
170
+ threadRef={threadRef}
171
+ key={surface.id}
172
+ surface={surface}
173
+ visible={visible}
174
+ onDismissSetup={() => {
175
+ props.onCloseSurface(surface);
176
+ useRightPanelStore.getState().show(threadRef);
177
+ }}
178
+ />
179
+ </Suspense>
180
+ );
181
+ case "files":
182
+ case "file": {
183
+ const files = props.files;
184
+ const attachment = surface.kind === "file" ? surface.attachment : undefined;
185
+ if (!attachment && (files.projectName === null || !files.workspaceRoot)) return null;
186
+ return (
187
+ <Suspense fallback={null}>
188
+ <FilePreviewPanel
189
+ key={`${props.environmentId}:${
190
+ attachment ? `attachment:${attachment.id}` : files.workspaceRoot
191
+ }`}
192
+ environmentId={props.environmentId}
193
+ cwd={files.workspaceRoot ?? ""}
194
+ projectName={files.projectName ?? ""}
195
+ threadRef={threadRef}
196
+ composerDraftTarget={props.composerDraftTarget}
197
+ keybindings={props.keybindings}
198
+ availableEditors={files.availableEditors}
199
+ relativePath={surface.kind === "file" ? surface.relativePath : null}
200
+ {...(attachment ? { attachment } : {})}
201
+ revealLine={surface.kind === "file" ? (surface.revealLine ?? null) : null}
202
+ revealRequestId={surface.kind === "file" ? surface.revealRequestId : 0}
203
+ onOpenFile={files.onOpenFile}
204
+ onNavigateFolder={(relativePath, folderTrail, keepSource) =>
205
+ useRightPanelStore
206
+ .getState()
207
+ .navigateFolder(threadRef, surface.id, relativePath, folderTrail, keepSource)
208
+ }
209
+ folderTrail={surface.folderTrail}
210
+ onPendingChange={files.onPendingChange}
211
+ selectedFilePending={surface.kind === "file" && files.pendingSurfaceIds.has(surface.id)}
212
+ workspaceMutationId={props.workspaceMutationId}
213
+ />
214
+ </Suspense>
215
+ );
216
+ }
217
+ }
218
+}