From 839bfc2b59638bae157509e1e72e1c1ca6124c82 Mon Sep 17 00:00:00 2001 From: "courtmanr@gmail.com" Date: Fri, 30 May 2025 15:10:27 +0100 Subject: [PATCH] feat: replace setup screen with automatic settings modal for initial configuration MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Remove redirect to setup.html in favor of always serving main application - Add automatic detection of placeholder configuration values on page load - Automatically open settings modal when configuration needs setup - Provide seamless unified interface for both initial setup and ongoing management - Eliminate need for separate setup.html page while maintaining full functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- server/index.js | 9 +-------- src/public/js/main.js | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/server/index.js b/server/index.js index 3c40d158b..c414780ab 100644 --- a/server/index.js +++ b/server/index.js @@ -125,14 +125,7 @@ app.use(express.static(publicDir, { index: false })); // Route to serve the main HTML file for the root path app.get('/', (req, res) => { - // Check if configuration is placeholder or missing using current state - const currentConfigStatus = stateManager.getState().isConfigPlaceholder; - - if (currentConfigStatus) { - // Redirect to setup page - return res.redirect('/setup.html'); - } - + // Always serve the main application with settings modal for initial configuration const indexPath = path.join(publicDir, 'index.html'); res.sendFile(indexPath, (err) => { if (err) { diff --git a/src/public/js/main.js b/src/public/js/main.js index 152c6bd7d..0a0cecbbf 100644 --- a/src/public/js/main.js +++ b/src/public/js/main.js @@ -243,6 +243,9 @@ document.addEventListener('DOMContentLoaded', function() { initializeModules(); + // Check if configuration is missing or contains placeholders and automatically open settings modal + checkAndOpenSettingsIfNeeded(); + // Fetch version immediately and retry after a short delay if needed fetchVersion(); @@ -258,4 +261,41 @@ document.addEventListener('DOMContentLoaded', function() { setInterval(() => { fetchVersion(); }, 6 * 60 * 60 * 1000); + + /** + * Check if configuration is missing or contains placeholder values and open settings modal + */ + async function checkAndOpenSettingsIfNeeded() { + try { + // Wait a moment for the socket connection to establish and initial data to arrive + setTimeout(async () => { + try { + const response = await fetch('/api/health'); + if (response.ok) { + const health = await response.json(); + + // Check if configuration has placeholder values or no data is available + if (health.system && health.system.configPlaceholder) { + console.log('[Main] Configuration contains placeholder values, opening settings modal...'); + + // Wait for settings module to be fully initialized + setTimeout(() => { + if (PulseApp.ui.settings && typeof PulseApp.ui.settings.openModal === 'function') { + PulseApp.ui.settings.openModal(); + } else { + console.warn('[Main] Settings module not available for auto-open'); + } + }, 500); + } else { + console.log('[Main] Configuration appears valid, not opening settings modal'); + } + } + } catch (error) { + console.error('[Main] Error checking configuration status:', error); + } + }, 2000); // Wait 2 seconds for everything to settle + } catch (error) { + console.error('[Main] Error in checkAndOpenSettingsIfNeeded:', error); + } + } });