Skip to content

console: a routed TypeScript SPA, built rather than hand-written - #1

Merged
blakebauman merged 2 commits into
mainfrom
console-typescript-spa
Aug 11, 2026
Merged

blakebauman merged 2 commits into
mainfrom
console-typescript-spa

Conversation

@blakebauman

Copy link
Copy Markdown
Member

The console was one hand-written page with one address. That shape was the
limit: everything had to be visible at once, the upstream table crammed
endpoints, labels, owner and error text into cells you could only read by
scrolling sideways, and there was nothing to send a colleague but a screenshot.

It is now TypeScript, Preact via preact/compat, TanStack Router and TanStack
Query, built with Vite, across five routes. Filters, sort and selection live in
the URL, so "the broken upstream" is a link.

Route
#/ Overview — configuration grouped: auth, federation, governance, tenancy, observability, discovery
#/upstreams Filterable, sortable, deep-linkable list
#/upstreams/<id> One upstream in full, including fields the table never had room for
#/catalog Searchable tools/prompts/resources with namespace attribution
#/test Invoke one and read the result, with the wire log

Rationale and what was deliberately left out: docs/design.md.

⚠️ Requires a companion change in fold

The vendored directory was console/; it is dist/ now.
docs/fold-sync-console.patch carries the one-line path change to
scripts/sync-console.sh plus reviewer notes, and must land in fold together
with a pin bump to this commit.

Until it does, fold's weekly console-sync will fail rather than open its PR —
loudly, by design: a pre-rename pin has no dist/, a post-rename one has no
console/, so the failure mode is a red build, never silently vendored stale
bytes. The embedded file set itself is unchanged, so fold's MANIFEST and
introspection_test.go need no edit. The patch is verified to apply cleanly to
a pristine fold checkout.

Review notes

Build output is committed, in dist/. fold builds from the Go module proxy
alone, which runs no generators, so the built bytes have to be in git or they
never reach an operator. Nothing there is hand-written — CI rebuilds and fails
on any drift, which is what makes the vendored copy trustworthy. Review src/;
dist/ is entailed by it.

Fragment routing is a deployment constraint, not a preference. fold serves
these assets from an http.FileServer over an embedded FS, so there is no SPA
fallback and GET /console/upstreams is a 404 in every shipped binary — which
this repo cannot fix. Hash routing makes every deep link a request for
/console/, and keeps the OAuth redirect_uri to one registerable value.

Security invariants are unchanged and now enforced. The token still lives in
page memory only. Upstream-controlled strings are still never markup — JSX
escapes text children, and eslint plus CI reject the escape hatches. Two CSP
consequences that were previously conventions now fail the build: no inline
<script> (Vite's module-preload polyfill is off for this reason) and no
style attributes, since default-src 'self' grants no 'unsafe-inline'.

The size budget moves 320 KiB → 384 KiB. Framework and router are ~137 KiB
of the 171 KiB bundle; the four font subsets are another 127 KiB. Current total
is 305 KiB. Flagging this explicitly — it is bytes on every operator's disk.

Also here

  • The Go dev harness is gone. It existed solely to give the page a single
    origin with the gateway; a Go module for one reverse proxy stopped paying for
    itself once a build step arrived with a dev server that proxies. The part that
    earned its keep — replaying fold's exact CSP against the built bundle —
    moved into vite.config.ts and still fails on drift from gateway/console.go.
  • Version skew is handled rather than assumed away. src/lib/version.ts
    gates each gateway-dependent surface on the version that introduced it: a
    feature the gateway is too old for is absent, never broken.
  • Bug fix: mcpPath was used as a root-absolute path, which broke behind a
    proxy adding a prefix — the same bug ../api already avoided.
  • owner.contact is now rendered. It has been in fold's API and never
    shown, and it is the most useful field on the page about an upstream that is
    down.

Known bug, inherited

The -400 and -600 font subsets are byte-identical, so nothing on the page is
actually bold. Documented at src/styles/app.css; the faces are declared
honestly so regenerating the subsets is the only fix needed. It also dictates
how fonts are wired — a module import would let the bundler deduplicate two of
the four out of existence and break fold's sync.

Verification

Typecheck, lint and all CI checks pass locally. Exercised end-to-end in a
browser against a live gateway: overview, list filtering and sort, detail deep
link after a hard reload, MCP connect (14 tools / 4 prompts / 3 resources),
schema-derived argument prefill, and a successful tools/call. No console
errors.

🤖 Generated with Claude Code

blakebauman and others added 2 commits August 11, 2026 07:50
The console was one hand-written page with one address. That shape was the
limit: everything had to be visible at once, the upstream table crammed
endpoints, labels, owner and error text into cells you could only read by
scrolling sideways, and there was nothing to send a colleague but a screenshot.

It is now TypeScript, Preact via preact/compat, TanStack Router and TanStack
Query, built with Vite, across five routes — overview, upstreams, upstream
detail, catalog, test console. Filters, sort and selection live in the URL, so
"the broken upstream" is a link. Rationale, and what was deliberately left out,
in docs/design.md.

Preact rather than React because the whole bundle ships inside every fold
binary; react-dom alone is most of a font subset's worth of bytes.

Routing is on the fragment, and that is a deployment constraint rather than a
preference. fold serves these assets from an http.FileServer over an embedded
FS, so there is no SPA fallback and GET /console/upstreams is a 404 in every
shipped binary — which this repo cannot fix, because that server lives behind a
reviewed vendoring step in another repo. Hash routing makes every deep link a
request for /console/, which the file server already answers, and keeps the
OAuth redirect_uri to one registerable value.

The security invariants are unchanged and now have teeth. The token still lives
in page memory only. Upstream-controlled strings are still never markup — JSX
escapes text children, and both eslint and CI reject the escape hatches. Two
CSP consequences that were previously only conventions are now enforced: no
inline <script> (Vite's module-preload polyfill is off for this reason) and no
style attributes, since default-src 'self' grants no 'unsafe-inline'.

BUILD OUTPUT IS COMMITTED, in dist/. fold builds from the Go module proxy
alone, which runs no generators, so the built bytes have to be in git or they
never reach an operator. CI rebuilds and fails on any drift, which is what
makes the vendored copy trustworthy.

REQUIRES A COMPANION CHANGE IN fold. The vendored directory was called
console/; it is dist/ now. docs/fold-sync-console.patch carries the one-line
path change to scripts/sync-console.sh plus the reviewer notes, and must land
there together with a pin bump to this commit. Until it does, fold's weekly
console-sync workflow will fail rather than open its PR — loudly, by design.
The embedded file set itself is unchanged, so fold's MANIFEST and
introspection_test.go need no edit.

Also here:

  - The Go dev harness is gone. It existed solely to give the page a single
    origin with the gateway; a Go module for one reverse proxy stopped paying
    for itself once a build step arrived with a dev server that proxies. The
    part that earned its keep — replaying fold's exact CSP against the built
    bundle — moved into vite.config.ts, and still fails on drift from
    gateway/console.go.
  - Version skew is handled instead of assumed away. src/lib/version.ts gates
    each gateway-dependent surface on the version that introduced it: a feature
    the gateway is too old for is absent, never broken.
  - mcpPath is resolved relative to the page rather than used as a
    root-absolute path, which was broken behind a proxy adding a prefix — the
    same bug ../api already avoided.
  - owner.contact is rendered. It has been in fold's API and never shown, and
    it is the most useful field on the page about an upstream that is down.
  - The size budget moves 320 KiB -> 384 KiB. Framework and router are ~137 KiB
    of the 171 KiB bundle; the four font subsets are another 127 KiB. Current
    total is 305 KiB.

Known bug, inherited and now documented at src/styles/app.css: the -400 and
-600 font subsets are byte-identical, so nothing on the page is actually bold.
The faces are declared honestly so regenerating the subsets is the only fix
needed. It also dictates how fonts are wired — a module import would let the
bundler deduplicate two of the four out of existence and break fold's sync.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
pnpm/action-setup refuses to start when a `version:` input and package.json's
"packageManager" both name a version, rather than guess which is authoritative
— so the workflow never reached a single check. Drop the input: corepack and
every contributor's shell already read the manifest, and one pin cannot skew
against itself.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
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.

1 participant