🌊 The original agent harness. Deploy intelligent multi-player swarms, coordinate autonomous workflows, and build conversational AI systems. Features adaptive memory, self-learning intelligence, federation, vector RAG integration, and native Claude Code / Codex / Hermes and many more Integrated
TypeScript agentic-aiagentic-frameworkagentic-workflowagentsai-agentsai-assistantai-skillsautonomous-agentsclaudecodexdsh-pluginharnessmcp-servermulti-agentmulti-agent-systemsnpmskillsswarmswarm-intelligencetypescript
feat(ruflo-console): 0.18.0 — Timeline look-back and who was busy; Events kind chips, find, pause, paging and detail
ruv20d280148bc5
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.jsonindex 99c3f3c50e..2d433c26a6 100644--- a/plugins/ruflo-console/.claude-plugin/plugin.json+++ b/plugins/ruflo-console/.claude-plugin/plugin.json@@ -1,7 +1,7 @@{"name": "ruflo-console","description": "ruflo's cockpit inside Claude Code and the one /ruflo command for every ruflo mod (function hooks, early access). Views: overview with health alerts, swarm topology graph, claims flow with TTL rings, federation map, plugin health matrix, learning curve and pipeline, MetaHarness radar and audit trend, memory, cost gauge, agent timeline, approvals queue, event stream, a main menu, an x.ruv.io federation board, an AI terminal (codex, claude or both in remembered sessions, streamed), Skills (npx skills), a Hive-Mind view, a MetaHarness lab, agent drill-down; a command palette for confirm-gated actions through the ruflo CLI; a band above the prompt. Reads ruflo's files and the CLI's local JSON; anything not measured reads n/a; no network by default.",- "version": "0.14.1",+ "version": "0.18.0","author": {"name": "ruvnet","url": "https://github.com/ruvnet"diff --git a/plugins/ruflo-console/hooks/bindings.ts b/plugins/ruflo-console/hooks/bindings.tsindex 5876abc588..f0e7901e17 100644--- a/plugins/ruflo-console/hooks/bindings.ts+++ b/plugins/ruflo-console/hooks/bindings.ts@@ -6,6 +6,7 @@ import { claimTask, handoffClaim, releaseClaim, stealClaim, whyNot } from './actimport { EVENT_KINDS } from './data/events'import { evolveActions } from './evolve'import { askActions } from './ask-claude'+import { watchActions } from './watch'import { missionActions } from './mission-control'import { catalogActions } from './plugin-catalog'import { saveAllowed } from './remember'@@ -326,6 +327,7 @@ export function actionsOf(state: State, host: Host, runner: Runner, steps: Stepssettings: settingsActions(state, host, runner, (agent, text) => actions.term.ask(agent, text), () => CLI_PREFIXES[state.options.cli], () => pluginNames(state, (catalogOf(state).plugins ?? []).filter(plugin => plugin.options.length > 0).map(plugin => plugin.name))),mission: missionActions(state, host, runner),ask: askActions(state, host, runner, () => actions),+ watch: watchActions(state, () => host.invalidate(), (question, view) => actions.ask.ask(question, view)),catalog: catalogActions(state, host, runner, text => actions.term.load('claude', text)),devtools: devtoolsActions(state, host, runner.runById, why => runner.ask(null, why)),}diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.tsindex c6ee240f96..3004460fb5 100644--- a/plugins/ruflo-console/hooks/views/common.ts+++ b/plugins/ruflo-console/hooks/views/common.ts@@ -4,6 +4,7 @@* Text colours are theme names only, so nothing fades on a light background.*/import type { AskActions } from '../ask-claude'+import type { WatchActions } from '../watch'import type { Attention } from './attention'import type { Elements, RenderChildren, RenderElement } from 'claude-code'@@ -68,6 +69,8 @@ export type Actions = {evolve: EvolveActions/** The Dev Tools view: keep a field's text, and Enter in a field runs its entry. */devtools: DevtoolsActions+ /** The Timeline and Events pages: look-back range, kind filter, search, pause, paging, an event's detail, and asking about one. */+ watch: WatchActions/** Ask Claude about this section (a visible prompt or a /btw aside) or run the plugin command that fits it: each asks first. */ask: AskActions/** Mission Control: goal, profile, create, run next, pause/resume/cancel, auto-run, ask aside, guide Claude. */diff --git a/plugins/ruflo-console/hooks/views/frames.ts b/plugins/ruflo-console/hooks/views/frames.tsindex b702054c93..c25d9ff46f 100644--- a/plugins/ruflo-console/hooks/views/frames.ts+++ b/plugins/ruflo-console/hooks/views/frames.ts@@ -23,7 +23,7 @@ import { openTasks } from './select'export const MAX_NODES = 100export const HEALTH_CHECKS = ['installed', 'enabled', 'clone', 'mod'] as const-const TIMELINE_MS = 15 * 60_000+import { watchOf } from '../watch'/** The radar's axis words: the score's own dimension names, shortened to fit at a spoke's end. */const AXIS: Record<string, string> = { harnessFit: 'fit', compileConfidence: 'compile', taskCoverage: 'coverage', toolSafety: 'safety', memoryUsefulness: 'memory' }@@ -96,7 +96,7 @@ export function healthRowsOf(state: State): HealthRow[] {/** The timeline's lanes over the last 15 minutes: ruflo agents' observed statuses and Claude Code's tool calls. */export function lanesOf(state: State, nowMs: number): Lane[] {- const from = nowMs - TIMELINE_MS+ const from = nowMs - watchOf(state).rangeMsconst labels = agentLabels(state.snapshot?.agents ?? [])const agents = (state.snapshot?.agents ?? []).slice(0, 24).map(agent => {const log = state.statusLog.get(agent.id) ?? []@@ -216,7 +216,7 @@ export function picturesOf(state: State, columns: number, nowMs: number, t: numbcase 'timeline': {const lanes = lanesOf(state, nowMs)- if (lanes.length > 0) pictures.set('gantt', ganttPicture(lanes, width, nowMs - TIMELINE_MS, nowMs))+ if (lanes.length > 0) pictures.set('gantt', ganttPicture(lanes, width, nowMs - watchOf(state).rangeMs, nowMs))break}default:diff --git a/plugins/ruflo-console/hooks/views/manage.ts b/plugins/ruflo-console/hooks/views/manage.tsindex 84639fb271..72ab1ca686 100644--- a/plugins/ruflo-console/hooks/views/manage.ts+++ b/plugins/ruflo-console/hooks/views/manage.ts@@ -5,16 +5,58 @@import type { RenderElement } from 'claude-code'import { approvalsOf } from '../data/alerts'+import { EVENT_KINDS } from '../data/events'+import type { Lane } from '../gfx/maps'+import { sparkline } from '../memory-lines'+import { idOf, eventsShown, kindCounts, PAGE, perMinute, RANGES, watchOf } from '../watch'+import { lanesOf } from './frames'import { ago, button, clip, col, picture, row, rule, text, THEME, type Ctx } from './common'+const chip = (ctx: Ctx, key: string, label: string, isOn: boolean, onPress: () => void): RenderElement =>+ ctx.kit.Button({ key, label: ` ${isOn ? '●' : '○'} ${label} `, plain: true, ...(isOn && { variant: 'primary' as const }), onPress })++/** Busy time as a share of the time this lane was observed in the window, and its tool calls. */+function statsOf(lane: Lane, fromMs: number, nowMs: number): { observedMs: number; busyMs: number; calls: number } {+ const spans = lane.spans.filter(span => span.toMs > fromMs)+ const first = spans.length === 0 ? nowMs : Math.max(fromMs, Math.min(...spans.map(span => span.fromMs)))++ return { observedMs: Math.max(0, nowMs - first), busyMs: spans.filter(span => span.busy).reduce((sum, span) => sum + Math.max(0, span.toMs - Math.max(span.fromMs, fromMs)), 0), calls: lane.ticks.filter(at => at >= fromMs).length }+}+export function timelineView(ctx: Ctx): RenderElement {- const agents = ctx.state.snapshot?.agents.length ?? 0- const rows: RenderElement[] = [rule(ctx, 'Timeline', 'last 15 minutes · observed since the console loaded')]+ const { state, nowMs } = ctx+ const watch = watchOf(state)+ const agents = state.snapshot?.agents.length ?? 0+ const lanes = lanesOf(state, nowMs)+ const rows: RenderElement[] = [rule(ctx, 'Timeline', `last ${RANGES.find(range => range.ms === watch.rangeMs)?.label ?? '15 min'} · observed since the console loaded`)]- rows.push(picture(ctx, 'gantt', agents === 0 && ctx.state.toolsByAgent.size === 0 ? 'no agents and no tool calls seen yet' : `${agents} agents`))+ rows.push(row(ctx, [text(ctx, ' look back '), ...RANGES.map(range => chip(ctx, `tl-range-${range.ms / 60_000}`, range.label, watch.rangeMs === range.ms, () => ctx.act.watch.range(range.ms)))], 'tl-ranges'))+ rows.push(picture(ctx, 'gantt', agents === 0 && state.toolsByAgent.size === 0 ? 'no agents and no tool calls seen yet' : `${agents} agents`))rows.push(text(ctx, '█ busy · ▁ idle (ruflo agent status, as each read saw it) · ▮ a tool call Claude Code made (main session and subagents)', { dimColor: true }))rows.push(text(ctx, "ruflo agents' own tool calls are not visible to Claude Code: their rows show status only", { dimColor: true }))+ if (lanes.length > 0) {+ rows.push(rule(ctx, 'Who was busy', 'a share of the time each lane was observed in this window'))++ for (const [i, lane] of lanes.slice(0, 12).entries()) {+ const stats = statsOf(lane, nowMs - watch.rangeMs, nowMs)+ const share = stats.observedMs === 0 ? null : Math.round((stats.busyMs / stats.observedMs) * 100)++ rows.push(+ row(+ ctx,+ [+ ctx.kit.Text({ bold: true, color: THEME.head, children: ` ${clip(lane.label, 20).padEnd(20)}` }),+ ctx.kit.Text({ color: share === null ? THEME.info : share >= 60 ? THEME.ok : share >= 20 ? THEME.warn : THEME.info, children: ` ${share === null ? 'no status seen' : `busy ${share}%`}${stats.observedMs > 0 ? ` of ${Math.max(1, Math.round(stats.observedMs / 60_000))} min` : ''}` }),+ ctx.kit.Text({ dimColor: true, children: ` · ${stats.calls} tool call${stats.calls === 1 ? '' : 's'} ` }),+ ctx.kit.Button({ key: `tl-ask-${i}`, label: ' ✦ ask Claude ', plain: true, dimColor: true, onPress: () => ctx.act.watch.ask(`In my ruflo swarm, the agent "${lane.label}" was busy ${share ?? 'n/a'}% of ${Math.round(stats.observedMs / 60_000)} minutes with ${stats.calls} tool calls. Is that healthy, and what should I look at?`) }),+ ],+ `tl-lane-${i}`,+ ),+ )+ }+ }+return col(ctx, rows, 'timeline')}@@ -49,17 +91,66 @@ const KIND_COLOR: Record<string, string> = { swarm: THEME.info, claims: THEME.waexport function eventsView(ctx: Ctx): RenderElement {const { state, nowMs } = ctx+ const watch = watchOf(state)const filter = state.eventFilter- const shown = state.events.filter(event => filter === 'all' || event.kind === filter)- const rows: RenderElement[] = [rule(ctx, 'Events', `${shown.length} · filter ${filter} (f)`)]-- if (shown.length === 0) rows.push(text(ctx, state.events.length === 0 ? 'Nothing has changed since the console loaded. Events are what changed between reads, and what this session did.' : `no ${filter} events`, { dimColor: true }))+ const shown = eventsShown(state)+ const counts = kindCounts(state)+ const pages = Math.max(1, Math.ceil(shown.length / PAGE))+ const page = Math.min(watch.page, pages - 1)+ const newest = shown.slice().reverse()+ const visible = newest.slice(page * PAGE, page * PAGE + PAGE)+ const fresh = watch.pausedAt === null ? 0 : state.events.length - watch.pausedAt+ const rows: RenderElement[] = [rule(ctx, 'Events', `${shown.length} shown · ${filter === 'all' ? 'every kind' : filter}${watch.query === '' ? '' : ` · "${watch.query}"`}${watch.pausedAt === null ? ' · live' : ` · paused (${fresh} new)`}`)]++ rows.push(+ row(ctx, [text(ctx, ' kind '), chip(ctx, 'ev-kind-all', `all ${state.events.length}`, filter === 'all', () => ctx.act.watch.kind('all')), ...EVENT_KINDS.filter(kind => (counts.get(kind) ?? 0) > 0 || filter === kind).map(kind => chip(ctx, `ev-kind-${kind}`, `${kind} ${counts.get(kind) ?? 0}`, filter === kind, () => ctx.act.watch.kind(kind)))], 'ev-kinds'),+ )++ const Input = ctx.kit.Input++ rows.push(+ row(+ ctx,+ [+ ...(Input === undefined ? [] : [ctx.kit.Box({ key: 'ev-query-box', borderStyle: 'round', borderColor: THEME.info, paddingX: 1, children: [Input({ key: 'ev-query', label: '🔎 find', placeholder: 'words in an event, or a kind (Enter)', submitLabel: 'find', onSubmit: (value: string) => ctx.act.watch.query(value) })] })]),+ ctx.kit.Button({ key: 'ev-pause', label: watch.pausedAt === null ? ' ⏸ pause ' : ' ▶ resume ', ...(watch.pausedAt === null ? { plain: true as const } : { variant: 'primary' as const }), onPress: () => ctx.act.watch.pause() }),+ ...(watch.query === '' ? [] : [ctx.kit.Button({ key: 'ev-clear', label: ' ✕ clear find ', plain: true, dimColor: true, onPress: () => ctx.act.watch.query('') })]),+ ],+ 'ev-tools',+ ),+ )+ rows.push(text(ctx, ` last 15 min, per minute ${sparkline(perMinute(shown, nowMs))} now`, { color: THEME.info }))++ if (shown.length === 0) rows.push(text(ctx, state.events.length === 0 ? 'Nothing has changed since the console loaded. Events are what changed between reads, and what this session did.' : 'no event matches this filter and search', { dimColor: true }))++ for (const event of visible) {+ const id = idOf(event)+ const isOpen = watch.open === id++ rows.push(+ row(+ ctx,+ [+ ctx.kit.Text({ dimColor: true, children: `${ago(event.atMs, nowMs).padStart(8)} ` }),+ ctx.kit.Text({ color: KIND_COLOR[event.kind] ?? THEME.info, children: `${event.kind.padEnd(10)} ` }),+ ctx.kit.Button({ key: `ev-open-${id}`, label: `${isOpen ? '▾' : '▸'} ${clip(event.text, Math.max(16, ctx.columns - 26))}`, plain: true, onPress: () => ctx.act.watch.open(id) }),+ ],+ `ev-${id}`,+ ),+ )++ if (isOpen) {+ rows.push(text(ctx, ` ${event.text}`, { bold: true }))+ rows.push(text(ctx, ` ${event.kind} · ${new Date(event.atMs).toISOString()}${event.agentId === undefined ? '' : ` · agent ${event.agentId}`}`, { dimColor: true }))+ rows.push(row(ctx, [ctx.kit.Button({ key: 'ev-ask', label: ' ✦ ask Claude about this event ', plain: true, onPress: () => ctx.act.watch.ask(`This event appeared in my ruflo console: "${event.text}" (kind ${event.kind}). What does it mean, and should I do anything?`) })], 'ev-detail'))+ }+ }- for (const event of shown.slice(-18).reverse()) {- rows.push(row(ctx, [ctx.kit.Text({ dimColor: true, children: `${ago(event.atMs, nowMs).padStart(8)} ` }), ctx.kit.Text({ color: KIND_COLOR[event.kind] ?? THEME.info, children: `${event.kind.padEnd(10)} ` }), ctx.kit.Text({ wrap: 'truncate-end', children: clip(event.text, Math.max(10, ctx.columns - 21)) })]))+ if (pages > 1) {+ rows.push(row(ctx, [text(ctx, ` page ${page + 1}/${pages} `, { dimColor: true }), ...(page < pages - 1 ? [button(ctx, 'ev-older', 'older ▸', () => ctx.act.watch.page(1))] : []), ...(page > 0 ? [button(ctx, 'ev-newer', '◂ newer', () => ctx.act.watch.page(-1))] : [])], 'ev-pages'))}- if (ctx.columns >= 44) rows.push(row(ctx, [button(ctx, 'filter', `Filter: ${filter}`, ctx.act.filter, { hotkey: 'f' })]))+ if (ctx.columns >= 44) rows.push(row(ctx, [button(ctx, 'filter', `Filter: ${filter} (cycle)`, ctx.act.filter, { hotkey: 'f' })]))return col(ctx, rows, 'events')}diff --git a/plugins/ruflo-console/hooks/watch.ts b/plugins/ruflo-console/hooks/watch.tsnew file mode 100644index 0000000000..e8075627cf--- /dev/null+++ b/plugins/ruflo-console/hooks/watch.ts@@ -0,0 +1,125 @@+/**+ * The Timeline and Events pages' own state and actions: how far back the timeline looks (5, 15 or 60 minutes), and for the event+ * stream a kind filter with counts, a text search, pause (the tail stops moving so a line can be read), paging back through what was+ * kept, and one event opened for its detail. Pure state over what the console already observed; nothing here reads or writes ruflo.+ */+import { plain } from './data/parse'+import type { ConsoleEvent } from './data/events'+import type { State } from './state'++export const RANGES: readonly { ms: number; label: string }[] = [+ { ms: 5 * 60_000, label: '5 min' },+ { ms: 15 * 60_000, label: '15 min' },+ { ms: 60 * 60_000, label: '60 min' },+]+export const PAGE = 12++export type WatchState = {+ rangeMs: number+ query: string+ /** The number of events when the tail was paused, or null while it runs. */+ pausedAt: number | null+ /** The event opened for detail: `<atMs>:<text length>`. */+ open: string | null+ /** Pages back from the newest. */+ page: number+}++const states = new WeakMap<State, WatchState>()++export function watchOf(state: State): WatchState {+ let found = states.get(state)++ if (found === undefined) {+ found = { rangeMs: 15 * 60_000, query: '', pausedAt: null, open: null, page: 0 }+ states.set(state, found)+ }++ return found+}++export const idOf = (event: ConsoleEvent): string => `${event.atMs}:${event.text.length}`++/** The events this page shows: the kind filter, the text search, and nothing newer than the pause point; oldest first. */+export function eventsShown(state: State): ConsoleEvent[] {+ const watch = watchOf(state)+ const query = watch.query.trim().toLowerCase()+ const base = watch.pausedAt === null ? state.events : state.events.slice(0, watch.pausedAt)++ return base.filter(event => (state.eventFilter === 'all' || event.kind === state.eventFilter) && (query === '' || event.text.toLowerCase().includes(query) || event.kind.includes(query)))+}++/** How many events of each kind (of what the pause point lets through), for the chips. */+export function kindCounts(state: State): Map<string, number> {+ const watch = watchOf(state)+ const base = watch.pausedAt === null ? state.events : state.events.slice(0, watch.pausedAt)+ const counts = new Map<string, number>()++ for (const event of base) counts.set(event.kind, (counts.get(event.kind) ?? 0) + 1)++ return counts+}++/** Events per minute over the last `minutes`, oldest first, for a sparkline. */+export function perMinute(events: readonly ConsoleEvent[], nowMs: number, minutes = 15): number[] {+ const bins = new Array<number>(minutes).fill(0)++ for (const event of events) {+ const back = Math.floor((nowMs - event.atMs) / 60_000)++ if (back >= 0 && back < minutes) bins[minutes - 1 - back] = (bins[minutes - 1 - back] ?? 0) + 1+ }++ return bins+}++export type WatchActions = {+ range: (ms: number) => void+ kind: (kind: State['eventFilter']) => void+ query: (text: string) => void+ /** Stops the tail where it is, or lets it run again. */+ pause: () => void+ /** Opens an event for detail, or closes it. */+ open: (id: string) => void+ /** Pages back (positive) or forward through the shown events. */+ page: (by: number) => void+ /** Asks the main Claude about one event or one agent (it asks first). */+ ask: (question: string) => void+}++export function watchActions(state: State, invalidate: () => void, ask: (question: string, view: 'events' | 'timeline') => void): WatchActions {+ const watch = watchOf(state)++ return {+ range: ms => {+ if (RANGES.some(range => range.ms === ms)) watch.rangeMs = ms+ invalidate()+ },+ kind: kind => {+ state.eventFilter = kind+ watch.page = 0+ invalidate()+ },+ query: text => {+ watch.query = plain(text, 80)+ watch.page = 0+ invalidate()+ },+ pause: () => {+ watch.pausedAt = watch.pausedAt === null ? state.events.length : null+ watch.page = 0+ invalidate()+ },+ open: id => {+ watch.open = watch.open === id ? null : id+ invalidate()+ },+ page: by => {+ const last = Math.max(0, Math.ceil(eventsShown(state).length / PAGE) - 1)++ watch.page = Math.max(0, Math.min(last, watch.page + by))+ invalidate()+ },+ ask: question => ask(plain(question, 600), state.view === 'timeline' ? 'timeline' : 'events'),+ }+}diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.shindex 59af72f5bf..24f2ac2417 100755--- a/plugins/ruflo-console/scripts/smoke.sh+++ b/plugins/ruflo-console/scripts/smoke.sh@@ -11,9 +11,9 @@ step() { printf "→ %s ... " "$1"; }ok() { printf "PASS\n"; PASS=$((PASS+1)); }bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }-step "1. plugin.json declares ruflo-console 0.14.1"+step "1. plugin.json declares ruflo-console 0.18.0"grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \- && grep -q '"version": "0.14.1"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"+ && grep -q '"version": "0.18.0"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"step "2. hooks.json names exactly one module and no classic hook commands"grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \diff --git a/plugins/ruflo-console/tests/sweep.test.ts b/plugins/ruflo-console/tests/sweep.test.tsindex fc37848d4c..bd95fd3590 100644--- a/plugins/ruflo-console/tests/sweep.test.ts+++ b/plugins/ruflo-console/tests/sweep.test.ts@@ -7,7 +7,7 @@ import { cliAnswer, command, elementsOf, keyOf, paneAt, PLUGIN, SESSION, textOf,const VIEWS = ['overview', 'swarm', 'hive', 'claims', 'federation', 'plugins', 'learning', 'metaharness', 'memory', 'cost', 'timeline', 'approvals', 'events', 'missions', 'xruv', 'skills', 'secure', 'perf', 'automate', 'neural', 'vector', 'evolve', 'devtools', 'market', 'settings']/** Buttons that only move the cursor inside a list that has nothing to move over in the fixture world. */-const SCROLL = /^(prev|next|up|down|older|newer|page|older-|newer-|refresh|close|task-next|approve-1|net-|sk-scope-project|evolve-reread|xr-(name|about)-|cat-load|cat-reload|st-name-|st-reload|st-level-|nav-style-|mc-tab-|mc-profile-|mc-rigor-|sec-)/i+const SCROLL = /^(prev|next|up|down|older|newer|page|older-|newer-|refresh|close|task-next|approve-1|net-|ev-kind-all|tl-range-|sk-scope-project|evolve-reread|xr-(name|about)-|cat-load|cat-reload|st-name-|st-reload|st-level-|nav-style-|mc-tab-|mc-profile-|mc-rigor-|sec-)/idescribe('every button does something', () => {for (const view of VIEWS) {diff --git a/plugins/ruflo-console/tests/watch.spec.ts b/plugins/ruflo-console/tests/watch.spec.tsnew file mode 100644index 0000000000..4da4959c93--- /dev/null+++ b/plugins/ruflo-console/tests/watch.spec.ts@@ -0,0 +1,92 @@+/**+ * The Timeline and Events state under vitest: the kind filter and the search, pausing the tail, counts per kind, events per minute,+ * paging, opening one event, and that asking about an event goes to the right page.+ */+import { describe, expect, it } from 'vitest'++import type { ConsoleEvent } from '../hooks/data/events'+import { newState, type State } from '../hooks/state'+import { eventsShown, idOf, kindCounts, PAGE, perMinute, RANGES, watchActions, watchOf } from '../hooks/watch'++const NOW = Date.UTC(2026, 9, 3, 12)+const ev = (kind: ConsoleEvent['kind'], text: string, agoMs = 0): ConsoleEvent => ({ kind, text, atMs: NOW - agoMs })++function stateWith(events: ConsoleEvent[]): State {+ const state = newState({})++ state.events = events++ return state+}++describe('watch: events and timeline', () => {+ it('the kind filter and the text search narrow the list; a search also matches the kind', () => {+ const state = stateWith([ev('swarm', 'agent coder joined'), ev('claims', 'claim ISSUE-1 taken'), ev('swarm', 'topology mesh')])++ expect(eventsShown(state)).toHaveLength(3)+ state.eventFilter = 'swarm'+ expect(eventsShown(state).map(event => event.text)).toEqual(['agent coder joined', 'topology mesh'])+ watchOf(state).query = 'MESH'+ expect(eventsShown(state).map(event => event.text)).toEqual(['topology mesh'])+ state.eventFilter = 'all'+ watchOf(state).query = 'claims'+ expect(eventsShown(state).map(event => event.text)).toEqual(['claim ISSUE-1 taken'])+ })++ it('pausing keeps the tail where it was: later events are not shown, the counts hold, and resuming shows them', () => {+ const state = stateWith([ev('swarm', 'a'), ev('swarm', 'b')])+ const actions = watchActions(state, () => undefined, () => undefined)++ actions.pause()+ state.events = [...state.events, ev('claims', 'c')]+ expect(eventsShown(state).map(event => event.text)).toEqual(['a', 'b'])+ expect(kindCounts(state).get('claims')).toBeUndefined()+ actions.pause()+ expect(eventsShown(state).map(event => event.text)).toEqual(['a', 'b', 'c'])+ })++ it('counts per kind, and events per minute over the last 15, oldest first', () => {+ const state = stateWith([ev('swarm', 'x'), ev('swarm', 'y'), ev('tools', 'z')])++ expect([...kindCounts(state)]).toEqual([['swarm', 2], ['tools', 1]])+ expect(perMinute([ev('swarm', 'now', 5_000), ev('swarm', 'now2', 10_000), ev('swarm', 'old', 14 * 60_000 + 1_000), ev('swarm', 'gone', 20 * 60_000)], NOW)).toEqual([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2])+ })++ it('paging stays inside the shown events; a new filter or search goes back to the newest page; opening toggles', () => {+ const state = stateWith(Array.from({ length: PAGE * 2 + 3 }, (_, i) => ev('swarm', `event ${i}`, i * 1000)))+ const actions = watchActions(state, () => undefined, () => undefined)++ actions.page(1)+ actions.page(1)+ actions.page(1)+ expect(watchOf(state).page).toBe(2)+ actions.page(-5)+ expect(watchOf(state).page).toBe(0)+ actions.page(1)+ actions.kind('swarm')+ expect(watchOf(state).page).toBe(0)++ const id = idOf(state.events[0] as ConsoleEvent)++ actions.open(id)+ expect(watchOf(state).open).toBe(id)+ actions.open(id)+ expect(watchOf(state).open).toBeNull()+ })++ it('the look-back range takes only the three offered values; asking goes to the page it was asked on', () => {+ const state = stateWith([])+ const asked: { question: string; view: string }[] = []+ const actions = watchActions(state, () => undefined, (question, view) => void asked.push({ question, view }))++ actions.range(7 * 60_000)+ expect(watchOf(state).rangeMs).toBe(15 * 60_000)+ actions.range(RANGES[0]?.ms ?? 0)+ expect(watchOf(state).rangeMs).toBe(5 * 60_000)+ state.view = 'timeline'+ actions.ask('is this healthy?')+ state.view = 'events'+ actions.ask('what is this event?')+ expect(asked.map(entry => entry.view)).toEqual(['timeline', 'events'])+ })+})diff --git a/plugins/ruflo-console/tests/watch.test.ts b/plugins/ruflo-console/tests/watch.test.tsnew file mode 100644index 0000000000..3c221d8906--- /dev/null+++ b/plugins/ruflo-console/tests/watch.test.ts@@ -0,0 +1,64 @@+/**+ * The Timeline and Events pages in the pane: the look-back chips redraw the title, and the event page's kind chips, search field,+ * pause button and empty-state wording are there and answer.+ */+import type { TestBody } from 'claude-code/testing'+import { describe, expect, mock, test } from 'claude-code/testing'++import { RUFLO_FILES } from './fixtures/ruflo-run'+import { command, elementsOf, keyOf, paneAt, PLUGIN, SESSION, textOf, worldOf } from './fixtures/world'++type Body = Parameters<TestBody>++const keys = (tree: Parameters<typeof elementsOf>[0]) => elementsOf(tree, 'Button').map(keyOf)++async function opened($: Body[0], on: Body[1], view: string) {+ worldOf(on, RUFLO_FILES)+ mock.clock(on)+ await $.session.start(SESSION)+ await $.command.run(command(view))++ const pane = await $.ui.mount({ ...paneAt(150), surface: 'terminal' as const, plugin: PLUGIN })++ await pane.drawn()++ return pane+}++describe('timeline and events pages', () => {+ test('timeline: the look-back chips change the window named in the title', { options: { boot: false } }, async ($, on) => {+ const pane = await opened($, on, 'timeline')+ const first = await pane.drawn()++ expect(keys(first)).toEqual(expect.arrayContaining(['tl-range-5', 'tl-range-15', 'tl-range-60']))+ expect(textOf(first)).toContain('last 15 min')+ await pane.press({ key: 'tl-range-60' })+ expect(textOf(await pane.drawn())).toContain('last 60 min')+ await pane.press({ key: 'tl-range-5' })+ expect(textOf(await pane.drawn())).toContain('last 5 min')+ await pane.unmount()+ })++ test('events: kind chips, a search field and a pause button; searching for nothing says no event matches; pause then resume flips the button', { options: { boot: false } }, async ($, on) => {+ const pane = await opened($, on, 'events')+ const first = await pane.drawn()++ expect(keys(first)).toEqual(expect.arrayContaining(['ev-kind-all', 'ev-pause']))+ expect(elementsOf(first, 'Input').map(keyOf)).toContain('ev-query')+ expect(textOf(first)).toContain('live')+ await pane.press({ key: 'ev-pause' })+ expect(textOf(await pane.drawn())).toContain('paused')+ expect(keys(await pane.drawn())).toContain('ev-pause')+ await pane.press({ key: 'ev-pause' })+ expect(textOf(await pane.drawn())).toContain('live')+ await pane.input({ key: 'ev-query', text: 'zzz-not-an-event', kind: 'submit' })++ const none = await pane.drawn()++ expect(textOf(none)).toMatch(/no event matches|Nothing has changed/)+ expect(keys(none)).toContain('ev-clear')+ await pane.press({ key: 'ev-clear' })+ expect(keys(await pane.drawn())).not.toContain('ev-clear')+ await pane.unmount()+ })+})diff --git a/scripts/ci-test-baseline.txt b/scripts/ci-test-baseline.txtindex 72c6395d9b..ece25ec4ac 100644--- a/scripts/ci-test-baseline.txt+++ b/scripts/ci-test-baseline.txt@@ -166,6 +166,7 @@ plugins/ruflo-console/tests/views.test.tsplugins/ruflo-console/tests/labs.test.tsplugins/ruflo-console/tests/attention.test.tsplugins/ruflo-console/tests/matrix.test.ts+plugins/ruflo-console/tests/watch.test.tsplugins/ruflo-console/tests/missions.test.tsplugins/ruflo-console/tests/settings.test.tsplugins/ruflo-console/tests/plugin-catalog.test.tsdiff --git a/v3/docs/adr/ADR-416-console-timeline-and-events.md b/v3/docs/adr/ADR-416-console-timeline-and-events.mdnew file mode 100644index 0000000000..3e2014cd9d--- /dev/null+++ b/v3/docs/adr/ADR-416-console-timeline-and-events.md@@ -0,0 +1,52 @@+# ADR 416: The Timeline and Events pages++Status: Accepted (ships in ruflo-console 0.18.0)++Date: 2026 10 03++Decision owner: Ruflo maintainers++Scope: `plugins/ruflo-console`: `hooks/watch.ts`, `hooks/views/manage.ts` (the Timeline and Events views), `hooks/views/frames.ts` (the Gantt window).++Extends: ADR 407. Companion to ADR 412 (answers open where asked) and ADR 411 (Ask Claude).++## 1. Context++Both pages were thin. The Timeline drew one Gantt picture of the last 15 minutes with a legend; there was no way to look further back or to read who was actually busy. The Events page listed the last 18 events, filtered only by a button that cycled through the kinds, and the newest line moved under the cursor as events arrived. rUv asked for a better timeline and the same for events.++## 2. Decision++### 2.1 Timeline+- **Look back 5, 15 or 60 minutes** (chips; default 15). The Gantt picture and the lane spans use the chosen window.+- **Who was busy:** under the picture, one row per lane (Claude's main session and subagents, then each ruflo agent): busy time as a share of the time that lane was observed in the window, the observed minutes, and the tool calls seen. A lane with no status seen says so rather than showing 0%. Each row has **✦ ask Claude** (a worded question about that lane's numbers, sent to the main UI; it asks first).+- Only what the console observed since it loaded is counted; before that a lane is blank, as before.++### 2.2 Events+- **Kind chips with counts** (all, and each kind that has events), replacing the cycle button (kept as `f`).+- **Find:** a text field matching the event text or its kind, with a clear button.+- **Pause / resume:** pausing stops the tail where it is (events arriving later are counted as "N new" in the title and not shown), so a line can be read; resuming shows them.+- **Per-minute sparkline** of the last 15 minutes of the shown events.+- **Paging** back through the 300 kept events, 12 at a time (older / newer); a new filter or search returns to the newest page.+- **One event opens for detail** (click a line): its full text, kind, ISO time and agent, and **✦ ask Claude about this event**.++### 2.3 State and actions+All of it is `WatchState` in `watch.ts` (range, query, pause point, open event, page), pure over `state.events` and `state.statusLog`, with `WatchActions` bound in `bindings.ts`. Nothing reads or writes ruflo.++## 3. Alternatives considered++- **Stream events with a live scroll.** Rejected: a moving list cannot be read or clicked; pause plus paging is the terminal-friendly answer.+- **Store more history.** Rejected here: the cap (300 events) is a memory bound; the pause and page controls make it usable.+- **A separate per-agent page.** Rejected: the drill-down page exists (the agent view); the lane rows summarise and ask.++## 4. Consequences++- Both pages are usable for longer sessions; asking about a lane or an event is one click and one confirm.+- The window change redraws the picture on the next frame; spans older than the window are clipped, not recomputed.++## 5. Safety++Read-only over what was observed; the only outward action is Ask Claude, which asks first, quotes data and screens nothing typed (the search text stays local).++## 6. Tests++`tests/watch.spec.ts` (filter and search, pause, counts and per-minute, paging, open toggle, range values, which page an ask goes to), `tests/watch.test.ts` (the look-back chips redraw the title; the Events chips, find field, pause and clear), and the dead-button sweep covers every button on both pages.