From 9da6c91dbebe9f674af84086f99260f8c62bcfe9 Mon Sep 17 00:00:00 2001 From: egg Date: Mon, 22 Dec 2025 18:56:40 +0800 Subject: [PATCH] fix: Add missing browser-api.js functions for browser mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add getConfig() for app initialization - Add openInBrowser() (no-op in browser mode) - Add onTranscriptionResult() for compatibility - Add onStreamStarted() for compatibility 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- client/src/services/browser-api.js | 51 ++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/client/src/services/browser-api.js b/client/src/services/browser-api.js index ab90a47..8da6124 100644 --- a/client/src/services/browser-api.js +++ b/client/src/services/browser-api.js @@ -22,6 +22,39 @@ let streamingSocket = null; // Browser mode API implementation const browserAPI = { + // Get app configuration (browser mode fetches from backend or uses defaults) + getConfig: async () => { + try { + // Try to fetch config from backend + const response = await fetch(`${API_BASE}/config/settings.js`); + if (response.ok) { + // settings.js exports a config object, parse it + const text = await response.text(); + // Simple extraction of the config object + const match = text.match(/export\s+const\s+config\s*=\s*(\{[\s\S]*?\});/); + if (match) { + // Use eval cautiously here - it's our own config file + const configStr = match[1]; + return eval('(' + configStr + ')'); + } + } + } catch (error) { + console.log('[Browser Mode] Could not load config from server, using defaults'); + } + + // Return browser mode defaults + return { + apiBaseUrl: `${window.location.origin}/api`, + uploadTimeout: 600000, + appTitle: "Meeting Assistant", + whisper: { + model: "medium", + device: "cpu", + compute: "int8" + } + }; + }, + // Navigate to a page navigate: (page) => { const pageMap = { @@ -223,6 +256,24 @@ const browserAPI = { } catch { return { ready: false }; } + }, + + // Open in browser - no-op in browser mode (already in browser) + openInBrowser: async () => { + console.log('[Browser Mode] Already running in browser'); + return { success: true, url: window.location.href }; + }, + + // Legacy transcription result listener (for file-based mode) + onTranscriptionResult: (callback) => { + // Not used in browser streaming mode, but provide for compatibility + console.log('[Browser Mode] onTranscriptionResult registered (legacy)'); + }, + + // Stream started listener + onStreamStarted: (callback) => { + // HTTP-based streaming doesn't have this event + console.log('[Browser Mode] onStreamStarted registered'); } };