mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user