Skip to content

feat: Add health check bridge (Python checker + Web UI dashboard)#1

Open
lairulan wants to merge 1 commit into
Backtthefuture:mainfrom
lairulan:feature/health-check-bridge
Open

feat: Add health check bridge (Python checker + Web UI dashboard)#1
lairulan wants to merge 1 commit into
Backtthefuture:mainfrom
lairulan:feature/health-check-bridge

Conversation

@lairulan

Copy link
Copy Markdown

Summary

  • Add a bridge layer (server/bridge/checker.ts) that spawns an external Python health checker process and caches the JSON results in data/last-check.json
  • Add 4 health API endpoints (/api/health/results, /api/health/status, /api/health/run, /api/health/skill/:name) for the frontend to consume
  • Add a new "健康" (Health) tab in the Web UI with a full dashboard showing per-skill health scores across 4 dimensions: code quality, git sync, runtime health, and activity
  • The Python checker is optional — if not present, the UI degrades gracefully (shows "no data, run a check" prompt)

New files

File Description
server/bridge/checker.ts Spawns python3 checker/main.py --json, reads JSON output, manages running state
server/routes/health.ts 4 Fastify API routes for health check results and triggering
web/src/hooks/useHealth.ts React hook: fetch cached results, poll check status, trigger new checks
web/src/components/HealthDashboard.tsx Dashboard UI with summary cards, score bars, category badges, staleness alerts

Modified files

File Change
server/index.ts Register health routes, rename /api/health/api/ping to avoid conflict, export broadcast()
web/src/App.tsx Add useHealth hook, "健康" tab button, health view rendering branch
.gitignore Add data/last-check.json

Architecture

Browser → Fastify Server (TS)
           ├── /api/health/results  → read data/last-check.json (cached)
           ├── /api/health/run      → spawn python3 checker/main.py --json
           └── /api/health/status   → check if Python process is running

Python checker (optional, user-provided):
  checker/main.py --json → data/last-check.json
  - 4-dimension scoring: code quality (flake8/black/bandit) + git sync + runtime + activity
  - Each dimension 0-25 points, total 0-100

Screenshots

The health dashboard displays:

  • Summary cards (total checked / healthy / warning / critical / timing)
  • Per-skill table with score badges, category badges, score bars, and staleness indicators
  • One-click "Run Check" button with polling progress

Test plan

  • npm run dev → verify all existing views (Skills, 相似检测, 仪表盘) still work
  • Click "健康" tab → shows "no data" prompt (no Python checker yet)
  • Place a Python checker at checker/main.py with --json support → click "Run Check" → verify results display
  • Verify /api/ping still returns { status: 'ok' }
  • Verify npm run build completes without TypeScript errors

Adds a bridge layer that spawns an external Python health checker and
displays the results in a new "健康" (Health) tab. The checker evaluates
skills across 4 dimensions (code quality, git sync, runtime health,
activity) and outputs JSON consumed by the frontend.

New files:
- server/bridge/checker.ts — spawns Python process, caches results
- server/routes/health.ts — 4 API endpoints (results/status/run/skill)
- web/src/hooks/useHealth.ts — React hook for health data
- web/src/components/HealthDashboard.tsx — health dashboard UI

Modified:
- server/index.ts — register health routes, rename /api/health → /api/ping
- web/src/App.tsx — add "健康" view tab with HealthDashboard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant