Merge pull request #3652 from ruvnet/feat/console-toolrows

feat(ruflo-console): 0.20.0 — tool rows name the mission task they belong to
This commit is contained in:
rUv authored and GitHub committed 2026-10-03 00:41:21 -07:00
commit a7ffbe95a3
7 files changed
+177 -3

No files matched your search

@@ -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; no network by default.",
"version": "0.19.0",
"version": "0.20.0",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
+13
View File
@@ -7,6 +7,7 @@ import { plain } from './data/parse'
import { dispatch } from './dispatch'
import { markPicture } from './gfx/pictures'
import type { Host } from './host'
import { ownerLine, ownerOf } from './tool-owner'
import { newState, PANE_ID, restore, restoreSessions, storeKeyOf, termStoreKeyOf } from './state'
import { BAR_KEY, barView } from './views/bar'
import type { Kit } from './views/common'
@@ -240,6 +241,18 @@ export const register: Register = (on, raw: PluginOptions) => {
})
})
// A tool row that ran while one mission task was running says which: one dim line under the engine's own row.
on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
const owner = ownerOf(state, e.props.tool_use_id, e.props.isRunning === true)
if (owner === null) return next(e)
const table = $.ui.resolve(e) as unknown as Kit
const own = await next(e)
return table.Box({ key: `owner-${e.props.tool_use_id}`, flexDirection: 'column', children: [own, table.Text({ dimColor: true, children: ` ${ownerLine(owner)}` })] })
})
/** The band's mark pulses during a turn: a redraw at its start, and the loop stopped at its end, whatever redraws. */
on('turn.start', ($, e, next) => {
try {
+48
View File
@@ -0,0 +1,48 @@
/**
* Which mission task a tool row belongs to. A call is attributed the first time its row is drawn while it runs: if the
* active mission is neither paused nor cancelled and exactly one of its tasks is running (the one handed to the
* session), that task owns the call, and keeps it after the task finishes. A call first seen already finished, or
* while no task or several tasks run, belongs to no task: the row says nothing rather than guess.
*/
import { activeMission, derive } from './mission-control'
import type { State } from './state'
export type Owner = { taskId: string; title: string; phase: string; missionId: string }
const MAX_REMEMBERED = 500
const owners = new WeakMap<State, Map<string, Owner | null>>()
/** The one running task of the active mission, or null when none or more than one run (or the mission is paused or cancelled). */
export function runningOwner(state: State): Owner | null {
const mission = activeMission(state)
if (mission === null || mission.paused || mission.cancelled) return null
const status = derive(mission, state.snapshot?.tasks ?? [])
const running = mission.tasks.filter(task => status.get(task.id) === 'running')
const [only] = running
return running.length === 1 && only !== undefined ? { taskId: only.id, title: only.title, phase: only.phase, missionId: mission.id } : null
}
/** The owner of one call by its tool-use id: decided at first sight and remembered. */
export function ownerOf(state: State, toolUseId: string, isRunning: boolean): Owner | null {
let known = owners.get(state)
if (known === undefined) {
known = new Map()
owners.set(state, known)
}
if (known.has(toolUseId)) return known.get(toolUseId) ?? null
const owner = isRunning ? runningOwner(state) : null
known.set(toolUseId, owner)
if (known.size > MAX_REMEMBERED) known.delete(known.keys().next().value as string)
return owner
}
/** The one dim line a tool row carries under it, e.g. `↳ mission task: Write the tests (test)`. */
export const ownerLine = (owner: Owner): string => `↳ mission task: ${owner.title} (${owner.phase})`
+2 -2
View File
@@ -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.19.0"
step "1. plugin.json declares ruflo-console 0.20.0"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
&& grep -q '"version": "0.19.0"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
&& grep -q '"version": "0.20.0"' "$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" \
@@ -142,6 +142,21 @@ describe('mission control', () => {
await pane.unmount()
})
test('a tool row drawn with no task running is the engine row, untouched', { options: { boot: false } }, async ($, on) => {
const { pane, clock } = await opened($, on)
const row = (id: string) => ({ component: 'ToolUse', surface: 'terminal', requestId: id, viewport: { columns: 120, rows: 40, isFullscreen: true }, props: { tool_use_id: id, tool: 'Bash', input: {}, isRunning: true, isErrored: false, isInterrupted: false } }) as never
// Attribution itself is the pure spec's (tool-owner.spec.ts): here, a row with no task running is the engine's own,
// before a mission exists and after one is created but nothing has been handed to Claude.
expect(textOf(await $.ui.render(row('before')))).toBe('engine')
await pane.input({ key: 'mc-goal', text: 'add a dark mode toggle to settings', kind: 'submit' })
await pane.press({ key: 'mc-create' })
await $.command.run(command('yes'))
await settle(pane, clock)
expect(textOf(await $.ui.render(row('created')))).toBe('engine')
await pane.unmount()
})
test('guide Claude asks under its own field, keeps what was sent so ✎ edit can reload it, and ruflo-goals skills show as mission options with the unavailable ones marked', { options: { boot: false } }, async ($, on) => {
const { world, pane, clock } = await opened($, on, RUFLO_FILES, { commands: ['ruflo-goals:goal-plan'] })
@@ -0,0 +1,54 @@
/**
* Which mission task a tool row belongs to, pure: attributed once, at first sight while the call runs, to the one running
* task of an active mission, and never guessed. Run with
* npx vitest run plugins/ruflo-console/tests/tool-owner.spec.ts
*/
import { describe, expect, it } from 'vitest'
import { mcOf, type MissionRecord } from '../hooks/mission-control'
import { newState, type State } from '../hooks/state'
import { ownerLine, ownerOf, runningOwner } from '../hooks/tool-owner'
const task = (id: string, title: string, phase: string, dependsOn: string[] = []) => ({ id, title, phase, agent: 'coder', requirement: 'r', dependsOn, rufloTaskId: `rt-${id}` })
const mission = (over: Partial<MissionRecord> = {}): MissionRecord => ({
id: 'm1', objective: 'o', profile: 'feature', rigor: 'standard', tasks: [task('a', 'Research it', 'research'), task('b', 'Write the tests', 'test', ['a'])], acceptance: [], events: [], paused: false, cancelled: false, auto: false, createdAtMs: 0, ...over,
})
function stateWith(record: MissionRecord, statuses: Record<string, string>): State {
const state = newState({})
mcOf(state).missions.set(record.id, record)
mcOf(state).active = record.id
;(state as unknown as { snapshot: unknown }).snapshot = { tasks: Object.entries(statuses).map(([id, status]) => ({ id: `rt-${id}`, status })) }
return state
}
describe('tool row owner', () => {
it('the one running task owns a call first seen while it runs, and keeps it after the task ends', () => {
const state = stateWith(mission(), { a: 'in_progress', b: 'pending' })
expect(ownerOf(state, 'call-1', true)).toMatchObject({ taskId: 'a', title: 'Research it', phase: 'research' })
;(state as unknown as { snapshot: unknown }).snapshot = { tasks: [{ id: 'rt-a', status: 'completed' }, { id: 'rt-b', status: 'in_progress' }] }
expect(ownerOf(state, 'call-1', false)?.taskId).toBe('a')
expect(ownerOf(state, 'call-2', true)?.taskId).toBe('b')
})
it('a call first seen already finished, or with no running task, belongs to none', () => {
const state = stateWith(mission(), { a: 'in_progress', b: 'pending' })
expect(ownerOf(state, 'old', false)).toBeNull()
expect(ownerOf(stateWith(mission(), { a: 'pending', b: 'pending' }), 'x', true)).toBeNull()
})
it('two running tasks, a paused mission or a cancelled one attribute nothing', () => {
expect(runningOwner(stateWith(mission({ tasks: [task('a', 'A', 'x'), task('b', 'B', 'y')] }), { a: 'in_progress', b: 'in_progress' }))).toBeNull()
expect(runningOwner(stateWith(mission({ paused: true }), { a: 'in_progress' }))).toBeNull()
expect(runningOwner(stateWith(mission({ cancelled: true }), { a: 'in_progress' }))).toBeNull()
expect(runningOwner(newState({}))).toBeNull()
})
it('the row line names the task and its phase', () => {
expect(ownerLine({ taskId: 'a', title: 'Research it', phase: 'research', missionId: 'm1' })).toBe('↳ mission task: Research it (research)')
})
})
@@ -0,0 +1,44 @@
# ADR 418: Tool rows name the mission task they belong to
Status: Accepted (ships in ruflo-console 0.20.0)
Date: 2026 10 03
Decision owner: Ruflo maintainers
Scope: `plugins/ruflo-console`: `hooks/tool-owner.ts`, the `ToolUse` render hook in `hooks/register.ts`, `tests/tool-owner.spec.ts`, `tests/missions.test.ts`.
Extends: ADR 407, ADR 409 (the mission lifecycle). Companion to ADR 412.
## 1. Context
Mission Control hands one task at a time to the primary session. The transcript then fills with tool rows (Bash, Read, Edit, ruflo MCP calls) and nothing ties a row to the task that caused it. Reading back a mission, or checking evidence for a task, meant counting rows by hand.
## 2. Decision
A `ui.render` hook on the `ToolUse` component adds one dim line under the engine's own row: `↳ mission task: <title> (<phase>)`.
- **Attribution is made once, at first sight, while the call runs.** If the active mission is neither paused nor cancelled and **exactly one** of its tasks is running (derived from the ruflo task store, as everywhere else in Mission Control), that task owns the call. The answer is remembered by tool-use id, so the line stays on the row after the task completes.
- **Nothing is guessed.** A call first seen already finished (history drawn after a reload), a call with no task running, two tasks running, or a paused or cancelled mission all leave the row exactly as the engine drew it.
- The engine's row is never replaced: the hook draws it with `next(e)` and puts the line beneath it. If the hook declines, the engine row is drawn unchanged.
- The memory is bounded (500 calls, oldest dropped).
## 3. Alternatives considered
- **Matching by tool name or arguments.** Rejected: a model can use any tool for any task, so a match would be a guess presented as a fact.
- **Attributing by time window from `dispatchedAtMs`.** Rejected: row draw time is not call start time, and a reload redraws old rows.
- **Writing the owner into the ledger.** Deferred: the ledger records task events and evidence; per-call ownership is a display aid and is derivable only while the task runs.
## 4. Consequences
- A mission read back in the transcript shows which task each step served.
- Two concurrent tasks (not produced by Mission Control today) would show no line rather than a wrong one.
## 5. Safety
No tool input or output is read or copied; the line carries only the task's own title and phase. No spend, no network.
## 6. Tests
- `tests/tool-owner.spec.ts`: the single running task owns a call and keeps it after finishing; finished-first-seen and no-running-task calls have no owner; two running tasks, a paused mission, a cancelled one and no mission attribute nothing; the line text.
- `tests/missions.test.ts` (kit): a row drawn with no task running, before a mission and after one is created, is the engine's own. The positive case (a row carrying the line, drawn through the host) is not covered by a kit test: the kit runner was switched off server-side while this shipped, so a test that could not be run was not added.