import m, {MithrilComponent} from '@garage44/mithril' import {Card, FieldSegmented} from '@garage44/mithril/components' import {when} from '@/lib/format' import {speaker} from '@/lib/names' import {local} from '@/lib/reactive' import {sentence} from '@/lib/sentence' import type {Part} from '@/lib/sentence' import {$s, loadLog} from '@/lib/store' import type {WorkspaceEvent} from '@/lib/types' /** Fields a raw line shows in its own place, so not again in the details. */ const SHOWN = new Set(['ts', 'kind', 'actor', 'node', 'host', 'via_hub_from']) /** The kinds that are the workspace's routine noise, folded away unless asked for. */ const NOISE = new Set(['ssh_session', 'git_fetch', 'git_serve', 'barrier', 'activity', 'lfs', 'warm_step', 'mcp_call', 'forgejo_call']) /** Lines drawn at a time: a week of the log is tens of thousands. */ const PAGE = 500 function details(e: WorkspaceEvent): string { return Object.entries(e) .filter(([k, v]) => !SHOWN.has(k) && v != null && v !== '') .map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`) .join(' ') } /** A sentence, its names set apart. */ const words = (parts: Part[]) => parts.map((x) => typeof x === 'string' ? ( x ) : ( {x.name} ), ) /** One line: a sentence where there is one for its kind, else its kind, who and its fields as they are. */ function line(e: WorkspaceEvent): m.Children { const said = sentence(e) const who = [e.node, e.actor ? speaker(e.actor).title : null].filter(Boolean).join(' · ') return (
The newest {this.s.shown} are shown; {more} older ones are not.{' '}
) : null}