feat(tui): add read-only insights overlay (i keybind) - #151
Merged
Conversation
Add a browsable, scrollable, READ-ONLY insights overlay to the live `keel tui` dashboard, reusing the already-shipped pure builders/renderers from `keel/commands/insights.py` verbatim (per-rule track record, promotion-gate distance, account summary, plus a compact recent-trades tail). Mirrors the existing help overlay's mode/scrolling/fail-soft conventions exactly: `i` opens it, `q`/Esc/`i` closes it, arrows/j/k/PgUp/PgDn/Home/End scroll via `_visible_slice`, and a transient read error (e.g. `database is locked` from a concurrent `keel agent` writer) paints an alert line instead of crashing the loop. `keel tui --once` is otherwise unaffected. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ertion Address review NITs on the insights overlay: add a test driving run_live into mode=insights with open_state rigged to raise on the insights build (separate try/except from normal mode's), asserting an "insights read failed" line is painted and the loop keeps polling/terminates cleanly afterwards. Also strengthen the existing Esc-close test, which previously only checked the insights heading was painted (a regression deleting the Esc branch would still pass, since q also ends the loop) -- it now asserts a later frame repaints the normal dashboard's title line, proving Esc actually returned control rather than the loop merely ending. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an
ikeybind to the livekeel tuidashboard that opens a browsable, scrollable, read-only insights overlay — reusing the pure builders shipped inkeel/commands/insights.py(PR #149). This is the deferred TUI follow-up to #149.The overlay shows: account/drawdown summary, per-rule track record with distance-to-promotion-gate, the small-sample honesty note, and a recent-trades tail (last 5) — all as a live view that refreshes each poll.
[i] insights.Esc(oriagain, orq) closes the overlay and returns to the dashboard; scrolling uses the same arrows/j/k/PgUp/PgDn/Home/End + clamped-offset infra as the existing help overlay.Design / safety
StatusReport+ repo reads — no writes, no order/broker/network beyond the broker-freegather_status. The build is wrapped intry/except Exception(notKeyboardInterrupt), so a transientdatabase is lockedfrom the concurrentkeel agentwriter paints an error line and the loop keeps polling — mirroring the existing main-view handler.insights.pyalready imports fromtui.py, so the reverse import isTYPE_CHECKING-only + lazy in-function (same pattern tui.py already uses forcli↔tui).keel/commands/insights.pyis unmodified.keel tui --onceis unchanged except the footer gaining the[i]hint.keel/commands/tui.py+tests/commands/test_tui.py.Tests
+12 tests (
1597 → 1609), ruff clean. Covers: overlay open-on-i/ close-on-Esc(asserts return to the dashboard), scroll offset movement, empty-DB friendly render, and the insights-branch fail-soft path (riggeddatabase is locked→ error line painted, loop survives).Review
Designed (Opus), built TDD (Sonnet), independently reviewed by a fresh-context Opus agent → verdict: mergeable-as-is (read-only / fail-soft / circular-import /
--onceimpact all verified clean). The two test-coverage NITs it raised (fail-soft path + Esc-close isolation) are included in this branch.🤖 Generated with Claude Code