Commit de47c40
authored
feat(dashboard): add instance health dashboard on GET / endpoint (#286)
* feat(dashboard): add Instance Health Dashboard on GET / endpoint
- Add dashboard module with metrics collector, HTML template, and handler
- Dashboard shows server info, registered instances, health status, sessions
- Supports content negotiation: HTML for browsers, JSON for API clients
- Add DASHBOARD_ENABLED config (default true, disable with =false)
- Instances show health status (healthy/degraded/offline) based on metrics
- HTML includes auto-refresh every 30 seconds
- Safe for MCP clients - they use POST /mcp, not GET /
- Add 44 unit tests for metrics, handler, and HTML template
Closes #275
* fix(docs): rename gtag.d.ts to gtag.ts for Vite compatibility (#287)
- Vite/Rollup cannot resolve .d.ts files as runtime imports
- Renamed declaration file to regular .ts (content unchanged)
- File contains `declare global` + `export {}` which is valid in both formats
Fixes #285
* fix(dashboard): add error handling and safe URL parsing
- Add try/catch in dashboardHandler for collectMetrics/renderDashboard failures
- Add safe URL parsing in renderInstanceCard with fallback to raw URL
- Use GITLAB_TOKEN config constant instead of direct process.env access
* fix(dashboard): remove unused parameter and improve URL parsing
- Remove unused lastSuccessfulRequestMs parameter from determineInstanceStatus
- Add .js extension to dashboard import in server.ts
- Add safe URL parsing for session hostnames in html-template.ts
- Add comprehensive tests for collectMetrics function
* test(dashboard): achieve 100% line coverage
- Add tests for error handling in dashboardHandler
- Add tests for getMetrics export function
- Add tests for OAuth and token auth modes
- Add tests for unknown status indicator
- Add tests for invalid URL parsing fallbacks
- Add tests for queue filling warning
- Add tests for formatRelativeTime (hours, days)
- Add tests for invalid URL in sessions byInstance
Coverage: Lines 100%, Branches 92.85%1 parent 25b2c1a commit de47c40
File tree
9 files changed
+2187
-0
lines changed- src
- dashboard
- tests/unit/dashboard
9 files changed
+2187
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
244 | 249 | | |
245 | 250 | | |
246 | 251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
0 commit comments