diff --git a/plugins/ruflo-console/hooks/data/parse.ts b/plugins/ruflo-console/hooks/data/parse.ts index 0b0da93fb3..2ea306844a 100644 --- a/plugins/ruflo-console/hooks/data/parse.ts +++ b/plugins/ruflo-console/hooks/data/parse.ts @@ -305,3 +305,20 @@ export function parseHive(text: string | null): HiveInfo | null { return info } + +/** The tail of an id a person can tell apart at a glance: `agent-1790954653916-od014i` → `od014i`. */ +export function shortId(id: string): string { + const tail = id.split(/[-_:]/).pop() ?? id + + return tail.length >= 4 ? tail.slice(-6) : id.slice(-6) +} + +/** One readable label per agent: its name, else its type, with a short id only where two would read the same. */ +export function agentLabels(agents: readonly { id: string; name?: string; type: string }[]): Map { + const base = (agent: { name?: string; type: string }) => agent.name ?? agent.type + const counts = new Map() + + for (const agent of agents) counts.set(base(agent), (counts.get(base(agent)) ?? 0) + 1) + + return new Map(agents.map(agent => [agent.id, (counts.get(base(agent)) ?? 0) > 1 ? `${base(agent)}·${shortId(agent.id).slice(-4)}` : base(agent)])) +} diff --git a/plugins/ruflo-console/hooks/gfx/flow.ts b/plugins/ruflo-console/hooks/gfx/flow.ts index 8c276563fc..289a2f6478 100644 --- a/plugins/ruflo-console/hooks/gfx/flow.ts +++ b/plugins/ruflo-console/hooks/gfx/flow.ts @@ -4,7 +4,7 @@ * for an instant on the real clock. The ring is data: time left to `expiresAt` where ruflo set one, else the claim's * age on a 24 h scale; an expired claim's ring blinks. */ -import type { AgentRecord, ClaimRecord, TaskRecord } from '../data/parse' +import { shortId, type AgentRecord, type ClaimRecord, type TaskRecord } from '../data/parse' import { COLOR, Grid, mix } from './raster' export const LANES = ['open', 'claimed', 'working', 'done', 'stealable'] as const @@ -12,7 +12,7 @@ export type LaneId = (typeof LANES)[number] export const LANE_TITLES: Record = { open: 'open tasks', claimed: 'claimed', working: 'working', done: 'done', stealable: 'stealable' } -export type FlowCard = { id: string; owner: string; lane: LaneId; claimedAtMs?: number; expiresAtMs?: number; handoffTo?: string; progress?: number } +export type FlowCard = { id: string; /** What the work is, where the task store says. */ title?: string; owner: string; lane: LaneId; claimedAtMs?: number; expiresAtMs?: number; handoffTo?: string; progress?: number } const DAY = 86_400_000 const RINGS = ['○', '◔', '◑', '◕', '●'] as const @@ -27,13 +27,15 @@ export function laneOf(claim: ClaimRecord): LaneId { } /** Cards for the lanes; a handoff names its target by the agent's name where the store has one. */ -export function flowModelOf(claims: readonly ClaimRecord[], openTasks: readonly TaskRecord[], agents: readonly AgentRecord[] = []): FlowCard[] { +export function flowModelOf(claims: readonly ClaimRecord[], openTasks: readonly TaskRecord[], agents: readonly AgentRecord[] = [], tasks: readonly TaskRecord[] = openTasks): FlowCard[] { const nameOf = (id: string) => agents.find(agent => agent.id === id)?.name ?? agents.find(agent => agent.id === id)?.type ?? id + const titleOf = (id: string) => tasks.find(task => task.id === id)?.description || undefined return [ - ...openTasks.slice(0, 40).map(task => ({ id: task.id, owner: task.description || task.type, lane: 'open' as const })), + ...openTasks.slice(0, 40).map(task => ({ id: task.id, ...(task.description ? { title: task.description } : {}), owner: task.type, lane: 'open' as const })), ...claims.slice(0, 200).map(claim => ({ id: claim.issueId, + ...(titleOf(claim.issueId) !== undefined && { title: titleOf(claim.issueId) as string }), owner: claim.claimant.agentType ?? claim.claimant.name ?? claim.claimant.id, lane: laneOf(claim), ...(claim.claimedAtMs !== undefined && { claimedAtMs: claim.claimedAtMs }), @@ -67,14 +69,35 @@ export function flowRows(cards: readonly FlowCard[], maxCards = 6): number { return 1 + 2 * Math.min(maxCards, fullest) + 1 } +/** Text cut to a width with an ellipsis, so a clipped title reads as clipped. */ +function fit(text: string, width: number): string { + return text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}…` +} + +/** + * Column widths for the five lanes: an empty lane keeps just enough for its title; the rest of the width goes to + * the lanes that hold cards, so titles are not cut short while four lanes stand empty. + */ +export function laneWidths(cards: readonly FlowCard[], columns: number): number[] { + const counts = LANES.map(lane => cards.filter(card => card.lane === lane).length) + const narrow = LANES.map(lane => LANE_TITLES[lane].length + 5) + const busy = counts.filter(count => count > 0).length + const spare = columns - narrow.reduce((sum, w, i) => sum + ((counts[i] as number) > 0 ? 0 : w), 0) + + if (busy === 0 || spare < busy * 14) return LANES.map(() => Math.max(6, Math.floor(columns / LANES.length))) + + return counts.map((count, i) => (count > 0 ? Math.floor(spare / busy) : (narrow[i] as number))) +} + export function flowPicture(cards: readonly FlowCard[], columns: number, rows: number, nowMs: number): Grid { const grid = new Grid(columns, rows) - const width = Math.max(6, Math.floor(columns / LANES.length)) + const widths = laneWidths(cards, columns) const maxCards = Math.max(0, Math.floor((rows - 2) / 2)) const blink = Math.floor(nowMs / 500) % 2 === 0 LANES.forEach((lane, li) => { - const x0 = li * width + const x0 = widths.slice(0, li).reduce((sum, w) => sum + w, 0) + const width = widths[li] as number const inLane = cards.filter(card => card.lane === lane) const title = `${LANE_TITLES[lane]} ${inLane.length}` @@ -88,7 +111,7 @@ export function flowPicture(cards: readonly FlowCard[], columns: number, rows: n const inner = width - 3 grid.set(x0, y, ring.isExpired && blink ? ' ' : ring.glyph, ring.color) - grid.text(x0 + 2, y, card.id.slice(0, inner), lane === 'stealable' ? COLOR.warn : 0xd0d0d0) + grid.text(x0 + 2, y, fit(card.title ?? card.id, inner), lane === 'stealable' ? COLOR.warn : 0xd0d0d0) if (card.handoffTo !== undefined) { const target = `→ ${card.handoffTo}` @@ -96,7 +119,9 @@ export function flowPicture(cards: readonly FlowCard[], columns: number, rows: n grid.text(x0 + 1, y + 1, '╰─▶', COLOR.warn) grid.text(x0 + 4, y + 1, target.slice(2, 2 + inner - 3), COLOR.warn) } else { - grid.text(x0 + 2, y + 1, `${card.owner}${card.progress !== undefined && card.progress > 0 ? ` ${card.progress}%` : ''}`.slice(0, inner), COLOR.dim) + const owner = `${card.owner}${card.progress !== undefined && card.progress > 0 ? ` ${card.progress}%` : ''}` + + grid.text(x0 + 2, y + 1, fit(card.title !== undefined ? `${owner} · #${shortId(card.id)}` : owner, inner), COLOR.dim) } }) diff --git a/plugins/ruflo-console/hooks/gfx/pictures.ts b/plugins/ruflo-console/hooks/gfx/pictures.ts index 060e67b4a7..21f3737218 100644 --- a/plugins/ruflo-console/hooks/gfx/pictures.ts +++ b/plugins/ruflo-console/hooks/gfx/pictures.ts @@ -10,6 +10,8 @@ export type TopoNode = { id: string; label: string; status: string; isLeader: bo export type TopoModel = { topology: string; nodes: TopoNode[] } export const PULSE_MS = 1_400 +/** How long a work-in-flight dot takes from the leader to a busy agent. */ +export const FLIGHT_MS = 1400 const isBusy = (status: string) => /busy|active|running|working/i.test(status) const isDown = (status: string) => /stop|terminat|offline|dead|error|fail/i.test(status) @@ -101,6 +103,20 @@ export function topologyPicture(model: TopoModel, columns: number, rows: number, if (p !== undefined && q !== undefined) canvas.line(p.x, p.y, q.x, q.y, COLOR.line) } + // Work in flight: while ruflo has an agent busy, a dim amber dot keeps travelling down its edge from the leader. + // It runs only for as long as the status says busy, so it is data, not decoration; each agent has its own phase. + model.nodes.forEach((node, i) => { + const q = points[i] + + if (i === 0 || leader === undefined || q === undefined || !isBusy(node.status)) return + + const k = (((t / FLIGHT_MS + i * 0.37) % 1) + 1) % 1 + const x = leader.x + (q.x - leader.x) * k + const y = leader.y + (q.y - leader.y) * k + + canvas.dot(x, y, mix(COLOR.warn, COLOR.line, 0.35)) + }) + model.nodes.forEach((node, i) => { const q = points[i] const k = node.pulseAtMs === undefined ? -1 : (t - node.pulseAtMs) / PULSE_MS @@ -128,9 +144,11 @@ export function topologyPicture(model: TopoModel, columns: number, rows: number, const cy = Math.floor(point.y / 4) const heartbeat = node.isLeader ? Math.max(0, Math.sin(t / 260)) ** 6 : 0 const flash = node.pulseAtMs !== undefined && t - node.pulseAtMs >= 0 && t - node.pulseAtMs < PULSE_MS + 600 - const color = flash ? 0xffffff : node.isLeader ? mix(COLOR.accent, 0xffffff, heartbeat) : nodeColor(node) + // A busy agent breathes (brighter and back, about once every 2 s) so it reads as working, not just coloured. + const breath = !node.isLeader && isBusy(node.status) ? 0.45 * Math.sin(t / 330 + i) ** 2 : 0 + const color = flash ? 0xffffff : node.isLeader ? mix(COLOR.accent, 0xffffff, heartbeat) : mix(nodeColor(node), 0xffffff, breath) - grid.set(cx, cy, node.isLeader ? '★' : '●', color) + grid.set(cx, cy, node.isLeader ? '★' : isBusy(node.status) ? '◉' : '●', color) if (room >= 5 || node.isLeader) { const label = node.label.slice(0, Math.max(3, room - 1)) diff --git a/plugins/ruflo-console/hooks/state.ts b/plugins/ruflo-console/hooks/state.ts index 8e2170a353..f10f2bed5b 100644 --- a/plugins/ruflo-console/hooks/state.ts +++ b/plugins/ruflo-console/hooks/state.ts @@ -15,20 +15,24 @@ export type ViewId = 'overview' | 'swarm' | 'claims' | 'federation' | 'plugins' * The views in tab order, each with its hotkey and the inline height it asks for. Digits are the first nine; the three * management views take letters no other control uses. `agent` is the drill-down, reached from a selection, not a tab. */ -export const VIEWS: readonly { id: ViewId; key: string; label: string; short: string; rows: number }[] = [ - { id: 'overview', key: '1', label: 'Overview', short: 'Ovr', rows: 26 }, - { id: 'swarm', key: '2', label: 'Swarm', short: 'Swm', rows: 30 }, - { id: 'claims', key: '3', label: 'Claims', short: 'Clm', rows: 30 }, - { id: 'federation', key: '4', label: 'Federation', short: 'Fed', rows: 26 }, - { id: 'plugins', key: '5', label: 'Plugins', short: 'Plg', rows: 30 }, - { id: 'learning', key: '6', label: 'Learning', short: 'Lrn', rows: 30 }, - { id: 'metaharness', key: '7', label: 'MetaHarness', short: 'MH', rows: 26 }, - { id: 'memory', key: '8', label: 'Memory', short: 'Mem', rows: 22 }, - { id: 'cost', key: '9', label: 'Cost', short: 'Cst', rows: 20 }, - { id: 'timeline', key: 'g', label: 'Timeline', short: 'Gnt', rows: 24 }, - { id: 'approvals', key: 'q', label: 'Approvals', short: 'Apv', rows: 24 }, - { id: 'events', key: 'e', label: 'Events', short: 'Evt', rows: 26 }, - { id: 'missions', key: 'm', label: 'Missions', short: 'Msn', rows: 26 }, +/** + * `icon` is one terminal cell (no emoji: those are two cells wide and render unevenly), shown in the tab bar; the + * current tab adds its label, and `blurb` is the one line under the bar that says what the view is for. + */ +export const VIEWS: readonly { id: ViewId; key: string; label: string; short: string; icon: string; blurb: string; rows: number }[] = [ + { id: 'overview', key: '1', label: 'Overview', short: 'Ovr', icon: '⌂', blurb: 'what ruflo is doing here: subsystems, mods, health alerts and live activity', rows: 26 }, + { id: 'swarm', key: '2', label: 'Swarm', short: 'Swm', icon: '⁂', blurb: 'the swarm as ruflo wrote it: topology, agents at work, and the hive-mind votes', rows: 30 }, + { id: 'claims', key: '3', label: 'Claims', short: 'Clm', icon: '⚑', blurb: 'who holds which task: claim, release, hand off or steal, each after a y/n confirm', rows: 30 }, + { id: 'federation', key: '4', label: 'Federation', short: 'Fed', icon: '⇄', blurb: 'this node, its peers, keys and channels, placed by how far each is trusted', rows: 26 }, + { id: 'plugins', key: '5', label: 'Plugins', short: 'Plg', icon: '◫', blurb: 'ruflo plugins: installed, enabled, in the marketplace clone, and loaded as mods', rows: 30 }, + { id: 'learning', key: '6', label: 'Learning', short: 'Lrn', icon: '✦', blurb: 'router picks and outcomes, and the RETRIEVE → JUDGE → DISTILL → CONSOLIDATE pipeline', rows: 30 }, + { id: 'metaharness', key: '7', label: 'MetaHarness', short: 'MH', icon: '⚙', blurb: 'harness readiness by axis, the audit trend, and the flywheel champion', rows: 26 }, + { id: 'memory', key: '8', label: 'Memory', short: 'Mem', icon: '▤', blurb: 'AgentDB entries by namespace: what the swarm has stored', rows: 22 }, + { id: 'cost', key: '9', label: 'Cost', short: 'Cst', icon: '$', blurb: 'this session spend against the budget, and how fast it is burning', rows: 20 }, + { id: 'timeline', key: 'g', label: 'Timeline', short: 'Gnt', icon: '◷', blurb: 'each agent busy or idle over the last minutes, beside Claude Code tool calls', rows: 24 }, + { id: 'approvals', key: 'q', label: 'Approvals', short: 'Apv', icon: '✓', blurb: 'decisions waiting for a person: votes, stealable claims, refused mods, budget', rows: 24 }, + { id: 'events', key: 'e', label: 'Events', short: 'Evt', icon: '≋', blurb: 'every swarm, claim, memory and mod event as it happens (f filters them)', rows: 26 }, + { id: 'missions', key: 'm', label: 'Missions', short: 'Msn', icon: '⚐', blurb: 'ADR-406 missions: the plan, task dependencies, acceptance and budget (observe only)', rows: 26 }, ] export const AGENT_VIEW = { id: 'agent' as const, rows: 28 } diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.ts index 1e5c0fd5fa..efbf8eca29 100644 --- a/plugins/ruflo-console/hooks/views/common.ts +++ b/plugins/ruflo-console/hooks/views/common.ts @@ -76,7 +76,7 @@ export function count(value: number | null | undefined): string { export const pct = (value: number | null | undefined): string => (value === null || value === undefined || !Number.isFinite(value) ? 'n/a' : `${Math.round(value * 100)}%`) -export function text(ctx: Ctx, children: string, props: { color?: string; bold?: boolean; dimColor?: boolean } = {}): RenderElement { +export function text(ctx: Ctx, children: string, props: { color?: string; bold?: boolean; dimColor?: boolean; italic?: boolean } = {}): RenderElement { return ctx.kit.Text({ wrap: 'truncate-end', ...props, children: clip(children, Math.max(4, ctx.columns)) }) } diff --git a/plugins/ruflo-console/hooks/views/frames.ts b/plugins/ruflo-console/hooks/views/frames.ts index 297ce7a593..0886e27234 100644 --- a/plugins/ruflo-console/hooks/views/frames.ts +++ b/plugins/ruflo-console/hooks/views/frames.ts @@ -5,6 +5,7 @@ */ import type { AuditTrend, HarnessScore, Intelligence } from '../data/cli' import { recentByAgent } from '../data/events' +import { agentLabels } from '../data/parse' import type { Snapshot } from '../data/snapshot' import type { Channels, Peers, Roster } from '../data/cli' import { pipelinePicture, radarPicture, samplesPicture, trendPicture, gaugePicture, type Stage } from '../gfx/charts' @@ -31,6 +32,7 @@ export function topoModelOf(snapshot: Snapshot | null, pulses: Map 0 ? snapshot.agents.filter(agent => swarm.agentIds.includes(agent.id)) : snapshot.agents + const labels = agentLabels(snapshot.agents) const leaderId = snapshot.hive?.queen ?? swarm?.id ?? 'swarm' const leaderPulse = pulses.get(leaderId) @@ -41,7 +43,7 @@ export function topoModelOf(snapshot: Snapshot | null, pulses: Map { const pulseAtMs = pulses.get(agent.id) - return { id: agent.id, label: agent.name ?? agent.type, status: agent.status, isLeader: false, ...(pulseAtMs !== undefined && { pulseAtMs }) } + return { id: agent.id, label: labels.get(agent.id) ?? agent.type, status: agent.status, isLeader: false, ...(pulseAtMs !== undefined && { pulseAtMs }) } }), ], } @@ -93,11 +95,12 @@ 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 labels = agentLabels(state.snapshot?.agents ?? []) const agents = (state.snapshot?.agents ?? []).slice(0, 24).map(agent => { const log = state.statusLog.get(agent.id) ?? [] return { - label: agent.name ?? agent.type, + label: labels.get(agent.id) ?? agent.type, spans: log.map((entry, i) => ({ fromMs: Math.max(from, entry.atMs), toMs: log[i + 1]?.atMs ?? nowMs, busy: /busy|active|working/i.test(entry.status) })).filter(span => span.toMs >= from), ticks: [], } @@ -128,7 +131,7 @@ export function picturesOf(state: State, columns: number, nowMs: number, t: numb break } case 'claims': { - const cards = flowModelOf(snapshot?.claims ?? [], openTasks(state), snapshot?.agents ?? []) + const cards = flowModelOf(snapshot?.claims ?? [], openTasks(state), snapshot?.agents ?? [], snapshot?.tasks ?? []) if (cards.length > 0) pictures.set('flow', flowPicture(cards, width, flowRows(cards), nowMs)) break diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.ts index aa0ae1f325..0317a93691 100644 --- a/plugins/ruflo-console/hooks/views/pane.ts +++ b/plugins/ruflo-console/hooks/views/pane.ts @@ -49,21 +49,35 @@ function tabs(ctx: Ctx): RenderElement { return text(ctx, `${index < 0 ? '·' : `${index + 1}/${VIEWS.length}`} ${label} · /ruflo help`, { bold: true, color: THEME.head }) } - const isShort = ctx.columns < 132 - + // Every tab is its icon; the current one adds its name in the heading colour, so the bar reads at a glance and + // still fits a docked pane. The names are in /ruflo help and in the line under the bar. return ctx.kit.Box({ flexDirection: 'row', gap: 1, key: 'tabs', children: VIEWS.map(view => { const isCurrent = view.id === ctx.state.view || (ctx.state.view === 'agent' && view.id === ctx.state.back) - const label = isShort ? view.short : view.label - return ctx.kit.Button({ key: `tab-${view.id}`, label: isCurrent ? `${label}◂` : label, hotkey: view.key, plain: true, ...(isCurrent ? {} : { dimColor: true }), onPress: () => ctx.act.view(view.id) }) + // A Button cannot be styled, so the current tab is Text: its key is not needed, the view is already open + // (from a drill-down, b goes back). + if (isCurrent) return ctx.kit.Box({ key: `tab-${view.id}`, children: [ctx.kit.Text({ bold: true, color: THEME.head, children: `${view.key}:${view.icon} ${view.label}` })] }) + + return ctx.kit.Button({ key: `tab-${view.id}`, label: view.icon, hotkey: view.key, plain: true, dimColor: true, onPress: () => ctx.act.view(view.id) }) }), }) } +/** One line under the tabs saying what the current view is for. */ +function blurb(ctx: Ctx): RenderElement | null { + if (ctx.columns < NARROW) return null + + const view = VIEWS.find(entry => entry.id === (ctx.state.view === 'agent' ? ctx.state.back : ctx.state.view)) + + if (view === undefined) return null + + return text(ctx, clip(ctx.state.view === 'agent' ? `drill-down: one agent's role, task, claims, activity and logs · b goes back to ${view.label}` : view.blurb, ctx.columns), { dimColor: true, italic: true }) +} + function help(ctx: Ctx): RenderElement { return col(ctx, [...HELP.split('\n').map((line, i) => text(ctx, line || ' ', i === 0 ? { bold: true, color: THEME.head } : /^[A-Z]/.test(line) ? { bold: true } : { dimColor: i > 20 })), row(ctx, [button(ctx, 'help-close', 'Back', ctx.act.help, { hotkey: 'h' })])], 'help') } @@ -131,7 +145,8 @@ export function paneView(ctx: Ctx): RenderElement { const header = ctx.pictures.get('header') const isCompact = ctx.state.pane.rows > 0 && ctx.state.pane.rows < rowsOf(ctx.state.view) const title = !isCompact && header !== undefined && ctx.kit.Raster !== undefined ? [ctx.kit.Raster(header.toRaster('header'))] : [] - const parts = isCompact ? [tabs(ctx), ...(confirm !== null ? [confirm] : []), footer(ctx), body] : [...title, tabs(ctx), body, ...(confirm !== null ? [confirm] : []), footer(ctx)] + const about = blurb(ctx) + const parts = isCompact ? [tabs(ctx), ...(confirm !== null ? [confirm] : []), footer(ctx), body] : [...title, tabs(ctx), ...(about !== null ? [about] : []), body, ...(confirm !== null ? [confirm] : []), footer(ctx)] return ctx.kit.Box({ flexDirection: 'column', children: parts }) } diff --git a/plugins/ruflo-console/hooks/views/swarm.ts b/plugins/ruflo-console/hooks/views/swarm.ts index 688290ea2b..19c4342778 100644 --- a/plugins/ruflo-console/hooks/views/swarm.ts +++ b/plugins/ruflo-console/hooks/views/swarm.ts @@ -1,5 +1,6 @@ import type { RenderElement } from 'claude-code' +import { agentLabels, shortId } from '../data/parse' import { button, clip, col, kv, picture, row, rule, text, THEME, type Ctx } from './common' import { selection } from './select' @@ -28,8 +29,9 @@ export function swarmView(ctx: Ctx): RenderElement { rows.push(kv(ctx, 'topology', swarm === null ? `${hive?.topology ?? 'n/a'} (hive-mind)` : `${swarm.topology}${swarm.strategy !== undefined ? ` · ${swarm.strategy}` : ''} · ${swarm.status}${swarm.maxAgents !== undefined ? ` · max ${swarm.maxAgents}` : ''}`)) rows.push(picture(ctx, 'topology', `graph needs a terminal: ${agents.length} agents`)) - rows.push(text(ctx, '★ leader (its heartbeat is decoration) · ● idle / busy / stopped as ruflo wrote them · a white pulse = an event about that agent', { dimColor: true })) + rows.push(text(ctx, '★ leader · ◉ busy (a dot runs to it while it works) · ● idle · grey stopped · a white flash = an event about that agent', { dimColor: true })) rows.push(rule(ctx, 'Agents', `${agents.length} · j/k pick · d open · x actions`)) + const labels = agentLabels(agents) for (const agent of agents.slice(0, 10)) { const isPicked = picked?.id === agent.id @@ -41,7 +43,8 @@ export function swarmView(ctx: Ctx): RenderElement { ctx.kit.Text({ wrap: 'truncate-end', ...(isPicked && { bold: true }), - children: clip(`${(agent.name ?? agent.type).padEnd(14)} ${agent.type.padEnd(12)} ${agent.status.padEnd(9)} tasks ${agent.taskCount ?? 'n/a'} · health ${agent.health === undefined ? 'n/a' : `${Math.round(agent.health * 100)}%`} · ${agent.id}`, ctx.columns - 3), + // One label (name, else type, with a short id only where two read the same); the type only when it differs. + children: clip(`${(labels.get(agent.id) ?? agent.type).padEnd(16)} ${agent.status.padEnd(8)} ${(agent.name !== undefined && agent.name !== agent.type ? agent.type : '').padEnd(12)} tasks ${agent.taskCount ?? 'n/a'} · health ${agent.health === undefined ? 'n/a' : `${Math.round(agent.health * 100)}%`} · #${shortId(agent.id)}`, ctx.columns - 3), }), ]), ) diff --git a/plugins/ruflo-console/tests/behaviour.test.ts b/plugins/ruflo-console/tests/behaviour.test.ts index 795ae2b9ce..cc9616e79d 100644 --- a/plugins/ruflo-console/tests/behaviour.test.ts +++ b/plugins/ruflo-console/tests/behaviour.test.ts @@ -14,9 +14,9 @@ describe('behaviour', () => { const pane = await $.ui.mount({ ...paneAt(110), plugin: PLUGIN }) - expect(textOf(await pane.drawn())).toContain('Ovr◂') + expect(textOf(await pane.drawn())).toContain('1:⌂ Overview') await pane.press({ key: 'tab-claims' }) - expect(textOf(await pane.drawn())).toContain('Clm◂') + expect(textOf(await pane.drawn())).toContain('3:⚑ Claims') expect(world.stored.get('ruflo-console/ui:/work')).toEqual({ view: 'claims', isClosedByPerson: false }) expect(world.opened.length).toBeGreaterThanOrEqual(2) await pane.unmount() @@ -96,7 +96,7 @@ describe('behaviour', () => { const pane = await $.ui.mount({ ...paneAt(100), plugin: PLUGIN }) const text = textOf(await pane.drawn()) - expect(text).toContain('◂') + expect(text).toMatch(/[0-9a-z]:\S \w/) // the current tab: key, icon and name await pane.unmount() } diff --git a/plugins/ruflo-console/tests/diagrams.spec.ts b/plugins/ruflo-console/tests/diagrams.spec.ts index 0d776c0b0b..4a119ef302 100644 --- a/plugins/ruflo-console/tests/diagrams.spec.ts +++ b/plugins/ruflo-console/tests/diagrams.spec.ts @@ -64,14 +64,25 @@ describe('diagrams', () => { }) it('an event pulse is data: it runs only in the 1.4 s after its event, and the frames differ while it does', () => { - const model = swarmOf(3, 'hierarchical', 99) + const idle = (model: TopoModel): TopoModel => ({ ...model, nodes: model.nodes.map(node => (node.isLeader ? node : { ...node, status: 'idle' })) }) + const model = idle(swarmOf(3, 'hierarchical', 99)) const frame = (t: number) => topologyPicture(model, 60, 12, t).encode() expect(frame(1_300)).not.toBe(frame(1_900)) - // Before the event, at two instants where the heartbeat (decoration) rests: nothing else moves. + // Before the event, with every agent idle, at two instants where the heartbeat (decoration) rests: nothing else moves. expect(frame(0)).toBe(frame(Math.PI * 260)) }) + it('work in flight is data too: a busy agent keeps a dot moving with no event, and it stops when the agent goes idle', () => { + const busy: TopoModel = { topology: 'hierarchical', nodes: [{ id: 'q', label: 'queen', status: 'leader', isLeader: true }, { id: 'a', label: 'coder', status: 'busy', isLeader: false }] } + const idle: TopoModel = { ...busy, nodes: busy.nodes.map(node => (node.isLeader ? node : { ...node, status: 'idle' })) } + // Two instants where the leader's heartbeat rests, so only data can differ between them. + const [t0, t1] = [0, Math.PI * 260] + + expect(topologyPicture(busy, 60, 12, t0).encode()).not.toBe(topologyPicture(busy, 60, 12, t1).encode()) + expect(topologyPicture(idle, 60, 12, t0).encode()).toBe(topologyPicture(idle, 60, 12, t1).encode()) + }) + it('claims fall in their lanes and a ring counts down a TTL on the real clock, else fills with age', () => { expect(flowModelOf(claims, []).map(card => [card.id, card.lane])).toEqual([ ['console-demo-1', 'claimed'], diff --git a/plugins/ruflo-console/tests/views.test.ts b/plugins/ruflo-console/tests/views.test.ts index 609ca17ef0..2d0156a7b2 100644 --- a/plugins/ruflo-console/tests/views.test.ts +++ b/plugins/ruflo-console/tests/views.test.ts @@ -61,7 +61,9 @@ describe('views', () => { expect(rasters).toEqual(['header', 'topology']) expect(text).toContain('hierarchical · specialized · running · max 6') - expect(text).toMatch(/▸● \ncoder\s+coder\s+idle/) + // One label per agent (no repeated type), then status; a short id instead of the full one. + expect(text).toMatch(/▸● \ncoder\s+idle\s+tasks/) + expect(text).toMatch(/· #[a-z0-9]{4,6}/) expect(text).toContain('design (raft) pending · for 0 · against 0') expect(text).not.toContain(HIVE_TOKEN) expect(elementsOf(tree, 'Button').map(keyOf)).toEqual(expect.arrayContaining(['agent-next', 'agent-prev', 'drill', 'palette', 'actions']))