Commit b21753a
committed
feat(tui-py): migrate TUI to Python/Textual; add tests + polish
Replace the Ink/React TUI under tui/ with a Python/Textual implementation
under tui-py/. New entry point: python3 tui-py/main.py (also wired into
the cctrace --tui CLI and dev:tui npm script).
Architecture
- Shared HighlightListView base class owns the highlight CSS, the
background-tint:transparent focus override, and the ensure_highlight()
cursor-init helper. SessionPicker, MessageList, and DetailView's items
list all extend it — one source of truth for selection styling and
initial cursor behaviour.
- MessageList.populate is async and awaits clear()/append()/remove().
An exclusive worker group ("populate_msglist") serialises back-to-back
populates so rapid SSE updates / load-session resets no longer race
with their own deferred clear() calls and produce duplicated rows.
- _load_session keeps the picker visible (LoadingIndicator overlay)
until the MessageList is fully populated, then flips the view —
avoiding the few-second window where j/k pressed against an empty
list pane.
- App.BINDINGS hosts j/k/Enter so they appear in the Footer on every
page; thin delegation actions forward to the focused widget's
cursor_up/cursor_down/select_cursor.
DetailView
- Bordered container; #msg-content gets a divider underneath.
- Two section headings: "RESPONSE" (top) and "STEP (N)" (between body
and items list). Headings hide when no message or no items.
- Async _rebuild eagerly clears stale state and toggles loading on the
pane while it rebuilds.
Other changes
- .gitignore: add Python entries (__pycache__, *.pyc, .venv).
- .github/dependabot.yml: add pip ecosystem for /tui-py.
- .claude/hooks/pre-commit.sh: run ruff format/lint when tui-py files
are staged.
- bin/cctrace.mjs + package.json dev:tui: launch the Python TUI.
- README: add Python and Textual badges.
Tests
- pytest + pytest-asyncio in requirements.txt; pytest.ini with
asyncio_mode = auto.
- tui-py/tests/ covers HighlightListView (ensure_highlight policy,
shared highlight color), MessageList (populate race-safety,
incremental diff, index preservation), DetailView (border, RESPONSE
and STEP headings with item count + hide rules). 15 tests, all pass.
Drops the old tui/ TypeScript/Ink implementation entirely.1 parent 2d184d9 commit b21753a
73 files changed
Lines changed: 4794 additions & 3705 deletions
File tree
- .claude/hooks
- .github
- bin
- specs
- src-tauri/src
- commands
- src
- components
- styles
- tui-py
- tests
- widgets
- tui
- src
- components
- lib
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
37 | 55 | | |
38 | 56 | | |
39 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
4 | 11 | | |
5 | 12 | | |
6 | 13 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | 60 | | |
78 | 61 | | |
79 | 62 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
16 | | - | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
160 | 162 | | |
161 | 163 | | |
162 | 164 | | |
163 | 165 | | |
164 | 166 | | |
165 | | - | |
| 167 | + | |
166 | 168 | | |
167 | | - | |
| 169 | + | |
168 | 170 | | |
169 | 171 | | |
170 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
47 | | - | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
0 commit comments