diff --git a/src/main/ipcHandlers.ts b/src/main/ipcHandlers.ts index bcf4e70..7f05ab9 100644 --- a/src/main/ipcHandlers.ts +++ b/src/main/ipcHandlers.ts @@ -11,7 +11,7 @@ import { import type { Market, Submission, StoryMeta, TelemetrySession } from './fileSystem' import { streamMessage, streamPrompt, resetClient } from './aiService' import type { AIPayload } from './aiService' -import { readGlobalConfig, writeGlobalConfig } from './globalConfig' +import { readGlobalConfig, writeGlobalConfig, getApiKey } from './globalConfig' import type { GlobalConfig } from './globalConfig' export function registerIpcHandlers(): void { @@ -54,6 +54,7 @@ export function registerIpcHandlers(): void { ipcMain.handle('telemetry:read', async () => readTelemetry()) // ── Config ──────────────────────────────────────────────────────────────────── + ipcMain.handle('config:isAIEnabled', async () => !!getApiKey()) ipcMain.handle('config:read', async () => readGlobalConfig()) ipcMain.handle('config:write', async (_e, updates: Partial) => { writeGlobalConfig(updates) diff --git a/src/preload/index.ts b/src/preload/index.ts index e0402cc..4949105 100644 --- a/src/preload/index.ts +++ b/src/preload/index.ts @@ -39,6 +39,7 @@ contextBridge.exposeInMainWorld('api', { loadRevision: (path: string, id: string): Promise => ipcRenderer.invoke('revisions:load', path, id), // Config + isAIEnabled: (): Promise => ipcRenderer.invoke('config:isAIEnabled'), readConfig: (): Promise => ipcRenderer.invoke('config:read'), writeConfig: (updates: Partial): Promise => ipcRenderer.invoke('config:write', updates), pickFolder: (): Promise => ipcRenderer.invoke('config:pickFolder'), diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx index e5c48a4..03fe30c 100644 --- a/src/renderer/App.tsx +++ b/src/renderer/App.tsx @@ -25,7 +25,7 @@ export default function App(): JSX.Element { } = useBorgesStore() const [settingsOpen, setSettingsOpen] = useState(false) - const [, setIsFirstRun] = useState(false) + const [aiEnabled, setAiEnabled] = useState(false) // Initialise app useEffect(() => { @@ -40,11 +40,7 @@ export default function App(): JSX.Element { setMarkets(marketsList) setSubmissions(subsList) await loadSession() - const cfg = await window.api.readConfig() - if (!cfg.apiKey) { - setIsFirstRun(true) - setSettingsOpen(true) - } + setAiEnabled(await window.api.isAIEnabled()) } init() }, []) @@ -146,12 +142,16 @@ export default function App(): JSX.Element { onClick={() => toggleSeg('sub')} title={submissionPanelOpen ? 'Hide submission panel' : 'Show submission panel'} /> -
-