c7dbaf2d9f
Two leftovers from the rebrand, done together because they touch the same docs and manifests. **Data directory.** `agent-dashboard` could not simply be renamed in the source: it names a real directory holding the live SQLite database. Startup now moves it once, via `migrateLegacyDataDir()` in `server/lib/claude-home.js` — a same-filesystem rename, so it is instant even at multiple gigabytes and cannot leave two divergent copies. `getDataDir()` stays PURE and resolves to the legacy path until the move happens; the first version of this put the rename inside the getter, which meant `npm run test:server` relocated the developer's real database as a side effect. The call sits behind `require.main === module` and ahead of the router requires, because those pull in db.js, which opens SQLite at module load. A failed rename is silent and the old directory keeps being used: an unfashionable directory name beats a blank database beside an unreachable one. Same treatment for the port-discovery file (`.agent-dashboard.json` → `.agenthub.json`, old one dropped on write). Not renamed on purpose: the Sagi localStorage keys (renaming silently resets everyone's prefs) and the PWA manifest `id` (changing it orphans an installed app). **MCP server.** 4 tool calls in 46 days across 577,132 events, against 4,556 lines of TypeScript, a 2 MB committed build artifact, and a pre-commit guard that had already blocked commits twice. Deleted: `mcp/`, the maintainer skills and `mcp-reviewer` agent, the build check, `plugins/agenthub/.mcp.json`, `docs/MCP.md`, 12 npm scripts, 5 Makefile targets, and every doc section describing it. Kept, because they are unrelated things sharing the name: the Config Explorer's MCP tab and its API, per-lane Playwright MCP, the agenthub-config plugin's MCP audit, and the historical `mcp__plugin_agenthub_*` events that analytics must keep attributing. Verified: server 1432/1432, client 459/459, tsc clean, prettier clean. Both directions of the migration proven — a sandbox-HOME test run leaves the legacy directory untouched, and a real boot moves it with its contents intact.
101 lines
4.4 KiB
TypeScript
101 lines
4.4 KiB
TypeScript
/**
|
|
* @file main.tsx
|
|
* @description Vite client entry point. Bootstraps React 18, loads global styles
|
|
* and i18n, registers the service worker for offline asset caching, and mounts
|
|
* {@link App} into `#root`.
|
|
*
|
|
* ## Fonts
|
|
* Only Latin subsets of Inter and JetBrains Mono are imported so Vite bundles
|
|
* lean WOFF2 files instead of every glyph subset Google Fonts would serve.
|
|
*
|
|
* ## Service worker reload policy
|
|
* On first visit there is no controlling SW yet — we must not reload when the
|
|
* initial SW activates (the page is already fresh). On subsequent deploys the
|
|
* page is controlled; when a new SW takes over we reload once so hashed bundle
|
|
* URLs update without a manual hard refresh.
|
|
*
|
|
* @author Nguyễn Ngọc Trí Vĩ <vinnt@smartgift.vn>
|
|
*/
|
|
/* =============================================================================
|
|
* MODULE_GUIDE — extended in-file reference (comments only; safe to read, never executed)
|
|
* =============================================================================
|
|
* **Purpose:** Dashboard module consumed by the React client, MCP tools, or desktop shell depending on deployment mode.
|
|
*
|
|
* ## Design constraints
|
|
* - Local-first: no telemetry leaves the machine unless the user configures webhooks.
|
|
* - Fail-safe hooks path on the server must never block Claude Code; UI mirrors that
|
|
* philosophy by degrading gracefully (empty states, stale badges, reconnect loops).
|
|
* - Destructive flows stay behind explicit confirmation modals and server-side gates.
|
|
* - Internationalization: user-visible strings belong in i18n JSON, not literals here.
|
|
*
|
|
* ## Remote data & SSH
|
|
* Remote Data Sources let operators aggregate multiple machines. SSH entries describe
|
|
* how to reach a peer dashboard; the global data scope (`dataScope.ts`) narrows every
|
|
* scoped GET via `?sources=`. Health checks and import history surface in Settings.
|
|
*
|
|
* ## Internal dependencies
|
|
* - `./App`
|
|
*
|
|
* ## Testing pointers
|
|
* - Prefer colocated `__tests__` with Vitest + Testing Library for UI.
|
|
* - Server contract changes require `npm run test:server` and OpenAPI sync.
|
|
*
|
|
* ## Related docs
|
|
* - `ARCHITECTURE.md` — hooks → API → SQLite → WebSocket → UI pipeline.
|
|
* - `docs/API.md` — REST reference.
|
|
* - `skills/file-headers/` — mandatory `@author` header policy.
|
|
* ============================================================================= */
|
|
|
|
import { StrictMode } from "react";
|
|
import { createRoot } from "react-dom/client";
|
|
// Latin-only subset (matches the app's previous Google Fonts request) so Vite
|
|
// bundles just the latin WOFF2 per weight instead of every subset.
|
|
import "@fontsource/inter/latin-400.css";
|
|
import "@fontsource/inter/latin-500.css";
|
|
import "@fontsource/inter/latin-600.css";
|
|
import "@fontsource/inter/latin-700.css";
|
|
import "@fontsource/jetbrains-mono/latin-400.css";
|
|
import "@fontsource/jetbrains-mono/latin-500.css";
|
|
// The lane terminal renders live Vietnamese output in this font (TerminalView),
|
|
// which the latin subset above doesn't cover — without it, missing glyphs fall
|
|
// back to another installed face with a different advance width and get
|
|
// visually mangled inside xterm's fixed-width cells.
|
|
import "@fontsource/jetbrains-mono/vietnamese-400.css";
|
|
import "@fontsource/jetbrains-mono/vietnamese-500.css";
|
|
import App from "./App";
|
|
import "./i18n";
|
|
import "./index.css";
|
|
|
|
if ("serviceWorker" in navigator) {
|
|
// Detect whether the page is already controlled by an SW *before* we
|
|
// register. On a truly fresh install there is no controller yet, so the
|
|
// first `controllerchange` should NOT reload (the user just opened the page
|
|
// - nothing is stale). On every subsequent rebuild the page is controlled,
|
|
// a new SW takes over, and a one-shot reload picks up the new bundle URLs
|
|
// automatically - no hard refresh needed.
|
|
const wasControlled = !!navigator.serviceWorker.controller;
|
|
let reloaded = false;
|
|
navigator.serviceWorker.addEventListener("controllerchange", () => {
|
|
if (!wasControlled || reloaded) return;
|
|
reloaded = true;
|
|
window.location.reload();
|
|
});
|
|
navigator.serviceWorker
|
|
.register("/sw.js")
|
|
.then((reg) => {
|
|
// Poke the registration so a freshly-built SW activates promptly
|
|
// instead of waiting for the browser's lazy update check.
|
|
reg.update().catch(() => {});
|
|
})
|
|
.catch(() => {});
|
|
}
|
|
|
|
const root = document.getElementById("root");
|
|
if (!root) throw new Error("Root element not found");
|
|
|
|
createRoot(root).render(
|
|
<StrictMode>
|
|
<App />
|
|
</StrictMode>
|
|
);
|