Skip to content

armgit / ruflo

Public Imported from GitHub
0

🌊 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

fix(ruflo-console): narrow pane: icon row slack and no-shrink, banner and page titles that fit, MENU chip, wrapping network links (ADR-430)

ruv23ad061f43b9
diff --git a/plugins/ruflo-console/hooks/gfx/pictures.ts b/plugins/ruflo-console/hooks/gfx/pictures.ts
index 13bf2f5e2e..3c44c1e7c4 100644
--- a/plugins/ruflo-console/hooks/gfx/pictures.ts
+++ b/plugins/ruflo-console/hooks/gfx/pictures.ts
@@ -341,9 +341,14 @@ export function bannerPicture(project: string, columns: number, t: number, age =
// The title, with the version and build when they fit beside the logo; when they do not, the title whole rather than cut mid-word.
const title = 'â–‘â–’â–“ AGENT SWARM CONSOLE'
const full = `${title} v${CONSOLE_VERSION}${getBuild() === '' ? '' : ` · ${getBuild()}`}`
+ // The longest that fits, never cut mid-word: version and build, the title, a shorter title, the shortest.
+ const room = columns - x0
+ const shown = [full, title, 'â–‘â–’â–“ SWARM CONSOLE', 'â–‘â–’â–“ CONSOLE'].find(text => text.length <= room) ?? 'â–‘â–’â–“ CONSOLE'
- grid.text(x0, 0, (full.length <= columns - x0 ? full : title).slice(0, columns - x0), NEON_MAGENTA)
- const node = `▸ npx ruflo · ${project}`.slice(0, columns - x0 - 2)
+ grid.text(x0, 0, shown.slice(0, room), NEON_MAGENTA)
+
+ const line = `▸ npx ruflo · ${project}`
+ const node = line.length <= room - 2 ? line : `${line.slice(0, Math.max(1, room - 3))}…`
grid.text(x0, 1, node, NEON_CYAN)
if (Math.floor(t / 530) % 2 === 0 && x0 + node.length + 1 < columns) grid.set(x0 + node.length + 1, 1, 'â–ˆ', NEON_CYAN)
diff --git a/plugins/ruflo-console/hooks/icon-layout.ts b/plugins/ruflo-console/hooks/icon-layout.ts
index 5eacd68596..01a3300976 100644
--- a/plugins/ruflo-console/hooks/icon-layout.ts
+++ b/plugins/ruflo-console/hooks/icon-layout.ts
@@ -22,11 +22,18 @@ export const ICONS = [
/** Cells after the last icon, so the row does not touch the host's ✕ at the edge. */
export const ICON_MARGIN = 2
+/**
+ * Cells kept free beside the row. The pane's body is a few cells narrower than its column count (the frame and the close mark), and the host's flex
+ * layout shrinks whatever does not fit: a lit icon (a text box) collapsed to nothing and the last word wrapped onto a second line when the row was
+ * sized to the exact count. Found by recording the real pane.
+ */
+export const ICON_SLACK = 4
+
/** The row's width in cells: glyph and a cell each, or glyph, word and a cell each; then the margin. */
export const iconCells = (withWords: boolean): number => ICONS.reduce((sum, icon) => sum + (withWords ? icon.glyph.length + 1 + icon.word.length + 1 : icon.glyph.length + 1), 0) + ICON_MARGIN
/** Whether each icon spells its word, given the pane's width and how many cells the header art uses of the first line. */
-export const iconsSpellWords = (columns: number, headerCells: number): boolean => columns >= ICON_WORDS_FROM && headerCells + iconCells(true) <= columns
+export const iconsSpellWords = (columns: number, headerCells: number): boolean => columns >= ICON_WORDS_FROM && headerCells + iconCells(true) + ICON_SLACK <= columns
/** How many columns of a cell grid hold anything: the right edge of what is drawn. `glyphs` is the grid's first cell of each three (glyph, fg, bg). */
export function usedColumns(cells: Uint32Array, columns: number, rows: number): number {
diff --git a/plugins/ruflo-console/hooks/views/frames.ts b/plugins/ruflo-console/hooks/views/frames.ts
index 5c6c78d386..7a3c7613e8 100644
--- a/plugins/ruflo-console/hooks/views/frames.ts
+++ b/plugins/ruflo-console/hooks/views/frames.ts
@@ -21,7 +21,7 @@ import { activityPicture, bannerPicture, bootPicture, titlePicture, curvePicture
import type { Grid } from '../gfx/raster'
import { PROBES, severityOf } from '../data/cli'
import { EXPECTED_IN_MARKET, RUFLO_MARKET } from '../data/snapshot'
-import { iconCells, usedColumns } from '../icon-layout'
+import { ICON_SLACK, iconCells, usedColumns } from '../icon-layout'
import { entryAge } from '../menu-entry'
import { BOOT_MIN_MS, isBooting, isCompactPane, VIEWS, type State } from '../state'
import { CARD_COLUMNS, hasCards } from './card'
@@ -128,12 +128,26 @@ const scoreShown = new WeakMap<object, number>()
* to 120 cells would sit under the icons. Built at the widest allowed size, then again at the width it really used.
*/
function fitHeader(paneColumns: number, build: (columns: number) => Grid, max: number): Grid {
- const wide = build(Math.max(8, Math.min(max, paneColumns - iconCells(false) - 1)))
+ const wide = build(Math.max(8, Math.min(max, paneColumns - iconCells(false) - ICON_SLACK)))
const used = usedColumns(wide.cells, wide.columns, wide.rows)
return used > 0 && used < wide.columns ? build(used) : wide
}
+/** The first name whose art fits the room beside the icon row, built at the width it uses; the last, clipped to the room, when none does. */
+function titleThatFits(paneColumns: number, names: readonly string[], build: (name: string, columns: number) => Grid): Grid {
+ const room = Math.max(8, Math.min(120, paneColumns - iconCells(false) - ICON_SLACK))
+
+ for (const name of names) {
+ const wide = build(name, 120)
+ const used = usedColumns(wide.cells, wide.columns, wide.rows)
+
+ if (used > 0 && used <= room) return build(name, used)
+ }
+
+ return build(names.at(-1) as string, room)
+}
+
export function picturesOf(state: State, columns: number, nowMs: number, t: number): Map<string, Grid> {
const pictures = new Map<string, Grid>()
// A page in cards (views/card.ts) is narrower by the border and padding: its pictures are drawn to that width, by the render and by the frame loop alike.
@@ -165,7 +179,11 @@ export function picturesOf(state: State, columns: number, nowMs: number, t: numb
// The menu is the RUFLO board itself; every other page reads `RUFLO | PAGE`, the logo's style left of the page's name.
const name = state.view === 'menu' && !state.isHelp && !state.palette.isOpen ? 'ruflo bbs' : `ruflo | ${page}`
- pictures.set('title', fitHeader(columns, size => titlePicture(name, size, t, headerAge), 120))
+ // The first of these whose art fits beside the icons: the whole name, the page alone, its short name; clipped only as a last resort.
+ const shortName = VIEWS.find(view => view.id === state.view)?.short ?? page
+ const names = state.view === 'menu' && !state.isHelp && !state.palette.isOpen ? [name] : [name, page, shortName]
+
+ pictures.set('title', titleThatFits(columns, names, (candidate, size) => titlePicture(candidate, size, t, headerAge)))
}
switch (state.view) {
diff --git a/plugins/ruflo-console/hooks/views/help.ts b/plugins/ruflo-console/hooks/views/help.ts
index 5bf1bf5a59..badcf74b40 100644
--- a/plugins/ruflo-console/hooks/views/help.ts
+++ b/plugins/ruflo-console/hooks/views/help.ts
@@ -116,7 +116,7 @@ export function helpView(ctx: Ctx): RenderElement {
? text(ctx, ' this surface has no text field: /ruflo help, or press ✦ Ask Claude on any page', { dimColor: true })
: ctx.kit.Input({
key: 'help-input',
- label: 'ruHelp ›',
+ label: ctx.columns < 70 ? '›' : 'ruHelp ›',
placeholder: 'ask anything: how do I start a swarm? set a budget? what is a claim?',
value: state.help.query,
submitLabel: 'ask',
diff --git a/plugins/ruflo-console/hooks/views/nav.ts b/plugins/ruflo-console/hooks/views/nav.ts
index df11a583ef..d8d67c14ff 100644
--- a/plugins/ruflo-console/hooks/views/nav.ts
+++ b/plugins/ruflo-console/hooks/views/nav.ts
@@ -38,7 +38,9 @@ export function groupedTabs(ctx: Ctx, hasHotkey: (view: View) => boolean): Rende
const badges = badgesOf(state, ctx.nowMs)
const badgeText = (view: View): string => (badges[view.id] === undefined ? '' : ` ${badges[view.id]?.text}`)
// The open page always spells out its whole name, whatever the form (see `tab`), so that is how wide it is.
- const openName = (view: View) => (isBbs() ? `[${view.key === '' ? '' : `${view.key}: `}${view.icon} ${view.label.toUpperCase()}]` : `${view.key === '' ? '' : `${view.key}: `}${view.icon} ${view.label}`)
+ // (On the main menu of a narrow card the chip says MENU, so it is not cut to "MAIN M…" beside the groups.)
+ const nameOf = (view: View) => (view.id === 'menu' && inner < 72 ? 'Menu' : view.label)
+ const openName = (view: View) => (isBbs() ? `[${view.key === '' ? '' : `${view.key}: `}${view.icon} ${nameOf(view).toUpperCase()}]` : `${view.key === '' ? '' : `${view.key}: `}${view.icon} ${nameOf(view)}`)
const cells = (view: View, form: string) => (view.id === open ? openName(view).length + 1 : (hasHotkey(view) && view.key !== '' ? 3 : 0) + spell(view, form).length + badgeText(view).length + 3)
const widest = (form: string) => Math.max(0, ...pages.map(ids => ids.reduce((sum, id) => sum + (find(id) === undefined ? 0 : cells(find(id) as View, form)), 0)))
// auto: the richest form whose widest row fits the page; the others are the person's choice (Settings).
@@ -65,7 +67,7 @@ export function groupedTabs(ctx: Ctx, hasHotkey: (view: View) => boolean): Rende
// The open page names itself whatever the style, as the flat tab bar did: [3: 📌 CLAIMS], [0: 📟 MAIN MENU].
const accent = isBbs() ? accentOfView(view.id) : null
- if (view.id === open) return ctx.kit.Box({ key: `tab-${view.id}`, children: [ctx.kit.Text({ ...(accent === null ? { bold: true, color: THEME.head } : chip(accent)), wrap: 'truncate-end', children: isBbs() ? `[${prefix}${view.icon} ${view.label.toUpperCase()}]` : `${prefix}${view.icon} ${view.label}` })] })
+ if (view.id === open) return ctx.kit.Box({ key: `tab-${view.id}`, children: [ctx.kit.Text({ ...(accent === null ? { bold: true, color: THEME.head } : chip(accent)), wrap: 'truncate-end', children: isBbs() ? `[${prefix}${view.icon} ${nameOf(view).toUpperCase()}]` : `${prefix}${view.icon} ${nameOf(view)}` })] })
return ctx.kit.Button({ key: `tab-${view.id}`, label: ` ${words}${badgeText(view)} `, ...(hasHotkey(view) && view.key !== '' && { hotkey: view.key }), plain: true, dimColor: true, onPress: () => ctx.act.view(view.id) })
}
diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.ts
index 3862beac6d..94c8e2e14c 100644
--- a/plugins/ruflo-console/hooks/views/pane.ts
+++ b/plugins/ruflo-console/hooks/views/pane.ts
@@ -266,13 +266,19 @@ function wildcat(ctx: Ctx): { strip: RenderElement[]; art: RenderElement[] } {
ctx.kit.Text({ bold: true, color: THEME.ok, children: clip('AGENTS WELCOME.', Math.max(4, ctx.columns - 16)) }),
], 'welcome'),
// Each network is a link to the view that shows it.
- row(ctx, [
- ctx.kit.Text({ color: THEME.head, children: 'NETWORKS: ' }),
- ...NETWORKS.flatMap(([name, view], i) => [
- ...(i > 0 ? [ctx.kit.Text({ color: THEME.info, dimColor: true, children: ' * ' })] : []),
- ctx.kit.Button({ key: `net-${view}-${i}`, label: name, plain: true, onPress: () => ctx.act.view(view) }),
- ]),
- ], 'networks'),
+ // (A row that wraps, so a narrow pane breaks it onto a second line rather than squeezing the names together.)
+ ctx.kit.Box({
+ flexDirection: 'row',
+ flexWrap: 'wrap',
+ key: 'networks',
+ children: [
+ ctx.kit.Text({ color: THEME.head, children: 'NETWORKS: ' }),
+ ...NETWORKS.flatMap(([name, view], i) => [
+ ...(i > 0 ? [ctx.kit.Text({ color: THEME.info, dimColor: true, children: ' * ' })] : []),
+ ctx.kit.Button({ key: `net-${view}-${i}`, label: name, plain: true, onPress: () => ctx.act.view(view) }),
+ ]),
+ ],
+ }),
],
art: art !== undefined && ctx.kit.Raster !== undefined ? [ctx.kit.Raster(art.toRaster('title'))] : [],
}
@@ -312,6 +318,7 @@ export function iconRow(ctx: Ctx): RenderElement {
return ctx.kit.Box({
flexDirection: 'row',
+ flexShrink: 0,
key: 'pane-icons',
children: [
...ICONS.map(icon => {
@@ -320,7 +327,7 @@ export function iconRow(ctx: Ctx): RenderElement {
const entry = press[icon.id]
return entry.isCurrent
- ? ctx.kit.Box({ key, children: [ctx.kit.Text({ bold: true, color: THEME.head, children: label })] })
+ ? ctx.kit.Box({ key, flexShrink: 0, children: [ctx.kit.Text({ bold: true, color: THEME.head, children: label })] })
: ctx.kit.Button({ key, label, plain: true, dimColor: true, onPress: entry.run })
}),
ctx.kit.Text({ children: ' '.repeat(ICON_MARGIN) }),
diff --git a/plugins/ruflo-console/tests/pane-icons.spec.ts b/plugins/ruflo-console/tests/pane-icons.spec.ts
index 12baf79cae..79447a22a1 100644
--- a/plugins/ruflo-console/tests/pane-icons.spec.ts
+++ b/plugins/ruflo-console/tests/pane-icons.spec.ts
@@ -156,19 +156,19 @@ describe('the icon row', () => {
describe('the icon row never runs under the header art', () => {
it('spells words only when the pane is wide and the art leaves room for the whole row', async () => {
- const { iconCells, iconsSpellWords, ICON_WORDS_FROM } = await import('../hooks/icon-layout')
+ const { iconCells, iconsSpellWords, ICON_SLACK, ICON_WORDS_FROM } = await import('../hooks/icon-layout')
expect(iconCells(true)).toBe(47)
expect(iconCells(false)).toBe(12)
expect(iconsSpellWords(ICON_WORDS_FROM - 1, 0)).toBe(false)
expect(iconsSpellWords(ICON_WORDS_FROM, 0)).toBe(true)
- expect(iconsSpellWords(126, 126 - 47)).toBe(true)
- expect(iconsSpellWords(126, 126 - 46)).toBe(false)
+ expect(iconsSpellWords(126, 126 - 47 - ICON_SLACK)).toBe(true)
+ expect(iconsSpellWords(126, 126 - 47 - ICON_SLACK + 1)).toBe(false)
})
it('draws every page\'s header art narrower than the pane by at least the glyph row, at every width from 40 to 220', async () => {
const { picturesOf } = await import('../hooks/views/frames')
- const { iconCells } = await import('../hooks/icon-layout')
+ const { ICON_SLACK, iconCells } = await import('../hooks/icon-layout')
const { VIEWS } = await import('../hooks/state')
const problems: string[] = []
@@ -185,7 +185,7 @@ describe('the icon row never runs under the header art', () => {
const pictures = picturesOf(state, columns, Date.now(), 0)
const art = pictures.get(view.id === 'menu' ? 'header' : 'title')
- if (art !== undefined && art.columns + iconCells(false) > columns) problems.push(`${view.id} at ${columns}: art ${art.columns} + icons ${iconCells(false)} > ${columns}`)
+ if (art !== undefined && art.columns + iconCells(false) + ICON_SLACK > columns) problems.push(`${view.id} at ${columns}: art ${art.columns} + icons ${iconCells(false)} + slack > ${columns}`)
}
}
@@ -222,3 +222,99 @@ describe('the icon row never runs under the header art', () => {
expect(page.art + iconCells(false)).toBeLessThanOrEqual(126)
})
})
+
+describe('the icon row does not shrink in the host\'s flex layout', () => {
+ it('is told not to shrink, nor is the lit icon, so a tight row clips the art instead of collapsing the icon', () => {
+ const tree = draw('settings', 126, 0)
+
+ expect(key(tree, 'pane-icons')?.props.flexShrink).toBe(0)
+ expect(key(tree, 'pane-icon-settings')?.props.flexShrink).toBe(0)
+ })
+})
+
+describe('a narrow pane reads cleanly', () => {
+ const rowOf = (grid: { columns: number; glyph: (x: number, y: number) => number }, y: number): string => Array.from({ length: grid.columns }, (_, x) => String.fromCodePoint(grid.glyph(x, y))).join('')
+
+ it('keeps the banner\'s title whole: the longest of version, title, shorter title that fits', async () => {
+ const { bannerPicture } = await import('../hooks/gfx/pictures')
+
+ expect(rowOf(bannerPicture('p', 90, 0), 0)).toMatch(/AGENT SWARM CONSOLE v\d/)
+ expect(rowOf(bannerPicture('p', 46, 0), 0)).toContain('AGENT SWARM CONSOLE')
+ expect(rowOf(bannerPicture('p', 44, 0), 0)).toContain('SWARM CONSOLE')
+ expect(rowOf(bannerPicture('p', 44, 0), 0)).not.toMatch(/CONSOL\s*$/)
+ expect(rowOf(bannerPicture('p', 34, 0), 0)).toContain('CONSOLE')
+ })
+
+ it('clips a long project name with an ellipsis, not mid-letter', async () => {
+ const { bannerPicture } = await import('../hooks/gfx/pictures')
+ const second = rowOf(bannerPicture('a-very-long-project-name', 44, 0), 1)
+
+ expect(second).toContain('…')
+ expect(second.trimEnd().length).toBeLessThanOrEqual(44)
+ })
+
+ it('draws a page title that fits the pane, whole: the page alone when the ruflo prefix will not fit, and never clipped mid-letter', async () => {
+ const { picturesOf } = await import('../hooks/views/frames')
+ const { titlePicture } = await import('../hooks/gfx/pictures')
+ const { usedColumns, iconCells, ICON_SLACK } = await import('../hooks/icon-layout')
+ const { VIEWS } = await import('../hooks/state')
+ const problems: string[] = []
+
+ for (const view of VIEWS) {
+ if (view.id === 'menu') continue
+
+ for (const columns of [50, 60, 70, 90, 126]) {
+ const state = newState({})
+
+ state.options.look = 'bbs'
+ state.options.boot = false
+ state.view = view.id
+ state.pane.columns = columns
+ state.snapshot = null
+
+ const art = picturesOf(state, columns, Date.now(), 0).get('title')
+ const unclipped = [`ruflo | ${view.label}`, view.label, view.short].map(name => {
+ const grid = titlePicture(name, 120, 0)
+
+ return usedColumns(grid.cells, grid.columns, grid.rows)
+ })
+ const room = columns - iconCells(false) - ICON_SLACK
+
+ // Whole means: its width is exactly the width of one of the unclipped names (or, when none fits the room, the room itself).
+ if (art !== undefined && !unclipped.includes(art.columns) && art.columns !== room) problems.push(`${view.id} at ${columns}: art ${art.columns}, names ${unclipped.join('/')}, room ${room}`)
+ if (art !== undefined && unclipped.some(width => width <= room) && art.columns > room) problems.push(`${view.id} at ${columns}: art wider than the room`)
+ // And the first name that fits is the one chosen.
+ const firstFit = unclipped.find(width => width <= room)
+
+ if (art !== undefined && firstFit !== undefined && art.columns !== firstFit) problems.push(`${view.id} at ${columns}: chose ${art.columns}, first that fits is ${firstFit}`)
+ }
+ }
+
+ expect(problems).toEqual([])
+ })
+
+ it('shows the main menu chip as MENU in a narrow nav, and the networks row wraps', async () => {
+ const tree = draw('menu', 60, 0)
+ const chipText = flat(tree).find(node => /\[0: .*MENU\]/.test(String(node.props.children)))
+
+ expect(chipText).toBeDefined()
+ expect(String(chipText?.props.children)).not.toContain('MAIN')
+ expect(key(tree, 'networks')?.props.flexWrap).toBe('wrap')
+ })
+
+ it('shortens the ruHelp field\'s label to the arrow when the pane is narrow', async () => {
+ const { helpView } = await import('../hooks/views/help')
+ const labelAt = (columns: number): string => {
+ const state = newState({})
+
+ state.isHelp = true
+
+ const tree = helpView({ kit, state, nowMs: Date.now(), columns, pictures: new Map(), act: recorder('') as never, cards: true } as unknown as Ctx) as unknown as El
+
+ return String(flat(tree).find(node => node.props.key === 'help-input')?.props.label)
+ }
+
+ expect(labelAt(56)).toBe('›')
+ expect(labelAt(120)).toBe('ruHelp ›')
+ })
+})
diff --git a/v3/docs/adr/ADR-430-console-menu-design.md b/v3/docs/adr/ADR-430-console-menu-design.md
index dcf8b5617a..86cbd4ec61 100644
--- a/v3/docs/adr/ADR-430-console-menu-design.md
+++ b/v3/docs/adr/ADR-430-console-menu-design.md
@@ -31,3 +31,7 @@ None of the glyphs is an emoji or has an emoji form (`?` drew visibly larger tha
Recording the walkthrough from the real pane found what the specs could not: the page title art (a Raster drawn padded to 120 cells) ran under the icon row on wide titles, pushing out `⟳ refresh` and hiding `⌘ palette`; the boot's scan grid clipped names mid-word (`Self-Evolu`, `Plugins &`); the palette opened with four red `n/a` entries and a `▶` best match Enter could not run; and the Cost guide's tip had lost a `$` (`$$` collapsed to `$` by a string replace). Fixes: the header pictures are built to the width they use and never wider than the pane leaves beside the icons (`hooks/icon-layout.ts`), and the icon row spells its words only when the pane is wide and the art leaves room for the whole row; the scan grid shows short names (Harness, Evolution, Plugins, Catalog, Cost, Perf, Terminal); entries that cannot run sort after those that can, so the `▶` is something Enter runs; the tip is restored and a spec guards it.
The console's smoke contract (step 5) now names its one network exception: the update check's single GET (`$.http.fetch` in `register.ts`, used by `update-flow.ts` alone, ADR-429), and fails on any other. `controller.ts` is back under 500 lines (the drill-down log read moved to `drill-logs.ts`).
+
+## Amendment (2026 10 03, later): a narrow pane, seen at phone width
+
+The tour GIF has to read on a phone, where GitHub shrinks it to the screen width, so it is recorded from the narrow cockpit (60 columns) and the narrow layout was looked at as a phone reader would see it. Fixes from that: the icon row keeps four cells of slack and does not shrink in the host's flex layout (a lit icon collapsed to nothing and the last word wrapped when it was sized to the exact column count); the banner shows the longest title that fits (version, `AGENT SWARM CONSOLE`, `SWARM CONSOLE`, `CONSOLE`) and clips a long project name with an ellipsis; a page title that will not fit beside the icons drops the `ruflo |` prefix, then uses the page's short name, instead of being clipped mid-letter (`RUFLO SW`); the main menu's chip in a narrow nav says `MENU`, not `MAIN M…`; the welcome strip's network links wrap; the ruHelp field's label is just `›` when narrow.