🌊 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): the mission strip is a card, the prompt is boxed, the footer fits, and sections wear the page's accent (ADR 430)
ruv52709af94e0d
diff --git a/plugins/ruflo-console/hooks/footer-layout.ts b/plugins/ruflo-console/hooks/footer-layout.tsnew file mode 100644index 0000000000..6d114f3725--- /dev/null+++ b/plugins/ruflo-console/hooks/footer-layout.ts@@ -0,0 +1,62 @@+/**+ * The footer's buttons, fitted to the width, pure (the footer that draws them is views/pane.ts). The row was a status text and seven+ * buttons with no budget, so below about 100 columns it ran off the edge and cut the last buttons in half. Now each button has a full+ * label, a short one and a priority, and the row shows as many in full as fit, shortens the least important first, and only then drops+ * them. A dropped button is not lost: the footer keeps it, hidden, so its hotkey still works (the console's rule: a key reaches a page or+ * an action from wherever the person is). Tested in tests/footer-layout.spec.ts.+ */+export type FooterItem = {+ id: string+ full: string+ short: string+ /** 1 is kept longest; the highest number is shortened and dropped first. */+ priority: number+}++export type FooterFit = {+ /** In the order given: what to draw, and whether in its short form. */+ shown: { id: string; label: string; isShort: boolean }[]+ /** Dropped to fit: drawn hidden by the footer, so their hotkeys still work. */+ hidden: string[]+ /** Columns the shown buttons take, so the status text knows what is left. */+ used: number+}++/** A button draws `[ label ]` and the row puts one column between buttons. */+export const buttonWidth = (label: string): number => label.length + 5++/**+ * Fits `items` in `room` columns, leaving `minStatus` for the status text. Shortens from the lowest priority up until they fit, then drops+ * from the lowest priority up. With no room, every button is hidden.+ */+export function fitFooter(items: readonly FooterItem[], room: number, minStatus = 10): FooterFit {+ const budget = Math.max(0, room - minStatus)+ const form = new Map<string, 'full' | 'short' | 'gone'>(items.map(item => [item.id, 'full']))+ const weakest = [...items].sort((a, b) => b.priority - a.priority)+ const width = (): number =>+ items.reduce((sum, item) => {+ const how = form.get(item.id)++ return how === 'gone' ? sum : sum + buttonWidth(how === 'short' ? item.short : item.full)+ }, 0)++ for (const item of weakest) {+ if (width() <= budget) break+ form.set(item.id, 'short')+ }++ for (const item of weakest) {+ if (width() <= budget) break+ form.set(item.id, 'gone')+ }++ return {+ shown: items.flatMap(item => {+ const how = form.get(item.id)++ return how === 'gone' ? [] : [{ id: item.id, label: how === 'short' ? item.short : item.full, isShort: how === 'short' }]+ }),+ hidden: items.filter(item => form.get(item.id) === 'gone').map(item => item.id),+ used: width(),+ }+}diff --git a/plugins/ruflo-console/hooks/menu-colors.ts b/plugins/ruflo-console/hooks/menu-colors.tsindex 66f35cead1..4f3e405bdf 100644--- a/plugins/ruflo-console/hooks/menu-colors.ts+++ b/plugins/ruflo-console/hooks/menu-colors.ts@@ -22,3 +22,19 @@ export const PALETTE: readonly string[] = ['#ffaf00', '#5fd7ff', '#ff5f5f', '#5f/** `#rrggbb` as the 0xRRGGBB number a Grid takes. */export const rgb = (hex: string): number => Number.parseInt(hex.slice(1), 16)++/**+ * The accent of a page's nav group. The menu names its groups one way (INTELLIGENCE, SAFETY & OPS) and the nav another (MIND, SAFETY),+ * so this maps the nav's names to the same five colours: a page's cards and section rules wear the accent of the group the menu+ * lists it under.+ */+export const NAV_ACCENT: Readonly<Record<string, string>> = {+ SWARM: ACCENT.SWARM as string,+ MIND: ACCENT.INTELLIGENCE as string,+ SAFETY: ACCENT['SAFETY & OPS'] as string,+ NETWORK: ACCENT['NETWORK & EXTEND'] as string,+ TOOLS: ACCENT.TOOLS as string,+}++/** The colour of a mission's status line, by tone: running and done green, ready amber, paused cyan, waiting dim. */+export const TONE = { live: '#5fd75f', ready: '#ffaf00', wait: '#8a8a8a', done: '#5fd75f', paused: '#5fd7ff' } as constdiff --git a/plugins/ruflo-console/hooks/mission-strip.ts b/plugins/ruflo-console/hooks/mission-strip.tsnew file mode 100644index 0000000000..c60ae90657--- /dev/null+++ b/plugins/ruflo-console/hooks/mission-strip.ts@@ -0,0 +1,47 @@+/**+ * The Mission Control strip's words, pure (the strip that draws them is views/mission-control.ts `missionStrip`). The strip said+ * "nothing ready" for four different things: no tasks yet, every task done, a task running, and the next task waiting on one that is not+ * done. Each now says which. Also the progress bar's cells and the percentage. Tested in tests/mission-strip.spec.ts.+ */+export type StripInput = {+ done: number+ total: number+ paused: boolean+ /** The task Claude is on now, if one is running. */+ running: { id: string; title: string } | null+ /** The next task that can be handed out, if there is one. */+ next: { id: string; stage: string; title: string } | null+}++export type StripStatus = { text: string; tone: 'live' | 'ready' | 'wait' | 'done' | 'paused' }++const cut = (text: string, max: number): string => (text.length > max ? `${text.slice(0, Math.max(1, max - 1))}…` : text)++/** What the mission is doing, in one line, and how loud: the first thing true of it, in this order. */+export function stripStatus(input: StripInput, max = 48): StripStatus {+ if (input.total === 0) return { text: 'no tasks yet: plan the goal first', tone: 'wait' }+ if (input.done >= input.total) return { text: '✔ every task is done', tone: 'done' }+ if (input.paused) return { text: '⏸ paused: resume to carry on', tone: 'paused' }+ if (input.running !== null) {+ const lead = `◐ running ${input.running.id} `++ return { text: `${lead}${cut(input.running.title, Math.max(6, max - lead.length))}`, tone: 'live' }+ }++ if (input.next !== null) {+ const lead = `▶ next ${input.next.id} [${input.next.stage}] `++ return { text: `${lead}${cut(input.next.title, Math.max(6, max - lead.length))}`, tone: 'ready' }+ }++ return { text: 'waiting: the next task needs one that is not done', tone: 'wait' }+}++/** The bar's cells: how many filled, how many empty, always `width` in all, and never a filled cell for none done. */+export function barCells(done: number, total: number, width = 10): { filled: number; empty: number } {+ const filled = total <= 0 ? 0 : Math.max(0, Math.min(width, Math.round((done / total) * width)))++ return { filled, empty: width - filled }+}++export const percentOf = (done: number, total: number): number => (total <= 0 ? 0 : Math.max(0, Math.min(100, Math.round((done / total) * 100))))diff --git a/plugins/ruflo-console/hooks/nav-state.ts b/plugins/ruflo-console/hooks/nav-state.tsindex 481013e3ab..80b791427c 100644--- a/plugins/ruflo-console/hooks/nav-state.ts+++ b/plugins/ruflo-console/hooks/nav-state.ts@@ -3,6 +3,7 @@* find. Pure and view-free (the nav card that draws it is views/nav.ts), so the page list, the grouping and the matching are tested* without a screen.*/+import { NAV_ACCENT } from './menu-colors'import { VIEWS, type State, type ViewId } from './state'/** The nav's groups, the main menu's own, each in rows short enough to spell their names: every view but the menu is in exactly one. */@@ -16,6 +17,9 @@ export const NAV_GROUPS: readonly { title: string; icon: string; rows: readonlyexport const groupOf = (view: ViewId): string | null => NAV_GROUPS.find(group => group.rows.some(row => row.includes(view)))?.title ?? null+/** The accent of a page's group, or null for a page in none (the menu): the colour its cards and section rules wear in the BBS look. */+export const accentOfView = (view: ViewId): string | null => NAV_ACCENT[groupOf(view) ?? ''] ?? null+/** The group whose pages the nav shows: the one the person picked while on this page, else the open page's own. */export function shownGroup(state: State): string {const open = state.view === 'agent' ? state.back : state.viewdiff --git a/plugins/ruflo-console/hooks/views/card.ts b/plugins/ruflo-console/hooks/views/card.tsindex e9e1e2aa94..ab67664171 100644--- a/plugins/ruflo-console/hooks/views/card.ts+++ b/plugins/ruflo-console/hooks/views/card.ts@@ -25,7 +25,8 @@ function holdsHead(children: unknown): boolean {/** Whether a page of this width and pane is drawn in cards: not in the narrow layout, and not in a compact inline pane (its rows are few). */export const hasCards = (columns: number, isCompact: boolean): boolean => columns >= 60 && !isCompact-export function withCards(kit: Ctx['kit']): Ctx['kit'] {+/** `accent` is the border's colour in the BBS look (the page's group colour); without it, the theme's. */+export function withCards(kit: Ctx['kit'], accent?: string): Ctx['kit'] {let made = 0const Box: Ctx['kit']['Box'] = props => {@@ -38,7 +39,7 @@ export function withCards(kit: Ctx['kit']): Ctx['kit'] {const out: unknown[] = []let card: unknown[] | null = nullconst close = () => {- if (card !== null) out.push(kit.Box({ key: `card-${made++}`, flexDirection: 'column', borderStyle: 'round', borderColor: THEME.info, paddingX: 1, children: card as never }))+ if (card !== null) out.push(kit.Box({ key: `card-${made++}`, flexDirection: 'column', borderStyle: 'round', borderColor: accent ?? THEME.info, paddingX: 1, children: card as never }))card = null}diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.tsindex cd44c8cbf7..dbbd4c12a2 100644--- a/plugins/ruflo-console/hooks/views/common.ts+++ b/plugins/ruflo-console/hooks/views/common.ts@@ -25,6 +25,7 @@ import { START_LABEL, type StartId } from '../starts'import type { MoreSkillActions } from '../skills-lab'import { VIEWS, type HarnessId, type NavStyle, type State, type ViewId } from '../state'import type { UpdatesMode } from '../updates'+import { accentOfView } from '../nav-state'import type { VectorActions } from '../vector'export type Kit = Pick<Elements['terminal'], 'Box' | 'Text' | 'Button'> & { Raster?: Elements['terminal']['Raster']; Input?: Elements['terminal']['Input'] }@@ -179,6 +180,11 @@ export function col(ctx: Ctx, parts: readonly RenderChildren[], key?: string): Rreturn ctx.kit.Box({ flexDirection: 'column', ...(key !== undefined && { key }), children: [...parts] })}+/** The colour a BBS page's section headers wear: the accent of its nav group (the menu's colours), else the theme's. Plain look: the theme's. */+function accentOf(ctx: Ctx): string {+ return look === 'bbs' ? (accentOfView(ctx.state.view === 'agent' ? ctx.state.back : ctx.state.view) ?? THEME.info) : THEME.info+}+/*** A collapsible section: its header is a button (▾ open, ▸ closed) and the rows follow only while it is open. `open` is the* section's default; pressing the header flips it for this session. The header reads as `rule` does.@@ -198,8 +204,8 @@ export function section(ctx: Ctx, id: string, title: string, right: string, chilctx,[ctx.kit.Button({ key: `sec-${id}`, label: head, plain: true, onPress: () => ctx.act.toggle(key) }),- ctx.kit.Text({ color: THEME.info, dimColor: true, children: `${(look === 'bbs' ? '═' : '─').repeat(fill)} ` }),- ctx.kit.Text({ color: THEME.info, children: right }),+ ctx.kit.Text({ color: accentOf(ctx), dimColor: true, children: `${(look === 'bbs' ? '═' : '─').repeat(fill)} ` }),+ ctx.kit.Text({ color: accentOf(ctx), children: right }),],`sec-row-${id}`,),@@ -215,7 +221,7 @@ export function rule(ctx: Ctx, title: string, right = ''): RenderElement {const head = `▓▒░ ${title.toUpperCase()} ░▒▓`const fill = Math.max(1, ctx.columns - head.length - right.length - 2)- const line = row(ctx, [ctx.kit.Text({ bold: true, color: THEME.head, children: head }), ctx.kit.Text({ color: THEME.info, dimColor: true, children: `${'═'.repeat(fill)} ` }), ctx.kit.Text({ color: THEME.info, children: right })])+ const line = row(ctx, [ctx.kit.Text({ bold: true, color: accentOf(ctx), children: head }), ctx.kit.Text({ color: accentOf(ctx), dimColor: true, children: `${'═'.repeat(fill)} ` }), ctx.kit.Text({ color: accentOf(ctx), children: right })])// In a card the header is the card's first row; otherwise a blank line above each section, so the board breathes instead of packing every block together.return ctx.cards === true ? marked(HEADS, line) : marked(HEADS, col(ctx, [ctx.kit.Text({ children: ' ' }), line]))diff --git a/plugins/ruflo-console/hooks/views/menu.ts b/plugins/ruflo-console/hooks/views/menu.tsindex 0b8e935950..e1cda83894 100644--- a/plugins/ruflo-console/hooks/views/menu.ts+++ b/plugins/ruflo-console/hooks/views/menu.ts@@ -183,18 +183,17 @@ export function menuView(ctx: Ctx): RenderElement {}),)rows.push(text(ctx, ' '))- rows.push(text(ctx, `T - ${online}`, { bold: true }))-+ // The prompt, in a box like the cards in the BBS look. (The `T - 01:00` line that sat above it said what the status bar's Online already does.)if (ctx.kit.Input !== undefined) {- rows.push(- ctx.kit.Input({- key: 'menu-prompt',- label: `(1:1) (ruflo: ${clip(project, 24)})`,- placeholder: 'a key or a name, then Enter (? for help)',- submitLabel: 'go',- onSubmit: value => ctx.act.menu(value),- }),- )+ const prompt = ctx.kit.Input({+ key: 'menu-prompt',+ label: bbs ? `${clip(project, 20)} ❯` : `(1:1) (ruflo: ${clip(project, 24)})`,+ placeholder: 'a key or a name, then Enter · ? for help',+ submitLabel: 'go',+ onSubmit: value => ctx.act.menu(value),+ })++ rows.push(bbs ? ctx.kit.Box({ key: 'menu-prompt-box', borderStyle: 'round', borderColor: ACCENT.TOOLS as string, paddingX: 1, children: [prompt] }) : prompt)} else {rows.push(row(ctx, [text(ctx, `(1:1) (ruflo: ${clip(project, 24)}) : press a key from the menu`, { color: THEME.warn })]))}diff --git a/plugins/ruflo-console/hooks/views/mission-control.ts b/plugins/ruflo-console/hooks/views/mission-control.tsindex 35ea972018..c37ab9528a 100644--- a/plugins/ruflo-console/hooks/views/mission-control.ts+++ b/plugins/ruflo-console/hooks/views/mission-control.ts@@ -3,7 +3,9 @@ import type { RenderElement } from 'claude-code'import { lifecycleOf, PHASE_NAME, PROFILES, RIGORS, stageOf } from '../goap'import { guidanceStatus } from '../mission-guidance'import { activeMission, derive, mcOf, nextTask, progressOf, rufloTaskOf, type Derived, type LedgerTask, type McTab, type MissionRecord } from '../mission-control'-import { ago, button, clip, col, confirmHere, row, rule, section, text, THEME, type Ctx } from './common'+import { ACCENT, INK, TONE } from '../menu-colors'+import { barCells, percentOf, stripStatus } from '../mission-strip'+import { ago, button, clip, col, confirmHere, isBbs, row, rule, section, text, THEME, type Ctx } from './common'import { GOALS_PLUGIN, isAvailable, MISSION_SKILLS, slashOf } from '../mission-skills'import { observationRows } from './missions'import { capabilityRows, launchRows } from './mission-launch'@@ -235,6 +237,57 @@ export function missionControlView(ctx: Ctx): RenderElement {return col(ctx, rows, 'mission-control')}+/**+ * The strip as a card in the BBS look: a solid title bar, the goal with a coloured bar and the percentage, a line that says what the+ * mission is doing (it said "nothing ready" for four different things), and the buttons under it. Every key is the one the plain+ * strip had, so a hotkey, a test and a click land where they did.+ */+function stripCard(ctx: Ctx, mission: ReturnType<typeof activeMission>, field: RenderElement[], open: RenderElement): RenderElement {+ const m = ctx.act.mission+ const accent = ACCENT.SWARM as string+ const inner = Math.max(24, ctx.columns - 4)+ const rows: RenderElement[] = [ctx.kit.Box({ backgroundColor: accent, key: 'menu-mc-bar', children: [ctx.kit.Text({ bold: true, color: INK, wrap: 'truncate-end', children: ' ▓▒░ MISSION CONTROL ░▒▓'.padEnd(inner).slice(0, inner) })] })]++ if (mission === null) {+ rows.push(...field, text(ctx, ' research → create (ADRs, SOP) → build → test → validate → secure → benchmark → learn', { dimColor: true }), row(ctx, [open], 'menu-mission-links'))+ } else {+ const tasks = ctx.state.snapshot?.tasks ?? []+ const { done, total } = progressOf(mission, tasks)+ const states = derive(mission, tasks)+ const running = mission.tasks.find(task => states.get(task.id) === 'running')+ const next = nextTask(mission, tasks)+ const status = stripStatus({ done, total, paused: mission.paused, running: running === undefined ? null : { id: running.id, title: running.title }, next: next === null ? null : { id: next.id, stage: next.stage ?? next.phase, title: next.title } }, Math.max(24, inner - 4))+ const cells = barCells(done, total, Math.min(20, Math.max(8, Math.floor(inner / 4))))++ rows.push(+ ...field,+ row(+ ctx,+ [+ ctx.kit.Text({ bold: true, children: ` ${clip(mission.objective, Math.max(12, inner - cells.filled - cells.empty - 14))} ` }),+ ctx.kit.Text({ color: TONE.live, children: '▮'.repeat(cells.filled) }),+ ctx.kit.Text({ color: TONE.wait, children: '▯'.repeat(cells.empty) }),+ ctx.kit.Text({ bold: true, children: ` ${done}/${total} ${percentOf(done, total)}%` }),+ ],+ 'menu-mission-goal',+ ),+ ctx.kit.Text({ color: TONE[status.tone], bold: status.tone === 'live' || status.tone === 'ready', children: ` ${status.text}` }),+ row(+ ctx,+ [+ ...(next === null ? [] : [ctx.kit.Button({ key: 'menu-mc-next', label: ' ▶ run next ', variant: 'primary' as const, onPress: () => m.next() })]),+ ctx.kit.Button({ key: 'menu-mc-pause', label: mission.paused ? ' ▶ resume ' : ' ⏸ pause ', plain: true, onPress: () => (mission.paused ? m.resume() : m.pause()) }),+ open,+ ],+ 'menu-mission-ctl',+ ),+ ...confirmHere(ctx, 'controls'),+ )+ }++ return ctx.kit.Box({ key: 'menu-mission-card', flexDirection: 'column', borderStyle: 'round', borderColor: accent, paddingX: 1, children: rows })+}+/*** Mission Control at the top of the main menu: the active mission's progress and what is next, with the buttons to hand the next* task to Claude, pause and open it; or, with none, the goal field (Enter plans it, asks Claude for guidance, and opens Missions).@@ -251,6 +304,9 @@ export function missionStrip(ctx: Ctx): RenderElement[] {m.goal(value)})+ // The BBS look draws the strip as a card; the plain look keeps its lines.+ if (isBbs()) return [stripCard(ctx, mission, field, open)]+if (mission === null) {return [row(ctx, [title, open], 'menu-mission-title'),diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.tsindex bfcf2cf5d6..eac11137cf 100644--- a/plugins/ruflo-console/hooks/views/pane.ts+++ b/plugins/ruflo-console/hooks/views/pane.ts@@ -13,6 +13,8 @@ import { CARD_COLUMNS, hasCards, withCards } from './card'import { groupedTabs } from './nav'import { stepsRows } from './steps'import { optimizerResult } from './optimizer'+import { fitFooter, type FooterItem } from '../footer-layout'+import { accentOfView } from '../nav-state'import { isBooting, isCompactPane, NAV_STYLES, VIEWS, type ViewId } from '../state'import { agentView } from './agent'import { automateResult, automateView } from './automate'@@ -197,24 +199,47 @@ function footer(ctx: Ctx, isPlaced = false): RenderElement {// BBS: the link status in modem-speak, [LINK OK] ▸ sync 3s · keys on.const read = state.snapshot === null ? (isBbs() ? '[DIALING…]' : 'reading…') : isBbs() ? `[LINK OK] ▸ sync ${ago(state.snapshot.readAtMs, nowMs).replace(' ago', '')}` : `read ${ago(state.snapshot.readAtMs, nowMs)}`const keys = state.pane.isFocused ? 'keys on' : 'keys off: click the pane (or /ruflo …)'+ const slash = slashFor(state, state.view)+ // The buttons, most important first. Each has a short form and a priority: a narrow pane shortens the least important, then drops them+ // (a dropped one stays, hidden, so its hotkey still works) instead of running off the edge and cutting the last in half.+ const items: FooterItem[] = ctx.columns < NARROW+ ? []+ : [+ { id: 'palette', full: 'Palette', short: 'p', priority: 1 },+ ...(state.view === 'agent' || state.palette.isOpen ? [] : [{ id: 'actions', full: 'Actions', short: 'x', priority: 5 }]),+ ...(state.palette.isOpen ? [] : [{ id: 'ask-claude', full: '✦ Ask Claude', short: '✦', priority: 2 }]),+ ...(state.palette.isOpen || slash === null ? [] : [{ id: 'ask-slash', full: `▸ /${slash}`, short: '▸', priority: 7 }]),+ { id: 'refresh', full: 'Refresh', short: 'r', priority: 6 },+ { id: 'help', full: 'Help', short: 'h', priority: 3 },+ { id: 'close', full: 'Close', short: '×', priority: 4 },+ ]+ const fit = fitFooter(items, ctx.columns - 2)+ const press: Record<string, () => void> = { palette: () => ctx.act.palette('all'), actions: () => ctx.act.palette('selection'), 'ask-claude': () => ctx.act.ask.ask(), 'ask-slash': () => ctx.act.ask.slash(), refresh: ctx.act.refresh, help: ctx.act.help, close: ctx.act.close }+ const hotkey: Record<string, string> = { palette: 'p', actions: 'x', refresh: 'r', help: 'h' }+ const full = new Map(items.map(item => [item.id, item.full]))+ const statusRoom = Math.max(10, ctx.columns - fit.used - 3)+ // BBS: the link in colour ([LINK OK] green, how fresh the read is, whether the keys are on); plain: one dim line, as before.+ const status =+ isBbs() && state.snapshot !== null+ ? [+ ctx.kit.Text({ bold: true, color: THEME.ok, children: '[LINK OK]' }),+ ctx.kit.Text({ dimColor: true, children: clip(` ▸ sync ${ago(state.snapshot.readAtMs, nowMs).replace(' ago', '')} · `, Math.max(4, statusRoom - 9)) }),+ ctx.kit.Text({ bold: state.pane.isFocused, color: state.pane.isFocused ? THEME.ok : THEME.warn, children: clip(`${keys} `, Math.max(4, statusRoom - 28)) }),+ ]+ : [text(ctx, `${clip(`${read} · ${keys}`, statusRoom)} `, { dimColor: true })]parts.push(row(ctx, [- text(ctx, `${clip(`${read} · ${keys}`, Math.max(10, ctx.columns - 46))} `, { dimColor: true }),- ...(ctx.columns >= NARROW- ? [- button(ctx, 'palette', 'Palette', () => ctx.act.palette('all'), { hotkey: 'p' }),- ...(state.view === 'agent' || state.palette.isOpen ? [] : [button(ctx, 'actions', 'Actions', () => ctx.act.palette('selection'), { hotkey: 'x' })]),- ...(state.palette.isOpen ? [] : [button(ctx, 'ask-claude', '✦ Ask Claude', () => ctx.act.ask.ask())]),- ...(state.palette.isOpen || slashFor(state, state.view) === null ? [] : [button(ctx, 'ask-slash', `▸ /${slashFor(state, state.view)}`, () => ctx.act.ask.slash())]),- button(ctx, 'refresh', 'Refresh', ctx.act.refresh, { hotkey: 'r' }),- button(ctx, 'help', 'Help', ctx.act.help, { hotkey: 'h' }),- button(ctx, 'close', 'Close', ctx.act.close),- ]- : []),+ ...status,+ ...fit.shown.map(entry => button(ctx, entry.id, entry.label, press[entry.id] as () => void, hotkey[entry.id] === undefined ? {} : { hotkey: hotkey[entry.id] })),]),)+ // A dropped button's hotkey must still work from here: drawn hidden, the engine still arms it.+ const hiddenKeys = fit.hidden.filter(id => hotkey[id] !== undefined)++ if (hiddenKeys.length > 0) parts.push(ctx.kit.Box({ key: 'footer-keys', display: 'none', children: hiddenKeys.map(id => button(ctx, id, full.get(id) ?? id, press[id] as () => void, { hotkey: hotkey[id] as string })) } as never))+return col(ctx, parts, 'footer')}@@ -281,7 +306,7 @@ export function paneView(base: Ctx): RenderElement {}// A section of a page is a bordered card (views/card.ts): the body is drawn narrower by the border and padding, through a kit that groups its rows.const cardsOn = hasCards(base.columns, isCompactPane(base.state)) && !ctx.state.palette.isOpen && !ctx.state.isHelp- const bodyCtx: Ctx = cardsOn ? { ...ctx, columns: ctx.columns - CARD_COLUMNS, cards: true, kit: withCards(ctx.kit) } : ctx+ const bodyCtx: Ctx = cardsOn ? { ...ctx, columns: ctx.columns - CARD_COLUMNS, cards: true, kit: withCards(ctx.kit, isBbs() ? (accentOfView(ctx.state.view === 'agent' ? ctx.state.back : ctx.state.view) ?? undefined) : undefined) } : ctxconst drawBody = () => (ctx.state.palette.isOpen ? paletteView(ctx) : ctx.state.isHelp ? help(ctx) : BODIES[ctx.state.view](bodyCtx))// A lab's result block is drawn first into the panel (pass one), then the page is drawn with the panel placed under the clicked row.if (ctx.state.origin !== null && (ctx.state.lab.result !== null || ctx.state.lab.running !== null)) {diff --git a/plugins/ruflo-console/tests/footer-layout.spec.ts b/plugins/ruflo-console/tests/footer-layout.spec.tsnew file mode 100644index 0000000000..9edbe715ae--- /dev/null+++ b/plugins/ruflo-console/tests/footer-layout.spec.ts@@ -0,0 +1,66 @@+/**+ * The footer's fit and the mission strip's words, pure. Run with+ * npx vitest run plugins/ruflo-console/tests/footer-layout.spec.ts+ */+import { describe, expect, it } from 'vitest'++import { buttonWidth, fitFooter, type FooterItem } from '../hooks/footer-layout'++const ITEMS: FooterItem[] = [+ { id: 'palette', full: 'Palette', short: 'p', priority: 1 },+ { id: 'actions', full: 'Actions', short: 'x', priority: 5 },+ { id: 'ask', full: '✦ Ask Claude', short: '✦', priority: 2 },+ { id: 'slash', full: '▸ /ruflo-swarm:swarm', short: '▸', priority: 7 },+ { id: 'refresh', full: 'Refresh', short: 'r', priority: 6 },+ { id: 'help', full: 'Help', short: 'h', priority: 3 },+ { id: 'close', full: 'Close', short: '×', priority: 4 },+]+const full = ITEMS.reduce((sum, item) => sum + buttonWidth(item.full), 0)++describe('the footer fit', () => {+ it('shows every button in full when there is room, with room left for the status', () => {+ const fit = fitFooter(ITEMS, full + 30)++ expect(fit.shown.map(entry => entry.id)).toEqual(ITEMS.map(item => item.id))+ expect(fit.shown.every(entry => !entry.isShort)).toBe(true)+ expect(fit.hidden).toEqual([])+ expect(fit.used).toBe(full)+ })++ it('shortens the least important first and keeps the most important in full', () => {+ const fit = fitFooter(ITEMS, full - 5 + 10)+ const shortened = fit.shown.filter(entry => entry.isShort).map(entry => entry.id)++ expect(shortened).toContain('slash')+ expect(fit.shown.find(entry => entry.id === 'palette')?.isShort).toBe(false)+ expect(fit.used).toBeLessThanOrEqual(full - 5)+ })++ it('never uses more than the room it was given, at any width', () => {+ for (let room = 0; room <= full + 40; room++) {+ const fit = fitFooter(ITEMS, room)++ expect(fit.used, `room ${room}`).toBeLessThanOrEqual(Math.max(0, room - 10))+ expect(fit.shown.length + fit.hidden.length, `room ${room}`).toBe(ITEMS.length)+ }+ })++ it('drops from the least important up once even the short forms do not fit, keeping the first buttons', () => {+ const fit = fitFooter(ITEMS, 10 + buttonWidth('p') + buttonWidth('✦'))++ expect(fit.shown.map(entry => entry.id)).toEqual(['palette', 'ask'])+ expect(fit.hidden.sort()).toEqual(['actions', 'close', 'help', 'refresh', 'slash'])+ })++ it('hides everything when there is no room, and every dropped button is named so its hotkey can be kept', () => {+ const fit = fitFooter(ITEMS, 4)++ expect(fit.shown).toEqual([])+ expect(fit.hidden.sort()).toEqual(ITEMS.map(item => item.id).sort())+ })++ it('keeps the order it was given', () => {+ // Four short buttons fit: the four of highest priority (palette, ask, help, close), drawn in the order given.+ expect(fitFooter(ITEMS, 10 + 4 * buttonWidth('p')).shown.map(entry => entry.id)).toEqual(['palette', 'ask', 'help', 'close'])+ })+})diff --git a/plugins/ruflo-console/tests/menu-style.spec.ts b/plugins/ruflo-console/tests/menu-style.spec.tsindex 28d080c183..0fa7032fb7 100644--- a/plugins/ruflo-console/tests/menu-style.spec.ts+++ b/plugins/ruflo-console/tests/menu-style.spec.ts@@ -9,6 +9,8 @@ import { describe, expect, it } from 'vitest'import type { ReadCache } from '../hooks/data/files'import { readSnapshot } from '../hooks/data/snapshot'import { ACCENT, badgesOf, INK, LOUD, MUTED, PALETTE } from '../hooks/menu-style'+import { NAV_ACCENT, TONE } from '../hooks/menu-colors'+import { accentOfView, NAV_GROUPS } from '../hooks/nav-state'import { secMemo } from '../hooks/secure'import { newState, VIEWS } from '../hooks/state'import { GROUPS } from '../hooks/views/menu'@@ -48,7 +50,7 @@ describe('the menu accents', () => {})it('uses only colours the 256-colour palette has, so they render the same without truecolor and in tmux', () => {- for (const color of [...Object.values(ACCENT), ...PALETTE, INK, MUTED, LOUD]) expect(isXterm256(color), color).toBe(true)+ for (const color of [...Object.values(ACCENT), ...PALETTE, INK, MUTED, LOUD, ...Object.values(TONE), ...Object.values(NAV_ACCENT)]) expect(isXterm256(color), color).toBe(true)})it('has ink on every accent that can be read (contrast 4.5 or more), and no two groups share a colour', () => {@@ -128,3 +130,22 @@ describe('the menu badges', () => {for (const view of Object.keys(badgesOf(state, 0))) expect(VIEWS.some(entry => entry.id === view), view).toBe(true)})})++describe('the accent a page wears', () => {+ it('gives every nav group one of the menu\'s five accents, so a page\'s cards match the group the menu lists it under', () => {+ expect(NAV_GROUPS.map(group => group.title).sort()).toEqual(Object.keys(NAV_ACCENT).sort())+ for (const color of Object.values(NAV_ACCENT)) expect(PALETTE).toContain(color)+ expect(new Set(Object.values(NAV_ACCENT)).size).toBe(Object.keys(NAV_ACCENT).length)+ })++ it('gives every page in a group the accent of that group, and the menu none', () => {+ for (const group of NAV_GROUPS) for (const view of group.rows.flat()) expect(accentOfView(view), view).toBe(NAV_ACCENT[group.title])+ expect(accentOfView('menu')).toBeNull()+ })++ it('matches the menu: a page is coloured as the menu group that lists it', () => {+ const menuAccent = (view: string) => GROUPS.find(group => group.sections.some(section => section.items.some(item => item.go === view)))?.title++ for (const group of NAV_GROUPS) for (const view of group.rows.flat()) expect(ACCENT[menuAccent(view) ?? ''], view).toBe(NAV_ACCENT[group.title])+ })+})diff --git a/plugins/ruflo-console/tests/mission-strip.spec.ts b/plugins/ruflo-console/tests/mission-strip.spec.tsnew file mode 100644index 0000000000..3fe583fc08--- /dev/null+++ b/plugins/ruflo-console/tests/mission-strip.spec.ts@@ -0,0 +1,59 @@+/**+ * The Mission Control strip's words, pure: what the mission is doing in one line, the bar and the percentage. Run with+ * npx vitest run plugins/ruflo-console/tests/mission-strip.spec.ts+ */+import { describe, expect, it } from 'vitest'++import { barCells, percentOf, stripStatus, type StripInput } from '../hooks/mission-strip'++const base: StripInput = { done: 3, total: 15, paused: false, running: null, next: null }++describe('what the strip says is happening', () => {+ it('says which of the four things "nothing ready" used to mean', () => {+ expect(stripStatus({ ...base, total: 0, done: 0 })).toEqual({ text: 'no tasks yet: plan the goal first', tone: 'wait' })+ expect(stripStatus({ ...base, done: 15 })).toEqual({ text: '✔ every task is done', tone: 'done' })+ expect(stripStatus({ ...base, running: { id: 't4', title: 'Write tests' } })).toEqual({ text: '◐ running t4 Write tests', tone: 'live' })+ expect(stripStatus(base)).toEqual({ text: 'waiting: the next task needs one that is not done', tone: 'wait' })+ })++ it('names the next task with its stage when one can be handed out', () => {+ expect(stripStatus({ ...base, next: { id: 't1', stage: 'research', title: 'Research prior art' } })).toEqual({ text: '▶ next t1 [research] Research prior art', tone: 'ready' })+ })++ it('says paused before it says what is running or next, and done before paused', () => {+ expect(stripStatus({ ...base, paused: true, running: { id: 't4', title: 'x' }, next: { id: 't5', stage: 's', title: 'y' } }).tone).toBe('paused')+ expect(stripStatus({ ...base, done: 15, paused: true }).tone).toBe('done')+ expect(stripStatus({ ...base, total: 0, done: 0, paused: true }).tone).toBe('wait')+ })++ it('cuts a long task title to fit with an ellipsis, never past the width', () => {+ const long = stripStatus({ ...base, next: { id: 't1', stage: 'research', title: 'x'.repeat(200) } }, 48)++ expect(long.text.length).toBeLessThanOrEqual(48)+ expect(long.text.endsWith('…')).toBe(true)+ })+})++describe('the bar', () => {+ it('fills in proportion, always the same width, and none for no tasks or none done', () => {+ expect(barCells(0, 15)).toEqual({ filled: 0, empty: 10 })+ expect(barCells(0, 0)).toEqual({ filled: 0, empty: 10 })+ expect(barCells(15, 15)).toEqual({ filled: 10, empty: 0 })+ expect(barCells(3, 15)).toEqual({ filled: 2, empty: 8 })+ expect(barCells(7, 15, 20)).toEqual({ filled: 9, empty: 11 })+ })++ it('stays inside its width when the numbers are odd', () => {+ expect(barCells(20, 15)).toEqual({ filled: 10, empty: 0 })+ expect(barCells(-3, 15)).toEqual({ filled: 0, empty: 10 })+ expect(barCells(1, -1)).toEqual({ filled: 0, empty: 10 })+ })++ it('gives a percentage that is whole and between 0 and 100', () => {+ expect(percentOf(0, 15)).toBe(0)+ expect(percentOf(3, 15)).toBe(20)+ expect(percentOf(15, 15)).toBe(100)+ expect(percentOf(1, 0)).toBe(0)+ expect(percentOf(30, 15)).toBe(100)+ })+})diff --git a/v3/docs/adr/ADR-430-console-main-menu-accents-chips-and-badges.md b/v3/docs/adr/ADR-430-console-main-menu-accents-chips-and-badges.mdindex 533df065c4..cf7c778347 100644--- a/v3/docs/adr/ADR-430-console-main-menu-accents-chips-and-badges.md+++ b/v3/docs/adr/ADR-430-console-main-menu-accents-chips-and-badges.md@@ -51,3 +51,16 @@ It has not been seen. The spec holds the colours, the contrast and what a badge- **The palette strip is animated.** It is now a picture (`palettePicture`, registered by `picturesOf` for the menu in the BBS look), not a row of Texts: one block of each accent across the width and a band of light that sweeps along it and starts again, about 28 cells a second, three cells a frame at the default 8 fps. Being a picture, it moves with the frame loop that already runs for the menu's other pictures, and costs one element, not one per cell. At `t` = 0 the light is off the strip and the cells are exactly the accents, so with `fps: 0` it draws that still strip; a surface that cannot draw pictures gets the Text strip as before. It is decoration and carries no data.- **The menu lists every page, but the search finds only pages.** Checked: all 26 pages and the three commands (palette, help, log off) are on the menu, none missing and none unknown. The menu prompt and the nav search match a page's name, key, group and one-line description, so a feature that is a section of a page (sentries, the loop manager, Updates in Settings, AIDefence) was not found by its own name. The descriptions of Security, Settings and Automation now name them, and `tests/nav-state.spec.ts` holds that searching for `sentries`, `doctor`, `aidefence`, `updates`, `loops`, `autopilot` and `kanban` finds the page each is on (which found one more gap, `aidefence`, when first run).- **Tests:** `tests/diagrams.spec.ts` (4): one row of blocks, exactly the colours at rest, a band that brightens only the cells it is on, moves about three cells a frame and starts again, and survives a tiny width and no colours; `tests/pure.spec.ts`: the strip is on the BBS menu only, as wide as the menu's rows, and still at fps 0.++## 8. Amendment: the strip, the prompt, the footer and the sections wear the same design++What the owner pasted from the menu: `test ▯▯▯▯▯▯▯▯▯▯ 0/15` over `nothing ready ⏸ pause`, then `T - 01:00`, then `(1:1) (ruflo: ruflo): a key or a name, then Enter (? for help)`, then a footer whose buttons ran off the edge (`keys of…[ Palette ][ Actions ]…[ Help ][`). The last line of the message was cut off at "make the sub sections use a similar design for f…", so "sub sections" is read here as the sections of every page, not the menu's sub-sections only; if it meant something else (a footer, a form), say so.++- **The Mission Control strip is a card** in the BBS look: a solid amber title bar, the goal with a coloured bar and a percentage, a status line, and the buttons under it. The plain look keeps its lines. Every key is the one the plain strip had (`menu-goal`, `menu-mc-next`, `menu-mc-pause`, `menu-go-missions-top`).+- **"nothing ready" said four different things.** `stripStatus` now says which: `no tasks yet: plan the goal first`, `✔ every task is done`, `⏸ paused: resume to carry on`, `◐ running t4 …`, `▶ next t1 [research] …`, or `waiting: the next task needs one that is not done`, in a colour for each. Its title budget follows the real prefix, which a spec found it did not at first (the line could overrun its width).+- **`T - 01:00` is gone.** It repeated the status bar's `Online 01:00`.+- **The prompt is in a box** like the cards (violet, the TOOLS accent), with the project and a `❯` as its label and a shorter placeholder. The plain look keeps `(1:1) (ruflo: project)`.+- **The footer fits.** It was a status text and seven buttons with no width budget, so below about a hundred columns the last buttons were cut in half. Each button now has a full label, a short one and a priority; `fitFooter` shows as many in full as fit, shortens the least important first (`Refresh` becomes `r`), and only then drops them, and a dropped button is kept hidden so its hotkey still works. In the BBS look the status is coloured (`[LINK OK]` green, `keys on` green, `keys off` amber).+- **Sections and cards wear the page's accent.** A page's section headers (the title, the rule, and the right-hand text) and the border of its cards are drawn in the accent of the nav group it is in, which is the colour of the menu group that lists it: Swarm pages amber, Mind cyan, Safety red, Network green, Tools violet. A spec holds that every nav group has one of the five accents, that every page in a group has it, and that it is the colour the menu gives the same page.+- **Tests:** `tests/footer-layout.spec.ts` (6: full when there is room, shortening in priority order, never wider than its room at any width, dropping the least important, hiding everything with no room, keeping the order); `tests/mission-strip.spec.ts` (7); `tests/menu-style.spec.ts` (12: now also the status tones and the nav accents are on the 256 palette, and agree with the menu).+- **Not seen.** A header's title is a Button, which cannot be coloured, so on a page the title keeps the theme's colour and only its rule, its right-hand text and the card border take the accent. The strip card, the boxed prompt and the footer's coloured status are in the kit tests (which need the host package) and have not been drawn.