fix: critical permission modal and config issues #127

Merged
naomi merged 19 commits from feat/many into main 2026-02-07 01:55:50 -08:00
Showing only changes of commit e8b8ee17fa - Show all commits
+30 -1
View File
@@ -62,8 +62,37 @@ console.log("[Tauri Listener] message");
- Config file gets reset to defaults
- Settings don't persist between sessions
- Model selection is lost
- Config appears to work, then randomly resets
**POTENTIAL CAUSES:**
**ACTUAL ROOT CAUSE (FIXED!):**
The config store had a **critical race condition bug** in `src/lib/stores/config.ts`. The pattern used everywhere was:
```typescript
// ❌ BUGGY CODE
let currentConfig = defaultConfig;
config.subscribe((c) => (currentConfig = c))(); // <-- Immediate unsubscribe!
return currentConfig;
```
**Why this caused config loss:**
- The `()` at the end immediately unsubscribes from the store
- This creates a race condition - sometimes you get the value, sometimes you don't
- When it fails, it returns `defaultConfig` instead of your actual config
- This is why your settings would randomly disappear!
**The fix:**
```typescript
// ✅ CORRECT CODE
function getCurrentConfig(): HikariConfig {
let currentConfig: HikariConfig = defaultConfig;
const unsubscribe = config.subscribe((c) => (currentConfig = c));
unsubscribe(); // <-- Proper cleanup after getting value
return currentConfig;
}
```
**POTENTIAL CAUSES (if the above is fixed):**
### 1. Missing `#[serde(default)]` Attribute