diff --git a/apps/web/src/components/chat/useRightPanelActions.browser.test.tsx b/apps/web/src/components/chat/useRightPanelActions.browser.test.tsx
new file mode 100644
index 0000000000000..9dc1a10fd53ed
--- /dev/null
+++ b/apps/web/src/components/chat/useRightPanelActions.browser.test.tsx
@@ -0,0 +1,63 @@
+import { scopeThreadRef } from "@t3tools/client-runtime/environment";
+import { EnvironmentId, ThreadId } from "@t3tools/contracts";
+import { expect, it } from "vite-plus/test";
+
+import { render } from "../../../test/render";
+import { __testing } from "../../previewStateStore";
+import { selectThreadRightPanelState, useRightPanelStore } from "../../rightPanelStore";
+import { useDeviceState } from "../../state/device";
+import { useRightPanelActions } from "./useRightPanelActions";
+
+it("remembers the browser's maximized size when toggling the side panel", async () => {
+ const ref = scopeThreadRef(EnvironmentId.make("panel-test"), ThreadId.make("panel-test"));
+ useRightPanelStore.setState({ byThreadKey: {} });
+ useRightPanelStore.getState().openBrowser(ref, null);
+ useRightPanelStore.getState().setMaximized(ref, true);
+
+ function Panel() {
+ const panel = useRightPanelStore((state) =>
+ selectThreadRightPanelState(state.byThreadKey, ref),
+ );
+ const device = useDeviceState(null);
+ const actions = useRightPanelActions({
+ activeThreadRef: ref,
+ activeProject: null,
+ activeRightPanelSurface:
+ panel.surfaces.find((surface) => surface.id === panel.activeSurfaceId) ?? null,
+ activePreviewState: __testing.EMPTY_THREAD_PREVIEW_STATE,
+ deviceState: device.state,
+ deviceStateLoaded: false,
+ pullRequestPanelTarget: null,
+ threadPanelPresentation: "inline",
+ isServerThread: true,
+ embedded: false,
+ isGitRepo: false,
+ browserAvailable: true,
+ canOperatePreview: true,
+ diffOpen: false,
+ previewPanelOpen: panel.isOpen,
+ rightPanelOpen: panel.isOpen,
+ canMaximizeRightPanel: panel.isOpen,
+ rightPanelMaximized: panel.isOpen && panel.maximized === true,
+ supportsPullRequests: false,
+ pullRequestsSurfaceAvailable: false,
+ gitCwd: null,
+ activeProjectCwd: null,
+ explicitDiffOpenRef: { current: null },
+ onDiffPanelOpen: undefined,
+ closeRightPanelSurface: () => undefined,
+ });
+ return ;
+ }
+
+ await using screen = await render();
+ const toggle = screen.getByRole("button", { name: "Toggle panel" });
+ await toggle.click();
+ expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, ref).isOpen).toBe(
+ false,
+ );
+ await toggle.click();
+ const reopened = selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, ref);
+ expect(reopened.isOpen).toBe(true);
+ expect(reopened.maximized).toBe(true);
+});
diff --git a/apps/web/src/components/chat/useRightPanelActions.ts b/apps/web/src/components/chat/useRightPanelActions.ts
index 0f8e8e3ce303f..358cfe9374054 100644
--- a/apps/web/src/components/chat/useRightPanelActions.ts
+++ b/apps/web/src/components/chat/useRightPanelActions.ts
@@ -179,7 +179,6 @@ export function useRightPanelActions(input: RightPanelActionsInput) {
deviceStateLoaded ? deviceState : null,
);
}
- useRightPanelStore.getState().setMaximized(activeThreadRef, false);
useRightPanelStore.getState().close(activeThreadRef);
}
};