webui

package
v0.29.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package webui serves the embedded read-only Atlas UI (D227).

The production bundle under dist/ is committed to the repository and embedded with go:embed. That is deliberate and it is the reason a generated artifact lives in version control: `go install github.com/BeppeTemp/cartographer/cmd/cartographer@latest` cannot run an npm build, and the promise is that every installation path — Homebrew, the Windows zip, the install scripts, the container, `go install` and the native service — serves the same UI from the one binary. A committed bundle is the price of that promise.

What keeps the committed bundle honest is provenance.json: `make web` writes the hash of the web/ source tree into it, and TestBundleMatchesSource recomputes that hash and fails when the two disagree. The check is pure Go, so `make gate` catches a stale bundle on a machine with no Node installed. There is deliberately no reproducible-rebuild check: Vite output is not byte-stable across Node patch releases, and a gate that fails for reasons unrelated to the change is a gate that gets bypassed.

Index

Constants

View Source
const MountPath = "/ui/"

MountPath is where the UI is served. The trailing slash is part of it: the SPA owns everything below this prefix and nothing at all outside it.

View Source
const ProvenanceFile = "provenance.json"

ProvenanceFile records which source tree produced the embedded bundle.

Variables

This section is empty.

Functions

func Assets

func Assets() (fs.FS, error)

Assets returns the embedded bundle rooted at its own directory, so the caller sees "index.html" rather than "dist/index.html".

func Handler

func Handler() (http.Handler, error)

Handler serves the embedded UI under MountPath.

Hashed asset filenames are immutable, so they are cached forever; the shell is not, so it must be revalidated or a browser keeps loading last release's entry point against this release's API. Any unknown path below MountPath serves the shell, because client-side routing owns those URLs — and nothing outside MountPath is routed here at all, which is what keeps the SPA fallback from swallowing /mcp, /health or /api.

func KBURL added in v0.29.0

func KBURL(uiURL, kb string) string

KBURL is the Atlas URL that opens one KB (the UI's ?kb= view state). The name is only ever a query value, escaped here.

func LoopbackURL added in v0.29.0

func LoopbackURL(addr string) string

LoopbackURL is URL for the one address kb_status may report (#1945): a loopback bind (client.IsLoopbackHost: 127.0.0.0/8, ::1, localhost) or a wildcard one, which only the machine itself reaches as 127.0.0.1. A bind to a specific other address is "": naming it would tell every authenticated caller where the server listens, and the operator, not the server, knows the address users reach it by.

func RedirectRoot

func RedirectRoot(next http.Handler) http.Handler

RedirectRoot sends a browser that asked for "/" to the UI, and passes everything else through untouched.

It wraps the *outside* of the authentication chain on purpose. A person typing the server's bare address has no bearer token yet, so inside the chain "/" would answer 401 and the UI would be reachable only by someone who already knew to type /ui/. Exempting "/" from authentication instead would weaken the middleware's default for every future endpoint; a redirect that reveals nothing is the narrower fix.

func SourceHash

func SourceHash(root string) (string, int, error)

SourceHash hashes a frontend source tree: every file path and its content, in sorted order. Paths are included, not only contents, so renaming a file changes the hash — a rename is a change to what the bundle was built from even when no byte of source moved.

Inside a git repository the files are the ones git tracks: a .DS_Store, a *.tsbuildinfo or a .env.local a machine happens to hold is not a source, and hashing it would make `make web` record a provenance CI cannot reproduce. Outside one (a source tarball, a temp copy) the tree is walked.

func URL added in v0.29.0

func URL(addr string) string

URL is the browser address of the Atlas served on a server http address ("127.0.0.1:39273", ":39273", "0.0.0.0:9090", "[::]:9090"). A bare port and a wildcard bind become 127.0.0.1: a server can listen on a wildcard, but a browser cannot open one. "" when addr is empty or unparseable. Shared by `cartographer service status` (the ui: line), the tray and kb_status, so the three print the same address.

Types

type Provenance

type Provenance struct {
	// SourceHash is the hash of the web/ source tree, as SourceHash computes
	// it. It is the whole point of the file.
	SourceHash string `json:"source_hash"`
	// Files is the number of source files that went into the hash, carried for
	// a human reading a diff: a hash that changed because one file moved looks
	// exactly like a hash that changed because the tree was emptied.
	Files int `json:"files"`
}

Provenance is the manifest `make web` writes next to the bundle.

func ReadProvenance

func ReadProvenance() (Provenance, error)

ReadProvenance returns the manifest embedded beside the bundle.

Directories

Path Synopsis
Command webui-provenance fingerprints the Atlas bundle: it writes internal/webui/dist/provenance.json with the hash of the web/ source tree.
Command webui-provenance fingerprints the Atlas bundle: it writes internal/webui/dist/provenance.json with the hash of the web/ source tree.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL