|
| 1 | +# TUI mx check Enhancement Design |
| 2 | + |
| 3 | +## Overview |
| 4 | + |
| 5 | +Enhance the TUI mx check overlay with error grouping, navigation, expanded diagnostics, and LLM-friendly structured output. |
| 6 | + |
| 7 | +## Part 1: Error Grouping + Deduplication |
| 8 | + |
| 9 | +### Problem |
| 10 | + |
| 11 | +Repeated errors (same code + element-id) fill the screen. 8 CE1613 errors render as 8 separate blocks. |
| 12 | + |
| 13 | +### Design |
| 14 | + |
| 15 | +Group by error code, deduplicate by element-id within each group. |
| 16 | + |
| 17 | +``` |
| 18 | +mx check Results |
| 19 | +● 8 errors |
| 20 | +
|
| 21 | +CE1613 — The selected association/attribute no longer exists |
| 22 | + MyFirstModule.P_ComboBox_Enum (Page) |
| 23 | + > Property 'Association' of combo box 'cmbPriority' |
| 24 | + MyFirstModule.P_ComboBox_Assoc (Page) (x7) |
| 25 | + > Property 'Attribute' of combo box 'cmbCategory' |
| 26 | +``` |
| 27 | + |
| 28 | +### Implementation |
| 29 | + |
| 30 | +- New types: `CheckGroup{Code, Severity, Message, Items}` and `CheckGroupItem{DocLocation, ElementName, Count}` |
| 31 | +- `groupCheckErrors([]CheckError) []CheckGroup`: groups by Code, deduplicates by element-id, counts occurrences |
| 32 | +- `renderCheckResults` renders grouped output instead of flat list |
| 33 | +- `formatCheckBadge` unchanged (counts raw errors by severity) |
| 34 | +- Group title: first entry's message (or common prefix if messages differ within a code) |
| 35 | + |
| 36 | +### Files |
| 37 | + |
| 38 | +- `cmd/mxcli/tui/checker.go` — add grouping types and logic, update renderCheckResults |
| 39 | +- `cmd/mxcli/tui/checker_test.go` — test grouping, deduplication, rendering |
| 40 | + |
| 41 | +## Part 2: Error Navigation |
| 42 | + |
| 43 | +### Design |
| 44 | + |
| 45 | +1. Check overlay becomes a selectable list — `j/k` moves cursor between error locations |
| 46 | +2. `Enter` on a location → closes overlay → tree navigates to the document |
| 47 | +3. App enters **check nav mode**: status bar shows current error + `]e`/`[e` hints |
| 48 | +4. `]e` jumps to next error document, `[e` jumps to previous |
| 49 | +5. `Esc` or any non-nav key exits check nav mode |
| 50 | +6. `!` reopens overlay at any time |
| 51 | + |
| 52 | +### Implementation |
| 53 | + |
| 54 | +- Add `checkNavActive bool`, `checkNavIndex int`, `checkNavLocations []CheckNavLocation` to App |
| 55 | +- `CheckNavLocation{ModuleName, DocumentName, Code, Message}` — unique documents extracted from grouped errors |
| 56 | +- `NavigateToDocMsg{ModuleName, DocumentName}` — sent by overlay Enter, received by App |
| 57 | +- App handles NavigateToDocMsg: search tree for matching node (by module + document name), expand path, select node |
| 58 | +- `]e`/`[e` keys in browser mode (when checkNavActive): increment/decrement checkNavIndex, send NavigateToDocMsg |
| 59 | +- Status bar in check nav mode: `[2/5] CE1613: MyFirstModule.P_ComboBox_Enum ]e next [e prev` |
| 60 | +- Check overlay needs cursor state: `selectedIndex int`, highlight selected row, Enter emits NavigateToDocMsg |
| 61 | + |
| 62 | +### Files |
| 63 | + |
| 64 | +- `cmd/mxcli/tui/checker.go` — add CheckNavLocation type, extraction function |
| 65 | +- `cmd/mxcli/tui/app.go` — add check nav state, handle NavigateToDocMsg, ]e/[e keys, status bar update |
| 66 | +- `cmd/mxcli/tui/overlayview.go` — add selectable mode with cursor for check overlay |
| 67 | +- `cmd/mxcli/tui/browserview.go` — add NavigateToNode method for tree navigation |
| 68 | +- `cmd/mxcli/tui/hintbar.go` — no changes (hints come from overlay/app) |
| 69 | +- `cmd/mxcli/tui/help.go` — document ]e/[e keys |
| 70 | + |
| 71 | +## Part 3: Warning + Deprecation Support |
| 72 | + |
| 73 | +### Design |
| 74 | + |
| 75 | +Run `mx check -j -w -d` to capture all diagnostic types. Add Tab filtering in check overlay. |
| 76 | + |
| 77 | +``` |
| 78 | +mx check Results [All: 8E 2W 1D] |
| 79 | +
|
| 80 | +Tab cycles: All → Errors → Warnings → Deprecations → All |
| 81 | +``` |
| 82 | + |
| 83 | +### Implementation |
| 84 | + |
| 85 | +- `runMxCheck`: add `-w`, `-d` flags to mx command |
| 86 | +- `mxCheckJSON`: add `Deprecations []mxCheckEntry` field |
| 87 | +- `CheckError.Severity`: extend to three values — `ERROR`, `WARNING`, `DEPRECATION` |
| 88 | +- Check overlay: `checkFilter` state (`all`/`error`/`warning`/`deprecation`), Tab key cycles filter |
| 89 | +- `renderCheckResults` accepts filter parameter, only renders matching groups |
| 90 | +- Filter indicator in overlay title bar: `[All: 8E 2W 1D]` or `[Errors: 8]` |
| 91 | +- `formatCheckBadge`: update to show `✗ 8E 2W 1D` |
| 92 | +- When overlay is refreshable (not switchable), Tab is repurposed for filter cycling |
| 93 | + |
| 94 | +### Files |
| 95 | + |
| 96 | +- `cmd/mxcli/tui/checker.go` — update runMxCheck flags, parse deprecations, add filter logic |
| 97 | +- `cmd/mxcli/tui/checker_test.go` — test deprecation parsing, filter rendering |
| 98 | +- `cmd/mxcli/tui/overlayview.go` — add checkFilter state, Tab handling for non-switchable overlays |
| 99 | + |
| 100 | +## Part 4: LLM Anchor Structured Output |
| 101 | + |
| 102 | +### Design |
| 103 | + |
| 104 | +Embed faint structured anchors in overlay rendering for LLM consumption via screenshots or clipboard copy. |
| 105 | + |
| 106 | +``` |
| 107 | +[mxcli:check] errors=8 warnings=2 deprecations=1 |
| 108 | +[mxcli:check:CE1613] severity=ERROR count=6 doc=MyFirstModule.P_ComboBox_Assoc type=Page element=combo_box.cmbCategory |
| 109 | +[mxcli:check:CE1613] severity=ERROR count=1 doc=MyFirstModule.P_ComboBox_Enum type=Page element=combo_box.cmbPriority |
| 110 | +[mxcli:check:CW0001] severity=WARNING count=2 doc=MyFirstModule.DoSomething type=Microflow element=variable.$var |
| 111 | +``` |
| 112 | + |
| 113 | +### Implementation |
| 114 | + |
| 115 | +- Replace current `[mxcli:overlay] mx check MDL` anchor with `[mxcli:check]` summary |
| 116 | +- Add per-group-item anchors with key=value pairs |
| 117 | +- Use `Faint(true)` styling — nearly invisible in terminal but preserved in copy/screenshot |
| 118 | +- `PlainText()` (for clipboard via `y`) includes anchor text |
| 119 | +- Anchors rendered before visible content in overlay |
| 120 | + |
| 121 | +### Files |
| 122 | + |
| 123 | +- `cmd/mxcli/tui/overlayview.go` — update Render() for check overlay anchor format |
| 124 | +- `cmd/mxcli/tui/checker.go` — add `renderCheckAnchors([]CheckGroup) string` function |
| 125 | + |
| 126 | +## Task Order |
| 127 | + |
| 128 | +1. Part 1: Error grouping + dedup (foundation for all other parts) |
| 129 | +2. Part 3: Warning/deprecation support (extends data model before navigation uses it) |
| 130 | +3. Part 4: LLM anchors (uses grouped data, no interaction changes) |
| 131 | +4. Part 2: Error navigation (most complex, depends on grouping being stable) |
| 132 | + |
| 133 | +## Dependencies |
| 134 | + |
| 135 | +- No new Go dependencies required |
| 136 | +- `element-id` and `unit-id` fields need to be added to `mxCheckLocation` struct for dedup and future navigation |
0 commit comments