|
| 1 | +# Panel System Refactor |
| 2 | + |
| 3 | +## Problem |
| 4 | +The tab/panel system for Terminal, Agent, Files/Git, and Editor was glitchy and inconsistent because there were **two separate systems** managing panel visibility: |
| 5 | + |
| 6 | +1. **Layout Preset System** - Used `leftPanel`/`rightPanel` signals with preset configurations |
| 7 | +2. **Direct Toggle Functions** - Used individual visibility signals (`terminalVisible`, `sidebarVisible`, `agentVisible`, `editorVisible`) |
| 8 | + |
| 9 | +These two systems weren't synchronized, causing issues like: |
| 10 | +- Closing panels could leave them "pinned" in unexpected positions |
| 11 | +- Agent panel wasn't integrated with the preset system |
| 12 | +- Toggling panels from different locations (TopBar vs StatusBar) could produce inconsistent results |
| 13 | + |
| 14 | +## Solution |
| 15 | +**Unified Panel Management System** with a single source of truth: |
| 16 | + |
| 17 | +### New Architecture |
| 18 | +- **Single state**: `visiblePanels` - a `Set<Panel>` containing: `"terminal"`, `"agent"`, `"files"`, `"editor"` |
| 19 | +- **Derived signals**: All visibility checks computed from the single state |
| 20 | +- **Simple API**: `togglePanel()`, `showPanel()`, `hidePanel()`, `setPanelVisibility()` |
| 21 | + |
| 22 | +### Key Changes |
| 23 | + |
| 24 | +#### 1. `src/stores/uiStore.ts` |
| 25 | +- **Removed**: `PanelSlot`, `LayoutPreset`, `LAYOUT_PRESETS`, `leftPanel`, `rightPanel`, layout preset functions |
| 26 | +- **Added**: `Panel` type, `visiblePanels` signal, unified panel management functions |
| 27 | +- **Kept for compatibility**: All existing toggle/setter functions now route through the unified system |
| 28 | + |
| 29 | +#### 2. `src/components/layout/TopBar.tsx` |
| 30 | +- **Removed**: Layout dropdown with presets |
| 31 | +- **Added**: Simple Agent toggle button (matches the existing Files toggle pattern) |
| 32 | +- Agent and Files toggles now sit side-by-side in the top bar |
| 33 | + |
| 34 | +#### 3. `src/stores/settingsStore.ts` |
| 35 | +- **Removed**: `leftPanel` and `rightPanel` from Settings interface |
| 36 | +- Panel visibility is now ephemeral (not persisted across sessions) |
| 37 | + |
| 38 | +#### 4. `src/App.tsx` |
| 39 | +- **Removed**: Layout restoration logic from settings |
| 40 | + |
| 41 | +## Benefits |
| 42 | +✅ **Single source of truth** - No more conflicting state |
| 43 | +✅ **Predictable behavior** - Toggling a panel always does the same thing |
| 44 | +✅ **Simpler UI** - Direct toggle buttons instead of complex preset system |
| 45 | +✅ **Better flexibility** - Users can show/hide any combination of panels |
| 46 | +✅ **Backward compatible** - All existing toggle functions still work |
| 47 | + |
| 48 | +## User-Facing Changes |
| 49 | +- **Layout dropdown removed** from top bar |
| 50 | +- **Agent toggle button added** to top bar (next to Files toggle) |
| 51 | +- Users now have direct control over each panel independently |
| 52 | +- Panel visibility resets to default (Terminal, Files, Editor) on app restart |
| 53 | + |
| 54 | +## Migration Notes |
| 55 | +- Existing saved layout preferences (`leftPanel`/`rightPanel` in settings) will be ignored |
| 56 | +- No data loss - just reverts to showing Terminal, Files, and Editor by default |
| 57 | +- Users can quickly toggle panels on/off using: |
| 58 | + - TopBar: Agent button, Files button |
| 59 | + - StatusBar: Terminal button, Agent button, Editor button |
| 60 | + |
| 61 | +## Technical Details |
| 62 | + |
| 63 | +### Before: |
| 64 | +```typescript |
| 65 | +// Two competing systems |
| 66 | +const [leftPanel, setLeftPanel] = createSignal<PanelSlot>("terminal"); |
| 67 | +const [rightPanel, setRightPanel] = createSignal<PanelSlot>("sidebar"); |
| 68 | +const [terminalVisible, setTerminalVisible] = createSignal(true); |
| 69 | +const [agentVisible, setAgentVisible] = createSignal(false); |
| 70 | +// ... could get out of sync |
| 71 | +``` |
| 72 | + |
| 73 | +### After: |
| 74 | +```typescript |
| 75 | +// Single source of truth |
| 76 | +const [visiblePanels, setVisiblePanels] = createSignal<Set<Panel>>( |
| 77 | + new Set(["terminal", "files", "editor"]) |
| 78 | +); |
| 79 | + |
| 80 | +// Derived signals (always consistent) |
| 81 | +const terminalVisible = () => visiblePanels().has("terminal"); |
| 82 | +const agentVisible = () => visiblePanels().has("agent"); |
| 83 | +``` |
| 84 | + |
| 85 | +## Testing Checklist |
| 86 | +- [ ] Toggle Terminal from StatusBar |
| 87 | +- [ ] Toggle Agent from TopBar |
| 88 | +- [ ] Toggle Agent from StatusBar |
| 89 | +- [ ] Toggle Files from TopBar |
| 90 | +- [ ] Toggle Editor from StatusBar |
| 91 | +- [ ] Close all panels except one - verify no "pinning" issues |
| 92 | +- [ ] Open multiple panels simultaneously |
| 93 | +- [ ] Restart app - verify default layout loads correctly |
| 94 | +- [ ] Resize panels - verify they maintain proper widths |
0 commit comments