|
| 1 | +# Settings Revamp & Restore Addon Only Feature |
| 2 | + |
| 3 | +**Status**: Proposal |
| 4 | +**Date**: 2026-01-04 |
| 5 | +**Author**: Kiro AI Assistant |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## 📋 Overview |
| 10 | + |
| 11 | +Revamp settings structure dan tambah fitur "Restore Addon Only" untuk restore hanya addon folders dari backup session. |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## 🎯 Goals |
| 16 | + |
| 17 | +1. **Simplify Settings** - Merge kategori yang isinya sedikit |
| 18 | +2. **Add Import/Export Settings** - Backup/restore konfigurasi SurfManager |
| 19 | +3. **Add Restore Addon Only** - Restore hanya addon folders (experimental) |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## 📐 Settings Structure (New) |
| 24 | + |
| 25 | +### **Current Structure (6 Categories)** |
| 26 | +``` |
| 27 | +├── Appearance → Theme only |
| 28 | +├── Behavior → Few options |
| 29 | +├── Sessions → Few options |
| 30 | +├── Notes → ??? |
| 31 | +├── Advanced → ??? |
| 32 | +└── Experimental → ??? |
| 33 | +``` |
| 34 | + |
| 35 | +### **Proposed Structure (4 Categories)** |
| 36 | +``` |
| 37 | +├── 🎨 General |
| 38 | +├── ⚙️ Behavior |
| 39 | +├── 📦 Sessions |
| 40 | +└── 🧪 Experimental |
| 41 | +``` |
| 42 | + |
| 43 | +--- |
| 44 | + |
| 45 | +## 🎨 General Settings |
| 46 | + |
| 47 | +| Setting | Type | Default | Description | |
| 48 | +|---------|------|---------|-------------| |
| 49 | +| **Theme** | Toggle (Dark/Auto/Light) | Dark | Color scheme | |
| 50 | +| **Remember Last Tab** | Toggle | ON | Remember last opened tab on startup | |
| 51 | +| **Import Settings** | Button | - | Import settings from .json file | |
| 52 | +| **Export Settings** | Button | - | Export settings to .json file | |
| 53 | +| **Reset Settings** | Button | - | Reset all settings to default | |
| 54 | + |
| 55 | +### Import/Export Settings Feature |
| 56 | + |
| 57 | +**Export Format** (`.surfmanager-settings.json`): |
| 58 | +```json |
| 59 | +{ |
| 60 | + "version": "2.0.1", |
| 61 | + "exported_at": "2026-01-04T16:50:00Z", |
| 62 | + "settings": { |
| 63 | + "theme": "dark", |
| 64 | + "rememberLastTab": true, |
| 65 | + "confirmBeforeReset": true, |
| 66 | + "confirmBeforeDelete": true, |
| 67 | + "autoBackup": true, |
| 68 | + "skipCloseApp": false, |
| 69 | + "showAutoBackups": true, |
| 70 | + "maxAutoBackups": 5, |
| 71 | + "experimental": { |
| 72 | + "showRestoreAddonOnly": false |
| 73 | + } |
| 74 | + } |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +**Import Behavior**: |
| 79 | +- Validate JSON structure |
| 80 | +- Show preview of changes |
| 81 | +- Confirm before applying |
| 82 | +- Backup current settings before import |
| 83 | + |
| 84 | +--- |
| 85 | + |
| 86 | +## ⚙️ Behavior Settings |
| 87 | + |
| 88 | +| Setting | Type | Default | Description | |
| 89 | +|---------|------|---------|-------------| |
| 90 | +| **Confirm before Reset** | Toggle | ON | Show confirmation dialog before reset | |
| 91 | +| **Confirm before Delete** | Toggle | ON | Show confirmation dialog before delete | |
| 92 | +| **Auto-Backup on Reset** | Toggle | ON | Create auto-backup before reset | |
| 93 | +| **Skip Close App** | Toggle | OFF | Don't close app during backup/reset | |
| 94 | + |
| 95 | +--- |
| 96 | + |
| 97 | +## 📦 Sessions Settings |
| 98 | + |
| 99 | +| Setting | Type | Default | Description | |
| 100 | +|---------|------|---------|-------------| |
| 101 | +| **Show Auto-backups** | Toggle | ON | Display auto-backups in session list | |
| 102 | +| **Max Auto-backups** | Number (1-10) | 5 | Maximum auto-backups per app | |
| 103 | +| **Open Backup Folder** | Button | - | Open backup folder in explorer | |
| 104 | +| **Clean Old Auto-backups** | Button | - | Delete all auto-backups older than X days | |
| 105 | + |
| 106 | +--- |
| 107 | + |
| 108 | +## 🧪 Experimental Settings |
| 109 | + |
| 110 | +| Setting | Type | Default | Description | |
| 111 | +|---------|------|---------|-------------| |
| 112 | +| **Show Restore Addon Only** | Toggle | OFF | Enable "Restore Addon Only" in context menu | |
| 113 | +| **Debug Mode** | Toggle | OFF | Show debug logs in console | |
| 114 | +| **Enable Beta Features** | Toggle | OFF | Enable experimental features | |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +## 🆕 Feature: Restore Addon Only |
| 119 | + |
| 120 | +### Overview |
| 121 | +Restore ONLY addon folders from a backup session, without touching the main data folder. |
| 122 | + |
| 123 | +### Use Case |
| 124 | +User wants to restore `.aws` credentials from backup without restoring entire VSCode settings. |
| 125 | + |
| 126 | +### Requirements |
| 127 | +1. **Setting enabled**: `Experimental > Show Restore Addon Only = ON` |
| 128 | +2. **App has addon paths**: `addon_backup_paths` not empty |
| 129 | +3. **Session has addons**: `_addons` folder exists in backup |
| 130 | + |
| 131 | +### UI Flow |
| 132 | + |
| 133 | +**Right-click Context Menu (Sessions Tab)**: |
| 134 | +``` |
| 135 | +┌─────────────────────────────┐ |
| 136 | +│ 📦 Restore Session │ |
| 137 | +│ 👤 Restore Account Only │ |
| 138 | +│ 📁 Restore Addon Only │ ← NEW (conditional) |
| 139 | +│ ─────────────────────────── │ |
| 140 | +│ ✓ Set as Active │ |
| 141 | +│ 📂 Open Folder │ |
| 142 | +│ ─────────────────────────── │ |
| 143 | +│ 🗑️ Delete Session │ |
| 144 | +└─────────────────────────────┘ |
| 145 | +``` |
| 146 | + |
| 147 | +**Visibility Logic**: |
| 148 | +```javascript |
| 149 | +showRestoreAddonOnly = |
| 150 | + settings.experimental.showRestoreAddonOnly === true && |
| 151 | + app.addon_backup_paths.length > 0 && |
| 152 | + sessionHasAddonsFolder(session) |
| 153 | +``` |
| 154 | + |
| 155 | +### Backend Implementation |
| 156 | + |
| 157 | +**New Function**: `RestoreAddonOnly(appKey, sessionName, skipClose)` |
| 158 | + |
| 159 | +```go |
| 160 | +func (a *App) RestoreAddonOnly(appKey, sessionName string, skipClose bool) error { |
| 161 | + cfg := a.GetApp(appKey) |
| 162 | + if cfg == nil { |
| 163 | + return fmt.Errorf("app not found: %s", appKey) |
| 164 | + } |
| 165 | + |
| 166 | + if len(cfg.AddonPaths) == 0 { |
| 167 | + return fmt.Errorf("no addon paths configured") |
| 168 | + } |
| 169 | + |
| 170 | + // Close app if needed |
| 171 | + if !skipClose { |
| 172 | + // ... close logic |
| 173 | + } |
| 174 | + |
| 175 | + // Restore ONLY addons from backup |
| 176 | + backupFolder := filepath.Join(m.backupPath, appKey, sessionName) |
| 177 | + return m.restoreAddons(backupFolder, cfg.AddonPaths, progressCb) |
| 178 | +} |
| 179 | +``` |
| 180 | + |
| 181 | +### Confirmation Dialog |
| 182 | + |
| 183 | +``` |
| 184 | +┌─────────────────────────────────────────┐ |
| 185 | +│ Restore Addon Folders Only │ |
| 186 | +├─────────────────────────────────────────┤ |
| 187 | +│ │ |
| 188 | +│ Restore addon folders from: │ |
| 189 | +│ "session-name" │ |
| 190 | +│ │ |
| 191 | +│ This will restore: │ |
| 192 | +│ • C:\Users\User\.aws │ |
| 193 | +│ • C:\Users\User\.ssh │ |
| 194 | +│ │ |
| 195 | +│ Main data folder will NOT be touched. │ |
| 196 | +│ │ |
| 197 | +│ ┌─────────┐ ┌─────────┐ │ |
| 198 | +│ │ Cancel │ │ Restore │ │ |
| 199 | +│ └─────────┘ └─────────┘ │ |
| 200 | +└─────────────────────────────────────────┘ |
| 201 | +``` |
| 202 | + |
| 203 | +--- |
| 204 | + |
| 205 | +## 🔧 Implementation Plan |
| 206 | + |
| 207 | +### Phase 1: Settings Revamp |
| 208 | +1. ✅ Merge settings categories (4 instead of 6) |
| 209 | +2. ✅ Add Import/Export Settings buttons |
| 210 | +3. ✅ Implement settings JSON export |
| 211 | +4. ✅ Implement settings JSON import with validation |
| 212 | +5. ✅ Add "Show Restore Addon Only" toggle in Experimental |
| 213 | + |
| 214 | +### Phase 2: Restore Addon Only |
| 215 | +1. ✅ Add backend function `RestoreAddonOnly` |
| 216 | +2. ✅ Add frontend context menu item (conditional) |
| 217 | +3. ✅ Add confirmation dialog |
| 218 | +4. ✅ Test with various scenarios |
| 219 | + |
| 220 | +### Phase 3: Polish |
| 221 | +1. ✅ Add tooltips for experimental features |
| 222 | +2. ✅ Add warning icons for experimental toggles |
| 223 | +3. ✅ Update documentation |
| 224 | + |
| 225 | +--- |
| 226 | + |
| 227 | +## 🎨 UI Mockups |
| 228 | + |
| 229 | +### Settings Page (General) |
| 230 | +``` |
| 231 | +┌─────────────────────────────────────────────────────────┐ |
| 232 | +│ SETTINGS │ |
| 233 | +├─────────────────────────────────────────────────────────┤ |
| 234 | +│ │ |
| 235 | +│ ┌──────────────┐ ┌─────────────────────────────────┐ │ |
| 236 | +│ │ 🎨 General │ │ Theme │ │ |
| 237 | +│ ├──────────────┤ │ Choose your color scheme │ │ |
| 238 | +│ │ ⚙️ Behavior │ │ ┌──────┐ ┌──────┐ ┌──────┐ │ │ |
| 239 | +│ ├──────────────┤ │ │ Dark │ │ Auto │ │Light │ │ │ |
| 240 | +│ │ 📦 Sessions │ │ └──────┘ └──────┘ └──────┘ │ │ |
| 241 | +│ ├──────────────┤ │ │ │ |
| 242 | +│ │ 🧪 Experim. │ │ ☑ Remember Last Tab │ │ |
| 243 | +│ └──────────────┘ │ │ │ |
| 244 | +│ │ ───────────────────────────── │ │ |
| 245 | +│ │ │ │ |
| 246 | +│ │ Settings Management │ │ |
| 247 | +│ │ ┌──────────────┐ │ │ |
| 248 | +│ │ │ Import │ │ │ |
| 249 | +│ │ └──────────────┘ │ │ |
| 250 | +│ │ ┌──────────────┐ │ │ |
| 251 | +│ │ │ Export │ │ │ |
| 252 | +│ │ └──────────────┘ │ │ |
| 253 | +│ │ ┌──────────────┐ │ │ |
| 254 | +│ │ │ Reset All │ │ │ |
| 255 | +│ │ └──────────────┘ │ │ |
| 256 | +│ └─────────────────────────────────┘ │ |
| 257 | +└─────────────────────────────────────────────────────────┘ |
| 258 | +``` |
| 259 | + |
| 260 | +### Settings Page (Experimental) |
| 261 | +``` |
| 262 | +┌─────────────────────────────────────────────────────────┐ |
| 263 | +│ SETTINGS │ |
| 264 | +├─────────────────────────────────────────────────────────┤ |
| 265 | +│ │ |
| 266 | +│ ┌──────────────┐ ┌─────────────────────────────────┐ │ |
| 267 | +│ │ 🎨 General │ │ Experimental Features │ │ |
| 268 | +│ ├──────────────┤ │ ⚠️ Use at your own risk │ │ |
| 269 | +│ │ ⚙️ Behavior │ │ │ │ |
| 270 | +│ ├──────────────┤ │ ☐ Show Restore Addon Only │ │ |
| 271 | +│ │ 📦 Sessions │ │ Enable "Restore Addon Only" │ │ |
| 272 | +│ ├──────────────┤ │ in session context menu │ │ |
| 273 | +│ │ 🧪 Experim. │◄─│ │ │ |
| 274 | +│ └──────────────┘ │ ☐ Debug Mode │ │ |
| 275 | +│ │ Show debug logs │ │ |
| 276 | +│ │ │ │ |
| 277 | +│ │ ☐ Enable Beta Features │ │ |
| 278 | +│ │ Unlock experimental features │ │ |
| 279 | +│ └─────────────────────────────────┘ │ |
| 280 | +└─────────────────────────────────────────────────────────┘ |
| 281 | +``` |
| 282 | + |
| 283 | +--- |
| 284 | + |
| 285 | +## 🧪 Testing Scenarios |
| 286 | + |
| 287 | +### Restore Addon Only |
| 288 | +1. ✅ App with addon paths + session with _addons → Show menu item |
| 289 | +2. ✅ App without addon paths → Hide menu item |
| 290 | +3. ✅ Session without _addons folder → Hide menu item |
| 291 | +4. ✅ Setting disabled → Hide menu item |
| 292 | +5. ✅ Restore only addons, verify data folder untouched |
| 293 | +6. ✅ Handle missing addon paths gracefully |
| 294 | + |
| 295 | +### Import/Export Settings |
| 296 | +1. ✅ Export settings to JSON |
| 297 | +2. ✅ Import valid JSON |
| 298 | +3. ✅ Import invalid JSON → Show error |
| 299 | +4. ✅ Import with missing fields → Use defaults |
| 300 | +5. ✅ Preview changes before import |
| 301 | + |
| 302 | +--- |
| 303 | + |
| 304 | +## 📝 Notes |
| 305 | + |
| 306 | +- **Backward Compatibility**: Old settings format should still work |
| 307 | +- **Migration**: Auto-migrate old settings to new structure |
| 308 | +- **Validation**: Validate all imported settings before applying |
| 309 | +- **Backup**: Always backup current settings before import |
| 310 | + |
| 311 | +--- |
| 312 | + |
| 313 | +## ✅ Acceptance Criteria |
| 314 | + |
| 315 | +- [ ] Settings page has 4 categories (General, Behavior, Sessions, Experimental) |
| 316 | +- [ ] Import/Export settings works correctly |
| 317 | +- [ ] "Restore Addon Only" appears in context menu when conditions met |
| 318 | +- [ ] "Restore Addon Only" restores ONLY addon folders |
| 319 | +- [ ] All existing settings still work after revamp |
| 320 | +- [ ] Settings are persisted correctly |
| 321 | +- [ ] UI is clean and intuitive |
| 322 | + |
| 323 | +--- |
| 324 | + |
| 325 | +## 🚀 Future Enhancements |
| 326 | + |
| 327 | +1. **Cloud Sync Settings** - Sync settings across devices |
| 328 | +2. **Settings Profiles** - Multiple setting profiles (Work, Personal, etc.) |
| 329 | +3. **Scheduled Auto-backups** - Automatic backup on schedule |
| 330 | +4. **Backup Compression** - Compress backups to save space |
| 331 | +5. **Backup Encryption** - Encrypt sensitive backups |
| 332 | + |
| 333 | +--- |
| 334 | + |
| 335 | +## 📚 Related Files |
| 336 | + |
| 337 | +- `frontend/src/lib/SettingsTab.svelte` - Settings UI |
| 338 | +- `frontend/src/lib/SessionsTab.svelte` - Context menu |
| 339 | +- `frontend/src/lib/stores/settings.js` - Settings store |
| 340 | +- `internal/config/config.go` - Settings backend |
| 341 | +- `app.go` - RestoreAddonOnly function |
| 342 | + |
| 343 | +--- |
| 344 | + |
| 345 | +**End of Proposal** |
0 commit comments