generated from nhcarrigan/template
3.8 KiB
3.8 KiB
Critical Bug Fixes - 2026-02-06
Summary
Fixed TWO CRITICAL BUGS that were causing permission modal issues and config loss.
Bug #1: Permission Modal Not Showing (Commit d16644a)
Symptom: Permission requests triggered but modal never appeared, app hung
Root Cause: Undefined variable error in src/lib/tauri.ts
- Called
debugConsoleStore.log()without importingdebugConsoleStore - Even if imported, that method doesn't exist on the store
- This crashed event listener initialization, preventing permission events from being captured
Fix:
- Removed the non-existent import
- Changed to
console.log()which gets automatically captured by the debug console - Added logging to track permission event flow
Files Changed:
src/lib/tauri.ts- Fixed undefined variable, added proper logging
Bug #2: Config Constantly Resetting (Commit 2c64ef0)
Symptom: Config settings would randomly reset to defaults, especially after permission approvals
Root Cause: Race condition in src/lib/stores/config.ts
- Used buggy pattern:
config.subscribe((c) => (currentConfig = c))() - The
()at the end immediately unsubscribes, creating a race condition - Sometimes got the value, sometimes returned defaults
- Affected 12 different methods in the config store!
Fix:
- Created proper
getCurrentConfig()helper function - Stores unsubscribe function, calls it AFTER getting value
- Replaced all 12 buggy occurrences with the safe pattern
Methods Fixed:
getConfig()- Core method used everywhereupdateConfig()- Base for all updatestoggleStreamerMode()/toggleCompactMode()increaseFontSize()/decreaseFontSize()addAutoGrantedTool()/removeAutoGrantedTool()setTheme()/setCustomThemeColors()- And more...
Files Changed:
src/lib/stores/config.ts- Fixed race condition in 12 methodssrc-tauri/src/config.rs- Added#[serde(default)]for resilience
Additional Improvements
Documentation (Commits 80ee25f, e8b8ee1, 4a99848):
- Created comprehensive
DEBUGGING.mdguide - Documented both bugs with code examples
- Added step-by-step debugging procedures
- Included common patterns and anti-patterns
- Prevention tips and testing checklist
Testing
Before deploying:
- Test permission modal shows up properly
- Test config persists through app restarts
- Test config survives permission reconnections
- Check browser console for any errors
- Verify all settings save and load correctly
Impact
High Priority - Breaking Bugs:
- Permission modal was completely broken (app unusable for restricted tools)
- Config loss made user experience terrible (settings constantly resetting)
Now Fixed:
- Permission modal should display reliably
- Config should persist across all operations
- No more random resets to default settings
Commits
d16644a- fix: resolve critical runtime errors blocking permission modal2c64ef0- fix: resolve critical config store race condition causing config loss80ee25f- docs: add comprehensive debugging guide for common issuese8b8ee1- docs: update DEBUGGING.md with config race condition fix4a99848- docs: massively expand DEBUGGING.md with comprehensive troubleshooting
Prevention
Always:
- Run
pnpm checkbefore committing - Test the app, especially permission flow
- Check browser console for errors
- Never use
store.subscribe(...)()pattern (immediate unsubscribe) - Import everything you use!
Never:
- Call
debugConsoleStore.log()(method doesn't exist) - Use race-condition patterns with Svelte stores
- Assume synchronous code is safe from race conditions
- Skip testing after changes to event listeners or stores
Date: 2026-02-06 Fixed By: Hikari Branch: feat/many Severity: Critical Status: Fixed ✅