Skip to content

Add embedded web console for Route42 management - #2

Merged
krugis merged 1 commit into
mainfrom
claude/epic-heisenberg-5m3wi7
Jul 13, 2026
Merged

Add embedded web console for Route42 management#2
krugis merged 1 commit into
mainfrom
claude/epic-heisenberg-5m3wi7

Conversation

@krugis

@krugis krugis commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Summary

This PR adds a built-in single-page web console to Route42, served at the root path (/). The console provides a dashboard for monitoring AI usage, managing provider keys, configuring routing preferences, and testing prompt routing—all without external dependencies or a build step.

Key Changes

  • Web UI Package (internal/webui/): New package that embeds static assets (HTML, CSS, JavaScript) using Go's embed directive. The console is served as a standard HTTP handler and can be disabled via configuration.

  • Console Assets (internal/webui/static/):

    • index.html: Single-page app shell with navigation, modals, and layout structure
    • app.js (716 lines): Zero-dependency SPA with tabs for Dashboard, Models, Preferences, Playground, and History. Handles API communication, token management (localStorage), formatting, and real-time stats rendering
    • style.css (489 lines): Hand-rolled dark theme (gray-950/900 surfaces, blue→purple gradients) matching the commercial UI design
    • logo.svg: Route42 brand mark
  • API Additions:

    • internal/api/interactions.go: New /api/interactions endpoint returning recent routed requests with configurable limit (default 50, max 500)
    • Updated internal/api/routes.go to register the webui handler and interactions endpoint
    • Updated internal/api/server.go to apply auth middleware correctly (UI and /health remain public even when api_token is set)
  • Configuration:

    • Added server.ui boolean flag (default true) to internal/config/config.go to allow disabling the console
    • Updated docs/config.md and cmd/route42/serve.go with UI configuration and startup logging
  • Testing: Added internal/api/webui_test.go with tests for UI serving, disabling, auth scope, and the interactions endpoint

Implementation Details

  • Zero Dependencies: The JavaScript uses only native browser APIs (fetch, localStorage, querySelector). No frameworks or build tools required.
  • Auth Scope: The console itself (HTML/CSS/JS) and /health remain public; only /api/* endpoints require the bearer token when configured.
  • Embedded Assets: All static files are compiled into the binary via go:embed, maintaining the single-binary deployment story.
  • Responsive Design: CSS grid layouts adapt to smaller screens; the console is usable on desktop and tablet.
  • Features: Dashboard with health/local model status and usage stats; Models tab with filtering and provider key management; Preferences for routing priority and limits; Playground for testing; History for interaction logs.

https://claude.ai/code/session_01JgWPXefHtzYcspK8zo4Bo6

…dency

Add a small management console served by the gateway at / — Dashboard
(health, local models, usage/spend, client snippets), Models (catalog +
provider keys), Preferences, Playground (recommend + streaming chat),
and Interaction History. Plain HTML/CSS/JS embedded via go:embed: no
build step, no external assets, single-binary story unchanged, and the
visual language matches the Route42 Pro desktop app (dark gray surfaces,
blue-to-purple gradients, Inter).

The console is optional: server.ui (default true, env ROUTE42_UI)
disables it, and the CLI + HTTP API work identically either way. The
auth middleware now guards exactly /api/* and /v1/* so the static
assets are public like /health; the console stores an entered token
and sends it on API calls.

Also:
- GET /api/interactions exposes the existing local interaction log
  (limit param, default 50, max 500) for the history page.
- config.Prefs gains snake_case json tags. This fixes the documented
  wire format: /api/prefs previously emitted Go field names, and
  `prefs set --json '{"fallback_depth":3}'` silently ignored
  underscored keys. Storage is column-based SQLite, so existing
  databases are unaffected.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JgWPXefHtzYcspK8zo4Bo6
@krugis
krugis merged commit b702831 into main Jul 13, 2026
3 checks passed
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.

2 participants