[Bug] Right-side panel does not auto-collapse in a narrow window
Background and impact
The recently added responsive behavior is intended to auto-collapse the right-side panel when the main workspace becomes narrower than 520 px. However, after a right-side panel is opened through a normal UI entry point, the auto-collapse condition is permanently bypassed. If a user opens Browser, Design, Video, or another right-side panel in a wide window and then narrows the window, the panel remains open and compresses the main workspace to its fallback width.
Affected module
apps/app/src/react-app/domains/session/chat/session-page.tsx
setCurrentSidePanel and toggleCurrentSidePanel set userOpenedSidePanelWhileNarrowRef.current to true whenever a right-side panel is opened, regardless of whether the layout is narrow. The auto-collapse effect runs only when this flag is false.
Steps to reproduce
- Keep the desktop window wider than 960 px.
- Open any right-side panel, such as Browser, Design, or Video.
- Reduce the window width until the main workspace has less than 520 px of available width.
- Observe the right-side panel and the main workspace.
Expected behavior
When the right-side panel was not explicitly reopened by the user in a narrow layout, it should auto-collapse once the available workspace width falls below the threshold, then restore according to the intended responsive behavior when space becomes available again.
Actual behavior
The right-side panel remains open because userOpenedSidePanelWhileNarrowRef prevents the auto-collapse path, even though the panel was opened while the window was wide.
Suggested investigation
Only record that a user intentionally opened the right-side panel while narrowLayout is true, or reset that flag when the layout transitions from wide to narrow. Add regression coverage for opening a right-side panel in a wide window and then narrowing the window.