Documentation
¶
Overview ¶
Package web holds akari's server-rendered UI: templ templates and the small view-model helpers they use. Handlers in the httpapi package resolve auth, query the store, and render these templates, so all rendering lives here.
Index ¶
- Constants
- Variables
- func AgentFacetHref(f store.SessionFilter, value string) templ.SafeURL
- func AnalyticsJSON(a store.Analytics) string
- func AnyFilterActive(f store.SessionFilter) bool
- func AttachmentAlt(a store.AttachmentView) string
- func AttachmentsByOrdinal(atts []store.AttachmentView) map[int][]store.AttachmentView
- func BaseName(p string) string
- func BlobURL(base, sha string) string
- func BodyPath(id int64) string
- func ChipLabel(mediaType string, bytes int64) string
- func ChurnSessions(sessions int) string
- func ConcurrencyBusiest(c store.ConcurrencyStats) string
- func ContextResetsLabel(s store.SessionSignals) string
- func DiffTool(name string) bool
- func DuplicateIDsLabel(n int) string
- func FeedIsGrouped(f store.SessionFilter) bool
- func FeedTime(t *time.Time) string
- func FmtAvgConcurrent(v float64) string
- func FmtBytes(n int64) string
- func FmtCost(usd float64, incomplete bool) string
- func FmtDuration(start, end *time.Time) string
- func FmtErrorRate(v float64) string
- func FmtLatency(d time.Duration) string
- func FmtPercent(f float64) string
- func FmtRate(v float64) string
- func FmtRelTime(t *time.Time) string
- func FmtSavings(usd float64, incomplete bool) string
- func FmtTime(t *time.Time) string
- func FmtTimeAt(t time.Time) string
- func FmtTokens(n int64) string
- func FmtTokensCompact(n int64) string
- func FoldUnknownModels(bs []store.Breakdown) []store.Breakdown
- func HygieneCount(n, d int) string
- func HygienePct(n, d int) string
- func IsImageMedia(mediaType string) bool
- func IsLocalKind(kind string) bool
- func LocalPath(p store.ProjectSummary) string
- func MachineFacetHref(f store.SessionFilter, value string) templ.SafeURL
- func OutcomeLabel(outcome string) string
- func OutlineStepClass(t store.ToolCallView) string
- func OutlineStepHasBody(t store.ToolCallView) bool
- func OutlineTitle(m store.Message) string
- func OutlineTurnClass(role string, steps []store.ToolCallView) string
- func OverviewPath(rng string, userIDs []int64) string
- func ParseRange(key string) string
- func PeakContextLabel(s store.SessionSignals) string
- func ProjectFacetHref(f store.SessionFilter, id int64) templ.SafeURL
- func ProjectFacetLabel(pf store.ProjectFacet) string
- func ProjectHref(id int64) templ.SafeURL
- func ProjectPath(id int64) string
- func ProjectTitle(p store.ProjectSummary) string
- func PublicBlobBase(publicID string) string
- func PublicHref(publicID string) templ.SafeURL
- func PublicOverviewHref(username string) templ.SafeURL
- func PublicOverviewPath(username string) string
- func PublicPath(publicID string) string
- func QualityGrade(s store.SessionSignals) string
- func QualityGradeClass(s store.SessionSignals) string
- func QualityScoreLabel(s store.SessionSignals) string
- func RangeSince(key string, now time.Time) time.Time
- func ReparsePercent(done, total int) int
- func RoleClass(role string) string
- func RowTokens(s store.SessionSummary) int64
- func SSEPath(id int64) string
- func SelectedUserIDs(raw []string, users []store.User) []int64
- func SessionBlobBase(id int64) string
- func SessionHref(id int64) templ.SafeURL
- func SessionPath(id int64) string
- func SessionProjectLabel(d store.SessionDetail) string
- func SessionRowProject(r store.SessionRow) string
- func SessionsHref(f store.SessionFilter) templ.SafeURL
- func SessionsPath(f store.SessionFilter) string
- func Sparkline(vals []float64) string
- func StatusClass(status string) string
- func ToolsByOrdinal(tools []store.ToolCallView) map[int][]store.ToolCallView
- func UserFacetHref(f store.SessionFilter, value string) templ.SafeURL
- func VelocityMsgsRate(v store.VelocityStats) string
- func VelocityToolsRate(v store.VelocityStats) string
- func VizColor(i int) string
- type BreakdownRow
- type ChurnBar
- type DateRange
- type DistRow
- type Facets
- type FeedRow
- type GuideLink
- type GuideNavItem
- type GuideTocItem
- type GuideView
- type HeaderStats
- type OGMeta
- type Page
- type RangeOption
- type ReparseView
- type SessionDayGroup
- type SessionSortOption
- type ToolBar
Constants ¶
const DefaultRange = "year"
DefaultRange is the window the overview opens on: a trailing year, wide enough to read seasonality and longer trends on the activity grid without jumping to all of history.
const OtherModelLabel = "Other"
OtherModelLabel is the bucket name for the model breakdown's long tail: every model without a pricing entry folds into this one row.
const SessionsBasePath = "/sessions"
SessionsBasePath is the global (cross-project) session list.
Variables ¶
var DateRanges = []DateRange{
{Key: "7d", Label: "7 days", Days: 7},
{Key: "30d", Label: "30 days", Days: 30},
{Key: "90d", Label: "90 days", Days: 90},
{Key: "year", Label: "Year", Days: 365},
{Key: "all", Label: "All", Days: 0},
}
DateRanges are the windows the overview offers, narrowest first. The selector renders them in this order, and ParseRange validates against their keys.
var Static embed.FS
Static holds the embedded static assets (htmx, stylesheet) served under /static/.
Functions ¶
func AgentFacetHref ¶
func AgentFacetHref(f store.SessionFilter, value string) templ.SafeURL
AgentFacetHref and friends return the toggle href for a facet option, holding the rest of the current selection.
func AnalyticsJSON ¶
AnalyticsJSON marshals a session's daily series for the inline chart script.
func AnyFilterActive ¶
func AnyFilterActive(f store.SessionFilter) bool
AnyFilterActive reports whether the global session list is currently narrowed, so the view can show a "clear all" affordance only when it would do something.
func AttachmentAlt ¶
func AttachmentAlt(a store.AttachmentView) string
AttachmentAlt is the alt text for a rendered image: its filename when one was recovered, else a generic label so the element is never unlabelled.
func AttachmentsByOrdinal ¶
func AttachmentsByOrdinal(atts []store.AttachmentView) map[int][]store.AttachmentView
AttachmentsByOrdinal groups attachments by the message ordinal they belong to, so the session view can render a message's images beneath it.
func BaseName ¶
BaseName returns the last path segment of a file path (handling both / and \ separators), for a compact label in the outline. It returns the input unchanged when there is no separator.
func ChurnSessions ¶
ChurnSessions labels how many sessions edited a file, so a path churned across the fleet reads apart from one a single session kept rewriting.
func ConcurrencyBusiest ¶
func ConcurrencyBusiest(c store.ConcurrencyStats) string
ConcurrencyBusiest formats the busiest user's peak for the concurrency panel: the name and their peak simultaneous sessions, or a dash when no user had a measurable span.
func ContextResetsLabel ¶
func ContextResetsLabel(s store.SessionSignals) string
ContextResetsLabel renders how many inferred context resets (compactions or clears) the session went through, for the Tokens tooltip. An unmeasured session reads a dash; a measured session with none reads "0", a real "it never shed context".
func DiffTool ¶
DiffTool reports whether a tool's input body is worth rendering as an inline diff rather than raw JSON (the file-editing tools across the three agents). The client reads this off the chip to decide how to expand the body.
func DuplicateIDsLabel ¶
DuplicateIDsLabel is the chip text for a session that repeats tool-call ids, pluralized for the count. The count itself is a bounded scalar from the store (DuplicateCallUIDCount), not computed over the in-memory tool calls.
func FeedIsGrouped ¶
func FeedIsGrouped(f store.SessionFilter) bool
FeedIsGrouped reports whether the feed for this filter is split into day headings, which it is only in the default most-recent order.
func FeedTime ¶
FeedTime is the clock time a feed row shows. The day already rides the group heading, so the row needs only the time of day; the exact stamp is the cell's title on hover.
func FmtAvgConcurrent ¶
FmtAvgConcurrent renders the average concurrency to one decimal, the granularity that reads as a rate ("1.4 concurrent") without implying false precision.
func FmtCost ¶
FmtCost renders a USD cost. Sub-cent costs still show enough precision to be meaningful.
func FmtDuration ¶
FmtDuration renders the span between start and end, or a dash.
func FmtErrorRate ¶
FmtErrorRate renders a failure share (a 0..1 fraction) as a whole-percent figure, with a "<1%" floor so a small but real error rate never rounds down to a reassuring "0%".
func FmtLatency ¶
FmtLatency renders a turn-cycle latency at the coarsest unit that still reads honestly: seconds under a minute, minutes and seconds under an hour, hours and minutes beyond. A zero or negative duration (no measured turn) shows a dash rather than "0s", so an absent figure never reads as an instantaneous reply. The value rounds to whole seconds before the unit split, so 59.6s reads as "1m 0s" rather than a misleading "60s".
func FmtPercent ¶
FmtPercent renders a 0..1 fraction as a whole-number percent, for the cache hit rate. A real but tiny rate (under 1%) rounds up to 1% rather than 0%, so a scope that did hit the cache never reads as a total miss; a true zero stays 0%.
func FmtRate ¶
FmtRate renders a per-minute throughput to one decimal, the same granularity as the concurrency average so the velocity and concurrency figures read in one register.
func FmtRelTime ¶
FmtRelTime renders a timestamp as a coarse "time ago" for the recent past (today, 1 day ago, ...), falling back to an absolute stamp once it is a week or more old, where a relative phrasing stops being useful. It reads "now" from the wall clock; relTime holds the testable core. It backs the "Updated" column on both the projects index and the per-project session table, so the two read alike (the global feed groups by day instead and uses FeedTime).
func FmtSavings ¶
FmtSavings renders a cache saving for the Cache tile. A non-negative saving reads as "saved $X"; the rare negative, where cache was written but never re-read enough to repay the creation premium, reads as "cost $X" on its magnitude, so the figure stays honest without printing a minus sign into a "saved" label.
An incomplete saving reads "... partial", NOT the "$X+" lower-bound marker the cost figures use. A saving omitted for an unpriced model can be negative (a Claude cache write is priced above input), so the true figure could be lower OR higher than shown: "partial" says it is incomplete without implying a direction the data cannot support.
func FmtTokensCompact ¶
FmtTokensCompact renders a token count to a short magnitude (2.1B, 1.7M, 63.0k, 412), for the feed's inline figure where the exact value lives in the hover card. The thousands-separated FmtTokens stays the form for places that show the full number. The buckets mirror fmtTok in static/charts.js, its client-side counterpart, so a figure reads the same on either surface.
func FoldUnknownModels ¶
FoldUnknownModels collapses every model without a pricing entry into a single "Other" row, leaving the priced (well-known) models untouched and in their incoming order. Only models we have rates for surface by name on the overview; the rest contribute their totals to "Other" but never their IDs, so a model still under a codename can be exercised without leaking its name.
The input is taken in its store order (cost descending); "Other" is appended last regardless of its totals, the usual place for a catch-all bucket. Summing the per-model session counts can overcount a session that spanned several unpriced models, the same approximation the by-model split already makes across its rows.
func HygieneCount ¶
HygieneCount renders the raw count behind a hygiene rate ("12 of 340"), the sub-line under each figure, so a reader sees the magnitude and not only the proportion (3% of 1000 prompts and 3% of 30 read very differently).
func HygienePct ¶
HygienePct renders a prompt-hygiene rate (a count over the prompt or session total) as a whole-percent figure. It keeps the "<1%" floor the tool error rate uses, so a rare but present signal does not round away to a clean 0%. A zero count reads as a real 0% (no such prompts), not a dash; the dash is only the guard for an empty denominator, which the panel already avoids by gating on PromptHygiene.HasData.
func IsImageMedia ¶
IsImageMedia reports whether a media type is an image the transcript can show inline, so a non-image attachment falls back to a download link instead.
func IsLocalKind ¶
IsLocalKind reports whether a project kind is one of the non-remote kinds (standalone or orphaned), which are grouped and labeled apart from git-remote projects in the UI.
func LocalPath ¶
func LocalPath(p store.ProjectSummary) string
LocalPath recovers the working-directory path from a local project's synthetic key ("local:machine:path"), for display beside the folder name. It returns "" for a remote project.
func MachineFacetHref ¶
func MachineFacetHref(f store.SessionFilter, value string) templ.SafeURL
func OutcomeLabel ¶
OutcomeLabel renders a stored outcome string title-cased for display. An empty or unrecognized value reads "Unknown", so the tile never shows a blank cell.
func OutlineStepClass ¶
func OutlineStepClass(t store.ToolCallView) string
OutlineStepClass maps a tool step to its CSS modifier, flagging an errored step in rose.
func OutlineStepHasBody ¶
func OutlineStepHasBody(t store.ToolCallView) bool
OutlineStepHasBody reports whether a tool step has a stored input or result body, so the outline can wire only those steps to the inspector.
func OutlineTitle ¶
OutlineTitle is a compact one-line label for an outline turn, drawn from the start of the message content. It collapses runs of whitespace and emits at most 48 runes, and it never scans more than scanCap runes of input, so even a whitespace-heavy message costs a fixed amount, independent of message size.
func OutlineTurnClass ¶
func OutlineTurnClass(role string, steps []store.ToolCallView) string
OutlineTurnClass maps a turn (its role and its tool steps) to its CSS modifier: role tone, with an error override so a turn with a failed tool reads in rose.
func OverviewPath ¶
OverviewPath builds the overview URL for a range key and a set of selected user ids: the shared target the range buttons link to and the user filter submits, so the two controls always round-trip the full window-and-users state together rather than each clobbering the other's selection.
func ParseRange ¶
ParseRange normalizes a range query value to a known key, falling back to the default for anything empty or unrecognized.
func PeakContextLabel ¶
func PeakContextLabel(s store.SessionSignals) string
PeakContextLabel renders the heaviest single-turn context the session reached, in full tokens, for the Tokens tooltip. It is a window-independent measure of how loaded the session got. An unmeasured session (no usage) reads a dash rather than a misleading zero.
func ProjectFacetHref ¶
func ProjectFacetHref(f store.SessionFilter, id int64) templ.SafeURL
ProjectFacetHref toggles the project selection for a facet row, holding the rest of the current selection.
func ProjectFacetLabel ¶
func ProjectFacetLabel(pf store.ProjectFacet) string
ProjectFacetLabel is the label for a project option in the session filter rail, friendly for a local project and the remote key otherwise.
func ProjectHref ¶
ProjectHref and friends return sanitized internal URLs for href attributes.
func ProjectPath ¶
ProjectPath returns the plain string path, used for htmx attributes (which are not URL-sanitized like href).
func ProjectTitle ¶
func ProjectTitle(p store.ProjectSummary) string
ProjectTitle is the heading shown for a project. A remote project shows its canonical remote key; a standalone or orphaned project shows its folder name, since its synthetic key ("local:machine:path") is an internal detail.
func PublicBlobBase ¶
func PublicHref ¶
func PublicOverviewHref ¶
PublicOverviewHref is the sanitized href form of PublicOverviewPath, for the account page's link and the signed-in overview badge.
func PublicOverviewPath ¶
PublicOverviewPath is the plain-string path of a user's public usage overview, rooted at /u/<username>. The username is path-escaped so an unusual character cannot break the URL or escape the segment. The range selector on the public page builds its buttons from this base (via RangeOptions), so switching the window refetches the public path rather than the authed overview, and the account page shows it as the shareable link.
func PublicPath ¶
PublicPath is the plain-string public URL, shown to the owner as the shareable link to copy.
func QualityGrade ¶
func QualityGrade(s store.SessionSignals) string
QualityGrade is the headline of the session Quality tile: the letter grade for a scored session, or a plain dash for an unscored one (an unknown outcome with no tool signal, where a letter would invent a verdict the transcript does not support).
func QualityGradeClass ¶
func QualityGradeClass(s store.SessionSignals) string
QualityGradeClass is the CSS modifier for the Quality tile, banding its colour the way a report card reads: A and B good, C watch, D and F poor, an unscored session neutral. It maps to the status palette already in the sheet (sage, peach, rose) rather than introducing new hues, keeping to the One Voice Rule.
func QualityScoreLabel ¶
func QualityScoreLabel(s store.SessionSignals) string
QualityScoreLabel renders the numeric score for the Quality tooltip: "n / 100" for a scored session, "not scored" otherwise, so an unscored session reads as a deliberate abstention rather than a zero.
func RangeSince ¶
RangeSince converts a range key to the lower time bound to pass to the store, measured back from now. The "all" window (zero Days) returns the zero time, which the store reads as "no bound".
func ReparsePercent ¶
ReparsePercent is the completed fraction of a reparse as an integer percent, for the progress bar's fill width. It is 0 before the total is known and is clamped to 100, so a late count revision can never overflow the track.
func RowTokens ¶
func RowTokens(s store.SessionSummary) int64
RowTokens is a session's total token volume across all four classes (input, output, cache read, cache write), matching the overview heatmap's notion of a day's "total tokens" so the figure and its breakdown agree across views.
func SSEPath ¶
SSEPath and BodyPath are the live-update endpoints for a session, carried on data attributes for the static app.js to wire up.
func SelectedUserIDs ¶
SelectedUserIDs parses the overview's repeated ?user= ids against the known accounts, keeping only ids that name a real user and returning them in the users-list order. A tampered, stale, or non-numeric id silently drops out, and the stable order keeps the collapsed pills from reshuffling between requests.
func SessionBlobBase ¶
SessionBlobBase and PublicBlobBase are the per-session prefixes under which CAS blobs are served, for the authenticated and logged-out views respectively. A blob URL is the base plus "/blob/{sha256}"; serving is gated on the session referencing the hash.
func SessionHref ¶
func SessionPath ¶
SessionPath is the plain-string session path, used for the row-navigation data attribute that makes a whole table row a click target.
func SessionProjectLabel ¶
func SessionProjectLabel(d store.SessionDetail) string
SessionProjectLabel is the project name shown in a session header: the folder name for a local session, the remote key otherwise. It keeps the synthetic "local:machine:path" key out of the heading.
func SessionRowProject ¶
func SessionRowProject(r store.SessionRow) string
SessionRowProject is the project label shown beside a session in the global session list: the folder name for a local project, the remote key otherwise.
func SessionsHref ¶
func SessionsHref(f store.SessionFilter) templ.SafeURL
SessionsHref is the sanitized href form of SessionsPath, for anchor tags.
func SessionsPath ¶
func SessionsPath(f store.SessionFilter) string
SessionsPath is the full global session-list path for the current selection, used as the htmx swap target so a facet click updates the URL coherently.
func Sparkline ¶
Sparkline renders a tiny inline SVG line of daily cost for a project row in the index. It is purely decorative trend context, so it carries aria-hidden and no axis; the cost column beside it holds the real number. Returns an empty string when there is nothing to draw (the cell stays blank).
func StatusClass ¶
StatusClass maps a tool result status to a CSS class.
func ToolsByOrdinal ¶
func ToolsByOrdinal(tools []store.ToolCallView) map[int][]store.ToolCallView
ToolsByOrdinal groups tool calls by the message ordinal they belong to, so the session view can render a message's tool calls beneath it.
func UserFacetHref ¶
func UserFacetHref(f store.SessionFilter, value string) templ.SafeURL
func VelocityMsgsRate ¶
func VelocityMsgsRate(v store.VelocityStats) string
VelocityMsgsRate and VelocityToolsRate format the throughput figures, dashing them when the scope had no active time to divide by (see VelocityStats.HasThroughput): a 0.0 over an undefined denominator would read as a real "no work happened" rate rather than "no rate to show".
func VelocityToolsRate ¶
func VelocityToolsRate(v store.VelocityStats) string
Types ¶
type BreakdownRow ¶
type BreakdownRow struct {
Label string
Cost string
CostUSD float64
Tokens int64
Input int64
Output int64
CacheRead int64
CacheWrite int64
Reasoning int64
Sessions int
Pct float64
Color string
// Incomplete marks a slice whose cost folded in an unpriced usage event, so the
// row shows the same "$X+" lower-bound marker the per-session figures use.
Incomplete bool
}
BreakdownRow is one bar in a by-model or by-agent breakdown: the label, its formatted cost, the raw token volume (total plus the four-class split that feeds the hover card), a fill width as a percentage of the largest token volume in the set, and its categorical color. The token fields stay raw int64s so the template runs them through the same FmtTokens the rest of the app uses.
func BuildBreakdown ¶
func BuildBreakdown(bs []store.Breakdown) []BreakdownRow
BuildBreakdown turns store breakdowns into renderable bar rows. Bar width is proportional to token volume so model and agent shares compare on the one figure every slice carries: a model still under a codename (unpriced, so its cost folds to zero) still draws a bar that reflects how much it was used.
type ChurnBar ¶
ChurnBar is one file's bar in the churn list: sized by edit count, labelled with its path, and annotated with how many sessions returned to it.
type DateRange ¶
DateRange is one option in the trailing-window selector. Days is the width of the window; a zero Days means all of history (no lower bound).
type DistRow ¶
DistRow is one bar in an Insights distribution: a display label, the session count, the fill width as a percent of the largest bar in the set, and the bar colour. It reuses the breakdown bars' markup and animation, so a distribution reads with the same instrument styling as the cost breakdowns.
func ArchetypeBars ¶
func ArchetypeBars(counts []store.LabeledCount) []DistRow
ArchetypeBars renders the archetype mix, lightest to heaviest, each in its own categorical hue.
func GradeBars ¶
func GradeBars(counts []store.LabeledCount) []DistRow
GradeBars renders the grade distribution: A through F then the unscored bucket, each banded in the report-card tone the session Quality tile uses.
func OutcomeBars ¶
func OutcomeBars(counts []store.LabeledCount) []DistRow
OutcomeBars renders the outcome distribution, reusing OutcomeLabel for the title-cased names and a semantic tone per outcome.
type FeedRow ¶
type FeedRow struct {
Row store.SessionRow
// FadeProject marks a row whose project repeats the row directly above it in
// the same day group, so the template can mute the repeated label and let a run
// of same-project sessions read as one burst rather than a stuttering column.
FadeProject bool
// TokenPct is the row's total token volume as a percent of the feed's largest
// session, backing a magnitude bar so the big runs stand out without the reader
// parsing seven-digit figures. It is 0 for a zero-token session.
TokenPct int
}
FeedRow is one session prepared for the feed: its source row plus the derived bits the template would otherwise have to compute inline.
type GuideNavItem ¶
type GuideNavItem struct {
// Num is the zero-padded reading position ("00".."08"), shown in mono beside
// the label.
}
GuideNavItem is one chapter in the docs sidebar rail.
type GuideTocItem ¶
GuideTocItem is one heading in the on-this-page table of contents. Level is 2 or 3; an H3 is indented under the H2 it follows.
type GuideView ¶
type GuideView struct {
Title string
Summary string
// BodyHTML is the chapter rendered to HTML by the guide package's goldmark
// pipeline over our own trusted Markdown, injected verbatim into the prose
// column.
BodyHTML string
// RawMarkdown is the exact Markdown source, embedded once so "Copy page" can
// place it on the clipboard without a network round-trip.
RawMarkdown string
// RawPath is the chapter's raw-Markdown URL (/guide/<slug>.md), the "View as
// Markdown" target and the rel=alternate the head advertises.
RawPath string
GithubURL string
Toc []GuideTocItem
Prev *GuideLink
Next *GuideLink
// LoggedIn switches the header's corner action between "Open app" and
// "Log in", since the guide is reachable in either state.
LoggedIn bool
}
GuideView is everything the docs page needs to render one chapter.
type HeaderStats ¶
type HeaderStats struct {
Cache store.CacheStats
Signals store.SessionSignals
}
HeaderStats bundles the derived stat-tile inputs the session instrument header renders beside the token figures: prompt-cache effectiveness and the session's quality signals. Threading one struct keeps the SessionMain / sessionStats / public render seams stable as the header grows, rather than widening every signature each time a new tile lands.
type OGMeta ¶
type OGMeta struct {
Title string
Description string
// Image is the absolute URL of the preview card. Open Graph requires an absolute
// URL here, so the handler builds it from the request origin; empty omits it.
Image string
// URL is the absolute canonical URL of the page; empty omits og:url.
URL string
}
OGMeta carries the Open Graph and Twitter card metadata a public page emits so a shared link unfurls with a title, description, and preview image. The zero value emits only the basic title tags; Image (an absolute URL) switches the Twitter card to the large-image form and adds og:image. Description and URL are optional.
type Page ¶
type Page struct {
Title string
Username string
IsAdmin bool
LoggedIn bool
// Active is the sidebar nav key for the current page ("overview",
// "sessions", "projects", "account"), so the shell can mark the
// current section. Empty leaves no item active.
Active string
// OverviewPublic reports whether the signed-in user has published their own
// usage overview, which drives the account page's Publicity controls and the
// "Public" badge on the signed-in overview. The share link is /u/<username>, so
// Username (already on the page) is all the badge and account section need to
// build it. This is populated from the same UserByID lookup that fills Username,
// so reading it costs no extra query.
OverviewPublic bool
}
Page is the shared layout context for every rendered page.
type RangeOption ¶
RangeOption is one rendered button in the trailing-window selector: the window label, the URL the button refetches the usage panel from, and whether it is the active window. The href is built per panel so the selector can sit on any page (the global overview or one project) and refetch from that page's own path.
func ProjectRangeOptions ¶
func ProjectRangeOptions(projectID int64, sel store.SessionFilter, active string) []RangeOption
ProjectRangeOptions is RangeOptions for a project's usage panel: it roots the selector at the project path and preserves the active session filters, so the window control and the filter rail share the URL without clobbering each other.
func RangeOptions ¶
func RangeOptions(basePath string, preserve url.Values, active string) []RangeOption
RangeOptions builds the selector's buttons for a panel rooted at basePath. Any params in preserve (except range, which each button sets) ride along on every href, so switching the window on a page that also carries other query state (the project page's session filters) does not drop that state from the URL.
type ReparseView ¶
ReparseView is the reparse status the account page renders: whether one is running and how far along. The httpapi layer fills it from the reparse service, so the web package stays free of a dependency on that service.
type SessionDayGroup ¶
SessionDayGroup is a run of feed rows under one day heading. Label is empty when the feed is not day-grouped (any order other than most-recent), in which case the template renders the rows without a heading.
func BuildSessionFeed ¶
func BuildSessionFeed(rows []store.SessionRow, grouped bool) []SessionDayGroup
BuildSessionFeed groups session rows for the feed. When grouped is true (the most-recent order) the rows, already sorted newest first, are split under day headings ("Today", "Yesterday", a weekday, then a date); otherwise they form a single unlabeled group in the order the query returned. Within a group a row whose project repeats the previous row's is flagged to mute its label. Token bars scale against the largest session across the whole feed, so magnitudes are comparable between groups.
type SessionSortOption ¶
SessionSortOption is one choice in the feed's sort control. The cross-project feed sorts by recency, volume, or message count; the categorical dimensions (agent, project, machine, user) are served by the filters instead, so the control stays a short list rather than a header per column.
func SessionSortOptions ¶
func SessionSortOptions() []SessionSortOption
SessionSortOptions are the feed's sort choices, in menu order. "updated" (the default) is the only one that day-groups the feed; the others read as a flat, ranked list.
type ToolBar ¶
type ToolBar struct {
Name string
Calls int
Pct float64
ErrText string // "" when the tool never failed, else its error rate ("12%")
Color string
}
ToolBar is one tool's bar in the mix: sized by call volume, coloured by its error band, and annotated with its error rate when it had any failures. The dual encoding reads mix (bar length) and reliability (colour and the error suffix) in one row.
func ToolBars ¶
ToolBars turns the fleet's busiest tools into renderable bars: each width is its share of the most-called tool, so the busiest tool is full and the rest are relative, and each colour bands the tool's reliability. A non-zero bar always shows at least a sliver so a rarely-called tool never reads as absent beside a dominant one.