feat: TUI skeleton and a synthetic workload generator#2
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2 +/- ##
===========================================
+ Coverage 19.16% 54.17% +35.01%
===========================================
Files 11 15 +4
Lines 287 515 +228
===========================================
+ Hits 55 279 +224
+ Misses 232 227 -5
- Partials 0 9 +9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request implements the core live monitor TUI for dbtop, introducing the main loop, tab navigation, and views for Activity, Metrics, and Statements. It also adds a synthetic workload generator to simulate database traffic during development. The review comments identify several critical issues: a compilation error in the workload generator due to a non-existent sync.WaitGroup.Go method, potential duplicate concurrent polling loops when pausing and unpausing the TUI, and unsafe byte-slicing of UTF-8 strings in the query truncation helper.
There was a problem hiding this comment.
Code Review
This pull request implements the initial TUI (Terminal User Interface) for dbtop using the Bubble Tea framework, including screens for Activity, Metrics, and Statements. It also introduces a synthetic workload generator to simulate database traffic for development. The review comments identify three valid issues: a compilation error in the workload generator where sync.WaitGroup is incorrectly called with a .Go() method, a potential panic or garbled character bug in truncate due to direct byte-slicing of UTF-8 strings, and a poor user experience when running the CLI with standard help or version flags.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a live monitor TUI using the Bubble Tea framework, along with a synthetic workload generator to simulate database traffic. The reviewer identified a critical compilation error in the workload generator where sync.WaitGroup is incorrectly used with a non-existent .Go() method. Additionally, the reviewer noted a UX lag issue in the TUI where switching tabs does not trigger an immediate database poll, recommending an immediate poll and cancellation of in-flight requests to improve responsiveness.
| case key.Matches(msg, m.keys.SwitchTab): | ||
| m.tab = m.tab.next() | ||
|
|
||
| return m, nil |
There was a problem hiding this comment.
- Severity: Medium
- Issue: Switching tabs does not trigger an immediate database poll. Instead, the TUI waits for the in-flight poll of the previous tab to finish, then waits for the tick interval, and only then starts polling the new tab. This can cause a noticeable delay or "lag" when navigating between tabs, especially if the previous poll was slow or the interval is large.
- Recommendation: Consider triggering an immediate poll upon switching tabs. To prevent concurrent overlapping polls, you can track an active cancellation context for the in-flight poll in the
Modeland cancel it when switching tabs or unpausing.
Summary
Adds the bubbletea TUI skeleton on top of the PostgreSQL driver, plus a synthetic workload generator for developing against live data.
Running
dbtop <postgres-dsn>now opens a live, polling TUI with three tabs (Activity / Metrics / Statements).TUI (
internal/tui)Model/Update/View. DB I/O never runs insideUpdate: a single tick chain drives polling (Initseeds one poll, each result schedules the next tick), so polls never overlap or pile up.tabswitches screens,spacepauses (stops the tick chain),q/ctrl+cquits. Bindings live in onekeyMapthat also feeds the footer, so the hints can't drift from the actual keys.CREATE EXTENSION pg_stat_statementshint instead of erroring when the extension is missing.CLI wiring (
internal/cli)dbtop <dsn>opens the PostgreSQL driver, probes capabilities, and launches the program. Amysql://DSN reports that the driver is not implemented yet.Workload generator (
cmd/workload, compose, Makefile)compose.yamlunder theloadprofile (so plaincompose upand CI stay quiet) and reachable vianetwork_mode: service:postgres.postgresnow preloadspg_stat_statementsand an initdb script creates the extension.make compose-up COMPOSE_PROFILE=loadbrings the database up with the workload.Testing
pg_stat_statementsdigest all appear.Notes