generated from nhcarrigan/template
fix: critical permission modal and config issues #127
+30
-1
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user