已关闭
Add embedded SvelteKit admin UI runtime and secure local listener #92
urandon创建于  13 天前关闭于  13 天前
urandon
urandon成员
13 天前 创建

Parent: #52

Design: https://gitcode.com/urandon/gitcode-mcp/wiki/Admin-Web-UI-Design-2026-08-25.md

Goal

Add the optional, secure single-binary runtime foundation for the local admin Web UI.

Scope

  • Scaffold web/ with Svelte 5, SvelteKit, TypeScript, Vite, and @sveltejs/adapter-static.
  • Build a static SPA bundle and embed it in the Go binary with //go:embed all:assets.
  • Serve embedded assets from a dedicated loopback admin listener owned by gitcode-mcp service run.
  • Add gitcode-mcp admin open and gitcode-mcp admin status.
  • Implement one-time launch-token exchange, bounded SameSite=Strict/HttpOnly session, CSRF protection, Host/Origin checks, CSP, no CORS, and loopback-only defaults.
  • Add a minimal version/readiness endpoint and an application shell that reports API/version mismatch.
  • Keep generated assets compilable for go install ./...; add deterministic rebuild verification in CI.
  • Document the optional listener config and how to disable it.

Acceptance criteria

  1. A released or source-installed gitcode-mcp binary opens the embedded UI without Node at runtime.
  2. admin open attaches to the existing daemon; it does not start a second control plane or writer owner.
  3. The listener defaults to a dynamic loopback port and rejects non-loopback binding unless an explicit unsafe override is supplied.
  4. Browser mutations cannot be triggered cross-origin; Host, Origin, session, CSRF, CSP, and security-header behavior have tests.
  5. One-time launch material is not retained in logs, API responses, browser history, or persistent config.
  6. Hashed assets are immutable-cacheable while index.html revalidates; client routes fall back to embedded index.html.
  7. go install ./..., go test ./..., frontend unit checks, an initial Playwright smoke, asset rebuild verification, and git diff --check pass.

Non-goals

  • Product data views beyond the version/readiness shell.
  • Hosted/remote administration or multi-user auth.
  • A separate Node server or separate long-lived UI daemon.
likedislike
urandonurandon成员
13 天前 添加了label:enhancement
urandonurandon成员
13 天前 关联了pull request:Add embedded admin UI foundation
urandon
urandon成员
13 天前 评论:

Implementation is ready in !96: https://gitcode.com/urandon/gitcode-mcp/merge_requests/96

What landed in the branch:

  • Svelte 5 / SvelteKit / TypeScript frontend compiled with adapter-static and embedded through go:embed; source installs still need no Node runtime.
  • admin open attaches to the existing daemon and lazily starts a dynamic loopback listener; admin status returns only sanitized listener state.
  • The CLI creates raw launch material locally and sends only its SHA-256 hash over the control socket. The token is one-time/one-minute, lives in the URL fragment, and is removed before exchange.
  • Browser sessions are bounded HttpOnly + SameSite Strict cookies. Mutations validate Host, Origin, Fetch Metadata and CSRF. API responses are no-store; assets use generated hash-based CSP, no CORS, no framing, immutable hashed-asset caching and no-store SPA entry revalidation.
  • Authenticated readiness reports daemon/session/cache/schema/version state and surfaces UI/API version mismatch.
  • The selected local-operator-console direction is implemented with a visible Light / Dark / System selector. System is the default and follows prefers-color-scheme; explicit choices persist locally.

Dogfood / visual QA:

  • Playwright exercised the real embedded listener and one-time session exchange, verified cookie flags, navigation, refresh, and all three theme states: 2/2 passed.
  • A same-viewport (1487×1058) side-by-side comparison was used to align the sidebar, content column, readiness rows, actions and theme control.
  • This QA caught a real CSP integration defect: SvelteKit's bootstrap was initially blocked. The fix uses a generated SHA-256 bootstrap hash and keeps unsafe-inline disabled.

Verification:

  • ./scripts/check-admin-ui-assets.sh
  • npm run check
  • npm run test
  • npm run test:e2e
  • go test ./...
  • go install ./...
  • git diff --check

The final source build is installed locally.

likedislike
urandonurandon成员
13 天前 关闭了 issue
urandonurandon成员
13 天前 添加了label:enhancement;删除了label:enhancement
urandonurandon成员
13 天前 关联了里程碑:Admin Web UI
urandonurandon成员
13 天前 添加了label:admin-ui
urandonurandon成员
13 天前 添加了label:service