fix: sync context panel iframe themes

Keeps embedded sessions aligned with parent theme
Prevents iframe reloads on theme changes
Supports theme hotkeys from focused iframes
This commit is contained in:
Bohdan Triapitsyn
2026-06-16 23:33:29 +03:00
parent 91e8e94961
commit 0fef61e25f
12 changed files with 484 additions and 118 deletions
@@ -10,6 +10,7 @@ import { useConfigStore } from '@/stores/useConfigStore';
import { canUseElectronDesktopIPC, invokeDesktop, isVSCodeRuntime } from '@/lib/desktop';
import { showOpenCodeStatus } from '@/lib/openCodeStatus';
import { eventMatchesShortcut, getEffectiveShortcutCombo, normalizeCombo } from '@/lib/shortcuts';
import { readEmbeddedThemeSearchParams } from '@/contexts/theme-embedded-bootstrap';
import { useDirectoryStore } from '@/stores/useDirectoryStore';
import { useProjectsStore } from '@/stores/useProjectsStore';
import { getCycledPrimaryAgentName } from '@/components/chat/mobileControlsUtils';
@@ -184,6 +185,10 @@ export const useKeyboardShortcuts = () => {
if (eventMatchesShortcut(e, combo('cycle_theme'))) {
e.preventDefault();
if (readEmbeddedThemeSearchParams() !== null && window.parent && window.parent !== window) {
window.parent.postMessage({ type: 'openchamber:cycle-theme-request' }, window.location.origin);
return;
}
const modes: Array<'light' | 'dark' | 'system'> = ['light', 'dark', 'system'];
const activeElement = document.activeElement as HTMLElement | null;
const currentIndex = modes.indexOf(themeModeRef.current);