feat(site): harden Agents embed frame communication and add theme sync (#23574)

Add theme synchronization, navigation blocking, scroll-to-bottom
handling, and chat-ready signaling to the agent embed page. The parent
frame can now set light/dark theme via postMessage or query param, and
ThemeProvider skips its own class manipulation when the embed marker is
present. Navigation attempts that leave the embed route are intercepted
and forwarded to the parent frame. The scroll container ref is lifted
to the layout so the parent can request scroll-to-bottom.
This commit is contained in:
Ehab Younes
2026-03-26 18:03:30 +03:00
committed by GitHub
parent 81fe7543b4
commit 249ef7c567
5 changed files with 141 additions and 5 deletions
+7 -1
View File
@@ -69,6 +69,10 @@ export const ThemeProvider: FC<PropsWithChildren> = ({ children }) => {
useEffect(() => {
const root = document.documentElement;
// Embedded pages manage theme independently.
if (root.dataset.embedTheme) {
return;
}
if (themePreference === "auto") {
root.classList.add(preferredColorScheme);
} else {
@@ -76,7 +80,9 @@ export const ThemeProvider: FC<PropsWithChildren> = ({ children }) => {
}
return () => {
root.classList.remove("light", "dark");
if (!root.dataset.embedTheme) {
root.classList.remove("light", "dark");
}
};
}, [themePreference, preferredColorScheme]);