-
Notifications
You must be signed in to change notification settings - Fork 2
feat: real-time bot logs and health monitoring dashboard #87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 28 commits
Commits
Show all changes
80 commits
Select commit
Hold shift + click to select a range
10174e9
feat(health): extend health endpoint with system info, error counts, …
BillChirico 739e385
feat: add restartTracker utility
BillChirico 82d9a09
feat: wire restart tracking into startup and graceful shutdown
BillChirico 044771c
feat: install ws package for WebSocket log streaming
BillChirico b173cdb
feat: add WebSocketTransport custom Winston transport
BillChirico dcbc76c
test: add restartTracker tests and fix index test mock for package.js…
BillChirico 96a063d
feat: add WebSocket log stream server with auth, filtering, and heart…
BillChirico 1db9b26
docs: update TASK.md with results
BillChirico 9347543
feat: wire WebSocket transport into server.js and logger.js
BillChirico 4fe40c4
feat: add WebSocket transport to startup sequence
BillChirico bae1dbd
test: add WebSocket transport and log stream tests
BillChirico 36cef93
chore: fix import order in logStream.js (biome lint)
BillChirico ab4f1fd
docs: update TASK.md with results
BillChirico 446e046
merge: integrate restart tracker into feat/logs-and-health
BillChirico 9b6fb0d
Merge branch 'feat/logs-and-health-health' into feat/logs-and-health
BillChirico 45f908d
feat: add bot health API proxy route
BillChirico 3c213c5
feat: add health cards component and shared types
BillChirico 88f10c2
feat: add /api/log-stream/ws-ticket route for authenticated WS connec…
BillChirico c71f821
feat: add restart history table component
BillChirico ea06e14
feat: add useLogStream WebSocket hook with auto-reconnect
BillChirico 8157ffe
feat: add health section orchestrator and logs page; fix gitignore fo…
BillChirico 8ae516d
feat: add LogViewer terminal-style component with auto-scroll and met…
BillChirico 0efdcf9
feat: add LogFilters component with level/module/search controls
BillChirico 1095bf1
feat: add /dashboard/logs page route
BillChirico ede33e4
feat: add Logs link to dashboard sidebar navigation
BillChirico 150af35
docs: update TASK.md with results
BillChirico 0553d32
docs: update TASK.md with completed log UI results
BillChirico d00a5c3
merge: integrate health UI and log viewer into logs page
BillChirico e678912
fix(security): replace raw BOT_API_SECRET with short-lived HMAC ticket
BillChirico 61589f7
fix: show CPU utilization % instead of raw cumulative seconds
BillChirico 642ed56
fix(a11y): make log metadata toggle keyboard-accessible
BillChirico f5252d9
fix: flatten server metadata field into meta during normalization
BillChirico 9c25e5f
fix: retry ticket-fetch failures with exponential backoff
BillChirico f88b176
chore: clean up .gitignore — remove redundant /logs/security/ and uni…
BillChirico 51a1370
fix: await async handleAuth in WS message handler, add shutdown metadata
BillChirico e8f5f13
fix: improve bot-health error logging — show which env vars are missing
BillChirico f33207b
fix: lazy-load queryLogs in health route, wrap in try/catch
BillChirico 167a06b
fix: pass sendFilter directly and disable filters until connected
BillChirico 2075903
fix: coerce message to string before search filtering in WS transport
BillChirico 8188397
fix: classify 300ms ping as yellow, not red
BillChirico e8af514
fix: self-heal getRestarts on missing table, add structured warn meta…
BillChirico 38c7a2d
fix: skip redundant setLoading(false) on background health refresh
BillChirico eff5fc0
fix: correctly remove timed-out queue waiters in test helper
BillChirico 4406415
fix: log shutdown uptime recording failures instead of swallowing sil…
BillChirico a14feca
fix: restart-history — remove dead code and fix 'start' matching 'res…
BillChirico 3523768
fix: validate individual RestartRecord items in isBotHealth
BillChirico 6e3e3c9
test: update restartTracker test for structured warn metadata
BillChirico 1267ab2
docs: update TASK.md with results
BillChirico c80a471
docs: update TASK.md with results
BillChirico 6d4e697
merge: integrate frontend fixes into feat/logs-and-health
BillChirico 7d2df72
fix(types): nullable errors counts and RestartRecord fields + isBotHe…
BillChirico 97c0381
fix: replace raw secret auth with HMAC ticket validation in WS logStream
BillChirico 8b372e4
fix(health-cards): null-safe rendering for error counts
BillChirico 5c12ac7
fix(restart-history): null-safe rendering for version and uptimeBefore
BillChirico 9042fe5
fix(health-section): avoid error flicker during background refresh
BillChirico 24bb60d
test: add self-heal tests for getRestarts 42P01 path
BillChirico 9068859
fix(log-viewer): widen level badge to min-w-[3rem] to prevent label c…
BillChirico 39c61a9
fix(log-ws): reset connectingRef in cleanup to unblock reconnect on r…
BillChirico ae9e095
fix: guard readFileSync for package.json and clean up orphaned WS tra…
BillChirico 0de3058
fix: trivial improvements — tombstone, wsTransport reset, ws.OPEN con…
BillChirico bb3f807
chore: remove transient TASK.md work artifact
BillChirico a1d8b6d
Merge branch 'feat/logs-health-r2-frontend' into feat/logs-and-health
BillChirico 56e707c
merge: resolve conflict with main (keep getPool + WS transport imports)
BillChirico 85943f6
fix(health.js): use getRestarts/getPool, return RestartRecord[] array
BillChirico 16c7868
fix(types): validate optional memory.rss in isBotHealth guard
BillChirico c7513d1
fix(logStream.js): type-guard ticket as string, use Number.isFinite f…
BillChirico 8d35e6d
fix(websocket.js): exclude splat from metadata, normalize message to …
BillChirico 4a1e99a
fix(health-section): use runtime locale, clear error on success, fix …
BillChirico d3c2474
fix(lib): extract shared formatUptime utility to format-time.ts
BillChirico 80c056c
fix(health-cards): clamp CPU% to 0-100, use shared formatUptime
BillChirico 929ae8d
fix(health.test.js): update restarts assertion to expect RestartRecor…
BillChirico f130ad7
fix(restart-history): sort DESC by timestamp, use runtime locale, use…
BillChirico de70d0b
fix(log-ws): add cache no-store to ticket fetch, fix connect race wit…
BillChirico 00c82b1
Merge branch 'fix/pr87-frontend' into feat/logs-and-health
BillChirico 808a723
fix(server): wrap setupLogStream in try/catch to prevent hanging Promise
BillChirico 2719b92
fix(logStream): guard double-call + fix history race condition by reg…
BillChirico 544bc48
fix(websocket): move EXCLUDED_KEYS to module scope to avoid per-call …
BillChirico 13526e7
test(health): add queryLogs failure-path test
BillChirico c730a09
fix(health-cards): use runtime locale instead of hardcoded en-US
BillChirico 3d9316b
fix(health-section): add router to useCallback dependency array
BillChirico File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| # Task: Health Cards + Restart History UI | ||
|
|
||
| ## Parent | ||
BillChirico marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - **Master Task:** task-001 | ||
| - **Branch:** feat/logs-and-health | ||
| - **Issue:** [#35](https://github.com/VolvoxLLC/volvox-bot/issues/35) | ||
|
|
||
| ## Context | ||
|
|
||
| Build health metric cards and restart history table for the dashboard. Data comes from the extended health endpoint (`GET /api/v1/health`). | ||
|
|
||
| ### Existing Code | ||
| - `web/src/lib/bot-api-proxy.ts` — API proxy for authenticated requests | ||
| - `web/src/components/dashboard/config-editor.tsx` — Reference for dashboard patterns | ||
| - `web/src/components/ui/` — shadcn/ui components (card, table, badge, etc.) | ||
| - Health endpoint returns: uptime, memory, discord, system, errors, restarts | ||
|
|
||
| ## IMPORTANT — READ FIRST | ||
|
|
||
| 1. **Commit after every file you create or major change** | ||
| 2. **Start writing code IMMEDIATELY** | ||
| 3. **Expected duration: ~15m** | ||
|
|
||
| **Commit flow:** | ||
| 1. Create health cards component → commit | ||
| 2. Create restart history component → commit | ||
| 3. Create page or section → commit | ||
| 4. Lint/build → commit | ||
|
|
||
| ## Files to Create | ||
|
|
||
| - `web/src/components/dashboard/health-cards.tsx` — Health metric cards | ||
| - `web/src/components/dashboard/restart-history.tsx` — Restart log table | ||
| - `web/src/app/dashboard/logs/page.tsx` — Add health section (if page exists from log viewer slice, just add to it — otherwise create) | ||
|
|
||
| ## Requirements | ||
|
|
||
| - [ ] **Health cards** (grid layout): | ||
| | Card | Data | Display | | ||
| |------|------|---------| | ||
| | Uptime | `health.uptime` | Human-readable ("3d 14h 22m") | | ||
| | Memory | `health.memory.heapUsed/heapTotal` | MB + percentage bar | | ||
| | Discord Ping | `health.discord.ping` | ms, color: green <100, yellow <300, red >300 | | ||
| | Guilds | `health.discord.guilds` | Count | | ||
| | Errors (1h) | `health.errors.lastHour` | Count, red if >0 | | ||
| | Errors (24h) | `health.errors.lastDay` | Count | | ||
| | CPU | `health.system.cpuUsage` | user + system % | | ||
| | Node | `health.system.nodeVersion` | Version string | | ||
| - [ ] **Restart history table**: | ||
| - Columns: timestamp, reason, version, uptime before restart | ||
| - Last 20 restarts from `health.restarts` | ||
| - Human-readable timestamps | ||
| - Color-coded reasons (startup=green, crash=red) | ||
| - [ ] Auto-refresh health data every 60s | ||
| - [ ] Loading skeleton while fetching | ||
| - [ ] Lint passes, build succeeds | ||
|
|
||
| ## Constraints | ||
| - Do NOT touch backend files | ||
| - Do NOT touch log viewer (different slice) | ||
| - Use shadcn/ui Card, Table, Badge components | ||
| - Use Tailwind for styling | ||
|
|
||
| ## Acceptance Criteria | ||
| - [ ] Health cards display all 8 metrics | ||
| - [ ] Color coding works for ping and errors | ||
| - [ ] Restart history table shows recent restarts | ||
| - [ ] Auto-refresh every 60s | ||
| - [ ] Loading state while fetching | ||
| - [ ] Lint + build pass | ||
|
|
||
| ## Results | ||
|
|
||
| **Status:** ✅ Done | ||
|
|
||
| **Commits:** | ||
| - `45f908d` feat: add bot health API proxy route | ||
| - `3c213c5` feat: add health cards component and shared types | ||
| - `c71f821` feat: add restart history table component | ||
| - `8157ffe` feat: add health section orchestrator and logs page; fix gitignore for logs route | ||
|
|
||
| **Changes:** | ||
| - `web/src/app/api/bot-health/route.ts` — authenticated proxy to bot's `GET /api/v1/health` | ||
| - `web/src/components/dashboard/types.ts` — `BotHealth` / `RestartRecord` types + runtime validator | ||
| - `web/src/components/dashboard/health-cards.tsx` — 8-card grid (uptime, memory + bar, discord ping w/ color, guilds, errors 1h/24h w/ red, CPU, Node version) | ||
| - `web/src/components/dashboard/restart-history.tsx` — table with last 20 restarts, color-coded reason badges, human-readable timestamps | ||
| - `web/src/components/dashboard/health-section.tsx` — client component with auto-refresh (60s), loading skeleton, error banner, refresh button | ||
| - `web/src/app/dashboard/logs/page.tsx` — new `/dashboard/logs` route rendering `<HealthSection />` | ||
| - `.gitignore` — added exception for `web/src/app/dashboard/logs/` (conflicts with `logs/` gitignore rule) | ||
|
|
||
| **Build:** ✅ `next build` — compiled successfully, `/dashboard/logs` route created | ||
| **TypeCheck:** ✅ `tsc --noEmit` — no errors in new files | ||
| **Root lint:** Pre-existing failures in bot JS files only (26 errors existed before this task) | ||
|
|
||
| **Acceptance Criteria:** | ||
| - [x] Health cards display all 8 metrics | ||
| - [x] Color coding works for ping (green/yellow/red) and errors (red if >0) | ||
| - [x] Restart history table shows recent restarts (last 20, reversed) | ||
| - [x] Auto-refresh every 60s | ||
| - [x] Loading state while fetching (skeleton cards + table skeleton) | ||
| - [x] Lint + build pass (build ✅, root lint pre-existing failures not introduced by this task) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.