Skip to content

Commit c4b7c8c

Browse files
committed
fix(preview): return to pip when closing the right panel
1 parent 3836890 commit c4b7c8c

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

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

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4293,10 +4293,21 @@ export default function ChatView(props: ChatViewProps) {
42934293
supportsPullRequests,
42944294
threadDetailLoading,
42954295
]);
4296+
const closePreviewPanel = useCallback(() => {
4297+
if (activeThreadRef) {
4298+
if (activeRightPanelSurface?.kind === "preview" && activeRightPanelSurface.resourceId) {
4299+
usePreviewMiniPlayerStore
4300+
.getState()
4301+
.open(activeThreadRef, activeRightPanelSurface.resourceId);
4302+
}
4303+
setMaximizedRightPanelThreadKey(null);
4304+
useRightPanelStore.getState().close(activeThreadRef);
4305+
}
4306+
}, [activeRightPanelSurface, activeThreadRef]);
42964307
const togglePreviewPanel = useCallback(() => {
42974308
if (!activeThreadRef || !isPreviewSupportedInRuntime()) return;
42984309
if (previewPanelOpen) {
4299-
useRightPanelStore.getState().close(activeThreadRef);
4310+
closePreviewPanel();
43004311
return;
43014312
}
43024313
const activeTabId = activePreviewState.activeTabId;
@@ -4305,13 +4316,13 @@ export default function ChatView(props: ChatViewProps) {
43054316
} else {
43064317
createBrowserSurface();
43074318
}
4308-
}, [activePreviewState.activeTabId, activeThreadRef, createBrowserSurface, previewPanelOpen]);
4309-
const closePreviewPanel = useCallback(() => {
4310-
if (activeThreadRef) {
4311-
setMaximizedRightPanelThreadKey(null);
4312-
useRightPanelStore.getState().close(activeThreadRef);
4313-
}
4314-
}, [activeThreadRef]);
4319+
}, [
4320+
activePreviewState.activeTabId,
4321+
activeThreadRef,
4322+
closePreviewPanel,
4323+
createBrowserSurface,
4324+
previewPanelOpen,
4325+
]);
43154326
const addTerminalSurface = useCallback(() => {
43164327
if (!activeThreadRef || !activeThreadId || !activeProject) return;
43174328
const cwd = gitCwd ?? activeProject.workspaceRoot;

0 commit comments

Comments
 (0)