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
@@ -158,6 +158,17 @@ export const getOrCreateEmbeddedSessionChatURL = (
return src;
};
export const getActiveEmbeddedSessionChatTab = <T extends { id: string }>(
tabs: T[],
activeTabID: string | null,
): T | null => {
if (!activeTabID) {
return null;
}
return tabs.find((tab) => tab.id === activeTabID) ?? null;
};
/**
* True when the current document is the embedded session-chat iframe
* (`?ocPanel=session-chat`). Used to distinguish the embedded iframe from