Files
hikari-desktop/FIXES-2026-02-06.md
T

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 importing debugConsoleStore
  • 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 everywhere
  • updateConfig() - Base for all updates
  • toggleStreamerMode() / toggleCompactMode()
  • increaseFontSize() / decreaseFontSize()
  • addAutoGrantedTool() / removeAutoGrantedTool()
  • setTheme() / setCustomThemeColors()
  • And more...

Files Changed:

  • src/lib/stores/config.ts - Fixed race condition in 12 methods
  • src-tauri/src/config.rs - Added #[serde(default)] for resilience

Additional Improvements

Documentation (Commits 80ee25f, e8b8ee1, 4a99848):

  • Created comprehensive DEBUGGING.md guide
  • 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:

  1. Test permission modal shows up properly
  2. Test config persists through app restarts
  3. Test config survives permission reconnections
  4. Check browser console for any errors
  5. 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 modal
  • 2c64ef0 - fix: resolve critical config store race condition causing config loss
  • 80ee25f - docs: add comprehensive debugging guide for common issues
  • e8b8ee1 - docs: update DEBUGGING.md with config race condition fix
  • 4a99848 - docs: massively expand DEBUGGING.md with comprehensive troubleshooting

Prevention

Always:

  1. Run pnpm check before committing
  2. Test the app, especially permission flow
  3. Check browser console for errors
  4. Never use store.subscribe(...)() pattern (immediate unsubscribe)
  5. 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