diff --git a/src/App.jsx b/src/App.jsx index 1f35e79..c531a57 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -687,10 +687,10 @@ export default function App() { } }; - window.electronAPI.onWindowFocus(handleFocus); + desktopApi.onWindowFocus(handleFocus); return () => { - window.electronAPI.offWindowFocus(handleFocus); + desktopApi.offWindowFocus(handleFocus); }; }, []); diff --git a/src/AssistantMessageContent.jsx b/src/AssistantMessageContent.jsx index 48129d3..0356819 100644 --- a/src/AssistantMessageContent.jsx +++ b/src/AssistantMessageContent.jsx @@ -65,7 +65,7 @@ export default function AssistantMessageContent({ content, streamOutput, sources event.preventDefault() try { const parsed = new URL(u) - window.electronAPI?.openPath?.(decodeURIComponent(parsed.pathname)) + desktopApi?.openPath?.(decodeURIComponent(parsed.pathname)) } catch {} }} > diff --git a/src/GeneralSettings.jsx b/src/GeneralSettings.jsx index 92c3089..f63b662 100644 --- a/src/GeneralSettings.jsx +++ b/src/GeneralSettings.jsx @@ -109,8 +109,8 @@ export default function GeneralSettings({ let cancelled = false; Promise.all([ - window.electronAPI.getSettings(), - window.electronAPI.getUpdateStatus(), + desktopApi.getSettings(), + desktopApi.getUpdateStatus(), ]).then(([settings, status]) => { if (cancelled) { return; @@ -202,13 +202,13 @@ export default function GeneralSettings({ } setSelectedModel(nextModel); - window.electronAPI.setSetting(MODEL_KEY, nextModel); + desktopApi.setSetting(MODEL_KEY, nextModel); if (onModelChange) { onModelChange(nextModel); } if (visionModels.includes(nextModel) && nextModel !== visionModel) { setVisionModel(nextModel); - window.electronAPI.setSetting(VISION_MODEL_KEY, nextModel); + desktopApi.setSetting(VISION_MODEL_KEY, nextModel); if (onVisionModelChange) { onVisionModelChange(nextModel); } @@ -232,7 +232,7 @@ export default function GeneralSettings({ } setVisionModel(nextModel); - window.electronAPI.setSetting(VISION_MODEL_KEY, nextModel); + desktopApi.setSetting(VISION_MODEL_KEY, nextModel); if (onVisionModelChange) { onVisionModelChange(nextModel); } @@ -251,7 +251,7 @@ export default function GeneralSettings({ const nextModel = embeddingModels[0] || DEFAULT_EMBED_MODEL; setEmbedModel(nextModel); - window.electronAPI.setSetting(EMBED_MODEL_KEY, nextModel); + desktopApi.setSetting(EMBED_MODEL_KEY, nextModel); }, [embeddingModels, embedModel, panel, settingsHydrated]); useEffect(() => { @@ -267,7 +267,7 @@ export default function GeneralSettings({ const nextModel = embedModel || rerankingModels[0] || DEFAULT_EMBED_MODEL; setRerankModel(nextModel); - window.electronAPI.setSetting(RERANK_MODEL_KEY, nextModel); + desktopApi.setSetting(RERANK_MODEL_KEY, nextModel); }, [rerankingModels, rerankModel, embedModel, panel, settingsHydrated]); useEffect(() => { @@ -283,7 +283,7 @@ export default function GeneralSettings({ const nextModel = whisperModels[0] || DEFAULT_TRANSCRIPTION_MODEL; setTranscriptionModel(nextModel); - window.electronAPI.setSetting(TRANSCRIPTION_MODEL_KEY, nextModel); + desktopApi.setSetting(TRANSCRIPTION_MODEL_KEY, nextModel); if (onTranscriptionModelChange) { onTranscriptionModelChange(nextModel); } @@ -353,13 +353,13 @@ export default function GeneralSettings({ const handleModelChange = (event) => { const newModel = event.target.value; setSelectedModel(newModel); - window.electronAPI.setSetting(MODEL_KEY, newModel); + desktopApi.setSetting(MODEL_KEY, newModel); if (onModelChange) { onModelChange(newModel); } if (visionModels.includes(newModel) && newModel !== visionModel) { setVisionModel(newModel); - window.electronAPI.setSetting(VISION_MODEL_KEY, newModel); + desktopApi.setSetting(VISION_MODEL_KEY, newModel); if (onVisionModelChange) { onVisionModelChange(newModel); } @@ -369,7 +369,7 @@ export default function GeneralSettings({ const handleVisionModelChange = (event) => { const newModel = event.target.value; setVisionModel(newModel); - window.electronAPI.setSetting(VISION_MODEL_KEY, newModel); + desktopApi.setSetting(VISION_MODEL_KEY, newModel); if (onVisionModelChange) { onVisionModelChange(newModel); } @@ -378,19 +378,19 @@ export default function GeneralSettings({ const handleEmbedModelChange = (event) => { const nextModel = event.target.value; setEmbedModel(nextModel); - window.electronAPI.setSetting(EMBED_MODEL_KEY, nextModel); + desktopApi.setSetting(EMBED_MODEL_KEY, nextModel); }; const handleRerankModelChange = (event) => { const nextModel = event.target.value; setRerankModel(nextModel); - window.electronAPI.setSetting(RERANK_MODEL_KEY, nextModel); + desktopApi.setSetting(RERANK_MODEL_KEY, nextModel); }; const handleTranscriptionModelChange = (event) => { const nextModel = event.target.value; setTranscriptionModel(nextModel); - window.electronAPI.setSetting(TRANSCRIPTION_MODEL_KEY, nextModel); + desktopApi.setSetting(TRANSCRIPTION_MODEL_KEY, nextModel); if (onTranscriptionModelChange) { onTranscriptionModelChange(nextModel); } @@ -434,7 +434,7 @@ export default function GeneralSettings({ const handleAudioInputDeviceChange = (event) => { const nextDeviceId = event.target.value; setAudioInputDeviceId(nextDeviceId); - window.electronAPI.setSetting(AUDIO_INPUT_DEVICE_ID_KEY, nextDeviceId); + desktopApi.setSetting(AUDIO_INPUT_DEVICE_ID_KEY, nextDeviceId); if (onAudioInputDeviceChange) { onAudioInputDeviceChange(nextDeviceId); } @@ -443,7 +443,7 @@ export default function GeneralSettings({ const handleAudioInputLanguageChange = (event) => { const nextLanguage = event.target.value; setAudioInputLanguage(nextLanguage); - window.electronAPI.setSetting(AUDIO_INPUT_LANGUAGE_KEY, nextLanguage); + desktopApi.setSetting(AUDIO_INPUT_LANGUAGE_KEY, nextLanguage); if (onAudioInputLanguageChange) { onAudioInputLanguageChange(nextLanguage); } @@ -452,7 +452,7 @@ export default function GeneralSettings({ const handleCheckForUpdates = async () => { setIsCheckingForUpdates(true); try { - const status = await window.electronAPI.checkForUpdates(); + const status = await desktopApi.checkForUpdates(); setUpdateStatus(status || DEFAULT_UPDATE_STATUS); } catch (error) { setUpdateStatus({ @@ -472,7 +472,7 @@ export default function GeneralSettings({ setChangelogError(''); try { - const result = await window.electronAPI.getChangelogPage(page); + const result = await desktopApi.getChangelogPage(page); setChangelogEntries(Array.isArray(result?.entries) ? result.entries : []); setChangelogPage(Number.isInteger(result?.page) ? result.page : page); setChangelogHasMore(Boolean(result?.hasMore)); diff --git a/src/InterfaceSettings.jsx b/src/InterfaceSettings.jsx index 9f0a649..c89e39d 100644 --- a/src/InterfaceSettings.jsx +++ b/src/InterfaceSettings.jsx @@ -28,7 +28,7 @@ export default function InterfaceSettings({ const [openDevToolsOnStartup, setOpenDevToolsOnStartup] = useState(false) useEffect(() => { - window.electronAPI.getSettings().then(settings => { + desktopApi.getSettings().then(settings => { const schemeName = settings.colorScheme || 'Default' setSelectedColorScheme(schemeName) setUiScale(normalizeUiScale(settings.uiScale)) @@ -44,13 +44,13 @@ export default function InterfaceSettings({ const handleColorSchemeChange = (event) => { const newScheme = event.target.value setSelectedColorScheme(newScheme) - window.electronAPI.setSetting(COLOR_SCHEME_KEY, newScheme) + desktopApi.setSetting(COLOR_SCHEME_KEY, newScheme) } const persistUiScale = (value) => { const nextScale = normalizeUiScale(value) setUiScale(nextScale) - window.electronAPI.setSetting(UI_SCALE_KEY, nextScale) + desktopApi.setSetting(UI_SCALE_KEY, nextScale) } const handleUiScaleChange = (event) => { @@ -64,12 +64,12 @@ export default function InterfaceSettings({ const handleOpenDevToolsOnStartupToggle = () => { const nextValue = !openDevToolsOnStartup setOpenDevToolsOnStartup(nextValue) - window.electronAPI.setSetting(OPEN_DEVTOOLS_ON_STARTUP_KEY, nextValue) + desktopApi.setSetting(OPEN_DEVTOOLS_ON_STARTUP_KEY, nextValue) } const handleStreamOutputToggle = () => { const nextValue = !streamOutput - window.electronAPI.setSetting(STREAM_KEY, nextValue) + desktopApi.setSetting(STREAM_KEY, nextValue) if (onStreamOutputChange) { onStreamOutputChange(nextValue) } diff --git a/src/LibraryManager.jsx b/src/LibraryManager.jsx index 3673d44..2a1a777 100644 --- a/src/LibraryManager.jsx +++ b/src/LibraryManager.jsx @@ -130,7 +130,7 @@ export default function LibraryManager({ async function addPaths() { if (!library) return - const paths = await window.electronAPI?.pickPaths?.() + const paths = await desktopApi?.pickPaths?.() if (!Array.isArray(paths) || paths.length === 0) return try { await registerPaths(paths) @@ -307,7 +307,7 @@ export default function LibraryManager({ > {file.enrich_enabled ? 'Use Raw Only' : 'Enable Enrich'} - + diff --git a/src/WebsearchSettings.jsx b/src/WebsearchSettings.jsx index d96527b..d4236fd 100644 --- a/src/WebsearchSettings.jsx +++ b/src/WebsearchSettings.jsx @@ -24,7 +24,7 @@ export default function WebsearchSettings({ useEffect(() => { let cancelled = false - window.electronAPI.getSettings().then(settings => { + desktopApi.getSettings().then(settings => { if (cancelled) { return } @@ -46,7 +46,7 @@ export default function WebsearchSettings({ const handleBackendUrlChange = (event) => { const newUrl = event.target.value setBackendApiUrl(newUrl) - window.electronAPI.setSetting(BACKEND_API_URL_KEY, newUrl) + desktopApi.setSetting(BACKEND_API_URL_KEY, newUrl) if (onBackendApiUrlChange) { onBackendApiUrlChange(newUrl) } @@ -55,7 +55,7 @@ export default function WebsearchSettings({ const handleOllamaUrlChange = (event) => { const newUrl = event.target.value setOllamaApiUrl(newUrl) - window.electronAPI.setSetting(OLLAMA_API_URL_KEY, newUrl) + desktopApi.setSetting(OLLAMA_API_URL_KEY, newUrl) } return ( diff --git a/src/main.jsx b/src/main.jsx index 8169910..be8a885 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -8,7 +8,7 @@ import { applyColorScheme } from './colorSchemes' function Main() { useEffect(() => { - window.electronAPI.getSettings().then(settings => { + desktopApi.getSettings().then(settings => { applyColorScheme(settings.colorScheme || 'Default') }) }, []) diff --git a/src/useChatScroll.js b/src/useChatScroll.js index fc52b9d..952146e 100644 --- a/src/useChatScroll.js +++ b/src/useChatScroll.js @@ -41,7 +41,7 @@ export function useChatScroll({ setScrollPositions(prev => { const updated = { ...prev, [leavingSessionId]: top } - window.electronAPI.updateSettings({ scrollPositions: updated }) + desktopApi.updateSettings({ scrollPositions: updated }) return updated }) }