Extend TUI: auto-sizing panels, responsive bar count, and add/edit rain records #5

Closed
opened 2026-06-30 20:33:05 +00:00 by coding-agent-marvin8 · 1 comment
coding-agent-marvin8 commented 2026-06-30 20:33:05 +00:00 (Migrated from codeberg.org)

The TUI currently hard-codes the stats panel at 30% width and the bar count at 30, with no way to add or edit records in-app.

Four improvements:

  1. Auto-size the stats panel to its actual content width so the chart gets more horizontal space.
  2. Compute the number of bars from the available terminal width on startup and on resize; keep manual +/- override with an 'auto' reset key.
  3. Add a modal (n key) to enter a new rain record, with optional backfill of zero-rain days back to the last known record.
  4. Add a modal (e key) to edit an existing rain record; in daily view a select mode (s key) lets you navigate to a bar to pre-populate the form.
The TUI currently hard-codes the stats panel at 30% width and the bar count at 30, with no way to add or edit records in-app. Four improvements: 1. Auto-size the stats panel to its actual content width so the chart gets more horizontal space. 2. Compute the number of bars from the available terminal width on startup and on resize; keep manual +/- override with an 'auto' reset key. 3. Add a modal (n key) to enter a new rain record, with optional backfill of zero-rain days back to the last known record. 4. Add a modal (e key) to edit an existing rain record; in daily view a select mode (s key) lets you navigate to a bar to pre-populate the form.
coding-agent-marvin8 commented 2026-06-30 20:33:20 +00:00 (Migrated from codeberg.org)

Explored the existing TUI (tui.py ~320 lines, single module). All four features fit in tui.py with no new source modules.

Plan of attack:

  • Task 1: Add pytest-asyncio to enable async Textual tests; change StatsPanel CSS to width:auto, BarChartWidget to width:1fr.
  • Task 2: Extract _compute_auto_bar_count() helper; add _bar_mode state (auto/manual) to RainTuiApp; wire on_resize; add 'a' binding to reset to auto.
  • Task 3: Add _parse_date_input() / _parse_amount_input() validators; AddRainResult dataclass; AddRainModal(ModalScreen); 'n' binding with backfill support.
  • Task 4: Add _select_mode / _selected_index state; 's' binding (daily grouping only, hidden via check_action); escape to exit; extend BarChartWidget.set_data and StatsPanel.update_stats with optional selected data; white (rgb(255,255,255)) bar highlight.
  • Task 5: EditRainResult dataclass; EditRainModal(ModalScreen); 'e' binding; pre-populate from selected bar when in select mode.
  • Task 6: Mark all four new Display items as done in improvements.md; open PR.

Branch: feat/issue-5-tui-enhancements

Explored the existing TUI (tui.py ~320 lines, single module). All four features fit in tui.py with no new source modules. Plan of attack: - Task 1: Add pytest-asyncio to enable async Textual tests; change StatsPanel CSS to width:auto, BarChartWidget to width:1fr. - Task 2: Extract _compute_auto_bar_count() helper; add _bar_mode state (auto/manual) to RainTuiApp; wire on_resize; add 'a' binding to reset to auto. - Task 3: Add _parse_date_input() / _parse_amount_input() validators; AddRainResult dataclass; AddRainModal(ModalScreen); 'n' binding with backfill support. - Task 4: Add _select_mode / _selected_index state; 's' binding (daily grouping only, hidden via check_action); escape to exit; extend BarChartWidget.set_data and StatsPanel.update_stats with optional selected data; white (rgb(255,255,255)) bar highlight. - Task 5: EditRainResult dataclass; EditRainModal(ModalScreen); 'e' binding; pre-populate from selected bar when in select mode. - Task 6: Mark all four new Display items as done in improvements.md; open PR. Branch: feat/issue-5-tui-enhancements
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
marvin8/rainlog#5
No description provided.