web

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

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

View Source
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.

View Source
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.

View Source
const SessionsBasePath = "/sessions"

SessionsBasePath is the global (cross-project) session list.

Variables

View Source
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.

View Source
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

func AnalyticsJSON(a store.Analytics) string

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

func BaseName(p string) string

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 BlobURL

func BlobURL(base, sha string) string

BlobURL builds a tool body's fetch URL from a session blob base and a hash.

func BodyPath

func BodyPath(id int64) string

func ChipLabel

func ChipLabel(mediaType string, bytes int64) string

ChipLabel renders a tool body's media type and size, for example "36.0 KB json".

func ChurnSessions

func ChurnSessions(sessions int) string

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

func DiffTool(name string) bool

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

func DuplicateIDsLabel(n int) string

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

func FeedTime(t *time.Time) string

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

func FmtAvgConcurrent(v float64) string

FmtAvgConcurrent renders the average concurrency to one decimal, the granularity that reads as a rate ("1.4 concurrent") without implying false precision.

func FmtBytes

func FmtBytes(n int64) string

FmtBytes renders a byte count compactly (the tool-body metadata chips).

func FmtCost

func FmtCost(usd float64, incomplete bool) string

FmtCost renders a USD cost. Sub-cent costs still show enough precision to be meaningful.

func FmtDuration

func FmtDuration(start, end *time.Time) string

FmtDuration renders the span between start and end, or a dash.

func FmtErrorRate

func FmtErrorRate(v float64) string

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

func FmtLatency(d time.Duration) string

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

func FmtPercent(f float64) string

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

func FmtRate(v float64) string

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

func FmtRelTime(t *time.Time) string

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

func FmtSavings(usd float64, incomplete bool) string

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 FmtTime

func FmtTime(t *time.Time) string

FmtTime renders a timestamp, or a dash when absent.

func FmtTimeAt

func FmtTimeAt(t time.Time) string

FmtTimeAt renders a non-pointer timestamp, or a dash when zero.

func FmtTokens

func FmtTokens(n int64) string

FmtTokens renders a token count with thousands separators.

func FmtTokensCompact

func FmtTokensCompact(n int64) string

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

func FoldUnknownModels(bs []store.Breakdown) []store.Breakdown

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

func HygieneCount(n, d int) string

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

func HygienePct(n, d int) string

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

func IsImageMedia(mediaType string) bool

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

func IsLocalKind(kind string) bool

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

func OutcomeLabel(outcome string) string

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

func OutlineTitle(m store.Message) string

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

func OverviewPath(rng string, userIDs []int64) string

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

func ParseRange(key string) string

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

func ProjectHref(id int64) templ.SafeURL

ProjectHref and friends return sanitized internal URLs for href attributes.

func ProjectPath

func ProjectPath(id int64) string

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 PublicBlobBase(publicID string) string

func PublicHref

func PublicHref(publicID string) templ.SafeURL

func PublicOverviewHref

func PublicOverviewHref(username string) templ.SafeURL

PublicOverviewHref is the sanitized href form of PublicOverviewPath, for the account page's link and the signed-in overview badge.

func PublicOverviewPath

func PublicOverviewPath(username string) string

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

func PublicPath(publicID string) string

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

func RangeSince(key string, now time.Time) time.Time

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

func ReparsePercent(done, total int) int

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 RoleClass

func RoleClass(role string) string

RoleClass maps a message role to a CSS class for styling.

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

func SSEPath(id int64) string

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

func SelectedUserIDs(raw []string, users []store.User) []int64

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

func SessionBlobBase(id int64) string

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 SessionHref(id int64) templ.SafeURL

func SessionPath

func SessionPath(id int64) string

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

func Sparkline(vals []float64) string

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

func StatusClass(status string) string

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

func VizColor

func VizColor(i int) string

VizColor returns the categorical color for index i, wrapping past the eighth.

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

type ChurnBar struct {
	Path     string
	Edits    int
	Sessions int
	Pct      float64
}

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.

func ChurnBars

func ChurnBars(c store.FileChurn) []ChurnBar

ChurnBars turns the most-edited files into renderable bars, each width its share of the most-churned file so the worst hotspot reads full and the rest relative.

type DateRange

type DateRange struct {
	Key   string
	Label string
	Days  int
}

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

type DistRow struct {
	Label string
	Count int
	Pct   float64
	Color string
}

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 Facets

type Facets struct {
	Agents   []string
	Machines []string
	Users    []string
}

Facets are the distinct filter values available for a project's session list.

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 GuideLink struct {
	Label string
	Route string
}

GuideLink is a prev/next navigation target.

type GuideNavItem

type GuideNavItem struct {
	// Num is the zero-padded reading position ("00".."08"), shown in mono beside
	// the label.
	Num    string
	Label  string
	Route  string
	Active bool
}

GuideNavItem is one chapter in the docs sidebar rail.

type GuideTocItem

type GuideTocItem struct {
	ID    string
	Text  string
	Level int
}

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
	Nav       []GuideNavItem
	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

type RangeOption struct {
	Label  string
	Href   string
	Active bool
}

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

type ReparseView struct {
	InProgress bool
	Done       int
	Total      int
	Failed     int
}

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

type SessionDayGroup struct {
	Label string
	Rows  []FeedRow
}

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

type SessionSortOption struct {
	Key   string
	Label string
}

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

func ToolBars(t store.ToolStats) []ToolBar

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.

Jump to

Keyboard shortcuts

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