magic-context-web
v0.1.0
Published
Unofficial local web dashboard for CortexKit Magic Context
Maintainers
Readme
Magic Context Web Dashboard
An unofficial, lightweight web dashboard for Magic Context, modeled on the official Tauri desktop app. It provides a browser-based alternative for environments where the desktop runtime is unavailable.
Reads and writes Magic Context's SQLite database using the same direct-access approach as the official dashboard, then serves a single-page web UI.
Requirements
- Node.js 18+ (for the
npxlauncher) - Python 3.8+ (dashboard backend; stdlib only, no dependencies)
Quick start
npx magic-context-webThe command downloads the package, starts the dashboard at
http://127.0.0.1:9077/, and opens it in the default browser. Stop it with
Ctrl+C. Magic Context must already be installed so its local context.db
is available.
npx magic-context-web --port 8080
npx magic-context-web --db /path/to/context.db
npx magic-context-web --no-openLocal development
npm test
node bin/magic-context-web.cjs --no-openBinds to 127.0.0.1 by default. Passing a non-loopback --host prints a
warning (session data is served over plain HTTP; use an SSH tunnel instead).
This package is community-maintained and is not an official CortexKit release.
Views
| View | Source tables |
|---|---|
| Overview | counts + DB/WAL sizes |
| Memories | memories (search, status/category filters, pagination, bulk archive/restore, optimistic edit locking) |
| Sessions | session_meta + related tables (search, harness filter, pagination, facts, notes, subagents, compartments, tags) |
| Compartments | compartments |
| Notes | notes |
| Primers | primers |
| Dreamer | dream_runs |
| Historian | historian_runs |
| Git Commits | git_commits |
| Diagnostics | tags + pending_ops (drop timeline) |
| Config | ~/.config/cortexkit/magic-context.jsonc |
Live updates
The page updates in real time: a background thread watches the DB/WAL
files for changes (1 s polling) and pushes change events to all connected
browsers over SSE (/api/events). On receipt, the frontend re-fetches
and re-renders the current view (1200 ms debounce), so new memories,
compartments, dream/historian runs, etc. appear automatically.
- Top-right dot: green = SSE connected, grey = reconnecting (fallback polling of nav counts every 30 s still applies).
- Works while editing files in Magic Context sessions, after
/ctx-dreamruns, or when the historian compacts history.
Editing
The dashboard can also write:
- Memories — create and edit; filter Active/Archived/All; bulk archive or
restore; paged browsing; and stale-editor conflict detection via
updated_at. Archive is reversible and makes the live plugin stop using the record. - Notes — create, edit (content / surface condition / status), delete.
- Config — edit
magic-context.jsoncin the browser (atomic write).
Write endpoints are POST /api/memories/{create,update,delete,status},
POST /api/notes/{create,update,delete}, and POST /api/config/save. All input is
validated against field whitelists; SQL is parameterized. Writes use a
separate mode=rw connection with a 5 s busy timeout, so they queue safely
behind the live Magic Context process (SQLite WAL).
Note: editing the DB directly does not update the plugin's in-memory cache until it reloads; new sessions pick changes up immediately.
Safety
- Read endpoints open the DB with
mode=ro; write endpoints use a dedicatedmode=rwconnection with busy timeout — never a live lock. - Loopback-only by default; static file serving has a path-traversal guard.
Architecture
Feature domains are separated from the HTTP shell:
mcweb/memories.py— paged queries, validation, optimistic locking, bulk status mutations.mcweb/sessions.py— paged session discovery and aggregated session detail.static/modules/memories.js— Memory Browser state, rendering, forms, and actions.static/modules/sessions.js— Session History list and detail rendering.server.py— HTTP/SSE/static serving plus legacy read models being migrated incrementally.static/app.js— application shell, routing, and remaining views.
Tests
npm testDifferences vs. the official desktop app
- No dream triggering, no log tailing (the official app's dreamer management and log viewer are not reimplemented).
- The official app ships a built-in
--serveweb mode (same UI over HTTP with bearer-token auth) — if you're on a machine where the desktop binary runs (glibc ≥ 2.32 + webkit2gtk), prefer that:magic-context-dashboard --serve.
Theme
The first visit follows the system preference. Toggle light/dark with the
sun/moon button in the top bar. Choice is persisted in localStorage
(mc-theme).
