Skip to content

Restore dashboard Feishu mirror toggle - #57

Open
AITCX08 wants to merge 1 commit into
mainfrom
feat/dashboard-mirror-toggle
Open

Restore dashboard Feishu mirror toggle#57
AITCX08 wants to merge 1 commit into
mainfrom
feat/dashboard-mirror-toggle

Conversation

@AITCX08

@AITCX08 AITCX08 commented Jun 20, 2026

Copy link
Copy Markdown
Owner

What

Restore the /api/mirror-toggle endpoint + the dashboard top-bar toggle button (MirrorToggle) that were dropped when the branch was reset to main. Reads/writes the same ~/.cc-connect/mirror.enabled flag the Feishu 转发开/关 command uses, so the dashboard button and the Feishu command share one state.

  • backend: GET/POST /api/mirror-toggle (Bearer-guarded, GET fail-closed to false on read error, POST validates enabled is bool)
  • frontend: MirrorToggle (Rss icon + 转发:开/关 + 3s poll + click-to-toggle), api.ts get/setMirrorToggle, rendered in TopBar

Verification (static, app not launched)

  • py_compile OK · npm run build OK (MirrorToggle in bundle) · dashboard restarted, /healthz 200
  • GET /api/mirror-toggle → 200 {enabled:true} · no token → 401
  • POST {enabled:false} → GET reflects false → ~/.cc-connect/mirror.enabled becomes off → restored to on
  • POST bad body → 400
  • Independent review: SHIP

Merge gate

Hold until the user manually verifies the button in Feishu/dashboard.

🤖 Generated with Claude Code

Re-add the /api/mirror-toggle GET/POST endpoints and the dashboard
MirrorToggle button that were dropped on main. Backend reads/writes
~/.cc-connect/mirror.enabled (on/off) -- the same flag the feishu
转发开/关 command uses -- so the dashboard button and feishu command
share one source of truth. Auth via existing Bearer token middleware.

## 主要改动
- court_dashboard_server.py: register GET/POST /api/mirror-toggle +
  handle_mirror_toggle_get/set reading/writing the shared flag file
- frontend MirrorToggle.tsx: Rss icon + 转发:开/关 text, 3s poll, click to flip
- api.ts: getMirrorToggle/setMirrorToggle
- TopBar.tsx: render <MirrorToggle/>

## 测试
- tsc -b && vite build: pass; MirrorToggle compiled into dist bundle
- curl GET (200 {enabled}) / POST off->file off / POST on->file on / bad body 400 / no-auth 401

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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