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): chips are drawn inverse so the selected page's text cannot vanish (ADR 430)

ruv8b356e0764dc
diff --git a/plugins/ruflo-console/hooks/menu-colors.ts b/plugins/ruflo-console/hooks/menu-colors.ts
index 4957d46fc6..374971a807 100644
--- a/plugins/ruflo-console/hooks/menu-colors.ts
+++ b/plugins/ruflo-console/hooks/menu-colors.ts
@@ -3,8 +3,14 @@
* menu-style.ts, which reaches the pages, re-exports them. Each is a step of the xterm 256-colour cube or its grey ramp
* (tests/menu-style.spec.ts holds that, and the contrast of the ink on each accent).
*/
-/** The ink on an accent's solid bar, and the muted ink for a badge that is only information. */
-export const INK = '#1c1c1c'
+/**
+ * A chip: the colour is its ground, drawn with `inverse`, so the text takes the terminal's own background colour over it. Never a fixed
+ * ink on an explicit background: if the host did not draw that background, the ink would be near-black on a dark terminal and the text
+ * would be gone. Inverse cannot vanish, and where it is not honoured the chip falls back to text in the colour itself.
+ */
+export const chip = (ground: string) => ({ color: ground, inverse: true, bold: true }) as const
+
+/** The muted colour of a badge that is only information, and the loud one for a badge that needs a person. */
export const MUTED = '#8a8a8a'
export const LOUD = '#ffaf00'
diff --git a/plugins/ruflo-console/hooks/menu-style.ts b/plugins/ruflo-console/hooks/menu-style.ts
index 878591c4ad..5b54861211 100644
--- a/plugins/ruflo-console/hooks/menu-style.ts
+++ b/plugins/ruflo-console/hooks/menu-style.ts
@@ -12,7 +12,7 @@ import { secMemo } from './secure'
import type { State, ViewId } from './state'
import { money } from './views/bar'
-export { ACCENT, INK, LOUD, MUTED, PALETTE } from './menu-colors'
+export { ACCENT, chip, LOUD, MUTED, PALETTE } from './menu-colors'
export type Badge = { text: string; tone: 'attention' | 'plain' }
diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.ts
index a27093b0c1..43782fdb59 100644
--- a/plugins/ruflo-console/hooks/views/common.ts
+++ b/plugins/ruflo-console/hooks/views/common.ts
@@ -25,7 +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 { COST_CHIP, INK } from '../menu-colors'
+import { chip, COST_CHIP } from '../menu-colors'
import { accentOfView } from '../nav-state'
import type { VectorActions } from '../vector'
@@ -154,7 +154,7 @@ export function tagChip(ctx: Ctx, text: string, color: string): RenderElement {
if (ground === undefined) return ctx.kit.Text({ bold: true, color, children: ` ${text}` })
- return ctx.kit.Box({ flexDirection: 'row', children: [ctx.kit.Text({ children: ' ' }), ctx.kit.Text({ bold: true, color: INK, backgroundColor: ground, children: text })] })
+ return ctx.kit.Box({ flexDirection: 'row', children: [ctx.kit.Text({ children: ' ' }), ctx.kit.Text({ ...chip(ground), children: text })] })
}
export const clip = (text: string, width: number): string => (text.length <= width ? text : `${text.slice(0, Math.max(0, width - 1))}…`)
diff --git a/plugins/ruflo-console/hooks/views/menu.ts b/plugins/ruflo-console/hooks/views/menu.ts
index e1cda83894..5044b71dff 100644
--- a/plugins/ruflo-console/hooks/views/menu.ts
+++ b/plugins/ruflo-console/hooks/views/menu.ts
@@ -1,6 +1,6 @@
import type { RenderElement } from 'claude-code'
-import { ACCENT, badgesOf, INK, LOUD, MUTED, PALETTE } from '../menu-style'
+import { ACCENT, badgesOf, chip, LOUD, MUTED, PALETTE } from '../menu-style'
import { VIEWS, type ViewId } from '../state'
import { barParts } from './bar'
import { clip, col, isBbs, picture, row, text, THEME, type Ctx } from './common'
@@ -103,7 +103,7 @@ export function menuView(ctx: Ctx): RenderElement {
key: `menu-${group.title}`,
children: [
bbs
- ? ctx.kit.Box({ backgroundColor: accent, key: `menu-bar-${group.title}`, children: [ctx.kit.Text({ bold: true, color: INK, wrap: 'truncate-end', children: ` ${title}`.padEnd(width - 2).slice(0, width - 2) })] })
+ ? ctx.kit.Box({ key: `menu-bar-${group.title}`, children: [ctx.kit.Text({ ...chip(accent), wrap: 'truncate-end', children: ` ${title}`.padEnd(width - 2).slice(0, width - 2) })] })
: ctx.kit.Text({ bold: true, color: THEME.head, wrap: 'truncate-end', children: title }),
...group.sections.flatMap(section => {
const items = section.items.filter(isShown)
@@ -121,7 +121,7 @@ export function menuView(ctx: Ctx): RenderElement {
key: `mi-${item.go}`,
children: [
// The key is a chip in the accent in the BBS look, so the keys read as the commands; plain, as it always was.
- bbs ? ctx.kit.Text({ bold: true, color: INK, backgroundColor: accent, children: ` ${key} ` }) : ctx.kit.Text({ bold: true, color: THEME.ok, children: ` (${key})` }),
+ bbs ? ctx.kit.Text({ ...chip(accent), children: ` ${key} ` }) : ctx.kit.Text({ bold: true, color: THEME.ok, children: ` (${key})` }),
ctx.kit.Button({ key: `menu-go-${item.go}`, label: ` ${clip(item.label, width - 11 - (badge === undefined ? 0 : badge.text.length + 1))}`, plain: true, onPress: go(item) }),
...(badge === undefined ? [] : [ctx.kit.Text({ bold: badge.tone === 'attention', color: bbs ? (badge.tone === 'attention' ? LOUD : MUTED) : badge.tone === 'attention' ? THEME.warn : THEME.info, children: ` ${badge.text}` })]),
],
diff --git a/plugins/ruflo-console/hooks/views/mission-control.ts b/plugins/ruflo-console/hooks/views/mission-control.ts
index c37ab9528a..0c2fdb354e 100644
--- a/plugins/ruflo-console/hooks/views/mission-control.ts
+++ b/plugins/ruflo-console/hooks/views/mission-control.ts
@@ -3,7 +3,7 @@ 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 { ACCENT, INK, TONE } from '../menu-colors'
+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 { GOALS_PLUGIN, isAvailable, MISSION_SKILLS, slashOf } from '../mission-skills'
@@ -246,7 +246,7 @@ function stripCard(ctx: Ctx, mission: ReturnType<typeof activeMission>, field: R
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) })] })]
+ 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'))
diff --git a/plugins/ruflo-console/hooks/views/nav.ts b/plugins/ruflo-console/hooks/views/nav.ts
index a11c9ab5b0..c332b056a8 100644
--- a/plugins/ruflo-console/hooks/views/nav.ts
+++ b/plugins/ruflo-console/hooks/views/nav.ts
@@ -8,7 +8,7 @@
*/
import type { RenderElement } from 'claude-code'
-import { INK, NAV_ACCENT } from '../menu-colors'
+import { chip, NAV_ACCENT } from '../menu-colors'
import { badgesOf } from '../menu-style'
import { accentOfView, findPages, NAV_GROUPS, shownGroup } from '../nav-state'
import { VIEWS, type ViewId } from '../state'
@@ -46,7 +46,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({ bold: true, color: accent === null ? THEME.head : INK, ...(accent !== null && { backgroundColor: 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} ${view.label.toUpperCase()}]` : `${prefix}${view.icon} ${view.label}` })] })
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) })
}
@@ -58,7 +58,7 @@ export function groupedTabs(ctx: Ctx, hasHotkey: (view: View) => boolean): Rende
const isSearchInline = inner - chipCells >= 28
const chips = NAV_GROUPS.map(group =>
group.title === shown && found === null
- ? ctx.kit.Box({ key: `nav-group-${group.title}`, children: [ctx.kit.Text({ bold: true, color: isBbs() ? INK : THEME.head, ...(isBbs() && { backgroundColor: NAV_ACCENT[group.title] ?? THEME.head }), children: `[${icons ? `${group.icon} ` : ''}${group.title} β–Ύ]` })] })
+ ? ctx.kit.Box({ key: `nav-group-${group.title}`, children: [ctx.kit.Text({ ...(isBbs() ? chip(NAV_ACCENT[group.title] ?? THEME.head) : { bold: true, color: THEME.head }), children: `[${icons ? `${group.icon} ` : ''}${group.title} β–Ύ]` })] })
: ctx.kit.Button({ key: `nav-group-${group.title}`, label: ` ${icons ? `${group.icon} ` : ''}${group.title} `, plain: true, dimColor: true, onPress: () => ctx.act.navigator.group(group.title) }),
)
const Input = ctx.kit.Input
diff --git a/plugins/ruflo-console/tests/design.spec.ts b/plugins/ruflo-console/tests/design.spec.ts
index 355c2edd6f..352df011f3 100644
--- a/plugins/ruflo-console/tests/design.spec.ts
+++ b/plugins/ruflo-console/tests/design.spec.ts
@@ -6,10 +6,12 @@
*/
import { afterEach, describe, expect, it } from 'vitest'
-import { COST_CHIP, INK, NAV_ACCENT } from '../hooks/menu-colors'
+import { COST_CHIP, NAV_ACCENT } from '../hooks/menu-colors'
import { newState, type State, type ViewId } from '../hooks/state'
import { CARD_COLUMNS } from '../hooks/views/card'
import { setLook, tagChip, THEME, type Actions, type Ctx } from '../hooks/views/common'
+import { menuView } from '../hooks/views/menu'
+import { missionStrip } from '../hooks/views/mission-control'
import { groupedTabs } from '../hooks/views/nav'
type El = { kind: string; props: Record<string, unknown> }
@@ -42,16 +44,16 @@ describe('a cost tag', () => {
setLook('bbs')
for (const [color, ground] of [[THEME.ok, COST_CHIP.ok], [THEME.info, COST_CHIP.info], [THEME.warn, COST_CHIP.warn], [THEME.bad, COST_CHIP.bad]] as const) {
- const shown = texts(chip(color)).find(node => node.props.backgroundColor !== undefined)
+ const shown = texts(chip(color)).find(node => node.props.inverse === true)
- expect(shown?.props, color).toMatchObject({ backgroundColor: ground, color: INK, bold: true, children: ' $0 ' })
+ expect(shown?.props, color).toMatchObject({ color: ground, inverse: true, bold: true, children: ' $0 ' })
}
})
it('stays coloured text in the plain look, as it always was, and a colour that is none of the four is text in either', () => {
setLook('plain')
expect(chip(THEME.ok)).toMatchObject({ kind: 'Text', props: { color: THEME.ok, children: ' $0 ' } })
- expect(flat(chip(THEME.ok)).some(node => node.props.backgroundColor !== undefined)).toBe(false)
+ expect(flat(chip(THEME.ok)).some(node => node.props.backgroundColor !== undefined || node.props.inverse === true)).toBe(false)
setLook('bbs')
expect(chip(THEME.head)).toMatchObject({ kind: 'Text' })
@@ -74,13 +76,14 @@ describe('the nav card', () => {
const bbs = tab(open('secure').card, 'secure')
const chipText = texts(bbs).find(node => String(node.props.children).includes('SECURITY & DOCTOR'))
- expect(chipText?.props).toMatchObject({ backgroundColor: NAV_ACCENT.SAFETY, color: INK, bold: true, children: '[u: πŸ”’ SECURITY & DOCTOR]' })
+ expect(chipText?.props).toMatchObject({ color: NAV_ACCENT.SAFETY, inverse: true, bold: true, children: '[u: πŸ”’ SECURITY & DOCTOR]' })
setLook('plain')
const plain = texts(tab(open('secure').card, 'secure')).find(node => String(node.props.children).includes('Security & Doctor'))
expect(plain?.props.backgroundColor).toBeUndefined()
+ expect(plain?.props.inverse).toBeUndefined()
expect(plain?.props.children).toBe('u: πŸ”’ Security & Doctor')
})
@@ -89,7 +92,7 @@ describe('the nav card', () => {
const group = texts(open('secure').card).find(node => String(node.props.children).includes('SAFETY β–Ύ'))
- expect(group?.props).toMatchObject({ backgroundColor: NAV_ACCENT.SAFETY, color: INK })
+ expect(group?.props).toMatchObject({ color: NAV_ACCENT.SAFETY, inverse: true })
})
it('puts the menu\'s badges on the page buttons: spend on Cost, an update on Settings', () => {
@@ -125,3 +128,22 @@ describe('the nav card', () => {
}
})
})
+
+describe('a chip cannot vanish', () => {
+ it('is drawn inverse, never in a fixed colour on an explicit background, so it stays there if the host does not draw that background', () => {
+ setLook('bbs')
+
+ const state = newState({})
+
+ state.view = 'menu'
+
+ const trees: unknown[] = [menuView(ctxOf(state, 120)), groupedTabs(ctxOf(state, 120), () => true), ...missionStrip(ctxOf(state, 120)), tagChip(ctxOf(state), ' $0 ', THEME.ok), tagChip(ctxOf(state), ' $$ ', THEME.bad)]
+
+ for (const tree of trees) {
+ for (const node of texts(tree)) expect(node.props.backgroundColor, String(node.props.children)).toBeUndefined()
+ }
+
+ // And there are chips to be checked: the menu's group bars and key chips, the nav's open page and group, the cost tags.
+ expect(trees.flatMap(texts).filter(node => node.props.inverse === true).length).toBeGreaterThan(10)
+ })
+})
diff --git a/plugins/ruflo-console/tests/menu-style.spec.ts b/plugins/ruflo-console/tests/menu-style.spec.ts
index 0fa7032fb7..37e965405e 100644
--- a/plugins/ruflo-console/tests/menu-style.spec.ts
+++ b/plugins/ruflo-console/tests/menu-style.spec.ts
@@ -8,7 +8,7 @@ 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 { ACCENT, badgesOf, 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'
@@ -50,11 +50,11 @@ 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, ...Object.values(TONE), ...Object.values(NAV_ACCENT)]) expect(isXterm256(color), color).toBe(true)
+ for (const color of [...Object.values(ACCENT), ...PALETTE, 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', () => {
- for (const [group, color] of Object.entries(ACCENT)) expect(contrast(INK, color), group).toBeGreaterThanOrEqual(4.5)
+ it('has accents that read as text on a dark terminal (contrast 4.5 or more), so a chip that falls back to coloured text stays legible, and no two groups share a colour', () => {
+ for (const [group, color] of Object.entries(ACCENT)) expect(contrast('#1c1c1c', color), group).toBeGreaterThanOrEqual(4.5)
expect(new Set(Object.values(ACCENT)).size).toBe(Object.keys(ACCENT).length)
})
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.md
index cf7c778347..46df7b0681 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
@@ -64,3 +64,13 @@ What the owner pasted from the menu: `test β–―β–―β–―β–―β–―β–―β–―β–―β–―β–― 0/15`
- **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.
+
+## 9. Amendment: a chip is drawn inverse, not in fixed ink on a background
+
+The owner reported that selecting `4: πŸ“Œ Claims` made the selected text disappear. That is the open page's chip, which ADR 430 drew as dark ink (`#1c1c1c`) on the accent as an explicit background. I could not see the screen, so the cause is not confirmed; the design had a failure mode that fits it exactly. Fixed ink is only legible if the host draws the background under it. If it does not, near-black text sits on a dark terminal and is gone.
+
+Every chip is now drawn **inverse**: the accent is the text's colour and `inverse` is set, so the text takes the terminal's own background colour over the accent. Inverse cannot vanish, and where a host does not honour it the chip falls back to text in the accent colour, which reads on a dark terminal. This covers the menu's group title bars and key chips, the mission strip's title bar, the cost tags on run rows, and the nav's open page and open group. The `INK` constant is gone, so it cannot come back by accident.
+
+What changes in the tests: the contrast check no longer measures dark ink on an accent (there is none); it holds each accent to a contrast of 4.5 as text on a dark terminal, the degraded case. And `tests/design.spec.ts` states the rule itself: rendering the menu, the nav card, the mission strip and the cost tags in the BBS look, no `Text` has a `backgroundColor` (checked by putting a fixed-ink chip back in the menu and watching it fail, naming the chip).
+
+On a light terminal an inverse chip is the terminal's light background over the accent, which has weak contrast; the console's pages are designed for a dark terminal and this has not been looked at on a light one.