mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-28 15:38:37 +02:00
The popup window has its own document and never received the data-theme attribute. Pass the current theme setting from the main process via the show event, resolve 'system' to effective dark/light, and apply to document.documentElement.dataset.theme so all CSS variables match the main app's appearance. - Add getCurrentTheme() to AryxAppService - Pass theme in toggleQuickPromptWindow / showQuickPromptWindow - Update onShow listener signature to receive theme string - Apply theme to documentElement on each popup activation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
51 lines
1.9 KiB
TypeScript
51 lines
1.9 KiB
TypeScript
import electron from 'electron';
|
|
|
|
import type { QuickPromptElectronApi } from '@shared/contracts/ipc';
|
|
|
|
const { contextBridge, ipcRenderer } = electron;
|
|
|
|
// Channel constants are inlined here (not imported from @shared/contracts/channels)
|
|
// to avoid Rollup code-splitting a shared chunk that Electron's sandboxed preload
|
|
// environment cannot resolve at runtime.
|
|
const ch = {
|
|
send: 'quick-prompt:send',
|
|
discard: 'quick-prompt:discard',
|
|
close: 'quick-prompt:close',
|
|
continueInAryx: 'quick-prompt:continue-in-aryx',
|
|
cancelTurn: 'quick-prompt:cancel-turn',
|
|
getCapabilities: 'quick-prompt:get-capabilities',
|
|
setSettings: 'quick-prompt:set-settings',
|
|
sessionEvent: 'quick-prompt:session-event',
|
|
show: 'quick-prompt:show',
|
|
hide: 'quick-prompt:hide',
|
|
} as const;
|
|
|
|
const api: QuickPromptElectronApi = {
|
|
send: (input) => ipcRenderer.invoke(ch.send, input),
|
|
discard: () => ipcRenderer.invoke(ch.discard),
|
|
close: () => ipcRenderer.invoke(ch.close),
|
|
continueInAryx: () => ipcRenderer.invoke(ch.continueInAryx),
|
|
cancelTurn: () => ipcRenderer.invoke(ch.cancelTurn),
|
|
getCapabilities: () => ipcRenderer.invoke(ch.getCapabilities),
|
|
setSettings: (settings) => ipcRenderer.invoke(ch.setSettings, settings),
|
|
onSessionEvent: (listener) => {
|
|
const handler = (_event: Electron.IpcRendererEvent, sessionEvent: Parameters<typeof listener>[0]) =>
|
|
listener(sessionEvent);
|
|
|
|
ipcRenderer.on(ch.sessionEvent, handler);
|
|
return () => ipcRenderer.off(ch.sessionEvent, handler);
|
|
},
|
|
onShow: (listener) => {
|
|
const handler = (_event: Electron.IpcRendererEvent, theme: string) => listener(theme);
|
|
ipcRenderer.on(ch.show, handler);
|
|
return () => ipcRenderer.off(ch.show, handler);
|
|
},
|
|
onHide: (listener) => {
|
|
const handler = () => listener();
|
|
ipcRenderer.on(ch.hide, handler);
|
|
return () => ipcRenderer.off(ch.hide, handler);
|
|
},
|
|
};
|
|
|
|
contextBridge.exposeInMainWorld('quickPromptApi', api);
|