Skip to content

feat(tui): add read-only insights overlay (i keybind) - #151

Merged
eaitbrahim merged 2 commits into
mainfrom
feat/tui-insights-panel
Jul 25, 2026
Merged

feat(tui): add read-only insights overlay (i keybind)#151
eaitbrahim merged 2 commits into
mainfrom
feat/tui-insights-panel

Conversation

@eaitbrahim

Copy link
Copy Markdown
Contributor

What

Adds an i keybind to the live keel tui dashboard that opens a browsable, scrollable, read-only insights overlay — reusing the pure builders shipped in keel/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.

  • Footer/keybind bar now advertises [i] insights.
  • Esc (or i again, or q) 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

  • Read-only, fail-soft. The overlay calls only read builders over the already-computed StatusReport + repo reads — no writes, no order/broker/network beyond the broker-free gather_status. The build is wrapped in try/except Exception (not KeyboardInterrupt), so a transient database is locked from the concurrent keel agent writer paints an error line and the loop keeps polling — mirroring the existing main-view handler.
  • Circular import avoided: insights.py already imports from tui.py, so the reverse import is TYPE_CHECKING-only + lazy in-function (same pattern tui.py already uses for clitui). keel/commands/insights.py is unmodified.
  • keel tui --once is unchanged except the footer gaining the [i] hint.
  • Diff confined to 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 (rigged database 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 / --once impact 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

eaitbrahim and others added 2 commits July 24, 2026 19:52
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>
@eaitbrahim
eaitbrahim merged commit 905f864 into main Jul 25, 2026
1 check passed
@eaitbrahim
eaitbrahim deleted the feat/tui-insights-panel branch July 25, 2026 00:50
@eaitbrahim eaitbrahim added the feature New capability (groups under Features) label Jul 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New capability (groups under Features)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant