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): the Performance page folds its verbs into groups, and a running measurement spins

ruvf1d5dda655ea
diff --git a/plugins/ruflo-console/hooks/controller.ts b/plugins/ruflo-console/hooks/controller.ts
index 31fbbea860..2e397107e2 100644
--- a/plugins/ruflo-console/hooks/controller.ts
+++ b/plugins/ruflo-console/hooks/controller.ts
@@ -285,8 +285,9 @@ export function createController(state: State, host: Host): Controller {
/** Runs the frame loop while the pane is shown and holds the keys (or plays the boot screen), at `fps`; stops it otherwise. */
function animate(): void {
- // The Missions page moves while a mission, a task or a guidance run is live, pictured or not: its spinners need the frames.
- const moving = state.view === 'missions' && hasLiveWork(state.snapshot?.missions?.missions ?? [], mcOf(state).guidance?.status === 'running')
+ // Something in progress moves its spinner, pictured or not: a lab action in flight (on any page), or, on the Missions page, a
+ // mission, a task or a guidance run that is live.
+ const moving = state.lab.running !== null || (state.view === 'missions' && hasLiveWork(state.snapshot?.missions?.missions ?? [], mcOf(state).guidance?.status === 'running'))
if (!(state.options.fps > 0 && isVisible() && (state.pane.isFocused || isBooting(state, Date.now())) && (state.mounted.size > 0 || moving))) {
cancel('frames')
diff --git a/plugins/ruflo-console/hooks/mission-list.ts b/plugins/ruflo-console/hooks/mission-list.ts
index 91e0fb6537..ff3899f3fd 100644
--- a/plugins/ruflo-console/hooks/mission-list.ts
+++ b/plugins/ruflo-console/hooks/mission-list.ts
@@ -4,6 +4,9 @@
* in tests/mission-list.spec.ts, so the list's behaviour is checked without the Claude Code test kit.
*/
import { money, type Mission } from './data/missions'
+import { spinAt } from './spinner'
+
+export { SPIN, spinAt } from './spinner'
/** The observation is older than this and the view says so: the daemon writes it after each change, so a long gap means it has stopped. */
export const STALE_AFTER_MS = 10 * 60_000
@@ -61,11 +64,6 @@ export function budgetShort(mission: Mission): string {
return `${money(budget.settledMinor ?? 0, budget.currency)} of ${money(budget.ceilingMinor, budget.currency)}`
}
-/** The spinner's frames, one per tenth of a second, so a running thing visibly turns. */
-export const SPIN = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
-
-export const spinAt = (nowMs: number): string => SPIN[Math.floor(nowMs / 100) % SPIN.length]
-
/** A mission or task the runtime is working on now. */
export const isLive = (state: string): boolean => state === 'running' || state === 'verifying'
diff --git a/plugins/ruflo-console/hooks/spinner.ts b/plugins/ruflo-console/hooks/spinner.ts
new file mode 100644
index 0000000000..44afd56bbc
--- /dev/null
+++ b/plugins/ruflo-console/hooks/spinner.ts
@@ -0,0 +1,7 @@
+/**
+ * The one spinner the console draws for anything in progress: a frame a tenth of a second, so a running thing visibly turns. Shared by
+ * the Missions page, the Performance page and every lab's result, so they all move the same way.
+ */
+export const SPIN = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
+
+export const spinAt = (nowMs: number): string => SPIN[Math.floor(nowMs / 100) % SPIN.length]
diff --git a/plugins/ruflo-console/hooks/views/perf.ts b/plugins/ruflo-console/hooks/views/perf.ts
index 0520a5316e..bf48b116d5 100644
--- a/plugins/ruflo-console/hooks/views/perf.ts
+++ b/plugins/ruflo-console/hooks/views/perf.ts
@@ -1,7 +1,7 @@
import type { RenderElement } from 'claude-code'
import { isPerfResult, PERF, perfMemo, sparkline } from '../perf'
-import { ago, col, row, rule, text, THEME, type Ctx } from './common'
+import { ago, col, row, rule, section, text, THEME, type Ctx } from './common'
import { COST_KEY, entryRow, naRow, resultRows } from './secure'
/** One latency series: its name, the line of blocks, and its newest, lowest and highest sample. */
@@ -27,18 +27,39 @@ function seriesRow(ctx: Ctx, key: string, name: string, values: readonly number[
* Performance: a latency sparkline per series (each `metrics` run adds a sample; `report` reads the stored history),
* every measuring verb by cost, and the last run's output. Nothing runs on open.
*/
+/** The measuring verbs, grouped by what they do: the ones to run now, the benchmarks, and the ones that write local records. */
+const GROUPS: readonly { id: string; title: string; ids: readonly string[]; note: (count: number) => string; open: boolean }[] = [
+ { id: 'perf-measure', title: 'Measure now', ids: ['perf-metrics', 'perf-profile'], note: count => `${count} · $0 · read-only`, open: true },
+ { id: 'perf-bench', title: 'Benchmarks', ids: ['perf-bench-wasm', 'perf-bench-all'], note: count => `${count} · the wasm suite is $0; all may download a model`, open: false },
+ { id: 'perf-record', title: 'Record and analyse', ids: ['perf-report', 'perf-bottleneck', 'perf-optimize'], note: count => `${count} · writes local files`, open: false },
+]
+
+/**
+ * Performance: a latency sparkline per series (each `metrics` run adds a sample; `report` reads the stored history), the
+ * measuring verbs grouped and folded (measure now is open; the benchmarks and the record verbs fold away, each header says what is
+ * inside), the two fixed tables it does not measure, and the last run's output with its spinner while it runs. Nothing runs on open.
+ */
export function perfView(ctx: Ctx): RenderElement {
const memo = perfMemo(ctx.state)
const rows: RenderElement[] = [
rule(ctx, 'Latency', memo.atMs === 0 ? 'no sample yet' : `last sample ${ago(memo.atMs, ctx.nowMs)}${memo.heapMb !== null ? ` · heap ${memo.heapMb.toFixed(1)} MB` : ''}`),
seriesRow(ctx, 'spark-loop', 'event loop', memo.loop, '▸ METRICS adds one sample per run (in-process, $0)'),
seriesRow(ctx, 'spark-report', 'report', memo.report, '▸ REPORT reads the stored history of .claude-flow/performance/metrics.json'),
- rule(ctx, 'Measure', 'local · in-process or a probe file'),
]
+ const grouped = new Set(GROUPS.flatMap(group => group.ids))
+
+ for (const group of GROUPS) {
+ const entries = PERF.filter(entry => group.ids.includes(entry.id))
+
+ rows.push(...section(ctx, group.id, group.title, group.note(entries.length), entries.map(entry => entryRow(ctx, entry)), group.open))
+ }
+
+ // Any verb not yet in a group still shows, in the last group, so none is lost when the list grows.
+ const loose = PERF.filter(entry => !grouped.has(entry.id))
+
+ if (loose.length > 0) rows.push(...section(ctx, 'perf-other', 'Other', `${loose.length}`, loose.map(entry => entryRow(ctx, entry)), false))
- for (const entry of PERF) rows.push(entryRow(ctx, entry))
- rows.push(naRow(ctx, 'CLI BOTTLENECK', '`performance bottleneck` and `optimize` print a fixed table: the MCP tools above measure'))
- rows.push(naRow(ctx, 'MCP METRICS', '`performance_metrics` reports fixed latency figures, so the sparkline reads `metrics` instead'))
+ rows.push(...section(ctx, 'perf-na', 'Not measured here', '2 fixed tables', [naRow(ctx, 'CLI BOTTLENECK', '`performance bottleneck` and `optimize` print a fixed table: the MCP tools above measure'), naRow(ctx, 'MCP METRICS', '`performance_metrics` reports fixed latency figures, so the sparkline reads `metrics` instead')], false))
rows.push(text(ctx, COST_KEY, { dimColor: true }))
rows.push(...resultRows(ctx, isPerfResult))
diff --git a/plugins/ruflo-console/hooks/views/secure.ts b/plugins/ruflo-console/hooks/views/secure.ts
index c992f365f3..a884f13c99 100644
--- a/plugins/ruflo-console/hooks/views/secure.ts
+++ b/plugins/ruflo-console/hooks/views/secure.ts
@@ -2,6 +2,7 @@ import type { RenderElement } from 'claude-code'
import { DOCTOR_COMPONENTS, isSecureResult, SECURE, SECURE_TEXT, secMemo, SEVERITIES, type SecCost, type Severity } from '../secure'
import { slot } from './attention'
+import { spinAt } from '../spinner'
import { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
/** Result lines in view at once; j/k scroll the rest. */
@@ -44,7 +45,7 @@ export function resultRows(ctx: Ctx, isMine: (id: string) => boolean): RenderEle
const right = running !== null ? `running ${Math.round((nowMs - running.startedAtMs) / 1000)}s` : result === null ? 'nothing run yet' : `${result.ok ? '✓' : '✗'} exit ${result.exitCode ?? 'n/a'} · ${ago(result.atMs, nowMs)}`
const rows: RenderElement[] = [rule(ctx, 'Result', right)]
- if (running !== null) rows.push(text(ctx, ` ▸ ${running.label} … ${Math.floor(nowMs / 500) % 2 === 0 ? '█' : ' '}`, { color: THEME.warn }))
+ if (running !== null) rows.push(text(ctx, ` ${spinAt(nowMs)} ${running.label} · ${Math.round((nowMs - running.startedAtMs) / 1000)}s`, { color: THEME.warn }))
if (result === null) {
if (running === null) rows.push(text(ctx, ' ▸ run an entry: a $0 read shows here at once; the rest show here after you confirm (y)', { dimColor: true }))