Skip to content

Commit b6b08f9

Browse files
committed
fix(web): preserve tabs opened during close confirmation
1 parent f6bead2 commit b6b08f9

1 file changed

Lines changed: 20 additions & 26 deletions

File tree

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

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3904,14 +3904,22 @@ function ChatViewContent(props: ChatViewProps) {
39043904
setActivePreviewTab(activeThreadRef, nextActiveSurface.resourceId);
39053905
}
39063906
}, [activeThreadRef]);
3907+
const finishRightPanelSurfaceClose = useCallback(
3908+
(surfaces: readonly RightPanelSurface[]) => {
3909+
if (!activeThreadRef) return;
3910+
cleanupRightPanelSurfaces(surfaces);
3911+
const store = useRightPanelStore.getState();
3912+
for (const surface of surfaces) {
3913+
store.closeSurface(activeThreadRef, surface.id);
3914+
}
3915+
syncActivePreviewSurface();
3916+
},
3917+
[activeThreadRef, cleanupRightPanelSurfaces, syncActivePreviewSurface],
3918+
);
39073919
const closeRightPanelSurface = useCallback(
39083920
(surface: RightPanelSurface) => {
39093921
if (!activeThreadRef) return;
3910-
const finishClose = () => {
3911-
cleanupRightPanelSurfaces([surface]);
3912-
useRightPanelStore.getState().closeSurface(activeThreadRef, surface.id);
3913-
syncActivePreviewSurface();
3914-
};
3922+
const finishClose = () => finishRightPanelSurfaceClose([surface]);
39153923
if (surface.kind === "preview") {
39163924
closeAfterAgentBrowserConfirmation([surface], finishClose);
39173925
return;
@@ -3936,27 +3944,21 @@ function ChatViewContent(props: ChatViewProps) {
39363944
activeThreadRef,
39373945
activeTerminalLabelsById,
39383946
closeAfterAgentBrowserConfirmation,
3939-
cleanupRightPanelSurfaces,
3940-
syncActivePreviewSurface,
3947+
finishRightPanelSurfaceClose,
39413948
],
39423949
);
39433950
const closeOtherRightPanelSurfaces = useCallback(
39443951
(surface: RightPanelSurface) => {
39453952
if (!activeThreadRef) return;
39463953
const surfaces = rightPanelState.surfaces.filter((entry) => entry.id !== surface.id);
3947-
const finishClose = () => {
3948-
cleanupRightPanelSurfaces(surfaces);
3949-
useRightPanelStore.getState().closeOtherSurfaces(activeThreadRef, surface.id);
3950-
syncActivePreviewSurface();
3951-
};
3954+
const finishClose = () => finishRightPanelSurfaceClose(surfaces);
39523955
closeAfterAgentBrowserConfirmation(surfaces, finishClose);
39533956
},
39543957
[
39553958
activeThreadRef,
39563959
closeAfterAgentBrowserConfirmation,
3957-
cleanupRightPanelSurfaces,
3960+
finishRightPanelSurfaceClose,
39583961
rightPanelState.surfaces,
3959-
syncActivePreviewSurface,
39603962
],
39613963
);
39623964
const closeRightPanelSurfacesToRight = useCallback(
@@ -3965,32 +3967,24 @@ function ChatViewContent(props: ChatViewProps) {
39653967
const surfaceIndex = rightPanelState.surfaces.findIndex((entry) => entry.id === surface.id);
39663968
if (surfaceIndex < 0) return;
39673969
const surfaces = rightPanelState.surfaces.slice(surfaceIndex + 1);
3968-
const finishClose = () => {
3969-
cleanupRightPanelSurfaces(surfaces);
3970-
useRightPanelStore.getState().closeSurfacesToRight(activeThreadRef, surface.id);
3971-
syncActivePreviewSurface();
3972-
};
3970+
const finishClose = () => finishRightPanelSurfaceClose(surfaces);
39733971
closeAfterAgentBrowserConfirmation(surfaces, finishClose);
39743972
},
39753973
[
39763974
activeThreadRef,
39773975
closeAfterAgentBrowserConfirmation,
3978-
cleanupRightPanelSurfaces,
3976+
finishRightPanelSurfaceClose,
39793977
rightPanelState.surfaces,
3980-
syncActivePreviewSurface,
39813978
],
39823979
);
39833980
const closeAllRightPanelSurfaces = useCallback(() => {
39843981
if (!activeThreadRef) return;
3985-
const finishClose = () => {
3986-
cleanupRightPanelSurfaces(rightPanelState.surfaces);
3987-
useRightPanelStore.getState().closeAllSurfaces(activeThreadRef);
3988-
};
3982+
const finishClose = () => finishRightPanelSurfaceClose(rightPanelState.surfaces);
39893983
closeAfterAgentBrowserConfirmation(rightPanelState.surfaces, finishClose);
39903984
}, [
39913985
activeThreadRef,
39923986
closeAfterAgentBrowserConfirmation,
3993-
cleanupRightPanelSurfaces,
3987+
finishRightPanelSurfaceClose,
39943988
rightPanelState.surfaces,
39953989
]);
39963990
const copyRightPanelFilePath = useCallback((relativePath: string) => {

0 commit comments

Comments
 (0)