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): compact layout leads with the title; the menu wraps its stage line and fits its status bar at small widths

ruv3e1ef5e5aebd
diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.ts
index 6de4f0e474..47c2b9a382 100644
--- a/plugins/ruflo-console/hooks/views/common.ts
+++ b/plugins/ruflo-console/hooks/views/common.ts
@@ -165,6 +165,21 @@ export function tagChip(ctx: Ctx, text: string, color: string): RenderElement {
return ctx.kit.Box({ flexDirection: 'row', children: [ctx.kit.Text({ children: ' ' }), ctx.kit.Text({ ...chip(ground), children: text })] })
}
+/** Words wrapped to `width`, so a long line reads as several instead of running off the edge. */
+export function wrap(line: string, width: number): string[] {
+ const out: string[] = []
+ let current = ''
+
+ for (const word of line.split(' ')) {
+ if (current !== '' && current.length + word.length + 1 > width) {
+ out.push(current)
+ current = word
+ } else current = current === '' ? word : `${current} ${word}`
+ }
+
+ return current === '' ? out : [...out, current]
+}
+
export const clip = (text: string, width: number): string => (text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}…`)
export function ago(atMs: number | null | undefined, nowMs: number): string {
diff --git a/plugins/ruflo-console/hooks/views/help.ts b/plugins/ruflo-console/hooks/views/help.ts
index 6d8a0a8311..5bf1bf5a59 100644
--- a/plugins/ruflo-console/hooks/views/help.ts
+++ b/plugins/ruflo-console/hooks/views/help.ts
@@ -4,22 +4,7 @@ import { GROUP_BLURB, HELP_GROUPS, searchDocs, type Go, type HelpStep, type Help
import { TOPICS, topicById } from '../help-topics'
import { START_LABEL } from '../starts'
import { VIEWS } from '../state'
-import { button, clip, col, row, rule, section, text, THEME, type Ctx } from './common'
-
-/** Words wrapped to `width`, so a long step reads as lines instead of running off the edge. */
-export function wrap(line: string, width: number): string[] {
- const out: string[] = []
- let current = ''
-
- for (const word of line.split(' ')) {
- if (current !== '' && current.length + word.length + 1 > width) {
- out.push(current)
- current = word
- } else current = current === '' ? word : `${current} ${word}`
- }
-
- return current === '' ? out : [...out, current]
-}
+import { button, clip, col, row, rule, section, text, THEME, wrap, type Ctx } from './common'
/** The words on a step's button: its own label, else what its target is. */
export function goLabel(step: HelpStep): string {
@@ -157,3 +142,5 @@ export function helpView(ctx: Ctx): RenderElement {
return col(ctx, rows, 'help')
}
+
+export { wrap }
diff --git a/plugins/ruflo-console/hooks/views/menu.ts b/plugins/ruflo-console/hooks/views/menu.ts
index 43c93ce807..c8874b9388 100644
--- a/plugins/ruflo-console/hooks/views/menu.ts
+++ b/plugins/ruflo-console/hooks/views/menu.ts
@@ -164,8 +164,11 @@ export function menuView(ctx: Ctx): RenderElement {
// The status bar under the box: the line, then what is live in this project, then how long the board has been open.
const online = mmss(nowMs - (state.pane.bootAtMs > 0 ? state.pane.bootAtMs : state.loadedAtMs))
const facts = barParts(state, nowMs).slice(0, 3)
- const line = ` ${state.snapshot?.isRufloProject === true ? 'Registered' : 'Unregistered'} β”‚ ANSI-BBS β”‚ 115200Β·N81 FDX`
+ const base = ` ${state.snapshot?.isRufloProject === true ? 'Registered' : 'Unregistered'}`
+ const modem = ' β”‚ ANSI-BBS β”‚ 115200Β·N81 FDX'
const right = ` Online ${online} `
+ // The modem text goes first when the pane is narrow, then the label is cut: the bar never runs past the edge.
+ const line = ctx.columns >= base.length + modem.length + right.length + 4 ? `${base}${modem}` : clip(base, Math.max(4, ctx.columns - right.length - 1))
let room = Math.max(4, ctx.columns - right.length - line.length)
rows.push(text(ctx, ' '))
diff --git a/plugins/ruflo-console/hooks/views/mission-control.ts b/plugins/ruflo-console/hooks/views/mission-control.ts
index 0c2fdb354e..c2fc8a2f3b 100644
--- a/plugins/ruflo-console/hooks/views/mission-control.ts
+++ b/plugins/ruflo-console/hooks/views/mission-control.ts
@@ -5,7 +5,7 @@ import { guidanceStatus } from '../mission-guidance'
import { activeMission, derive, mcOf, nextTask, progressOf, rufloTaskOf, type Derived, type LedgerTask, type McTab, type MissionRecord } from '../mission-control'
import { ACCENT, chip as inverseChip, 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 { ago, button, clip, col, confirmHere, isBbs, row, rule, section, text, THEME, wrap, type Ctx } from './common'
import { GOALS_PLUGIN, isAvailable, MISSION_SKILLS, slashOf } from '../mission-skills'
import { observationRows } from './missions'
import { capabilityRows, launchRows } from './mission-launch'
@@ -206,6 +206,10 @@ function controlRows(ctx: Ctx, mission: MissionRecord): RenderElement[] {
return rows
}
+/** The mission's stages on one dim line, wrapped to the width so a narrow pane reads it as lines instead of losing the end. */
+const FLOW = 'research β†’ create (ADRs, SOP) β†’ build β†’ test β†’ validate β†’ secure β†’ benchmark β†’ learn'
+const flowRows = (ctx: Ctx): RenderElement[] => wrap(FLOW, Math.max(20, ctx.columns - 4)).map((line, i) => text(ctx, `${i === 0 ? ' ' : ' '}${line}`, { dimColor: true }))
+
/**
* Mission Control: a goal becomes a SPARC plan found by a goal-oriented planner, the plan a governed mission and a ruflo
* task per node, and the Claude session does the work one task at a time with its result recorded in the task store
@@ -249,7 +253,7 @@ function stripCard(ctx: Ctx, mission: ReturnType<typeof activeMission>, field: R
const rows: RenderElement[] = [ctx.kit.Box({ key: 'menu-mc-bar', children: [ctx.kit.Text({ ...inverseChip(accent), 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'))
+ rows.push(...field, ...flowRows(ctx), row(ctx, [open], 'menu-mission-links'))
} else {
const tasks = ctx.state.snapshot?.tasks ?? []
const { done, total } = progressOf(mission, tasks)
@@ -311,7 +315,7 @@ export function missionStrip(ctx: Ctx): RenderElement[] {
return [
row(ctx, [title, open], 'menu-mission-title'),
...field,
- text(ctx, ' research β†’ create (ADRs, SOP) β†’ build β†’ test β†’ validate β†’ secure β†’ benchmark β†’ learn', { dimColor: true }),
+ ...flowRows(ctx),
text(ctx, ' '),
]
}
diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.ts
index 4e3f492ffc..cede7d5a5a 100644
--- a/plugins/ruflo-console/hooks/views/pane.ts
+++ b/plugins/ruflo-console/hooks/views/pane.ts
@@ -350,9 +350,9 @@ export function paneView(base: Ctx): RenderElement {
const isTerminal = ctx.state.view === 'terminal'
const gap = isBbs() && !isCompact && !isMenu ? [text(ctx, ' ')] : []
// The confirm row sits above the body in both layouts: below it, a tall view would push the question off the screen.
- // Compact keeps every page's title and its line of purpose; only the banner and the spacing go.
+ // Compact keeps every page's title and its line of purpose; only the banner and the spacing go. The title leads, then the tabs, as in the wide layout.
const parts = isCompact
- ? [tabs(ctx), ...bbs.art, ...(about !== null ? [about] : []), ...(confirm !== null && !confirmInline(ctx.state.view, ctx.state.pending?.scope) ? [confirm] : []), footer(ctx, attention.placed), body]
+ ? [...bbs.art, ...(about !== null ? [about] : []), tabs(ctx), ...(confirm !== null && !confirmInline(ctx.state.view, ctx.state.pending?.scope) ? [confirm] : []), footer(ctx, attention.placed), body]
: !isMenu && isBbs()
? // Every page but the main menu leads with its own title and purpose line; the welcome line and network links follow, with a blank row between the blocks.
[...bbs.art, ...(about !== null ? [about] : []), ...(cardsOn ? [] : [...gap, ...bbs.strip, ...gap]), tabs(ctx), ...(cardsOn ? [] : gap), footer(ctx, attention.placed), ...(confirm !== null && !isTerminal && !confirmInline(ctx.state.view, ctx.state.pending?.scope) ? [confirm] : []), body, ...(confirm !== null && isTerminal ? [confirm] : [])]
diff --git a/plugins/ruflo-console/tests/menu-wrap.spec.ts b/plugins/ruflo-console/tests/menu-wrap.spec.ts
new file mode 100644
index 0000000000..504438102a
--- /dev/null
+++ b/plugins/ruflo-console/tests/menu-wrap.spec.ts
@@ -0,0 +1,120 @@
+/**
+ * The main menu wraps at small widths: no text and no row of it is wider than the pane, at any width from 30 to 120 columns (the mission
+ * strip's stage line wraps; the status bar drops its modem text before it overflows). Run with
+ * npx vitest run plugins/ruflo-console/tests/menu-wrap.spec.ts
+ */
+import { afterEach, describe, expect, it } from 'vitest'
+
+import { newState } from '../hooks/state'
+import { setLook, type Ctx } from '../hooks/views/common'
+import { menuView } from '../hooks/views/menu'
+import { wrap } from '../hooks/views/common'
+
+type El = { props: Record<string, unknown>; kind: string }
+
+const make = (kind: string) => (props: Record<string, unknown>): El => ({ kind, props })
+const kit = { Box: make('Box'), Text: make('Text'), Button: make('Button'), Input: make('Input'), Raster: make('Raster') }
+const act = (() => {
+ const proxy: unknown = new Proxy(() => undefined, { get: (_t, key) => (key === 'then' ? undefined : proxy), apply: () => undefined })
+
+ return proxy
+})() as never
+
+/** How wide an element draws: a row is the sum of its parts, a column its widest part, a button its label and a gap. */
+function widthOf(el: unknown): number {
+ const node = el as El
+
+ if (typeof node !== 'object' || node === null) return 0
+
+ const kids = node.props.children
+
+ if (node.kind === 'Button') return String(node.props.label).length + 1
+ if (typeof kids === 'string') return kids.length
+ if (Array.isArray(kids)) return node.props.flexDirection === 'row' ? kids.reduce((sum: number, kid) => sum + widthOf(kid), 0) : Math.max(0, ...kids.map(widthOf))
+
+ return kids === undefined ? 0 : widthOf(kids)
+}
+
+/** Every row and text in the tree wider than `columns`, as a short description. */
+function overflow(columns: number): string[] {
+ const state = newState({})
+
+ state.options.look = 'bbs'
+ state.view = 'menu'
+ setLook('bbs')
+
+ const found: string[] = []
+ const walk = (el: unknown): void => {
+ const node = el as El
+
+ if (typeof node !== 'object' || node === null) return
+
+ // A box with its own width clips what is inside it (the group cards): they are checked by their own widths below.
+ if (node.kind === 'Text' || node.props.flexDirection === 'row') {
+ const width = widthOf(node)
+
+ if (width > columns) found.push(`${width} > ${columns}: ${String(node.props.key ?? (typeof node.props.children === 'string' ? node.props.children.slice(0, 24) : node.kind))}`)
+ }
+
+ const kids = node.props.children
+
+ if (Array.isArray(kids)) kids.forEach(walk)
+ else if (typeof kids === 'object') walk(kids)
+ }
+
+ walk(menuView({ kit, state, nowMs: 5_000, columns, pictures: new Map(), act, cards: false } as unknown as Ctx))
+
+ return found
+}
+
+/** Every string the menu draws, joined: what a person can read of it. */
+function readable(columns: number): string {
+ const state = newState({})
+
+ state.options.look = 'bbs'
+ state.view = 'menu'
+ setLook('bbs')
+
+ const out: string[] = []
+ const walk = (el: unknown): void => {
+ const node = el as El
+
+ if (typeof node !== 'object' || node === null) return
+
+ const kids = node.props.children
+
+ if (typeof kids === 'string') out.push(kids)
+ else if (Array.isArray(kids)) kids.forEach(walk)
+ else if (typeof kids === 'object') walk(kids)
+ }
+
+ walk(menuView({ kit, state, nowMs: 5_000, columns, pictures: new Map(), act, cards: false } as unknown as Ctx))
+
+ return out.join('\n')
+}
+
+afterEach(() => setLook('plain'))
+
+describe('the main menu at small widths', () => {
+ it('has no text or row wider than the pane, at any width from 30 to 120 columns', () => {
+ const problems: string[] = []
+
+ for (let columns = 30; columns <= 120; columns++) problems.push(...overflow(columns).map(problem => `${columns} columns: ${problem}`))
+
+ expect(problems).toEqual([])
+ })
+
+ it('wraps the mission stages instead of cutting them off: every stage is readable at every width', () => {
+ for (let columns = 30; columns <= 120; columns++) {
+ const text = readable(columns)
+
+ for (const stage of ['research', 'create', 'build', 'test', 'validate', 'secure', 'benchmark', 'learn']) expect(text, `${columns} columns: ${stage}`).toContain(stage)
+ expect(text, `${columns} columns`).not.toContain('SOP…')
+ }
+ })
+
+ it('wraps the stage line into several lines when the pane is narrow, and keeps every stage', () => {
+ expect(wrap('research β†’ create (ADRs, SOP) β†’ build β†’ test β†’ validate β†’ secure β†’ benchmark β†’ learn', 30).length).toBeGreaterThan(2)
+ expect(wrap('research β†’ create (ADRs, SOP) β†’ build β†’ test β†’ validate β†’ secure β†’ benchmark β†’ learn', 30).join(' ')).toContain('benchmark β†’ learn')
+ })
+})
diff --git a/plugins/ruflo-console/tests/pane-order.spec.ts b/plugins/ruflo-console/tests/pane-order.spec.ts
new file mode 100644
index 0000000000..4d4d04e051
--- /dev/null
+++ b/plugins/ruflo-console/tests/pane-order.spec.ts
@@ -0,0 +1,69 @@
+/**
+ * The pane's order, small and wide: the page's title art leads and the tabs follow. In the compact layout (an inline pane shorter than the
+ * page asks for) the tabs used to come first, above the title. Run with
+ * npx vitest run plugins/ruflo-console/tests/pane-order.spec.ts
+ */
+import { afterEach, describe, expect, it } from 'vitest'
+
+import { Grid } from '../hooks/gfx/raster'
+import { newState, type State, type ViewId } from '../hooks/state'
+import { setLook, type Ctx } from '../hooks/views/common'
+import { paneView } from '../hooks/views/pane'
+
+type El = { props: Record<string, unknown>; kind: string }
+
+const act = (() => {
+ const proxy: unknown = new Proxy(() => undefined, { get: (_t, key) => (key === 'then' ? undefined : proxy), apply: () => undefined })
+
+ return proxy
+})() as never
+const make = (kind: string) => (props: Record<string, unknown>): El => ({ kind, props })
+const kit = { Box: make('Box'), Text: make('Text'), Button: make('Button'), Input: make('Input'), Raster: make('Raster') }
+const flat = (el: unknown): El[] => {
+ const node = el as El
+
+ if (typeof node !== 'object' || node === null) return []
+
+ const kids = node.props.children
+
+ return [node, ...(Array.isArray(kids) ? kids.flatMap(flat) : typeof kids === 'object' ? flat(kids) : [])]
+}
+
+/** The top-level parts of the pane, as indexes: where the title's raster is, and where the first tab is. */
+function order(view: ViewId, columns: number, rows: number): { title: number; tabs: number } {
+ const state: State = newState({})
+
+ state.options.look = 'bbs'
+ state.options.boot = false
+ state.view = view
+ state.pane.placement = 'inline'
+ state.pane.rows = rows
+ state.pane.columns = columns
+ state.snapshot = null
+
+ const pictures = new Map([['title', new Grid(40, 2)]])
+ const tree = paneView({ kit, state, nowMs: Date.now(), columns, pictures, act, cards: false } as unknown as Ctx) as unknown as El
+ const parts = tree.props.children as unknown[]
+ const at = (match: (node: El) => boolean): number => parts.findIndex(part => flat(part).some(match))
+
+ return { title: at(node => node.kind === 'Raster'), tabs: at(node => /^(tab-|nav-)/.test(String(node.props.key)) || String(node.props.key).startsWith('tabs')) }
+}
+
+afterEach(() => setLook('plain'))
+
+describe('the pane\'s order', () => {
+ it('leads with the title and then the tabs in the compact layout', () => {
+ const { title, tabs } = order('swarm', 100, 8)
+
+ expect(title).toBeGreaterThanOrEqual(0)
+ expect(tabs).toBeGreaterThanOrEqual(0)
+ expect(title).toBeLessThan(tabs)
+ })
+
+ it('leads with the title and then the tabs in the wide layout too', () => {
+ const { title, tabs } = order('swarm', 140, 0)
+
+ expect(title).toBeGreaterThanOrEqual(0)
+ expect(title).toBeLessThan(tabs)
+ })
+})