|
| 1 | +# Design: TUI Enhancements |
| 2 | + |
| 3 | +## Issues |
| 4 | + |
| 5 | +| # | Title | Type | Priority | Size | |
| 6 | +|---|-------|------|----------|------| |
| 7 | +| 204 | TUI: Add search/filter within loaded results | feature | P2-Medium | M | |
| 8 | +| 205 | TUI: Add multi-cell selection with Shift+Arrow | feature | P2-Medium | M | |
| 9 | +| 206 | TUI: Export selection as CSV/TSV | feature | P2-Medium | S | |
| 10 | +| 207 | TUI: Add mouse support for table navigation | feature | P3-Low | S | |
| 11 | +| 208 | TUI: Query history as selectable list | feature | P2-Medium | M | |
| 12 | +| 234 | refactor(tui): Abstract SQL table pattern for reuse across all data tables | refactor | P2-Medium | L | |
| 13 | + |
| 14 | +## Context |
| 15 | + |
| 16 | +The TUI (Terminal User Interface) provides an interactive SQL query experience for Dataverse. Current implementation works but lacks ergonomic features that would improve daily workflow. |
| 17 | + |
| 18 | +### Current TUI Location |
| 19 | +``` |
| 20 | +src/PPDS.Cli/Tui/ |
| 21 | +├── SqlQueryScreen.cs # Main query interface |
| 22 | +├── DataTableView.cs # Table display component |
| 23 | +├── QueryInputView.cs # SQL input component |
| 24 | +└── ... |
| 25 | +``` |
| 26 | + |
| 27 | +## Feature Dependencies |
| 28 | + |
| 29 | +``` |
| 30 | +#234 (Abstract table pattern) ─┬─► #204 (Search/filter) |
| 31 | + ├─► #205 (Multi-cell selection) |
| 32 | + ├─► #206 (Export CSV) |
| 33 | + └─► #207 (Mouse support) |
| 34 | +
|
| 35 | +#208 (Query history) ──► Independent |
| 36 | +``` |
| 37 | + |
| 38 | +**Recommendation:** Do #234 first to establish the abstraction, then others can build on it. |
| 39 | + |
| 40 | +## Suggested Implementation Order |
| 41 | + |
| 42 | +1. **#234** - Abstract SQL table pattern (foundation for others) |
| 43 | +2. **#208** - Query history (independent, can be parallel) |
| 44 | +3. **#204** - Search/filter within results |
| 45 | +4. **#205** - Multi-cell selection |
| 46 | +5. **#206** - Export CSV (needs #205 for selection) |
| 47 | +6. **#207** - Mouse support (nice-to-have) |
| 48 | + |
| 49 | +## Key Files |
| 50 | + |
| 51 | +``` |
| 52 | +src/PPDS.Cli/Tui/SqlQueryScreen.cs |
| 53 | +src/PPDS.Cli/Tui/DataTableView.cs |
| 54 | +src/PPDS.Cli/Tui/QueryInputView.cs |
| 55 | +src/PPDS.Cli/Services/QueryHistoryService.cs (new) |
| 56 | +``` |
| 57 | + |
| 58 | +## Technical Notes |
| 59 | + |
| 60 | +### #234 - Table Abstraction |
| 61 | +- Extract generic `DataTableView<T>` from current SQL-specific implementation |
| 62 | +- Should support: column definitions, row data, selection, scrolling |
| 63 | +- Reusable for: query results, metadata listings, import previews |
| 64 | + |
| 65 | +### #204 - Search/Filter |
| 66 | +- `/` key to enter search mode (vim-style) |
| 67 | +- Filter rows by text match across all visible columns |
| 68 | +- `n`/`N` to navigate between matches |
| 69 | +- `Esc` to clear filter |
| 70 | + |
| 71 | +### #205 - Multi-Cell Selection |
| 72 | +- `Shift+Arrow` to extend selection |
| 73 | +- `Ctrl+A` to select all |
| 74 | +- Visual highlight for selected cells |
| 75 | +- Store selection state for export |
| 76 | + |
| 77 | +### #206 - Export CSV |
| 78 | +- `Ctrl+E` or command to export |
| 79 | +- Export current selection or all if no selection |
| 80 | +- Prompt for file path or use clipboard |
| 81 | +- Support both CSV and TSV formats |
| 82 | + |
| 83 | +### #207 - Mouse Support |
| 84 | +- Terminal.Gui supports mouse events |
| 85 | +- Click to select cell |
| 86 | +- Drag to select range |
| 87 | +- Scroll wheel for navigation |
| 88 | + |
| 89 | +### #208 - Query History |
| 90 | +- Store last N queries (configurable, default 100) |
| 91 | +- `Ctrl+R` for reverse search (like bash) |
| 92 | +- Arrow up/down in query input to cycle history |
| 93 | +- Persist to `~/.ppds/query-history.json` |
| 94 | + |
| 95 | +## Acceptance Criteria |
| 96 | + |
| 97 | +### #234 |
| 98 | +- [ ] Generic `DataTableView<T>` component extracted |
| 99 | +- [ ] Current SqlQueryScreen uses the abstraction |
| 100 | +- [ ] No regression in existing TUI functionality |
| 101 | + |
| 102 | +### #204 |
| 103 | +- [ ] `/` enters filter mode |
| 104 | +- [ ] Filter text shown in status bar |
| 105 | +- [ ] Rows filtered in real-time |
| 106 | +- [ ] `Esc` clears filter |
| 107 | + |
| 108 | +### #205 |
| 109 | +- [ ] Shift+Arrow extends selection |
| 110 | +- [ ] Selection visually highlighted |
| 111 | +- [ ] Selection state accessible programmatically |
| 112 | + |
| 113 | +### #206 |
| 114 | +- [ ] Export hotkey works |
| 115 | +- [ ] CSV format correct (quoted strings, escaped commas) |
| 116 | +- [ ] TSV option available |
| 117 | +- [ ] Clipboard support if no file specified |
| 118 | + |
| 119 | +### #207 |
| 120 | +- [ ] Click selects cell |
| 121 | +- [ ] Drag selects range |
| 122 | +- [ ] Scroll wheel scrolls table |
| 123 | + |
| 124 | +### #208 |
| 125 | +- [ ] History persisted across sessions |
| 126 | +- [ ] Arrow keys cycle through history |
| 127 | +- [ ] Ctrl+R reverse search works |
| 128 | +- [ ] Duplicate queries collapsed |
0 commit comments