Add localhost web console to BlackbookServer (KPI dashboard + safe actions) - #41
Merged
Merged
Conversation
…tions)
BlackbookServer was headless (HTTP API + menu-bar popover); there was no
way to see operational health at a glance. Adds a web console.
- Second NWListener bound to 127.0.0.1:8766 (requiredLocalEndpoint). The
Cloudflare tunnel maps only 8765, so the console is never internet-
exposed and needs no password. Reuses the existing receiveRequest/
sendResponse plumbing; cancelled on stop()/scheduleRestart(); a loopback
remote-endpoint check adds defense-in-depth.
- Routes (no header auth): GET / -> bundled console.html; GET /api/stats
-> KPI JSON; POST /api/imessage/{backfill,toggle} -> safe actions.
- /api/stats aggregates: sync health (latest heartbeat per device),
backups (count/bytes/per-user), requests (access-log status histogram +
recent tail), data (per-model fetchCount + iMessage stats).
- console.html: single self-contained dark dashboard, polls every 5s,
Sync-Last-30-Days + toggle buttons. Auto-bundled via the source glob.
- ServerStatusModel passes the iMessage service into BackupServer;
ServerMenuView gains an "Open Web Console" button.
Localhost-only by design; safe actions only (no delete/restart). Verified:
GET / 200, /api/stats full JSON; LAN:8766 refused; tunnel /api/stats 401.
BlackbookServer is local-deploy (not TestFlight); rebuild/reinstall per
docs/test-scenarios/TEST_SCENARIOS.md.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
BlackbookServerwas headless — an HTTP API plus a tiny menu-bar popover. There was no way to see operational health at a glance: sync status per device, storage, request errors, record counts, or iMessage-sync stats. This adds a localhost-only web console.What
NWListenerbound to127.0.0.1:8766(requiredLocalEndpoint). The Cloudflare tunnel forwards only 8765, so the console is never internet-exposed and needs no password. Reuses the existingreceiveRequest/sendResponseplumbing; cancelled instop()/scheduleRestart(). A loopback remote-endpoint check adds defense-in-depth.GET /→ bundledconsole.html;GET /api/stats→ KPI JSON;POST /api/imessage/backfill+/api/imessage/toggle→ safe actions (202/200)./api/statsaggregates four sections from existing data: sync health (latest heartbeat per device), backups & storage (count/bytes/per-user), requests (today's access-log status histogram + recent tail), data (per-modelfetchCountfor all 10 models + iMessage stats).console.html— one self-contained dark dashboard (inline CSS+JS, no CDN), polls every 5 s, with Sync Last 30 Days and Toggle iMessage Logging buttons. Auto-bundled by thesources: - BlackbookServerglob.BackupServer.initgains animessage:param;ServerStatusModelpasses it in;ServerMenuViewgets an Open Web Console button.Security
Test plan
console.htmlbundled inContents/Resources/.GET /→ 200 text/html (12049 B);GET /api/stats→ full JSON (Contacts 1288, backups 5/3.8 MB, 2 sync devices, 148 reqs today). Verified with curl + strict Python HTTP client.https://sync.libersecretorum.com/api/stats→ 401 (hits the 8765 sync server; console route absent). Backfill endpoint → 202.Deploy note
BlackbookServer is not in TestFlight. After merge, rebuild/reinstall locally (commands in
docs/test-scenarios/TEST_SCENARIOS.md). Main Blackbook app is untouched.🤖 Generated with Claude Code