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 Missions page animates while a mission, a task or a guidance run is live

ruvab5ecd6aa179
diff --git a/plugins/ruflo-console/hooks/controller.ts b/plugins/ruflo-console/hooks/controller.ts
index 07f269f087..31fbbea860 100644
--- a/plugins/ruflo-console/hooks/controller.ts
+++ b/plugins/ruflo-console/hooks/controller.ts
@@ -14,7 +14,8 @@ import { markPicture } from './gfx/pictures'
import type { Host } from './host'
import { agentLogs } from './ops'
import { createRunner, type Runner } from './runner'
-import { advance, loadLedger } from './mission-control'
+import { advance, loadLedger, mcOf } from './mission-control'
+import { hasLiveWork } from './mission-list'
import { loadAllowed } from './remember'
import { loadAiPrefs } from './settings'
import { openLoaders } from './view-open'
@@ -284,7 +285,10 @@ 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 {
- if (!(state.options.fps > 0 && isVisible() && (state.pane.isFocused || isBooting(state, Date.now())) && state.mounted.size > 0)) {
+ // 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')
+
+ if (!(state.options.fps > 0 && isVisible() && (state.pane.isFocused || isBooting(state, Date.now())) && (state.mounted.size > 0 || moving))) {
cancel('frames')
return
diff --git a/plugins/ruflo-console/hooks/mission-list.ts b/plugins/ruflo-console/hooks/mission-list.ts
index bde58f3644..91e0fb6537 100644
--- a/plugins/ruflo-console/hooks/mission-list.ts
+++ b/plugins/ruflo-console/hooks/mission-list.ts
@@ -61,14 +61,31 @@ export function budgetShort(mission: Mission): string {
return `${money(budget.settledMinor ?? 0, budget.currency)} of ${money(budget.ceilingMinor, budget.currency)}`
}
-const GLYPH: Record<string, string> = { running: '◐', verifying: '◐', completed: '●', failed: '✖', blocked: '✖', cancelled: '–' }
+/** The spinner's frames, one per tenth of a second, so a running thing visibly turns. */
+export const SPIN = '⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏'
-/** The one-line row: a state glyph, the objective cut to fit, then the state, tasks, evidence and budget. */
-export function missionRow(mission: Mission, maxObjective = 36): string {
+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'
+
+const GLYPH: Record<string, string> = { completed: '●', failed: '✖', blocked: '✖', cancelled: '–' }
+
+/** The one-line row: a state glyph (a spinner while it runs), the objective cut to fit, then the state, tasks, evidence and budget. */
+export function missionRow(mission: Mission, nowMs = 0, maxObjective = 36): string {
const objective = mission.objective === '' ? '(no objective)' : mission.objective
const cut = objective.length > maxObjective ? `${objective.slice(0, maxObjective - 1)}…` : objective
+ const glyph = isLive(mission.state) ? spinAt(nowMs) : (GLYPH[mission.state] ?? '○')
- return `${GLYPH[mission.state] ?? '○'} ${cut} · ${mission.state} · tasks ${taskProgress(mission)} · verified ${mission.evidence.verified}/${mission.evidence.count} · ${budgetShort(mission)}`
+ return `${glyph} ${cut} · ${mission.state} · tasks ${taskProgress(mission)} · verified ${mission.evidence.verified}/${mission.evidence.count} · ${budgetShort(mission)}`
+}
+
+/**
+ * Whether anything on the list is moving now (a mission running or verifying, a task running, or a guidance run in flight), so the
+ * pane keeps redrawing while it is and stops when it is not.
+ */
+export function hasLiveWork(missions: readonly Mission[], guidanceRunning: boolean): boolean {
+ return guidanceRunning || missions.some(mission => isLive(mission.state) || mission.plan.tasks.some(task => task.status === 'running'))
}
/** The cursor kept on the list: 0 for an empty list, else between the first and last mission. */
@@ -82,7 +99,7 @@ export function clampCursor(cursor: number, total: number): number {
* The part of the list the view draws: a window of `size` missions that keeps the cursor on screen, the one-line row of each,
* and the cursor's mission to expand below them. `hidden` counts the missions outside the window.
*/
-export function listLayout(missions: readonly Mission[], cursor: number, size = LIST_WINDOW): { rows: { index: number; line: string }[]; expanded: Mission | null; hidden: number } {
+export function listLayout(missions: readonly Mission[], cursor: number, nowMs = 0, size = LIST_WINDOW): { rows: { index: number; line: string }[]; expanded: Mission | null; hidden: number } {
const sorted = sortMissions(missions)
if (sorted.length === 0) return { rows: [], expanded: null, hidden: 0 }
@@ -90,7 +107,7 @@ export function listLayout(missions: readonly Mission[], cursor: number, size =
const at = clampCursor(cursor, sorted.length)
const start = Math.min(Math.max(0, at - Math.floor(size / 2)), Math.max(0, sorted.length - size))
const end = Math.min(sorted.length, start + size)
- const rows = sorted.slice(start, end).map((mission, i) => ({ index: start + i, line: missionRow(mission) }))
+ const rows = sorted.slice(start, end).map((mission, i) => ({ index: start + i, line: missionRow(mission, nowMs) }))
return { rows, expanded: sorted[at], hidden: sorted.length - rows.length }
}
diff --git a/plugins/ruflo-console/hooks/views/missions.ts b/plugins/ruflo-console/hooks/views/missions.ts
index 40c6b58e63..c52a8e7eb0 100644
--- a/plugins/ruflo-console/hooks/views/missions.ts
+++ b/plugins/ruflo-console/hooks/views/missions.ts
@@ -1,7 +1,7 @@
import type { RenderElement } from 'claude-code'
import { money, type Mission } from '../data/missions'
-import { attentionCount, clampCursor, freshnessOf, listLayout } from '../mission-list'
+import { attentionCount, clampCursor, freshnessOf, isLive, listLayout, spinAt } from '../mission-list'
import { ago, kv, rule, text, THEME, type Ctx } from './common'
const STATE_COLOR: Record<string, string> = { running: THEME.warn, verifying: THEME.warn, completed: THEME.ok, failed: THEME.bad, blocked: THEME.bad, paused: THEME.info, queued: THEME.info }
@@ -15,12 +15,12 @@ function missionRows(ctx: Ctx, mission: Mission, isFirst: boolean): RenderElemen
text(ctx, `${isFirst ? '▸' : ' '} ${mission.objective || '(no objective)'}`, { bold: true, ...(STATE_COLOR[mission.state] !== undefined && { color: STATE_COLOR[mission.state] }) }),
text(
ctx,
- ` ${mission.state} · rev ${mission.revision} · ${mission.executionMode === 'session-bound' ? 'session-bound (runs only while a session drives it)' : mission.executionMode} · ${mission.id}`,
+ ` ${isLive(mission.state) ? `${spinAt(ctx.nowMs)} ` : ''}${mission.state} · rev ${mission.revision} · ${mission.executionMode === 'session-bound' ? 'session-bound (runs only while a session drives it)' : mission.executionMode} · ${mission.id}`,
{ dimColor: true },
),
text(
ctx,
- ` plan rev ${mission.plan.revision}: ${mission.plan.taskCount === 0 ? 'no tasks yet' : mission.plan.tasks.map(task => `${TASK_GLYPH[task.status] ?? '?'} ${task.id}`).join(' → ')}${mission.plan.taskCount > mission.plan.tasks.length ? ` (+${mission.plan.taskCount - mission.plan.tasks.length})` : ''}`,
+ ` plan rev ${mission.plan.revision}: ${mission.plan.taskCount === 0 ? 'no tasks yet' : mission.plan.tasks.map(task => `${task.status === 'running' ? spinAt(ctx.nowMs) : (TASK_GLYPH[task.status] ?? '?')} ${task.id}`).join(' → ')}${mission.plan.taskCount > mission.plan.tasks.length ? ` (+${mission.plan.taskCount - mission.plan.tasks.length})` : ''}`,
),
text(
ctx,
@@ -59,7 +59,7 @@ export function observationRows(ctx: Ctx): RenderElement[] {
// One line a mission; the cursor's mission (j and k move it) is expanded below the list.
const cursor = clampCursor(ctx.state.select.item, observation.missions.length)
- const layout = listLayout(observation.missions, cursor)
+ const layout = listLayout(observation.missions, cursor, ctx.nowMs)
for (const { index, line } of layout.rows) rows.push(text(ctx, `${index === cursor ? '▸' : ' '} ${line}`, index === cursor ? { bold: true } : { dimColor: true }))
if (layout.hidden > 0) rows.push(text(ctx, ` ${layout.hidden} more not shown · j and k scroll`, { dimColor: true }))
diff --git a/plugins/ruflo-console/tests/mission-list.spec.ts b/plugins/ruflo-console/tests/mission-list.spec.ts
index 538836621c..5918d8804a 100644
--- a/plugins/ruflo-console/tests/mission-list.spec.ts
+++ b/plugins/ruflo-console/tests/mission-list.spec.ts
@@ -6,7 +6,7 @@
import { describe, expect, it } from 'vitest'
import { money, type Mission } from '../hooks/data/missions'
-import { attentionCount, budgetShort, clampCursor, freshnessOf, listLayout, LIST_WINDOW, missionRank, missionRow, sortMissions, STALE_AFTER_MS, taskProgress } from '../hooks/mission-list'
+import { attentionCount, budgetShort, clampCursor, freshnessOf, hasLiveWork, listLayout, LIST_WINDOW, missionRank, missionRow, SPIN, sortMissions, spinAt, STALE_AFTER_MS, taskProgress } from '../hooks/mission-list'
const mission = (over: Partial<Mission> = {}): Mission => ({
id: 'm',
@@ -49,6 +49,28 @@ describe('mission order', () => {
})
})
+describe('live indicators', () => {
+ it('turns a spinner one frame every tenth of a second, so a running thing visibly moves', () => {
+ expect(spinAt(0)).toBe(SPIN[0])
+ expect(spinAt(100)).toBe(SPIN[1])
+ expect(spinAt(1_000)).toBe(SPIN[0])
+ })
+
+ it('a running mission carries the spinner on its row; a finished one keeps its fixed glyph', () => {
+ expect(missionRow(mission({ state: 'running' }), 200).startsWith(`${SPIN[2]} `)).toBe(true)
+ expect(missionRow(mission({ state: 'completed' }), 200).startsWith('● ')).toBe(true)
+ })
+
+ it('there is live work while a mission, a task or a guidance run is moving, and none once all have stopped', () => {
+ const task = (status: string) => ({ id: 't', title: 't', dependsOn: [], status })
+
+ expect(hasLiveWork([mission({ state: 'running' })], false)).toBe(true)
+ expect(hasLiveWork([mission({ plan: { revision: 1, taskCount: 1, tasks: [task('running')] } })], false)).toBe(true)
+ expect(hasLiveWork([], true)).toBe(true)
+ expect(hasLiveWork([mission({ state: 'completed' }), mission({ state: 'blocked' })], false)).toBe(false)
+ })
+})
+
describe('observation age', () => {
const now = 1_000_000_000
@@ -97,9 +119,9 @@ describe('one-line row', () => {
})
it('cuts a long objective to fit and names a missing one', () => {
- const long = missionRow(mission({ objective: 'x'.repeat(80) }), 20)
+ const long = missionRow(mission({ objective: 'x'.repeat(80) }), 0, 20)
- expect(long.startsWith('◐ xxxxxxxxxxxxxxxxxxx… ·')).toBe(true)
+ expect(long.startsWith(`${spinAt(0)} xxxxxxxxxxxxxxxxxxx… ·`)).toBe(true)
expect(missionRow(mission({ objective: '' }))).toContain('(no objective)')
})
})