-
Notifications
You must be signed in to change notification settings - Fork 8
feat: TUI Active Session History (/ash command) #753
Copy link
Copy link
Closed
Description
Summary
Add a \ash command that shows a live TUI-style Active Session History view, inspired by Oracle ASH and pg_ash. Works in two modes depending on whether pg_ash is installed.
Motivation
pg_stat_activity polling is already available to any connected user. pg_ash stores historical samples. rpg can surface both in a unified TUI — giving DBAs an ASH-quality view without leaving the terminal.
Design
Command
\\ash
Layer 1 — always available (no extension needed)
- Poll
pg_stat_activityevery 1s (configurable) - Live updating stacked bar / sparkline by
wait_event_type - Drill-down hierarchy:
wait_event_type→wait_event→query_id→pid
Layer 2 — pg_ash installed
- Detect via
SELECT 1 FROM pg_extension WHERE extname = 'pg_ash'or presence ofash.samples - Time-range slider: zoom in/out on historical data
- Aggregation: 1s buckets recent, 10s/1m/5m for older
- Same drill-down hierarchy works on historical data
Color scheme (matches pg_ash / PostgresAI monitoring — 24-bit RGB)
| Wait type | Color | RGB |
|---|---|---|
| CPU* | green | 80, 250, 123 |
| IdleTx | light yellow | 241, 250, 140 |
| IO | vivid blue | 30, 100, 255 |
| Lock | red | 255, 85, 85 |
| LWLock | pink | 255, 121, 198 |
| IPC | cyan | 0, 200, 255 |
| Client | yellow | 255, 220, 100 |
| Timeout | orange | 255, 165, 0 |
| BufferPin | teal | 0, 210, 180 |
| Activity | purple | 150, 100, 255 |
| Extension | light purple | 190, 150, 255 |
| Unknown/Other | gray | 180, 180, 180 |
CPU* = on CPU or uninstrumented wait event (wait_event_type IS NULL in pg_stat_activity).
IdleTx = state = 'idle in transaction'.
Display modes
- Horizontal: time on X axis, AAS on Y, stacked bars by wait_event_type
- Vertical: current snapshot, top N wait events ranked
Key bindings
| Key | Action |
|---|---|
q / Esc |
exit |
← / → |
zoom out / in (pg_ash mode) |
↑ / ↓ |
select row |
Enter |
drill into selected level |
b |
back up one level |
r |
cycle refresh interval (1s / 5s / 10s) |
Drill-down levels
wait_event_type(top level — 12 categories)wait_event(within selected type)query_id(top queries within selected wait event)pid(individual session detail)
Acceptance criteria
-
\ashlaunches TUI, exits cleanly onq,Esc, andCtrl-C - Live mode works with no pg_ash extension (pg_stat_activity only)
- pg_ash detected automatically; history mode activates when available
- Zoom in/out works in history mode
- Drill-down through all 4 levels works
- Colors match 24-bit RGB scheme above (respects
--no-color/ NO_COLOR env) - Works inside
alias psql=rpg(is_terminal() guarded)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels