Documentation
¶
Overview ¶
Package web hosts the HTMX-driven browser UI. Templates and assets are embedded at build time via //go:embed — no toolchain on either the contributor or the end-user side. PLAN-5 / C8.
Index ¶
- func AssetsFS() (fs.FS, error)
- func FmtCost(usd float64) string
- func FmtDuration(d time.Duration) string
- func MountAssets(mux *http.ServeMux) error
- func MustTemplates() *template.Template
- func RenderAwaitPending(t *template.Template) string
- func RenderAwaitResolved(t *template.Template) string
- func RenderConnected(t *template.Template) string
- func RenderHookFragment(t *template.Template, hf HookFragment) string
- func RenderHookLine(t *template.Template, h HookLine) string
- func RenderPage(t *template.Template, d PageData) string
- func RenderPipelineInit(t *template.Template) string
- func RenderReplyLine(t *template.Template, r ReplyLine) string
- func RenderStageCard(t *template.Template, st *views.Stage) string
- func RenderStatusBanner(t *template.Template, s StatusBanner) string
- type HookFragment
- type HookLine
- type PageData
- type ReplyLine
- type StageSeed
- type StatusBanner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssetsFS ¶
AssetsFS returns the embedded assets/ subtree, suitable for serving via http.FileServer.
func FmtCost ¶
FmtCost formats USD with four decimals. Numbers under $0.01 stay readable; rounded to 4dp is enough for sub-step granularity. The dashboard route (C7) aggregates to step / run / day with two decimals.
func FmtDuration ¶
FmtDuration is a small helper for stage-card Duration fields. Kept here so templates can call it via FuncMap if a future fragment needs it.
func MountAssets ¶
MountAssets registers GET /assets/... on mux to serve the embedded assets/ subtree. PLAN-5 / C8.
Cache-Control: no-store on every response so browsers always re-fetch when the ape binary's embedded assets change. Without this, the OS-level Chrome / Firefox disk cache cheerfully keeps the prior run's styles.css / page.tmpl / app.js, even across hard-refresh in some cases. Embed-time assets cycle on every rebuild; conditional GET / ETag doesn't add real value here.
func MustTemplates ¶
MustTemplates parses page.tmpl + fragments.tmpl. Panics on parse error — both files are embedded at compile time so a parse failure is a build bug, not a runtime concern.
func RenderAwaitPending ¶
RenderAwaitPending / RenderAwaitResolved produce the decision-gate OOB swaps for the await-pending / await-resolved SSE events.
func RenderAwaitResolved ¶
func RenderConnected ¶
RenderConnected returns the OOB swap that flips the #status banner from 'connecting…' to 'connected'. Emitted by the hub on every new SSE subscriber so the page state is deterministic regardless of which htmx event names the browser fires. PLAN-5 / C8.
func RenderHookFragment ¶
func RenderHookFragment(t *template.Template, hf HookFragment) string
RenderHookFragment turns a HookFragment into one row for the #hooks scrolling feed. PLAN-5 / C8.
func RenderPage ¶
RenderPage returns the full HTML body for GET /.
func RenderPipelineInit ¶
RenderPipelineInit emits the reset-and-scaffold fragment for fresh connections. PLAN-5 / C8 — `pipeline-init` event.
func RenderStageCard ¶
RenderStageCard returns the HTML fragment for a stage-card SSE event.
func RenderStatusBanner ¶
func RenderStatusBanner(t *template.Template, s StatusBanner) string
Types ¶
type HookFragment ¶
type HookFragment struct {
At time.Time
Event string
SessionID string
AgentID string
Step string
// Payload is the raw hook envelope as forwarded by `ape notify`.
// Shape varies by event; the renderer extracts tool name + a
// short summary appropriate to the event kind.
Payload []byte
// ProjectRoot, when non-empty, is stripped from any
// file-path-shaped summary so the feed shows relative paths
// instead of absolute ones.
ProjectRoot string
}
HookFragment is the orchestrator-facing input to the activity-feed renderer. It mirrors orchestrator.HookEvent but the web package declares it locally so internal/web stays import-free of orchestrator (the webRenderer adapter in apecmd bridges the two).
type HookLine ¶
type HookLine struct {
TS string
Event string
Tool string
Summary string
// CSSClass selects an accent colour by event kind (tool / agent /
// prompt / endturn). Optional.
CSSClass string
}
HookLine is the typed input to the hook-line fragment.
type PageData ¶
type PageData struct {
Title string
Subtitle string
// Mode is "pipeline" or "chat". Controls whether the
// decision-gate / reply form renders (chat only).
Mode string
// Stages, when non-empty, seeds the #stages scaffold with
// pending placeholders so the user sees every stage from the
// first page load. Pipeline mode populates this from spec.Stages().
Stages []StageSeed
}
PageData is the input for the page template.
type StageSeed ¶
StageSeed is one stage placeholder for the initial page scaffold. Slug must match the slug used by SSE stage-card fragments so later updates target the same id.
type StatusBanner ¶
type StatusBanner struct {
Class string // "connected" / "disconnected" / "" (default styling)
Text string
}
StatusBanner is the model for the status-banner template fragment rendered on the stopped / error / connected SSE events.