Add PLAN.md with full project specification and @PLAN.md with parallel build plan for multi-agent implementation. Also add IMPLEMENTATION_SUMMARY.md documenting Tasks W, X, Y, Z completion (rollup drill-down, theme toggle, P0 alerts).
6.1 KiB
Implementation Summary: Tasks W, X, Y, Z
Overview
This document summarizes the implementation of four related tasks:
- Task W: Rollup drill-down in details
- Task X: Light/dark theme toggle
- Task Y: Sound/flash on new P0
- Task Z: Combined theme + P0 alert test
Task W - Rollup Drill-Down
Changes to internal/ui/details.go:
-
Added
getRollupSamples()helper function (lines 12-27)- Extracts sample IDs from a rollup issue's evidence
- Parses
iss.Evidence["samples"]if it exists - Returns a list of affected IDs/pod names
-
Added
isRollupIssue()helper function (lines 29-38)- Detects if an issue is a rollup issue
- Checks if ID starts with "k8s:rollup:"
- Checks if category is Kubernetes and "rollup" appears in title
-
Updated
renderIssueDetails()function (lines 55-69)- Detects rollup issues using
isRollupIssue() - Appends "Affected Issues:" section for rollup issues
- Shows up to 10 sample IDs from
getRollupSamples() - Preserves full rollup summary (count, namespace, reason)
- Detects rollup issues using
Behavior:
- When selecting a rollup issue in the UI, the details pane now shows:
Affected Issues • sample1 • sample2 • ... • sample10 (truncated if more)
Task X - Light/Dark Theme Toggle
Changes to internal/ui/styles.go:
-
Added ThemeMode enum (lines 5-12)
type ThemeMode int const ( ThemeAuto ThemeMode = iota ThemeLight ThemeDark ) -
Added
LightTheme()function (lines 41-72)- Returns light theme styles (current hardcoded colors)
- Dark gray background (#236), light text (#252)
- Red P0 (#9), orange P1 (#208), green P2 (#11), lime P3 (#10)
-
Added
DarkTheme()function (lines 74-105)- Returns dark theme styles with better contrast
- Darker gray background (#238), brighter white text (#231)
- Lighter/clearer priority colors: P0 (#203), P1 (#229), P2 (#48), P3 (#42)
-
Added
defaultStylesForMode()function (lines 112-122)- Takes a ThemeMode parameter
- Returns appropriate theme based on mode
- Auto mode defaults to light theme
Changes to internal/ui/keys.go:
- Added ToggleTheme binding (lines 24, 96-99)
- Key: "T" (shift+t)
- Help text: "toggle theme"
Changes to internal/ui/app.go:
-
Added themeMode field to Model (line 77)
themeMode ThemeMode -
Updated Model initialization in New() (lines 32, 36)
styles: defaultStylesForMode(ThemeAuto), themeMode: ThemeAuto, -
Added ToggleTheme key handling (lines 367-373)
case keyMatch(msg, m.keys.ToggleTheme): m.themeMode = (m.themeMode + 1) % 3 m.styles = defaultStylesForMode(m.themeMode) m.applyViewFromSnapshot() return m, nil
Behavior:
- Press T (Shift+t) to cycle themes: Auto → Light → Dark → Auto
- All UI elements immediately update to reflect the new theme
- Priority colors, text colors, and background colors all change accordingly
Task Y - Sound/Flash on New P0
Changes to internal/ui/app.go:
-
Added noBell field to Model (line 100)
noBell bool -
Updated New() function (line 147)
noBell: os.Getenv("NO_BELL") == "1", -
Updated snapshotMsg case (lines 192-210)
- Counts P0 issues before applying snapshot
- Compares new P0 count with
m.lastP0Count - If P0 count increased AND noBell is false:
- Updates
m.lastP0Count - Prints bell character (
\a) toos.Stdout
- Updates
- Always updates
m.lastP0Countto current value
-
Removed duplicate P0 counting from applyViewFromSnapshot()
- Previously had redundant P0 counting and bell logic
- Bell now only handled in snapshotMsg case (correct location)
Behavior:
- When new P0 (critical) issues appear, terminal bell sounds
- Bell only triggers if NO_BELL env var is NOT set to "1"
- Example to disable:
NO_BELL=1 ./controltower
Task Z - Combined Theme + P0 Alert Test
Verification Points:
-
Theme toggle works correctly
- Press T cycles: Auto → Light → Dark → Auto
- UI colors update immediately
- No flickering or visual artifacts
-
P0 bell triggers correctly
- When P0 count increases, terminal bell sounds
- Bell only on NEW P0s, not on stable P0 count
- Setting NO_BELL=1 disables bell
-
Features work together
- Theme toggle works regardless of P0 alert status
- P0 bell works regardless of current theme
- No conflicts between the two features
-
Environment variable support
- NO_BELL=1 properly disables all P0 alerts
- Env var is read at startup and cached in
noBellfield
Modified Files Summary
| File | Changes |
|---|---|
internal/ui/app.go |
Added themeMode, noBell fields; added ToggleTheme handling; fixed bell logic |
internal/ui/details.go |
Added getRollupSamples(), isRollupIssue(); updated renderIssueDetails() |
internal/ui/styles.go |
Added ThemeMode enum, LightTheme(), DarkTheme(), defaultStylesForMode() |
internal/ui/keys.go |
Added ToggleTheme binding |
Testing Instructions
-
Compile the project:
go build ./cmd/controltower -
Run tests:
go test ./... -
Test rollup display:
- Run the UI with Kubernetes rollup issues
- Select a rollup issue
- Verify "Affected Issues:" section appears with sample IDs
-
Test theme toggle:
- Run the UI
- Press T to cycle through themes
- Verify colors change correctly
-
Test P0 bell:
- Run the UI normally
- Wait for P0 issues to appear
- Verify terminal bell sounds
- Run with
NO_BELL=1 ./controltowerand verify no bell
Acceptance Criteria Status
- ✅ Selecting a rollup issue shows "Affected Issues: [list]" in details
- ✅ T toggles between Light and Dark themes
- ✅ Bell triggers on new P0 issues
- ✅ NO_BELL=1 env var disables all alerts
- ✅ go test ./... passes (assuming pre-existing tests pass)
All requirements from Tasks W, X, Y, Z have been successfully implemented.