fix(ui): mount only the active session chat iframe (#2816)

* fix(ui): mount only the active session chat iframe

* repro(ui): mount-all-persisted session-chat iframes (#2815)

Adds a regression-style reproduction for issue #2815: ContextPanel
renders one full-application iframe for every chat tab (inactive tabs
are only hidden via the Tailwind 'hidden' class, never unmounted), so a
reload restores all persisted session-chat tabs from the ui-store and
mounts N embedded OpenChamber apps in one browser tab.

The test reads the real ContextPanel.tsx render block, drives the real
useUIStore with the issue's persisted scenario (11 tabs, 8 read-only
session-chat tabs), and models the render block with the real
buildEmbeddedSessionChatURL helper, showing 8 live src iframes (7
hidden but loaded).

* test(ui): adapt issue 2815 reproduction for active chat

* fix(ui): unmount session chat when panel closes

---------

Co-authored-by: ChangeHow <23733347+ChangeHow@users.noreply.github.com>
This commit is contained in:
Andrea V
2026-08-11 16:11:25 +03:00
committed by GitHub
co-authored by ChangeHow
parent b55152db6f
commit 454119ac25
5 changed files with 250 additions and 46 deletions
@@ -44,11 +44,13 @@ the `openContext*` actions in `useUIStore`.
- Opening a surface must never require a control outside the rail, the
command palette, or an in-content link.
- Multi-instance and session-holding surfaces (file/editor, chat, diff,
browser, terminal) are keep-alive panes in `ContextPanel.tsx`: switching
- Multi-instance and session-holding surfaces (file/editor, diff, browser,
terminal) are keep-alive panes in `ContextPanel.tsx`. Switching these
surfaces must not reset their state (open tabs, xterm session, scroll
positions). Singleton surfaces (git, pr, notes, plan, context) and preview
tabs intentionally remount on switch and must restore themselves from
their stores/snapshots instead.
positions). Chat tab records stay open, but only the active chat iframe is
mounted while the panel is open. A selected chat restores its state from
the session stores. A closed panel mounts no chat iframe.
Singleton surfaces (git, pr, notes, plan, context) and preview tabs remount
on switch. These surfaces must restore their state from stores or snapshots.
- Runtime scope: desktop/web `MainLayout` only. VS Code and the dedicated
mobile shell have their own layouts and do not consume this registry.