-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
feat: Add full WSL2/WSLg compatibility for Electron desktop app #1166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
447a4b6
72d8e8b
03784a5
f367715
91fe625
ee65999
c9e433b
c53969b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,3 +1,91 @@ | ||||||
| ## Unreleased - WSL2/WSLg Compatibility | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use an H1 for the first heading. Line 1: markdownlint MD041 expects the first heading to be H1. 📝 Proposed fix-## Unreleased - WSL2/WSLg Compatibility
+# Unreleased - WSL2/WSLg Compatibility📝 Committable suggestion
Suggested change
🧰 Tools🪛 markdownlint-cli2 (0.18.1)1-1: First line in a file should be a top-level heading (MD041, first-line-heading, first-line-h1) 🤖 Prompt for AI Agents |
||||||
|
|
||||||
| ### ✨ New Platform Support | ||||||
|
|
||||||
| - **Full WSL2/WSLg compatibility** - Auto Claude Electron desktop app now runs natively on Windows 11 WSL2 with WSLg (Windows Subsystem for Linux Graphics) | ||||||
|
|
||||||
| - Added comprehensive WSL2 setup guide and troubleshooting documentation ([guides/WSL2_SETUP.md](guides/WSL2_SETUP.md)) | ||||||
|
|
||||||
| ### 🛠️ Technical Improvements | ||||||
|
|
||||||
| **Lazy Initialization Pattern:** | ||||||
| - Implemented lazy initialization for all Electron app access to handle delayed initialization on WSL2 | ||||||
| - Replaced direct `@electron-toolkit/utils` usage with safe platform detection | ||||||
| - Added Proxy-based lazy initialization for singleton services (ProjectStore, ChangelogService, TitleGenerator) | ||||||
|
|
||||||
| **Sentry Integration:** | ||||||
| - Fixed Sentry initialization timing with safe version detection and package.json fallback | ||||||
| - Sentry now initializes before app.whenReady() while remaining WSL2-compatible | ||||||
| - Temporarily disabled Sentry environment propagation to subprocesses for WSL2 compatibility | ||||||
|
|
||||||
| **electron-log:** | ||||||
| - Disabled preload script to avoid WSL2 path resolution issues | ||||||
| - Main logging functionality preserved and working correctly | ||||||
|
|
||||||
| **electron-updater:** | ||||||
| - Implemented lazy loading pattern with module-level variable | ||||||
| - Added null checks to all autoUpdater access functions | ||||||
| - Changed `getCurrentVersion()` to use `app.getVersion()` instead of autoUpdater for better reliability | ||||||
|
|
||||||
| **Settings Management:** | ||||||
| - Fixed settings path resolution by using `getSettingsPath()` function calls instead of module-level constants | ||||||
|
|
||||||
| **Build Configuration:** | ||||||
| - Ensured CJS format with `.js` extensions for main and preload bundles | ||||||
| - Fixed preload script path from `.mjs` to `.js` to match build output | ||||||
| - Externalized Sentry packages to avoid bundling issues | ||||||
|
|
||||||
| **Backend Path Detection:** | ||||||
| - Added safe `app.getAppPath()` access with try-catch for WSL2 compatibility | ||||||
| - Multiple fallback paths for backend detection | ||||||
|
|
||||||
| ### 🐛 Bug Fixes | ||||||
|
|
||||||
| - Fixed "app.getVersion() is not a function" errors on WSL2 startup | ||||||
| - Fixed "autoUpdater is not defined" errors when accessing update functions | ||||||
| - Fixed "settingsPath is not defined" error in setup wizard | ||||||
| - Fixed preload script "index.mjs" not found error | ||||||
| - Fixed Sentry initialization timing error: "SDK should be initialized before app ready event" | ||||||
| - Fixed electron-log preload script path resolution failures | ||||||
| - Fixed module-level constant initialization issues on WSL2 | ||||||
| - Fixed singleton service initialization timing on WSL2 | ||||||
|
|
||||||
| ### 📚 Documentation | ||||||
|
|
||||||
| - Added [WSL2_SETUP.md](guides/WSL2_SETUP.md) with: | ||||||
| - Prerequisites and installation steps | ||||||
| - Step-by-step WSLg verification guide | ||||||
| - Comprehensive troubleshooting section | ||||||
| - Technical explanations of all fixes | ||||||
| - Architecture patterns for WSL2 compatibility | ||||||
| - Testing checklist for WSL2 development | ||||||
|
|
||||||
| ### 🔧 Files Changed | ||||||
|
|
||||||
| **Main Process:** | ||||||
| - `apps/frontend/src/main/index.ts` - Lazy platform detection, safe app initialization | ||||||
| - `apps/frontend/src/main/sentry.ts` - Safe version detection with fallbacks | ||||||
| - `apps/frontend/src/main/app-logger.ts` - Disabled preload for WSL2 | ||||||
| - `apps/frontend/src/main/app-updater.ts` - Lazy loading with null checks | ||||||
| - `apps/frontend/src/main/project-store.ts` - Proxy-based lazy initialization | ||||||
| - `apps/frontend/src/main/changelog/changelog-service.ts` - Proxy-based lazy initialization, safe path detection | ||||||
| - `apps/frontend/src/main/title-generator.ts` - Proxy-based lazy initialization, safe path detection | ||||||
| - `apps/frontend/src/main/env-utils.ts` - Disabled Sentry subprocess env for WSL2 | ||||||
|
|
||||||
| **IPC Handlers:** | ||||||
| - `apps/frontend/src/main/ipc-handlers/settings-handlers.ts` - Function-based path resolution | ||||||
| - `apps/frontend/src/main/ipc-handlers/context/utils.ts` - WSL2-safe path handling | ||||||
| - `apps/frontend/src/main/ipc-handlers/project-handlers.ts` - WSL2-safe initialization | ||||||
|
|
||||||
| **Build Configuration:** | ||||||
| - `apps/frontend/electron.vite.config.ts` - CJS format, external dependencies | ||||||
| - `apps/frontend/package.json` - Updated for WSL2 compatibility | ||||||
|
|
||||||
| **Other:** | ||||||
| - `.gitignore` - Added logs/security/ exclusion | ||||||
|
|
||||||
| --- | ||||||
|
|
||||||
| ## 2.7.4 - Terminal & Workflow Enhancements | ||||||
|
|
||||||
| ### ✨ New Features | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -20,31 +20,24 @@ const sentryDefines = { | |||||||||||||||||||||||||||||||||||||||||||||||||
| export default defineConfig({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| main: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| define: sentryDefines, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plugins: [externalizeDepsPlugin({ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Bundle these packages into the main process (they won't be in node_modules in packaged app) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| exclude: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'uuid', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'chokidar', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'kuzu', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'electron-updater', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@electron-toolkit/utils', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Sentry and its transitive dependencies (opentelemetry -> debug -> ms) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@sentry/electron', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@sentry/core', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@sentry/node', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@sentry/utils', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@opentelemetry/instrumentation', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'debug', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'ms' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| })], | ||||||||||||||||||||||||||||||||||||||||||||||||||
| plugins: [externalizeDepsPlugin()], | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: Short answer:
Sources: 🏁 Script executed: # First, let's examine the electron.vite.config.ts file to understand the context
find . -name "electron.vite.config.ts" -type f | head -5Repository: AndyMik90/Auto-Claude Length of output: 104 🏁 Script executed: # Check the actual file content to understand the changes
if [ -f "apps/frontend/electron.vite.config.ts" ]; then
cat -n "apps/frontend/electron.vite.config.ts"
fiRepository: AndyMik90/Auto-Claude Length of output: 3678 Migrate away from deprecated externalizeDepsPlugin in electron-vite v5. The 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| build: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| rollupOptions: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| input: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| index: resolve(__dirname, 'src/main/index.ts') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // Only node-pty needs to be external (native module rebuilt by electron-builder) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| external: ['@lydell/node-pty'] | ||||||||||||||||||||||||||||||||||||||||||||||||||
| output: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| format: 'cjs', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| entryFileNames: '[name].js' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| // External modules that should not be bundled | ||||||||||||||||||||||||||||||||||||||||||||||||||
| external: [ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@lydell/node-pty', // Native module | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@sentry/electron', // Sentry main (causes WSL2 issues when bundled) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@sentry/core', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@sentry/node', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| '@electron-toolkit/utils' // Electron utilities (access app before ready) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ] | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+29
to
+40
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
fd -a -t f 'package.json' -x python3 - <<'PY'
import json, sys
path = sys.argv[1]
try:
with open(path, "r", encoding="utf-8") as f:
data = json.load(f)
module_type = data.get('type', '(unset)')
print(f"{path}: type={module_type}")
except Exception as e:
print(f"{path}: ERROR - {e}")
PYRepository: AndyMik90/Auto-Claude Length of output: 151 🏁 Script executed: cat apps/frontend/electron.vite.config.tsRepository: AndyMik90/Auto-Claude Length of output: 3006 🏁 Script executed: fd 'package.json' -t f | head -20Repository: AndyMik90/Auto-Claude Length of output: 104 🏁 Script executed: cat package.json 2>/dev/null | grep -E '"type"|"name"' || echo "No root package.json or type field"Repository: AndyMik90/Auto-Claude Length of output: 108 🏁 Script executed: cat apps/frontend/package.json 2>/dev/null | grep -E '"type"|"name"' || echo "No frontend package.json or type field"Repository: AndyMik90/Auto-Claude Length of output: 163 Fix CJS output naming for The Change both Required fixFor output: {
format: 'cjs',
- entryFileNames: '[name].js'
+ entryFileNames: '[name].cjs'
},For output: {
format: 'cjs',
- entryFileNames: '[name].js'
+ entryFileNames: '[name].cjs'
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -54,6 +47,10 @@ export default defineConfig({ | |||||||||||||||||||||||||||||||||||||||||||||||||
| rollupOptions: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| input: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| index: resolve(__dirname, 'src/preload/index.ts') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| output: { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| format: 'cjs', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| entryFileNames: '[name].js' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,10 +18,13 @@ | |
| "node": ">=24.0.0", | ||
| "npm": ">=10.0.0" | ||
| }, | ||
| "//": "NOTE: Use 'dev:wsl2' scripts for WSL2 environments. The --no-sandbox flag disables Chromium's sandbox security feature and should ONLY be used in WSL2. Regular 'dev' scripts are safe for macOS/Windows/Linux. Production builds never use --no-sandbox.", | ||
| "scripts": { | ||
| "postinstall": "node scripts/postinstall.cjs", | ||
| "dev": "electron-vite dev", | ||
| "dev:debug": "cross-env DEBUG=true electron-vite dev", | ||
| "dev:wsl2": "node scripts/check-wsl2.cjs && electron-vite dev -- --no-sandbox", | ||
| "dev:debug:wsl2": "node scripts/check-wsl2.cjs && cross-env DEBUG=true electron-vite dev -- --no-sandbox", | ||
|
Comment on lines
+21
to
+27
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Good approach: Separate WSL2 scripts isolate the security-sensitive flag. The dedicated Consider adding WSL2 variants for MCP scripts as well for consistency: "dev:mcp": "electron-vite dev -- --remote-debugging-port=9222",
+ "dev:mcp:wsl2": "node scripts/check-wsl2.cjs && electron-vite dev -- --no-sandbox --remote-debugging-port=9222",🤖 Prompt for AI Agents |
||
| "dev:mcp": "electron-vite dev -- --remote-debugging-port=9222", | ||
| "build": "electron-vite build", | ||
| "start": "electron .", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /** | ||
| * WSL2 Detection Script | ||
| * | ||
| * Validates that the development environment is running in WSL2 before allowing | ||
| * --no-sandbox flag usage. This prevents accidental use of disabled Chromium | ||
| * sandbox outside of WSL2 environments where it's required. | ||
| * | ||
| * Usage: node scripts/check-wsl2.cjs | ||
| * Exit codes: | ||
| * 0 - Running in WSL2 (safe to use --no-sandbox) | ||
| * 1 - Not running in WSL2 (should not use --no-sandbox) | ||
| */ | ||
|
|
||
| const fs = require('fs'); | ||
|
|
||
| /** | ||
| * Check if running in WSL2 environment | ||
| * @returns {boolean} true if in WSL2, false otherwise | ||
| */ | ||
| function isWSL2() { | ||
| // Method 1: Check WSL_DISTRO_NAME environment variable | ||
| if (process.env.WSL_DISTRO_NAME) { | ||
| return true; | ||
| } | ||
|
|
||
| // Method 2: Check /proc/version for WSL2 signature (Linux only) | ||
| if (process.platform === 'linux') { | ||
| try { | ||
| const versionInfo = fs.readFileSync('/proc/version', 'utf8').toLowerCase(); | ||
| // WSL2 typically contains 'microsoft' and 'wsl2' in kernel version | ||
| if (versionInfo.includes('microsoft') && versionInfo.includes('wsl2')) { | ||
| return true; | ||
| } | ||
| // Older WSL2 versions might only have 'microsoft' | ||
| if (versionInfo.includes('microsoft')) { | ||
| return true; | ||
| } | ||
| } catch { | ||
| // /proc/version doesn't exist or can't be read | ||
| return false; | ||
| } | ||
|
Comment on lines
+26
to
+41
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid early return so later detection methods still run. If 🛠️ Proposed fix- } catch {
- // /proc/version doesn't exist or can't be read
- return false;
- }
+ } catch {
+ // /proc/version doesn't exist or can't be read
+ // fall through to other detection methods
+ }🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| // Method 3: Check for WSL interop (wsl.exe in PATH) | ||
| if (process.platform === 'linux') { | ||
| try { | ||
| const { execSync } = require('child_process'); | ||
| execSync('which wsl.exe', { stdio: 'ignore' }); | ||
| return true; | ||
| } catch { | ||
| // wsl.exe not found | ||
| } | ||
| } | ||
|
|
||
| return false; | ||
|
Comment on lines
+20
to
+55
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, find the platform module
find . -type f -name "*platform*" | grep -E "\.(ts|tsx|js)$" | head -20Repository: AndyMik90/Auto-Claude Length of output: 164 🏁 Script executed: # Check directory structure of apps/frontend
ls -la apps/frontend/ 2>/dev/null || echo "Directory not found"Repository: AndyMik90/Auto-Claude Length of output: 1266 🏁 Script executed: # Look for the script file
find . -type f -name "check-wsl2.cjs" 2>/dev/nullRepository: AndyMik90/Auto-Claude Length of output: 103 🏁 Script executed: # Read the platform module files to see what's exported
echo "=== apps/frontend/src/shared/platform.ts ===" && wc -l apps/frontend/src/shared/platform.tsRepository: AndyMik90/Auto-Claude Length of output: 149 🏁 Script executed: # Check if there's a platform module in main/
ls -la apps/frontend/src/main/platform/ 2>/dev/null || echo "Not found"Repository: AndyMik90/Auto-Claude Length of output: 421 🏁 Script executed: # Read the actual check-wsl2.cjs script
cat -n apps/frontend/scripts/check-wsl2.cjsRepository: AndyMik90/Auto-Claude Length of output: 3138 🏁 Script executed: # Read the main platform module
head -60 apps/frontend/src/main/platform/index.tsRepository: AndyMik90/Auto-Claude Length of output: 1614 🏁 Script executed: # Read shared platform module
cat -n apps/frontend/src/shared/platform.tsRepository: AndyMik90/Auto-Claude Length of output: 2080 🏁 Script executed: # Read the rest of the main platform module
cat -n apps/frontend/src/main/platform/index.tsRepository: AndyMik90/Auto-Claude Length of output: 14717 🏁 Script executed: # Search for isWSL2 in the codebase
rg "isWSL2" --type ts --type js --type cjsRepository: AndyMik90/Auto-Claude Length of output: 92 🏁 Script executed: # Search for isWSL2 without file type filter
rg "isWSL2" -A 3Repository: AndyMik90/Auto-Claude Length of output: 1709 🏁 Script executed: # Check if there's a built version or dist directory
find . -type d -name "dist" -o -name "build" | head -10Repository: AndyMik90/Auto-Claude Length of output: 47 🏁 Script executed: # Check how other scripts import from platform module
ls -la apps/frontend/scripts/Repository: AndyMik90/Auto-Claude Length of output: 529 🏁 Script executed: # Check package.json to see how scripts/cjs files use the platform module
head -100 apps/frontend/package.json | grep -A 20 "scripts"Repository: AndyMik90/Auto-Claude Length of output: 2332 🏁 Script executed: # Check if there's a built/bundled version of platform module
find . -path "*/dist/*" -o -path "*/build/*" | grep platform | head -10Repository: AndyMik90/Auto-Claude Length of output: 47 🏁 Script executed: # Check how postinstall.cjs or other scripts import from TypeScript modules
head -50 apps/frontend/scripts/postinstall.cjsRepository: AndyMik90/Auto-Claude Length of output: 1612 🏁 Script executed: # Verify the exact differences in /proc/version checks between platform module and script
echo "=== Platform module check ===" && sed -n '95,108p' apps/frontend/src/main/platform/index.ts
echo "=== Script check ===" && sed -n '26,42p' apps/frontend/scripts/check-wsl2.cjsRepository: AndyMik90/Auto-Claude Length of output: 1182 🏁 Script executed: # Check if platform module has build output or if it's directly imported
cat apps/frontend/tsconfig.json | head -50Repository: AndyMik90/Auto-Claude Length of output: 880 🏁 Script executed: # Verify how env-utils.ts imports isWSL2 from platform module (TypeScript to TypeScript)
grep -A 5 "import.*isWSL2" apps/frontend/src/main/env-utils.tsRepository: AndyMik90/Auto-Claude Length of output: 243 Consolidate WSL2 detection into platform module; the refactor suggestion needs adjustment for CJS compatibility. This script uses To properly refactor:
Also note the 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| // Main execution | ||
| const isWsl2 = isWSL2(); | ||
|
|
||
| if (isWsl2) { | ||
| console.log('✓ WSL2 environment detected - --no-sandbox flag is safe to use'); | ||
| process.exit(0); | ||
| } else { | ||
| console.error('✗ Not running in WSL2!'); | ||
| console.error(''); | ||
| console.error('The dev:wsl2 script is designed for WSL2 environments only.'); | ||
| console.error('It disables Chromium sandbox (--no-sandbox) which is a security risk outside WSL2.'); | ||
| console.error(''); | ||
| console.error('Please use one of these alternatives:'); | ||
| console.error(' • npm run dev - Development mode with Chromium sandbox enabled'); | ||
| console.error(' • npm run dev:debug - Debug mode with Chromium sandbox enabled'); | ||
| console.error(''); | ||
| console.error('If you are in WSL2 but seeing this error, check:'); | ||
| console.error(' 1. WSL_DISTRO_NAME environment variable is set'); | ||
| console.error(' 2. Running WSL2 (not WSL1): wsl.exe --list --verbose'); | ||
| process.exit(1); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,7 +22,7 @@ import os from 'os'; | |
|
|
||
| // Configure electron-log (wrapped in try-catch for re-import scenarios in tests) | ||
| try { | ||
| log.initialize(); | ||
| log.initialize({ preload: false }); // Disable preload to avoid WSL2 path issues | ||
| } catch { | ||
| // Already initialized, ignore | ||
| } | ||
|
|
@@ -42,15 +42,19 @@ log.transports.console.format = '[{h}:{i}:{s}] [{level}] {text}'; | |
| // Determine if this is a beta version | ||
| function isBetaVersion(): boolean { | ||
| try { | ||
| // WSL2 compatibility: app may not be ready yet at module load time | ||
| if (!app || typeof app.getVersion !== 'function') { | ||
| return false; | ||
| } | ||
| const version = app.getVersion(); | ||
| return version.includes('-beta') || version.includes('-alpha') || version.includes('-rc'); | ||
| } catch (error) { | ||
| log.warn('Failed to detect beta version:', error); | ||
| // Silently fail if app is not ready yet - this is called at module load time | ||
| return false; | ||
|
Comment on lines
+45
to
53
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick | 🔵 Trivial Beta logging may never enable if Line 45-63: If ♻️ Proposed refactor-// Enhanced logging for beta versions (lazy check - safe for WSL2)
-if (isBetaVersion()) {
- log.transports.file.level = 'debug';
- log.info('Beta version detected - enhanced logging enabled');
-} else {
- log.transports.file.level = 'info';
-}
+const enableBetaLogging = () => {
+ if (isBetaVersion()) {
+ log.transports.file.level = 'debug';
+ log.info('Beta version detected - enhanced logging enabled');
+ } else {
+ log.transports.file.level = 'info';
+ }
+};
+
+enableBetaLogging();
+if (app && typeof app.whenReady === 'function') {
+ app.whenReady().then(enableBetaLogging).catch(() => {
+ // ignore: fallback to default log level
+ });
+}Also applies to: 57-63 🤖 Prompt for AI Agents |
||
| } | ||
| } | ||
|
|
||
| // Enhanced logging for beta versions | ||
| // Enhanced logging for beta versions (lazy check - safe for WSL2) | ||
| if (isBetaVersion()) { | ||
| log.transports.file.level = 'debug'; | ||
| log.info('Beta version detected - enhanced logging enabled'); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.