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

feat(ruflo-console): Mods section on the Room and a count on Overview (0.33.1)

ruv9d4b45de0f7c
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.json
index 93f7fcaaf8..4fae1545e6 100644
--- a/plugins/ruflo-console/.claude-plugin/plugin.json
+++ b/plugins/ruflo-console/.claude-plugin/plugin.json
@@ -1,7 +1,7 @@
{
"name": "ruflo-console",
"description": "ruflo's cockpit inside Claude Code and the one /ruflo command for every ruflo mod (function hooks, early access). Views: overview with health alerts, swarm topology graph, claims flow with TTL rings, federation map, plugin health matrix, learning curve and pipeline, MetaHarness radar and audit trend, memory, cost gauge, agent timeline, approvals queue, event stream, a main menu, an x.ruv.io federation board, an AI terminal (codex, claude or both in remembered sessions, streamed), Skills (npx skills), a Hive-Mind view, a MetaHarness lab, agent drill-down; a command palette for confirm-gated actions through the ruflo CLI; a band above the prompt. Reads ruflo's files and the CLI's local JSON; anything not measured reads n/a. The one network call it makes by itself is a daily read of the published plugin.json at github.com/ruvnet/ruflo to offer an update (Settings → Updates: ask, auto, or off); it installs only through Claude Code's own claude plugin update, and never a new major version without asking.",
- "version": "0.33.0",
+ "version": "0.33.1",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-console/hooks/data/files.ts b/plugins/ruflo-console/hooks/data/files.ts
index 7f117a3425..57a6787774 100644
--- a/plugins/ruflo-console/hooks/data/files.ts
+++ b/plugins/ruflo-console/hooks/data/files.ts
@@ -60,7 +60,7 @@ export type ReadCache = Map<string, { mtimeMs: number; size: number; text: strin
export const MISSING_RECHECK_MS = 10_000
/** Reads one file, unless its mtime and size match what was read last; stats first, so a huge file is never read. */
-export async function readBounded(fs: ReaderFs, cache: ReadCache, path: string): Promise<Read> {
+export async function readBounded(fs: ReaderFs, cache: ReadCache, path: string, max = READ_MAX): Promise<Read> {
let stat: { mtimeMs?: number; size?: number } | undefined
const before = cache.get(path)
@@ -80,7 +80,7 @@ export async function readBounded(fs: ReaderFs, cache: ReadCache, path: string):
const mtimeMs = stat?.mtimeMs ?? -1
const size = stat?.size ?? -1
- if (size > READ_MAX) {
+ if (size > max) {
cache.delete(path)
return { text: null, reason: 'too-large', size }
diff --git a/plugins/ruflo-console/hooks/data/mods.ts b/plugins/ruflo-console/hooks/data/mods.ts
new file mode 100644
index 0000000000..2671d2fe57
--- /dev/null
+++ b/plugins/ruflo-console/hooks/data/mods.ts
@@ -0,0 +1,68 @@
+import { readBounded, under, type ReadCache, type ReaderFs } from './files'
+import { jsonObject } from './parse'
+
+/** The most mod folders read, and the most bytes of one status file (a larger one is refused, not trimmed). */
+export const MODS_MAX_FILES = 60
+export const MODS_MAX_BYTES = 8192
+/** A status file older than this was written by a session that has ended. */
+export const MODS_STALE_MS = 6 * 3_600_000
+
+const ROOT = '.claude-flow'
+const DIR = /^[a-z0-9][a-z0-9-]{0,40}-mod$/
+
+/** One mod's status file (ADR-446): the counters every mod writes; per-plugin counters are not read here. */
+export type ModRow = { name: string; guard: boolean | null; calls: number | null; blocked: number; updatedMs: number | null; startedMs: number | null }
+
+/** What the folder scan found: the rows kept, how many folders were refused (unknown shape, too large, unreadable), and whether the cap cut the list. */
+export type ModsFacts = { rows: ModRow[]; refused: number; truncated: boolean }
+
+export const NO_MODS: ModsFacts = { rows: [], refused: 0, truncated: false }
+
+const whole = (v: unknown): number | null => (typeof v === 'number' && Number.isFinite(v) && v >= 0 ? Math.floor(v) : null)
+
+/** Parses one status file; anything that is not version 1 of an object is null (the console never guesses at a shape it does not know). */
+export function parseModStatus(name: string, text: string | null): ModRow | null {
+ const value = jsonObject(text)
+
+ if (value === null || value.version !== 1) return null
+
+ return {
+ name: name.slice(0, -4),
+ guard: typeof value.guard === 'boolean' ? value.guard : null,
+ calls: whole(value.calls),
+ blocked: whole(value.blocked) ?? 0,
+ updatedMs: whole(value.updatedMs),
+ startedMs: whole(value.startedMs),
+ }
+}
+
+/** Blocked first (most blocked leading), then the most recently written, then by name. */
+export function orderMods(rows: readonly ModRow[]): ModRow[] {
+ return [...rows].sort((a, b) => Number(b.blocked > 0) - Number(a.blocked > 0) || b.blocked - a.blocked || (b.updatedMs ?? -1) - (a.updatedMs ?? -1) || a.name.localeCompare(b.name))
+}
+
+export const isStale = (row: ModRow, nowMs: number): boolean => row.updatedMs === null || nowMs - row.updatedMs > MODS_STALE_MS
+
+/** Lists `.claude-flow` for `*-mod` folders and reads each `status.json`, bounded by count and size; never rejects. */
+export async function readMods(fs: ReaderFs, cache: ReadCache, cwd: string): Promise<ModsFacts> {
+ const entries = await fs.list(under(cwd, ROOT)).catch(() => null)
+
+ if (entries === null) return NO_MODS
+
+ const names = entries.filter(entry => entry.kind !== 'file' && DIR.test(entry.name)).map(entry => entry.name).sort()
+ const kept = names.slice(0, MODS_MAX_FILES)
+ const reads = await Promise.all(kept.map(async name => ({ name, read: await readBounded(fs, cache, under(cwd, `${ROOT}/${name}/status.json`), MODS_MAX_BYTES) })))
+ const rows: ModRow[] = []
+ let refused = 0
+
+ for (const { name, read } of reads) {
+ if (read.text === null && read.reason === 'missing') continue
+
+ const row = parseModStatus(name, read.text)
+
+ if (row === null) refused += 1
+ else rows.push(row)
+ }
+
+ return { rows: orderMods(rows), refused, truncated: names.length > kept.length }
+}
diff --git a/plugins/ruflo-console/hooks/data/snapshot.ts b/plugins/ruflo-console/hooks/data/snapshot.ts
index 6163409a81..783c5fc261 100644
--- a/plugins/ruflo-console/hooks/data/snapshot.ts
+++ b/plugins/ruflo-console/hooks/data/snapshot.ts
@@ -26,6 +26,7 @@ import {
import { parseMissions, type MissionObservation } from './missions'
import { readBounded, readDisk, textOf, type ProjectKey, type Read, type ReadCache, type ReaderFs } from './files'
import { parseAgentdbMod, type AgentdbMod } from './agentdb-mod'
+import { readMods, type ModsFacts } from './mods'
import {
parseAgents,
parseClaims,
@@ -81,6 +82,8 @@ export type Snapshot = {
missions: MissionObservation | null
/** The ruflo-agentdb mod's own status file (ADR-445); null while the mod has not written one. */
agentdbMod: AgentdbMod | null
+ /** Every `.claude-flow/<short>-mod/status.json` the per-plugin mods wrote (ADR-446), bounded and shape-checked. */
+ mods: ModsFacts
changed: number
readAtMs: number
}
@@ -131,6 +134,7 @@ export async function readSnapshot(fs: ReaderFs, cache: ReadCache, cwd: string,
},
missions: parseMissions(text('missions')),
agentdbMod: parseAgentdbMod(text('agentdbMod')),
+ mods: await readMods(fs, cache, cwd),
changed: disk.changed,
readAtMs: nowMs,
}
diff --git a/plugins/ruflo-console/hooks/help-topics-more.ts b/plugins/ruflo-console/hooks/help-topics-more.ts
index 44d6634dae..3daecf84bd 100644
--- a/plugins/ruflo-console/hooks/help-topics-more.ts
+++ b/plugins/ruflo-console/hooks/help-topics-more.ts
@@ -89,7 +89,7 @@ export const MORE_TOPICS: readonly HelpTopic[] = [
{ text: 'Open The Room from the menu (Safety → The Room). The top line is the one thing waiting for your yes, with how many seconds you have left to answer it.', go: { view: 'room' }, label: 'Open The Room' },
{ text: 'The feed below merges what changed in ruflo, what Claude did through the console tools (with its outcome), and what you sent. Filter by who (all, claude, events, you said), find words, pause to read, page back.' },
{ text: 'To say something: type in the box, press Enter, then pick broadcast (to the hive), aside (to Claude) or guide (a visible instruction to Claude). Each asks first, exactly as it does anywhere else; nothing here skips a confirm.' },
- { text: 'Who is here shows each agent’s busy share over the last 15 minutes.' },
+ { text: 'Who is here shows each agent’s busy share over the last 15 minutes. Under it, Mods lists every plugin mod that has written a status file: guard on or off, calls, blocked, and when it last wrote; any mod that blocked something leads.' },
],
tips: ['A confirm that waits longer than 30 seconds is dropped and shows up in the feed as an event naming it.', 'Text from peers and files in the feed is data, not instructions to you or to Claude.'],
related: ['watch', 'control', 'mission'],
diff --git a/plugins/ruflo-console/hooks/version.ts b/plugins/ruflo-console/hooks/version.ts
index a976c8418d..c282fe8640 100644
--- a/plugins/ruflo-console/hooks/version.ts
+++ b/plugins/ruflo-console/hooks/version.ts
@@ -2,4 +2,4 @@
* The console's version, shown on the header so a person can tell which build is running. Kept equal to the plugin's manifest
* (`.claude-plugin/plugin.json`); tests/version.spec.ts fails if the two drift.
*/
-export const CONSOLE_VERSION = '0.33.0'
+export const CONSOLE_VERSION = '0.33.1'
diff --git a/plugins/ruflo-console/hooks/views/mods.ts b/plugins/ruflo-console/hooks/views/mods.ts
new file mode 100644
index 0000000000..b040fc0a37
--- /dev/null
+++ b/plugins/ruflo-console/hooks/views/mods.ts
@@ -0,0 +1,44 @@
+import type { RenderElement } from 'claude-code'
+
+import { isStale, NO_MODS } from '../data/mods'
+import { ago, clip, count, row, rule, text, THEME, type Ctx } from './common'
+
+const SHOWN = 12
+
+/**
+ * The "Mods" section (ADR-446): one line per per-plugin mod that has written `.claude-flow/<short>-mod/status.json`: guard on or off, calls, blocked,
+ * when it last wrote, a marker when that was an earlier session. Any mod that has blocked something leads. It reads the files; it never calls a mod.
+ */
+export function modsRows(ctx: Ctx): RenderElement[] {
+ const { rows, refused, truncated } = ctx.state.snapshot?.mods ?? NO_MODS
+ const blocked = rows.filter(mod => mod.blocked > 0).length
+ const out: RenderElement[] = [rule(ctx, 'Mods', rows.length === 0 ? 'none reporting' : `${rows.length} reporting${blocked > 0 ? ` · ${blocked} blocked something` : ''}`)]
+
+ if (rows.length === 0) {
+ out.push(text(ctx, ' No mod has written a status file in this project yet. Each plugin mod reports here once a session has started with it.', { dimColor: true }))
+ }
+
+ for (const [i, mod] of rows.slice(0, SHOWN).entries()) {
+ const stale = isStale(mod, ctx.nowMs)
+
+ out.push(
+ row(
+ ctx,
+ [
+ ctx.kit.Text({ bold: true, color: mod.blocked > 0 ? THEME.warn : THEME.head, children: ` ${clip(mod.name, 22).padEnd(22)}` }),
+ ctx.kit.Text({ color: mod.guard === true ? THEME.ok : undefined, dimColor: mod.guard !== true, children: ` guard ${mod.guard === null ? '–' : mod.guard ? 'on ' : 'off'}` }),
+ ctx.kit.Text({ children: ` · calls ${mod.calls === null ? '–' : count(mod.calls)}` }),
+ ctx.kit.Text({ color: mod.blocked > 0 ? THEME.warn : undefined, dimColor: mod.blocked === 0, children: ` · blocked ${count(mod.blocked)}` }),
+ ctx.kit.Text({ dimColor: true, children: ` · ${mod.updatedMs === null ? 'never written' : ago(mod.updatedMs, ctx.nowMs)}${stale ? ' · stale (an earlier session)' : ''}` }),
+ ],
+ `mod-${i}-${mod.name}`,
+ ),
+ )
+ }
+
+ if (rows.length > SHOWN) out.push(text(ctx, ` +${rows.length - SHOWN} more mods reporting`, { dimColor: true }))
+ if (truncated) out.push(text(ctx, ' more mod folders than the 60 the console reads; the rest are not shown', { dimColor: true }))
+ if (refused > 0) out.push(text(ctx, ` ${refused} status file${refused === 1 ? '' : 's'} not shown: an unknown shape, too large, or unreadable`, { color: THEME.warn }))
+
+ return out
+}
diff --git a/plugins/ruflo-console/hooks/views/overview.ts b/plugins/ruflo-console/hooks/views/overview.ts
index d8994c6e11..d2274c2170 100644
--- a/plugins/ruflo-console/hooks/views/overview.ts
+++ b/plugins/ruflo-console/hooks/views/overview.ts
@@ -5,7 +5,7 @@ import type { MemoryStats } from '../data/cli'
import type { StartId } from '../starts'
import { controlRows, isControlActive } from './control'
import { optimizerRows } from './optimizer'
-import { ago, col, count, kv, live, picture, rule, sourceLine, starts, text, THEME, type Ctx } from './common'
+import { ago, button, col, count, kv, live, row, picture, rule, sourceLine, starts, text, THEME, type Ctx } from './common'
/** Each subsystem in one line: what it is, from where, as of when. Nothing on this view is estimated. */
export function overviewView(ctx: Ctx): RenderElement {
@@ -70,6 +70,11 @@ export function overviewView(ctx: Ctx): RenderElement {
),
)
rows.push(kv(ctx, 'function hooks', `on (this mod runs) · mods seen since it loaded: ${loaded} loaded, ${refused} refused`, refused > 0 ? THEME.warn : THEME.ok))
+ const modsSeen = snap?.mods?.rows ?? []
+ const modsBlocked = modsSeen.filter(mod => mod.blocked > 0).length
+
+ rows.push(kv(ctx, 'mods reporting', modsSeen.length === 0 ? 'none yet' : `${modsSeen.length}${modsBlocked > 0 ? ` · ${modsBlocked} blocked something` : ''}`, modsBlocked > 0 ? THEME.warn : undefined))
+ rows.push(row(ctx, [button(ctx, 'overview-mods', 'The Room: Mods', () => ctx.act.view('room'))], 'overview-mods-row'))
rows.push(kv(ctx, 'swarm', swarm === null ? 'n/a — no swarm on disk' : `${swarm.id} · ${swarm.topology} · ${swarm.status} · ${swarm.agentIds.length || (snap?.agents.length ?? 0)} agents`))
// What is missing here, each with the button that adds it, most basic first.
diff --git a/plugins/ruflo-console/hooks/views/room.ts b/plugins/ruflo-console/hooks/views/room.ts
index 0cc41f821f..4933d5c165 100644
--- a/plugins/ruflo-console/hooks/views/room.ts
+++ b/plugins/ruflo-console/hooks/views/room.ts
@@ -6,6 +6,7 @@ import { ROOM_PAGE, roomOf } from '../room'
import { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
import { lanesOf } from './frames'
import { statsOf } from './manage'
+import { modsRows } from './mods'
const TONE_COLOR = { ok: THEME.ok, warn: THEME.warn, bad: THEME.bad, info: THEME.info } as const
const SOURCES: readonly { id: 'all' | RoomSource; label: string }[] = [
@@ -104,5 +105,7 @@ export function roomView(ctx: Ctx): RenderElement {
rows.push(row(ctx, [ctx.kit.Text({ bold: true, color: THEME.head, children: ` ${clip(lane.label, 20).padEnd(20)}` }), ctx.kit.Text({ color: share === null ? THEME.info : share >= 60 ? THEME.ok : share >= 20 ? THEME.warn : THEME.info, children: ` ${share === null ? 'no status seen' : `busy ${share}%`}` }), ctx.kit.Text({ dimColor: true, children: ` · ${stats.calls} tool call${stats.calls === 1 ? '' : 's'}` })], `room-lane-${i}`))
}
+ rows.push(...modsRows(ctx))
+
return col(ctx, rows, 'room')
}
diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.sh
index 3aba708173..26efac8e36 100755
--- a/plugins/ruflo-console/scripts/smoke.sh
+++ b/plugins/ruflo-console/scripts/smoke.sh
@@ -11,9 +11,9 @@ step() { printf "→ %s ... " "$1"; }
ok() { printf "PASS\n"; PASS=$((PASS+1)); }
bad() { printf "FAIL: %s\n" "$1"; FAIL=$((FAIL+1)); }
-step "1. plugin.json declares ruflo-console 0.33.0"
+step "1. plugin.json declares ruflo-console 0.33.1"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
- && grep -q '"version": "0.33.0"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
+ && grep -q '"version": "0.33.1"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
step "2. hooks.json names exactly one module and no classic hook commands"
grep -q '"modules": \["./register.ts"\]' "$HOOKS/hooks.json" && ! grep -q '"command"' "$HOOKS/hooks.json" \
diff --git a/plugins/ruflo-console/tests/mods-section.spec.ts b/plugins/ruflo-console/tests/mods-section.spec.ts
new file mode 100644
index 0000000000..a46051e874
--- /dev/null
+++ b/plugins/ruflo-console/tests/mods-section.spec.ts
@@ -0,0 +1,137 @@
+/**
+ * The Mods section (ADR-446 status files): the shape-checked parser, the order, the file and size caps, hostile content, and the folder scan.
+ * npx vitest run plugins/ruflo-console/tests/mods-section.spec.ts
+ */
+import { describe, expect, it } from 'vitest'
+
+import type { ReaderFs } from '../hooks/data/files'
+import { newState } from '../hooks/state'
+import { readSnapshot } from '../hooks/data/snapshot'
+import type { Actions } from '../hooks/views/common'
+import { viewText } from '../hooks/views/pane'
+import { isStale, MODS_MAX_BYTES, MODS_MAX_FILES, MODS_STALE_MS, orderMods, parseModStatus, readMods, type ModRow } from '../hooks/data/mods'
+
+const status = (extra: Record<string, unknown> = {}) => JSON.stringify({ version: 1, updatedMs: 1_000, calls: 5, blocked: 0, startedMs: 500, guard: true, ...extra })
+const row = (name: string, blocked: number, updatedMs: number | null): ModRow => ({ name, guard: true, calls: 1, blocked, updatedMs, startedMs: null })
+
+/** A fake project: folder name → status text (null = no status.json), plus loose files. */
+function fakeFs(mods: Record<string, string | null>, loose: string[] = []): ReaderFs & { reads: string[] } {
+ const reads: string[] = []
+
+ return {
+ reads,
+ list: async () => [...Object.keys(mods).map(name => ({ name, kind: 'directory' })), ...loose.map(name => ({ name, kind: 'file' }))],
+ stat: async path => {
+ const text = mods[path.split('/').at(-2) ?? '']
+
+ if (text === null || text === undefined) throw new Error('ENOENT')
+
+ return { mtimeMs: 1, size: text.length }
+ },
+ read: async path => {
+ reads.push(path)
+
+ return mods[path.split('/').at(-2) ?? ''] ?? ''
+ },
+ }
+}
+
+describe('parseModStatus', () => {
+ it('reads version 1 and names the mod from its folder, never from the file', () => {
+ expect(parseModStatus('docs-mod', status({ mod: 'evil' }))).toEqual({ name: 'docs', guard: true, calls: 5, blocked: 0, updatedMs: 1000, startedMs: 500 })
+ })
+
+ it('refuses unknown versions and junk', () => {
+ for (const text of [status({ version: 2 }), status({ version: '1' }), 'nope', '[]', '"x"', 'null', '', null]) expect(parseModStatus('docs-mod', text)).toBeNull()
+ })
+
+ it('treats hostile numbers and types as absent, not as values', () => {
+ const parsed = parseModStatus('docs-mod', JSON.stringify({ version: 1, calls: -3, blocked: 'lots', updatedMs: 1e999, guard: 'yes', startedMs: null, __proto__: { x: 1 } }))
+
+ expect(parsed).toEqual({ name: 'docs', guard: null, calls: null, blocked: 0, updatedMs: null, startedMs: null })
+ })
+
+ it('floors fractions and is stale when old or unwritten', () => {
+ expect(parseModStatus('a-mod', status({ calls: 2.9 }))?.calls).toBe(2)
+ expect(isStale(row('a', 0, 1000), 1000 + MODS_STALE_MS)).toBe(false)
+ expect(isStale(row('a', 0, 1000), 1001 + MODS_STALE_MS)).toBe(true)
+ expect(isStale(row('a', 0, null), 5)).toBe(true)
+ })
+})
+
+describe('orderMods', () => {
+ it('leads with blocked (most first), then newest, then name', () => {
+ const ordered = orderMods([row('b', 0, 10), row('a', 0, 10), row('z', 1, 1), row('y', 4, 1), row('n', 0, 99), row('u', 0, null)])
+
+ expect(ordered.map(mod => mod.name)).toEqual(['y', 'z', 'n', 'a', 'b', 'u'])
+ })
+})
+
+describe('readMods', () => {
+ it('reads only *-mod folders and skips a folder with no status file', async () => {
+ const fs = fakeFs({ 'docs-mod': status({ blocked: 2 }), 'sparc-mod': status(), 'agentdb': status(), 'quiet-mod': null, 'Bad-Mod': status(), '..-mod': status() }, ['loose-mod'])
+ const mods = await readMods(fs, new Map(), '/p')
+
+ expect(mods.rows.map(mod => mod.name)).toEqual(['docs', 'sparc'])
+ expect(mods).toMatchObject({ refused: 0, truncated: false })
+ expect(fs.reads.every(path => path.startsWith('/p/.claude-flow/') && path.endsWith('/status.json'))).toBe(true)
+ })
+
+ it('caps the folders read at 60 and says so', async () => {
+ const many = Object.fromEntries(Array.from({ length: 75 }, (_, i) => [`m${String(i).padStart(2, '0')}-mod`, status()]))
+ const fs = fakeFs(many)
+ const mods = await readMods(fs, new Map(), '/p')
+
+ expect(mods.rows).toHaveLength(MODS_MAX_FILES)
+ expect(fs.reads).toHaveLength(MODS_MAX_FILES)
+ expect(mods.truncated).toBe(true)
+ })
+
+ it('refuses a file over 8 KB without reading it, and counts unknown shapes as refused', async () => {
+ const fs = fakeFs({ 'big-mod': status({ pad: 'x'.repeat(MODS_MAX_BYTES) }), 'odd-mod': status({ version: 9 }), 'junk-mod': '{{{', 'ok-mod': status() })
+ const mods = await readMods(fs, new Map(), '/p')
+
+ expect(mods.rows.map(mod => mod.name)).toEqual(['ok'])
+ expect(mods.refused).toBe(3)
+ expect(fs.reads.some(path => path.includes('/big-mod/'))).toBe(false)
+ })
+
+ it('answers none when the folder cannot be listed', async () => {
+ const fs: ReaderFs = { list: async () => Promise.reject(new Error('EACCES')), stat: async () => undefined, read: async () => '' }
+
+ expect(await readMods(fs, new Map(), '/p')).toEqual({ rows: [], refused: 0, truncated: false })
+ })
+})
+
+describe('the Mods section on the pages', () => {
+ const act = new Proxy(() => undefined, { get: () => act, apply: () => undefined }) as unknown as Actions
+ const empty: ReaderFs = { read: () => Promise.reject(new Error('ENOENT')), stat: () => Promise.reject(new Error('ENOENT')), list: () => Promise.reject(new Error('ENOENT')) }
+ const draw = async (view: 'room' | 'overview', rows: ModRow[], extra: { refused?: number; truncated?: boolean } = {}) => {
+ const state = newState({})
+ const snapshot = await readSnapshot(empty, new Map(), '/work', '/home/dev', {}, 0)
+
+ state.snapshot = { ...snapshot, mods: { rows: orderMods(rows), refused: extra.refused ?? 0, truncated: extra.truncated ?? false } }
+ state.view = view
+
+ return viewText({ state, nowMs: 30_000_000, columns: 100, act }, view)
+ }
+
+ it('the Room leads with a blocking mod and marks a stale one', async () => {
+ const text = await draw('room', [row('quiet', 0, 30_000_000 - 5000), row('docs', 3, 30_000_000 - 60_000), row('old', 0, 1000)], { refused: 2 })
+ const lines = text.split('\n')
+
+ expect(text).toContain('Mods')
+ expect(text).toContain('3 reporting · 1 blocked something')
+ expect(lines.findIndex(l => l.includes('docs'))).toBeLessThan(lines.findIndex(l => l.includes('quiet')))
+ expect(text).toMatch(/old.*stale \(an earlier session\)/)
+ expect(text).toContain('2 status files not shown')
+ })
+
+ it('says none reporting when no mod has written, and Overview carries the count and the link', async () => {
+ const overview = await draw('overview', [row('docs', 1, 29_999_000)])
+
+ expect(await draw('room', [])).toContain('No mod has written a status file')
+ expect(overview).toMatch(/mods reporting\s+1 · 1 blocked something/)
+ expect(overview).toContain('The Room: Mods')
+ })
+})