Trim comments across Rust and webapp source to direct one-liners (ticket 030)

Pass over src/*.rs, webapp/src/**, and the in-app "?" docs prose:
condensed multi-paragraph doc comments to single lines that state the
non-obvious why, deleted comments that only restated adjacent code, and
tightened the Docs.tsx help-panel wording. No logic, structure, or code
formatting changed — verified via cargo test (143 passed) and
tsc -b && vite build.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XFUNZwCvz3kcod3352ZR2o
This commit is contained in:
Hugh Kaznowski
2026-09-05 17:02:33 +01:00
co-authored by Claude Sonnet 5
parent 3cef6dc8ae
commit 00c21c8032
32 changed files with 347 additions and 1550 deletions
+12 -34
View File
@@ -1,7 +1,4 @@
/// `MetricPrimitive` is a Rust enum with derived `Serialize`, so its JSON
/// form is externally tagged, e.g. `{ "String": "info" }`, `{ "Number":
/// { "Int": 5 } }`, `{ "Timestamp": 1710000000000 }`, `{ "Duration": 1500 }`
/// (milliseconds, ticket 023).
// Externally-tagged JSON matching the Rust `MetricPrimitive` enum's derived `Serialize`, e.g. `{ "Duration": 1500 }` (milliseconds).
export type MetricPrimitive =
| { String: string }
| { Number: { Int: number } | { Float: number } }
@@ -20,9 +17,7 @@ export interface LogEntry {
sequence: number
timestamp_ms: number
text: string
/// Derived param values (declared via `POST /api/params`) that matched
/// this line's text, keyed by param name. A param with no match on this
/// line is simply absent from the map.
// A param with no match on this line is simply absent from the map.
params: Record<string, MetricPrimitive>
}
@@ -46,7 +41,6 @@ export interface Stats {
last_timestamp_ms: number | null
}
/** Whether a param contributes to a bucket's labels or is its captured value (ticket 022). */
export type ParamRole = 'label' | 'value'
export interface MetricParamMatcher {
@@ -61,7 +55,7 @@ export interface MetricDeclaration {
name: string
message_match_regex: string
params: MetricParamMatcher[]
/** Fixed labels applied on a match/non-match, on top of any captured params (ticket 025). */
/** Fixed labels applied on a match/non-match, on top of any captured params. */
matched_labels?: Record<string, string> | null
unmatched_labels?: Record<string, string> | null
}
@@ -73,8 +67,7 @@ export interface BucketValue {
value: MetricPrimitive
}
/// Error shape returned by API handlers on a 4xx/5xx response:
/// `{ "error": "..." }` (see `ErrorDto` on the backend).
// Error shape returned by API handlers on a 4xx/5xx response (see `ErrorDto` on the backend).
export interface ApiErrorBody {
error: string
}
@@ -103,7 +96,7 @@ export interface Settings {
active_profile: string | null
/** Maximum ingested logs kept in memory; `null` means unlimited. */
max_logs: number | null
/** Id of the selected custom theme entry (ticket 033), or `null` if `color_scheme` alone applies. */
/** Id of the selected custom theme entry, or `null` if `color_scheme` alone applies. */
custom_theme_id: string | null
}
@@ -114,7 +107,7 @@ export interface CssEntry {
kind: CssEntryKind
filename: string | null
path_or_url: string | null
/** Whether this entry is a selectable colour-scheme theme (ticket 033) rather than arbitrary CSS. */
/** Whether this entry is a selectable colour-scheme theme rather than arbitrary CSS. */
is_theme: boolean
}
@@ -125,9 +118,7 @@ export interface ProfileSummary {
dashboard_count: number
}
/// One chart-ready time series returned by `GET /api/query` (ticket 013):
/// a label combination plus its `(timestamp_ms, value)` points, sorted by
/// timestamp. See `PromqlSeriesDto` on the backend.
// One chart-ready time series from `GET /api/query`: a label combination plus its `(timestamp_ms, value)` points, sorted by timestamp.
export interface PromqlSeries {
labels: Record<string, string>
points: [number, number][]
@@ -148,20 +139,16 @@ export interface Dashboard {
panels: Panel[]
}
/// Comparison operator shared by `AlertCondition::Threshold`/`Ratio` and
/// filter-query metric comparisons (see `CompareOp` on the backend).
export type CompareOp = 'lt' | 'gt' | 'le' | 'ge' | 'eq' | 'ne'
/// What triggers an alert rule (ticket 017/018). Externally tagged on
/// `kind`, matching `AlertCondition`'s `#[serde(tag = "kind")]`.
// Externally tagged on `kind`, matching `AlertCondition`'s `#[serde(tag = "kind")]` on the backend.
export type AlertCondition =
| { kind: 'immediate'; query: string }
| { kind: 'threshold'; query: string; op: CompareOp; threshold: number; window_ms: number }
| { kind: 'newvalue'; field_regex: string; capture_group: string }
| { kind: 'ratio'; query_a: string; query_b: string; op: CompareOp; ratio: number; window_ms: number }
/// Where a fired alert is delivered (ticket 019). Only one sink kind exists
/// today, but this stays a tagged union to match the backend.
// Only one sink kind exists today, but this stays a tagged union to match the backend.
export type AlertSink = { kind: 'ntfy'; topic: string; server: string | null }
export interface AlertRule {
@@ -189,11 +176,7 @@ async function getJson<T>(path: string): Promise<T> {
return res.json() as Promise<T>
}
/// POSTs a JSON body to `path`. On a non-ok response, attempts to parse the
/// body as `{ "error": "..." }` (the shape every declaration endpoint uses
/// for validation failures) and throws an `ApiError` with that message so
/// callers can surface it inline; falls back to a generic message if the
/// body isn't in that shape.
// Throws `ApiError` (not `Error`) with the parsed `{ "error": "..." }` message so callers can surface it inline.
async function postJson<T>(path: string, body: unknown): Promise<T> {
const res = await fetch(path, {
method: 'POST',
@@ -357,10 +340,7 @@ export function activateProfile(name: string): Promise<Settings> {
return sendJson(`/api/settings/profiles/${encodeURIComponent(name)}/activate`, 'POST')
}
/// Evaluates a PromQL query (ticket 013) via `GET /api/query`. Throws on a
/// malformed query (`400` with `{ "error": "..." }`), so callers should catch
/// and surface the message inline (e.g. per-panel) rather than letting it
/// crash the page.
// Throws on a malformed query (400); callers should catch and surface the message inline rather than letting it crash the page.
export function fetchPromqlSeries(params: {
promql: string
startMs?: number
@@ -419,9 +399,7 @@ export function deleteAlertRule(id: string): Promise<void> {
return sendJson(`/api/settings/alerts/${encodeURIComponent(id)}`, 'DELETE')
}
/// Delivers a test notification to `topic`/`server` (ticket 020) without
/// requiring the rule to be saved first. Throws `ApiError` on failure (e.g.
/// ntfy unreachable) so callers can surface it inline.
// Delivers a test notification without requiring the rule to be saved first; throws `ApiError` on failure so callers can surface it inline.
export function sendTestAlertNotification(topic: string, server: string | null): Promise<void> {
return sendJson('/api/settings/alerts/test', 'POST', { topic, server })
}