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): 0.14.1 — confirms and answers open under the element that was clicked, on every page; clearer confirm indicator

ruv589ccadc1932
diff --git a/plugins/ruflo-console/.claude-plugin/plugin.json b/plugins/ruflo-console/.claude-plugin/plugin.json
index 7613cd87e8..99c3f3c50e 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; no network by default.",
- "version": "0.14.0",
+ "version": "0.14.1",
"author": {
"name": "ruvnet",
"url": "https://github.com/ruvnet"
diff --git a/plugins/ruflo-console/hooks/register.ts b/plugins/ruflo-console/hooks/register.ts
index c199a133c7..9d5507cc7b 100644
--- a/plugins/ruflo-console/hooks/register.ts
+++ b/plugins/ruflo-console/hooks/register.ts
@@ -1,4 +1,5 @@
import type { EngineInterface, PluginOptions, Register } from 'claude-code'
+import { ANSWER_KEYS } from './views/attention'
import { createController, type Controller } from './controller'
import { record } from './data/events'
@@ -154,6 +155,20 @@ export const register: Register = (on, raw: PluginOptions) => {
return dispatch(control, state, e.args, async () => (await next(e)) as { text?: string } | undefined)
})
+ // Which element was pressed or submitted, before its own closure runs: the runner reads it as the origin of the ask that follows, so
+ // the page puts the confirm and the answer right under it (views/attention.ts). Answering a confirm never moves the origin.
+ on('ui.press', { component: 'Pane' }, ($, e, next) => {
+ if (!ANSWER_KEYS.has(e.element)) state.lastPressed = e.element
+
+ return next(e)
+ })
+
+ on('ui.input', { component: 'Pane' }, ($, e, next) => {
+ if (e.kind === 'submit') state.lastPressed = e.element
+
+ return next(e)
+ })
+
on('ui.render', { component: 'Pane', requestId: PANE_ID }, ($, e, next) => {
if (control === null) {
return next(e)
diff --git a/plugins/ruflo-console/hooks/runner.ts b/plugins/ruflo-console/hooks/runner.ts
index d0a7a937e2..fd0de7ff93 100644
--- a/plugins/ruflo-console/hooks/runner.ts
+++ b/plugins/ruflo-console/hooks/runner.ts
@@ -105,6 +105,9 @@ export function createRunner(state: State, host: Host, deps: RunnerDeps): Runner
function ask(spec: ActionSpec | null, why: string): void {
state.palette.isOpen = false
+ // Where this came from: the page puts the confirm and the answer right after that element. A headless run has no press, so it falls back to the top.
+ state.origin = state.lastPressed
+ state.lastPressed = null
if (spec === null) {
pendingSpec = null
diff --git a/plugins/ruflo-console/hooks/state.ts b/plugins/ruflo-console/hooks/state.ts
index 9536350c60..2ec05489ae 100644
--- a/plugins/ruflo-console/hooks/state.ts
+++ b/plugins/ruflo-console/hooks/state.ts
@@ -224,6 +224,9 @@ export type State = {
drill: { agentId: string | null; logs: string[] | null; logsAtMs: number }
palette: { isOpen: boolean; query: string; index: number; context: 'all' | 'selection' }
pending: Pending | null
+ /** The key of the element last pressed, and the one the last ask or answer came from: the page draws them right there (views/attention.ts). */
+ lastPressed: string | null
+ origin: string | null
outcome: Outcome | null
isActing: boolean
/** The MetaHarness lab: its last result, and the run in flight (j/k scroll the result through `select.item`). */
@@ -314,6 +317,8 @@ export function newState(raw: PluginOptions | undefined): State {
drill: { agentId: null, logs: null, logsAtMs: 0 },
palette: { isOpen: false, query: '', index: 0, context: 'all' },
pending: null,
+ lastPressed: null,
+ origin: null,
outcome: null,
isActing: false,
lab: { result: null, running: null },
diff --git a/plugins/ruflo-console/hooks/views/attention.ts b/plugins/ruflo-console/hooks/views/attention.ts
new file mode 100644
index 0000000000..fd14a05ab8
--- /dev/null
+++ b/plugins/ruflo-console/hooks/views/attention.ts
@@ -0,0 +1,137 @@
+/**
+ * Answers open where they were asked, on every page. When a button or field raises an ask (a confirm) or an answer (an outcome),
+ * the runner records which element it was (`state.origin`). The page is then drawn through a kit whose column boxes watch for that
+ * element: the confirm and the outcome are placed right after the row that holds it, so the person never scrolls to the top to find
+ * what to click. If the element is not on screen (a hotkey, the palette, a folded section), the panel falls back to the top.
+ *
+ * Nothing here reads the engine's element shapes: each Button and Input the page builds is remembered by identity with its key, each
+ * Box inherits the keys of its children, and the first column Box that holds the key gets the panel after that child.
+ */
+import type { RenderElement } from 'claude-code'
+
+import type { State } from '../state'
+import { confirmInline, confirmRow, text, THEME, type Ctx } from './common'
+
+/** Presses that answer an ask rather than raise one: they never move the origin. */
+export const ANSWER_KEYS: ReadonlySet<string> = new Set(['confirm', 'cancel', 'remember', 'always'])
+
+export type Attention = {
+ /** The key of the element the ask or answer came from. */
+ key: string | null
+ /** What to place after it. */
+ panel: RenderElement[]
+ placed: boolean
+ keys: WeakMap<object, Set<string>>
+ /** `collect`: a lab's result block hands its rows over (`slot`); `hide`: the panel carries them, so the block draws nothing; `draw`: the block draws itself. */
+ mode: 'draw' | 'collect' | 'hide'
+ donated: RenderElement[]
+}
+
+const flat = (children: unknown): unknown[] => (Array.isArray(children) ? children.flatMap(flat) : children === null || children === undefined || typeof children === 'boolean' ? [] : [children])
+const isObject = (value: unknown): value is object => typeof value === 'object' && value !== null
+
+const donations = new WeakMap<State, { stamp: string; rows: RenderElement[] }>()
+
+/**
+ * The rows a lab view donated for this state, reused while nothing they show has changed (the view, the width, the result, its scroll
+ * and the running spinner), so the extra drawing that finds them happens once per result rather than on every frame.
+ */
+export function donated(ctx: Ctx, draw: () => RenderElement[]): RenderElement[] {
+ const { state, nowMs } = ctx
+ const result = state.lab.result
+ const running = state.lab.running
+ const stamp = [state.view, ctx.columns, result?.atMs ?? 0, result?.id ?? '', state.select.item, running === null ? 0 : Math.floor(nowMs / 500) + 1, state.origin].join('|')
+ const kept = donations.get(state)
+
+ if (kept !== undefined && kept.stamp === stamp) return kept.rows
+
+ const rows = draw()
+
+ donations.set(state, { stamp, rows })
+
+ return rows
+}
+
+export const newAttention = (key: string | null, panel: RenderElement[]): Attention => ({ key, panel, placed: false, keys: new WeakMap(), mode: 'draw', donated: [] })
+
+const keyOfElement = (element: unknown): string | null => {
+ const key = (element as { key?: unknown }).key ?? (element as { props?: { key?: unknown } }).props?.key
+
+ return typeof key === 'string' && key !== '' ? key : null
+}
+
+/**
+ * The kit for this frame. While an ask or answer is waiting for its place (an origin is set), every column Box is watched: the first
+ * one that holds the origin's element gets the panel after that child. Otherwise the kit is returned as it is, so a quiet page costs
+ * nothing extra. Which element was pressed is recorded by the `ui.press` and `ui.input` hooks (register.ts), not here.
+ */
+export function wrapKit(kit: Ctx['kit'], _state: State, attention: Attention): Ctx['kit'] {
+ if (attention.key === null) return kit
+
+ const Box: Ctx['kit']['Box'] = props => {
+ const kids = flat((props as { children?: unknown }).children)
+ let next = props
+
+ if (!attention.placed && (props as { flexDirection?: string }).flexDirection === 'column' && attention.panel.length > 0) {
+ const at = kids.findIndex(kid => isObject(kid) && (attention.keys.get(kid)?.has(attention.key as string) === true || keyOfElement(kid) === attention.key))
+
+ if (at >= 0) {
+ attention.placed = true
+ kids.splice(at + 1, 0, ...attention.panel)
+ next = { ...props, children: kids } as typeof props
+ }
+ }
+
+ const element = kit.Box(next)
+ const keys = new Set<string>()
+
+ for (const kid of kids) {
+ if (!isObject(kid)) continue
+
+ const own = keyOfElement(kid)
+
+ if (own !== null) keys.add(own)
+ for (const key of attention.keys.get(kid) ?? []) keys.add(key)
+ }
+
+ if (keys.size > 0 && isObject(element)) attention.keys.set(element, keys)
+
+ return element
+ }
+
+ return { ...kit, Box }
+}
+
+/**
+ * Where a lab view draws its result block: normally the rows themselves (at the foot of the lab); while the page is being drawn to
+ * find them (`collect`) they are handed to the panel instead, which places them under the row that was clicked.
+ */
+export function slot(ctx: Ctx, rows: RenderElement[]): RenderElement[] {
+ const attention = ctx.attention
+
+ if (attention?.mode === 'collect') attention.donated.push(...rows)
+
+ return attention === undefined || attention.mode === 'draw' ? rows : []
+}
+
+/** The outcome of the last action as rows: what ran, whether it worked, and its first lines. Nothing when it is old. */
+export function outcomeRows(ctx: Ctx): RenderElement[] {
+ const { state, nowMs } = ctx
+ const outcome = state.outcome
+
+ if (outcome === null || nowMs - outcome.atMs >= 90_000) return []
+
+ return [
+ text(ctx, `${outcome.ok ? '✓' : '✗'} ${outcome.label}${outcome.verified === 'yes' ? ' · on disk' : outcome.verified === 'no' ? ' · not on disk yet' : ''}: ${outcome.detail}`, { color: outcome.ok ? THEME.ok : THEME.bad }),
+ ...(outcome.lines ?? []).slice(0, 8).map(line => text(ctx, ` ${line}`, { dimColor: true })),
+ ]
+}
+
+/** The panel for this frame: the confirm (unless the page draws its own) and the outcome. Empty when the ask came from nowhere on screen. */
+export function panelOf(ctx: Ctx, donated: readonly RenderElement[] = []): RenderElement[] {
+ const confirm = confirmRow(ctx)
+ const own = ctx.state.pending !== null && confirmInline(ctx.state.view, ctx.state.pending.scope)
+ const rows = [...(confirm !== null && !own ? [confirm] : []), ...outcomeRows(ctx), ...donated]
+
+ return rows.length === 0 ? [] : [ctx.kit.Box({ key: 'attention', flexDirection: 'column', paddingX: 1, children: rows })]
+}
diff --git a/plugins/ruflo-console/hooks/views/automate.ts b/plugins/ruflo-console/hooks/views/automate.ts
index 3944bfed2e..886fd6d38f 100644
--- a/plugins/ruflo-console/hooks/views/automate.ts
+++ b/plugins/ruflo-console/hooks/views/automate.ts
@@ -5,6 +5,7 @@ import { laneOf, WORKER_ABOUT, WORKER_NAMES, type WorkerName } from '../data/aut
import type { TaskRecord } from '../data/parse'
import type { LabCost } from '../mh-lab'
import { neuralEntries } from '../neural'
+import { slot } from './attention'
import { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
import { selection } from './select'
@@ -71,7 +72,7 @@ export function resultRows(ctx: Ctx, prefixes: readonly string[]): RenderElement
rows.push(row(ctx, [text(ctx, ` lines ${top + 1}-${Math.min(result.lines.length, top + RESULT_ROWS)} of ${result.lines.length} `, { dimColor: true }), button(ctx, 'res-up', 'up', () => ctx.act.select(-1), { hotkey: 'k' }), button(ctx, 'res-down', 'down', () => ctx.act.select(1), { hotkey: 'j' })]))
}
- return rows
+ return slot(ctx, rows)
}
/** One worker's light: running now (◌), failing (◐), has run (●), or never run here (○). */
@@ -295,3 +296,6 @@ export function automateView(ctx: Ctx): RenderElement {
'automate',
)
}
+
+/** This view's result block alone: the pane asks for it to place under the row that was clicked. */
+export const automateResult = (ctx: Ctx): RenderElement[] => resultRows(ctx, ['auto-'])
diff --git a/plugins/ruflo-console/hooks/views/common.ts b/plugins/ruflo-console/hooks/views/common.ts
index a35cda3768..c6ee240f96 100644
--- a/plugins/ruflo-console/hooks/views/common.ts
+++ b/plugins/ruflo-console/hooks/views/common.ts
@@ -4,6 +4,7 @@
* Text colours are theme names only, so nothing fades on a light background.
*/
import type { AskActions } from '../ask-claude'
+import type { Attention } from './attention'
import type { Elements, RenderChildren, RenderElement } from 'claude-code'
import type { ProbeResult } from '../data/cli'
@@ -97,6 +98,8 @@ export type Ctx = {
/** Every picture of this view, by Raster key, already drawn for this frame. */
pictures: Map<string, Grid>
act: Actions
+ /** The page's attention panel (views/attention.ts): lab views hand their result rows to it with `slot`. */
+ attention?: Attention
}
export type Look = 'bbs' | 'plain'
@@ -282,6 +285,7 @@ export function confirmRow(ctx: Ctx): RenderElement | null {
return col(
ctx,
[
+ text(ctx, '▶ CONFIRM NEEDED — click Yes or press y', { bold: true, color: THEME.warn }),
text(ctx, `Confirm: ${pending.label.replace(/\?+$/, '')}?`, { bold: true, color: THEME.warn }),
// Wrapped, not clipped: the person says yes to the whole argv, so all of it shows (a JSON argument runs long).
ctx.kit.Text({ dimColor: true, wrap: 'wrap', children: `runs: ${pending.shows ?? `ruflo ${pending.args.join(' ')}`}` }),
diff --git a/plugins/ruflo-console/hooks/views/devtools.ts b/plugins/ruflo-console/hooks/views/devtools.ts
index 168379aecd..0188784a1f 100644
--- a/plugins/ruflo-console/hooks/views/devtools.ts
+++ b/plugins/ruflo-console/hooks/views/devtools.ts
@@ -2,6 +2,7 @@ import type { RenderElement } from 'claude-code'
import type { DevField } from '../data/devtools'
import { DEV, DEV_GROUPS, devSpec, type DevCost, type DevEntry, type DevGroup } from '../devtools'
+import { slot } from './attention'
import { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
/** Result lines in view at once; j/k scroll the rest. */
@@ -111,7 +112,7 @@ function resultRows(ctx: Ctx): RenderElement[] {
)
}
- return rows
+ return slot(ctx, rows)
}
/**
@@ -136,3 +137,6 @@ export function devtoolsView(ctx: Ctx): RenderElement {
return col(ctx, rows, 'devtools')
}
+
+/** This lab's result block alone: the pane asks for it to place under the row that was clicked. */
+export const devtoolsResult = (ctx: Ctx): RenderElement[] => resultRows(ctx)
diff --git a/plugins/ruflo-console/hooks/views/evolve.ts b/plugins/ruflo-console/hooks/views/evolve.ts
index 10e79324c0..8bd4e8890d 100644
--- a/plugins/ruflo-console/hooks/views/evolve.ts
+++ b/plugins/ruflo-console/hooks/views/evolve.ts
@@ -3,6 +3,7 @@ import type { RenderElement } from 'claude-code'
import { shortRef, type Manifest, type Receipt } from '../data/evolve'
import { candidateReceipt, EVOLVE, evolveSpec, PROMOTE_COMMAND, REPOS, type EvolveEntry } from '../evolve'
import { lineageOf, loopStagesOf, type LineageRow } from '../gfx/evolve'
+import { slot } from './attention'
import { ago, button, clip, col, kv, picture, row, rule, text, THEME, type Ctx } from './common'
/** Result lines in view at once; j/k scroll the rest. */
@@ -193,7 +194,7 @@ function resultRows(ctx: Ctx): RenderElement[] {
for (const line of result.lines.slice(top, top + RESULT_ROWS)) out.push(text(ctx, ` ${line}`))
if (result.lines.length > RESULT_ROWS) out.push(row(ctx, [text(ctx, ` lines ${top + 1}-${Math.min(result.lines.length, top + RESULT_ROWS)} of ${result.lines.length} `, { dimColor: true }), button(ctx, 'evolve-up', 'up', () => ctx.act.select(-1), { hotkey: 'k' }), button(ctx, 'evolve-down', 'down', () => ctx.act.select(1), { hotkey: 'j' })]))
- return out
+ return slot(ctx, out)
}
/**
@@ -224,3 +225,6 @@ export function evolveView(ctx: Ctx): RenderElement {
'evolve',
)
}
+
+/** This view's result block alone: the pane asks for it to place under the row that was clicked. */
+export const evolveResult = (ctx: Ctx): RenderElement[] => resultRows(ctx)
diff --git a/plugins/ruflo-console/hooks/views/mh-lab.ts b/plugins/ruflo-console/hooks/views/mh-lab.ts
index 449398129f..2097467a55 100644
--- a/plugins/ruflo-console/hooks/views/mh-lab.ts
+++ b/plugins/ruflo-console/hooks/views/mh-lab.ts
@@ -1,6 +1,7 @@
import type { RenderElement } from 'claude-code'
import { LAB, LAB_GROUPS, labSpec, PROMOTE_COMMAND, type LabCost, type LabEntry } from '../mh-lab'
+import { slot } from './attention'
import { ago, button, clip, row, rule, text, THEME, type Ctx } from './common'
/** Result lines in view at once; j/k scroll the rest. */
@@ -71,7 +72,7 @@ function resultRows(ctx: Ctx): RenderElement[] {
)
}
- return rows
+ return slot(ctx, rows)
}
/**
@@ -97,3 +98,6 @@ export function labRows(ctx: Ctx): RenderElement[] {
return rows
}
+
+/** This lab's result block alone: the pane asks for it to place under the row that was clicked. */
+export const labResult = (ctx: Ctx): RenderElement[] => resultRows(ctx)
diff --git a/plugins/ruflo-console/hooks/views/neural.ts b/plugins/ruflo-console/hooks/views/neural.ts
index 4e94c3b83c..b8cbe14e7e 100644
--- a/plugins/ruflo-console/hooks/views/neural.ts
+++ b/plugins/ruflo-console/hooks/views/neural.ts
@@ -97,3 +97,6 @@ export function neuralView(ctx: Ctx): RenderElement {
'neural',
)
}
+
+/** This view's result block alone: the pane asks for it to place under the row that was clicked. */
+export const neuralResult = (ctx: Ctx): RenderElement[] => resultRows(ctx, ['nn-'])
diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.ts
index 4945d1d200..b20601513d 100644
--- a/plugins/ruflo-console/hooks/views/pane.ts
+++ b/plugins/ruflo-console/hooks/views/pane.ts
@@ -8,16 +8,17 @@ import type { RenderElement } from 'claude-code'
import { HELP } from '../commands'
import { slashFor } from '../ask-claude'
import { launchRows } from './launch'
+import { donated, newAttention, panelOf, wrapKit } from './attention'
import { isBooting, isCompactPane, NAV_STYLES, VIEWS, type ViewId } from '../state'
import { agentView } from './agent'
-import { automateView } from './automate'
+import { automateResult, automateView } from './automate'
import { claimsView } from './claims'
import { ago, button, clip, col, confirmInline, confirmRow, isBbs, row, setLook, text, THEME, type Ctx } from './common'
import { costView } from './cost'
-import { evolveView } from './evolve'
+import { evolveResult, evolveView } from './evolve'
import { catalogView } from './plugin-catalog'
import { settingsView } from './settings'
-import { devtoolsView } from './devtools'
+import { devtoolsResult, devtoolsView } from './devtools'
import { federationView } from './federation'
import { hiveView } from './hive'
import { learningView } from './learning'
@@ -25,17 +26,18 @@ import { approvalsView, eventsView, timelineView } from './manage'
import { memoryView } from './memory'
import { menuView } from './menu'
import { metaharnessView } from './metaharness'
-import { neuralView } from './neural'
+import { labResult } from './mh-lab'
+import { neuralResult, neuralView } from './neural'
import { missionControlView } from './mission-control'
import { overviewView } from './overview'
import { paletteView } from './palette'
-import { perfView } from './perf'
+import { perfResult, perfView } from './perf'
import { pluginsView } from './plugins'
-import { secureView } from './secure'
+import { secureResult, secureView } from './secure'
import { skillsView } from './skills'
import { swarmView } from './swarm'
import { terminalView } from './terminal'
-import { vectorView } from './vector'
+import { vectorResult, vectorView } from './vector'
import { xruvView } from './xruv'
export const NARROW = 44
@@ -167,11 +169,14 @@ function help(ctx: Ctx): RenderElement {
}
-function footer(ctx: Ctx): RenderElement {
+function footer(ctx: Ctx, isPlaced = false): RenderElement {
const { state, nowMs } = ctx
- const outcome = state.outcome
+ const outcome = isPlaced ? null : state.outcome
const parts: RenderElement[] = []
+ // Something is waiting for a yes or no: said here, where the keys are, wherever the confirm itself sits.
+ if (state.pending !== null) parts.push(text(ctx, `⚠ confirm needed: ${clip(state.pending.label, Math.max(20, ctx.columns - 40))} — y yes · n cancel${isPlaced ? ' (under what you clicked)' : ''}`, { bold: true, color: THEME.warn }))
+
if (outcome !== null && nowMs - outcome.atMs < 90_000) {
parts.push(
text(ctx, `${outcome.ok ? '✓' : '✗'} ${outcome.label}${outcome.verified === 'yes' ? ' · on disk' : outcome.verified === 'no' ? ' · not on disk yet' : ''}: ${outcome.detail}`, {
@@ -238,8 +243,24 @@ function wildcat(ctx: Ctx): { strip: RenderElement[]; art: RenderElement[] } {
}
}
-export function paneView(ctx: Ctx): RenderElement {
- setLook(ctx.state.options.look)
+/** The views whose lab result block can be drawn alone (so finding it costs one block, not a second page). */
+const RESULT_OF: Partial<Record<ViewId, (ctx: Ctx) => RenderElement[]>> = {
+ metaharness: labResult,
+ devtools: devtoolsResult,
+ vector: vectorResult,
+ evolve: evolveResult,
+ secure: secureResult,
+ perf: perfResult,
+ automate: automateResult,
+ neural: neuralResult,
+}
+
+export function paneView(base: Ctx): RenderElement {
+ setLook(base.state.options.look)
+
+ // Every Button and Input remembers its key, and a column that holds the origin of the current ask places the confirm and the answer after it.
+ const attention = newAttention(base.state.origin, [])
+ const ctx: Ctx = { ...base, kit: wrapKit(base.kit, base.state, attention), attention }
// The BBS boot screen: the first seconds after the pane opens (or until the first read lands, at most 6 s).
if (isBooting(ctx.state, ctx.nowMs)) {
@@ -249,11 +270,39 @@ export function paneView(ctx: Ctx): RenderElement {
? col(ctx, [ctx.kit.Raster(boot.toRaster('boot'))], 'boot')
: col(ctx, [text(ctx, 'CONNECT 115200 · RUFLO AGENT SWARM CONSOLE · loading…', { bold: true, color: THEME.head })], 'boot')
}
- const shownBody = ctx.state.palette.isOpen ? paletteView(ctx) : ctx.state.isHelp ? help(ctx) : BODIES[ctx.state.view](ctx)
- // Every section ends with its Launch section: the commands of the plugins it owns, run in the Claude UI.
+ const drawBody = () => (ctx.state.palette.isOpen ? paletteView(ctx) : ctx.state.isHelp ? help(ctx) : BODIES[ctx.state.view](ctx))
+ // A lab's result block is drawn first into the panel (pass one), then the page is drawn with the panel placed under the clicked row.
+ if (ctx.state.origin !== null && (ctx.state.lab.result !== null || ctx.state.lab.running !== null)) {
+ attention.donated = donated(ctx, () => {
+ attention.mode = 'collect'
+ RESULT_OF[ctx.state.view]?.(ctx)
+
+ return [...attention.donated]
+ })
+ }
+
+ if (ctx.state.origin !== null) attention.panel = panelOf(base, attention.donated)
+ attention.mode = attention.donated.length > 0 ? 'hide' : 'draw'
+
+ let body = drawBody()
+
+ // The clicked element is not on screen (a hotkey, the palette, a folded section): the lab keeps its own result block at its foot, and the confirm goes to the top.
+ if (!attention.placed && attention.donated.length > 0) {
+ attention.panel = []
+ attention.key = null
+ attention.donated = []
+ attention.mode = 'draw'
+ body = drawBody()
+ }
+
+ // Every section ends with its Launch section: the commands of the plugins it owns, run in the Claude UI. Drawn through the same kit, so
+ // a launch ask is placed under its own row when nothing above held the origin.
const launch = ctx.state.palette.isOpen || ctx.state.isHelp ? [] : launchRows(ctx)
- const body = launch.length === 0 ? shownBody : col(ctx, [shownBody, ...launch], 'body')
- const confirm = confirmRow(ctx)
+
+ if (launch.length > 0) body = col(ctx, [body, ...launch], 'body')
+
+ // Placed under what was clicked: not drawn again at the top.
+ const confirm = attention.placed ? null : confirmRow(ctx)
const header = ctx.pictures.get('header')
const isCompact = isCompactPane(ctx.state)
const title = !isCompact && header !== undefined && ctx.kit.Raster !== undefined ? [ctx.kit.Raster(header.toRaster('header'))] : []
@@ -267,11 +316,11 @@ export function paneView(ctx: Ctx): RenderElement {
// The confirm row sits above the body in both layouts: below it, a tall view would push the question off the screen.
// Compact keeps every page's title and its line of purpose; only the banner and the spacing go.
const parts = isCompact
- ? [tabs(ctx), ...bbs.art, ...(about !== null ? [about] : []), ...(confirm !== null && !confirmInline(ctx.state.view, ctx.state.pending?.scope) ? [confirm] : []), footer(ctx), body]
+ ? [tabs(ctx), ...bbs.art, ...(about !== null ? [about] : []), ...(confirm !== null && !confirmInline(ctx.state.view, ctx.state.pending?.scope) ? [confirm] : []), footer(ctx, attention.placed), body]
: !isMenu && isBbs()
? // Every page but the main menu leads with its own title and purpose line; the welcome line and network links follow, with a blank row between the blocks.
- [...bbs.art, ...(about !== null ? [about] : []), ...gap, ...bbs.strip, ...gap, tabs(ctx), ...gap, footer(ctx), ...(confirm !== null && !isTerminal && !confirmInline(ctx.state.view, ctx.state.pending?.scope) ? [confirm] : []), body, ...(confirm !== null && isTerminal ? [confirm] : [])]
- : [...title, ...(isMenu && isBbs() ? [text(ctx, ' ')] : []), ...bbs.strip, ...(isMenu && isBbs() ? [text(ctx, ' ')] : []), ...gap, tabs(ctx), ...gap, ...(isMenu && isBbs() ? [] : [...bbs.art, ...(about !== null ? [about] : [])]), ...gap, ...(isMenu ? [] : [footer(ctx)]), ...(confirm !== null && !isTerminal && !confirmInline(ctx.state.view, ctx.state.pending?.scope) ? [confirm] : []), body, ...(confirm !== null && isTerminal ? [confirm] : []), ...gap, ...(isMenu ? [footer(ctx)] : [])]
+ [...bbs.art, ...(about !== null ? [about] : []), ...gap, ...bbs.strip, ...gap, tabs(ctx), ...gap, footer(ctx, attention.placed), ...(confirm !== null && !isTerminal && !confirmInline(ctx.state.view, ctx.state.pending?.scope) ? [confirm] : []), body, ...(confirm !== null && isTerminal ? [confirm] : [])]
+ : [...title, ...(isMenu && isBbs() ? [text(ctx, ' ')] : []), ...bbs.strip, ...(isMenu && isBbs() ? [text(ctx, ' ')] : []), ...gap, tabs(ctx), ...gap, ...(isMenu && isBbs() ? [] : [...bbs.art, ...(about !== null ? [about] : [])]), ...gap, ...(isMenu ? [] : [footer(ctx, attention.placed)]), ...(confirm !== null && !isTerminal && !confirmInline(ctx.state.view, ctx.state.pending?.scope) ? [confirm] : []), body, ...(confirm !== null && isTerminal ? [confirm] : []), ...gap, ...(isMenu ? [footer(ctx, attention.placed)] : [])]
return ctx.kit.Box({ flexDirection: 'column', children: parts })
}
diff --git a/plugins/ruflo-console/hooks/views/perf.ts b/plugins/ruflo-console/hooks/views/perf.ts
index 0b132f20ab..0520a5316e 100644
--- a/plugins/ruflo-console/hooks/views/perf.ts
+++ b/plugins/ruflo-console/hooks/views/perf.ts
@@ -44,3 +44,6 @@ export function perfView(ctx: Ctx): RenderElement {
return col(ctx, rows, 'perf')
}
+
+/** This view's result block alone: the pane asks for it to place under the row that was clicked. */
+export const perfResult = (ctx: Ctx): RenderElement[] => resultRows(ctx, isPerfResult)
diff --git a/plugins/ruflo-console/hooks/views/secure.ts b/plugins/ruflo-console/hooks/views/secure.ts
index 57198fdcdc..c992f365f3 100644
--- a/plugins/ruflo-console/hooks/views/secure.ts
+++ b/plugins/ruflo-console/hooks/views/secure.ts
@@ -1,6 +1,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 { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
/** Result lines in view at once; j/k scroll the rest. */
@@ -73,7 +74,7 @@ export function resultRows(ctx: Ctx, isMine: (id: string) => boolean): RenderEle
)
}
- return rows
+ return slot(ctx, rows)
}
const SEVERITY_COLOR: Record<Severity, () => string> = { critical: () => THEME.bad, high: () => THEME.bad, medium: () => THEME.warn, low: () => THEME.info }
@@ -196,3 +197,6 @@ export function secureView(ctx: Ctx): RenderElement {
return col(ctx, rows, 'secure')
}
+
+/** This view's result block alone: the pane asks for it to place under the row that was clicked. */
+export const secureResult = (ctx: Ctx): RenderElement[] => resultRows(ctx, isSecureResult)
diff --git a/plugins/ruflo-console/hooks/views/vector.ts b/plugins/ruflo-console/hooks/views/vector.ts
index 8bc3efca22..2c6df5632d 100644
--- a/plugins/ruflo-console/hooks/views/vector.ts
+++ b/plugins/ruflo-console/hooks/views/vector.ts
@@ -2,6 +2,7 @@ import type { RenderElement } from 'claude-code'
import { targetOf, type VectorField } from '../data/vector'
import { VEC, VEC_SECTIONS, vecSpec, type VecCost, type VecEntry, type VecSection } from '../vector'
+import { slot } from './attention'
import { ago, button, clip, row, rule, text, THEME, type Ctx } from './common'
/** Result lines in view at once; j/k scroll the rest. */
@@ -125,7 +126,7 @@ function resultRows(ctx: Ctx): RenderElement[] {
)
}
- return rows
+ return slot(ctx, rows)
}
/**
@@ -148,3 +149,6 @@ export function vectorView(ctx: Ctx): RenderElement {
return ctx.kit.Box({ flexDirection: 'column', key: 'vector', children: rows })
}
+
+/** This lab's result block alone: the pane asks for it to place under the row that was clicked. */
+export const vectorResult = (ctx: Ctx): RenderElement[] => resultRows(ctx)
diff --git a/plugins/ruflo-console/scripts/smoke.sh b/plugins/ruflo-console/scripts/smoke.sh
index 2aac411f25..59af72f5bf 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.14.0"
+step "1. plugin.json declares ruflo-console 0.14.1"
grep -q '"name": "ruflo-console"' "$ROOT/.claude-plugin/plugin.json" \
- && grep -q '"version": "0.14.0"' "$ROOT/.claude-plugin/plugin.json" && ok || bad "name/version"
+ && grep -q '"version": "0.14.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/attention.test.ts b/plugins/ruflo-console/tests/attention.test.ts
new file mode 100644
index 0000000000..87419cf0bd
--- /dev/null
+++ b/plugins/ruflo-console/tests/attention.test.ts
@@ -0,0 +1,87 @@
+/**
+ * Answers open where they were asked, on every page: the confirm of a press is drawn right after the row that was pressed, the
+ * answer (the lab result) follows it there, nothing is drawn twice, and a confirm raised with no press falls back to the top.
+ */
+import type { TestBody } from 'claude-code/testing'
+import { describe, expect, mock, test } from 'claude-code/testing'
+
+import { RUFLO_FILES } from './fixtures/ruflo-run'
+import { command, elementsOf, keyOf, paneAt, PLUGIN, SESSION, textOf, worldOf } from './fixtures/world'
+
+const keys = (tree: Parameters<typeof elementsOf>[0]) => elementsOf(tree, 'Button').map(keyOf)
+
+type Body = Parameters<TestBody>
+
+async function opened($: Body[0], on: Body[1], view: string) {
+ worldOf(on, RUFLO_FILES)
+ mock.clock(on)
+ await $.session.start(SESSION)
+ await $.command.run(command(view))
+
+ const pane = await $.ui.mount({ ...paneAt(150), surface: 'terminal' as const, plugin: PLUGIN })
+
+ await pane.drawn()
+
+ return pane
+}
+
+describe('attention: the ask and its answer sit under what was clicked', () => {
+ for (const [view, key] of [['metaharness', 'lab-mh-flywheel-run'], ['devtools', 'dt-llm-hnsw']] as const) {
+ test(`${view}: the confirm is the next thing after ${key}, the result follows it, and nothing is drawn twice`, { options: { boot: false } }, async ($, on) => {
+ const pane = await opened($, on, view)
+ const before = keys(await pane.drawn())
+ const at = before.indexOf(key)
+
+ expect(at, `${key} is on the ${view} page`).toBeGreaterThan(-1)
+ await pane.press({ key })
+
+ const asked = await pane.drawn()
+ const askedKeys = keys(asked)
+
+ // The confirm's buttons come straight after the pressed row's button, before the next row's.
+ expect(askedKeys.indexOf('confirm')).toBe(at + 1)
+ expect(askedKeys.indexOf('cancel')).toBe(at + 2)
+ expect(askedKeys.filter(candidate => candidate === 'confirm')).toHaveLength(1)
+ expect(textOf(asked)).toContain('CONFIRM NEEDED')
+ expect(textOf(asked)).toContain('⚠ confirm needed')
+
+ await pane.press({ key: 'confirm' })
+ await pane.drawn()
+
+ const answered = await pane.drawn()
+ const text = textOf(answered)
+
+ // The answer is under the same row: exactly one result block, and the page below it is whole.
+ expect(text.split('▓▒░ RESULT ░▒▓').length - 1).toBeLessThanOrEqual(1)
+ // The row after the pressed one (when there is one) is still there, below it.
+ const next = before[at + 1]
+
+ if (next !== undefined) expect(keys(answered).indexOf(next)).toBeGreaterThan(keys(answered).indexOf(key))
+ await pane.unmount()
+ })
+ }
+
+ test('a page whose clicked row is folded away shows the confirm at the top instead, once', { options: { boot: false } }, async ($, on) => {
+ const pane = await opened($, on, 'memory')
+
+ await pane.press({ key: 'mem-do-store' })
+
+ const tree = await pane.drawn()
+
+ expect(keys(tree).filter(candidate => candidate === 'confirm').length).toBeLessThanOrEqual(1)
+ await pane.unmount()
+ })
+
+ test('a headless ask (no press) is drawn at the top, above the body', { options: { boot: false } }, async ($, on) => {
+ const pane = await opened($, on, 'metaharness')
+
+ await $.command.run(command('run mh-flywheel-run'))
+
+ const tree = await pane.drawn()
+ const order = keys(tree)
+
+ expect(order.filter(candidate => candidate === 'confirm')).toHaveLength(1)
+ expect(order.indexOf('confirm')).toBeLessThan(order.indexOf('lab-mh-flywheel-run'))
+ await pane.unmount()
+ })
+})
diff --git a/scripts/ci-test-baseline.txt b/scripts/ci-test-baseline.txt
index 9611463705..72c6395d9b 100644
--- a/scripts/ci-test-baseline.txt
+++ b/scripts/ci-test-baseline.txt
@@ -164,6 +164,7 @@ plugins/ruflo-console/tests/behaviour.test.ts
plugins/ruflo-console/tests/palette.test.ts
plugins/ruflo-console/tests/views.test.ts
plugins/ruflo-console/tests/labs.test.ts
+plugins/ruflo-console/tests/attention.test.ts
plugins/ruflo-console/tests/matrix.test.ts
plugins/ruflo-console/tests/missions.test.ts
plugins/ruflo-console/tests/settings.test.ts
diff --git a/v3/docs/adr/ADR-408-ruflo-console-mission-control.md b/v3/docs/adr/ADR-408-ruflo-console-mission-control.md
index 214c5f7dcd..2800ecfc62 100644
--- a/v3/docs/adr/ADR-408-ruflo-console-mission-control.md
+++ b/v3/docs/adr/ADR-408-ruflo-console-mission-control.md
@@ -71,6 +71,16 @@ Writes are confirm-gated with the exact argv. Remembered actions are not offered
- **Plugin map and Launch section (0.14.0).** `hooks/plugin-map.ts` gives each directory under `plugins/` one owning section, or says why it is reached from the Plugin Catalog only (domain plugins that can spend or write devices, and the console itself); `tests/plugin-coverage.spec.ts` fails on an unmapped plugin, a stale entry or a home that is not a view. Every section ends with a folded **Launch** section (`views/launch.ts`) listing the slash commands of the plugins it owns that the session lists; each button asks first, then runs the command in the main Claude UI (mid-turn it only fills the prompt box). A section whose plugins are not loaded draws nothing; the page redraws when the command list arrives.
- **Regression matrix** (`tests/matrix.test.ts`): every view, at 80 and 150 columns, draws without error text, names itself, has no duplicate element keys, and its Ask button asks first and then sends exactly one prompt (quoted data, no secret). `tests/ask-claude.spec.ts` covers the table, the scrubber and delivery. `scripts/e2e-smoke.sh` opens every view in a real Claude Code with no AI turn and no write (live only with `RUFLO_E2E_LIVE=1`, otherwise it skips). Smoke steps 14-16 run every pure spec, the e2e skip path and the table coverage.
+## 11a. The same on every page (0.14.1)
+
+Memory Lab's rule is now the console's, with no per-view code (`views/attention.ts`):
+
+- **Origin.** The `ui.press` and `ui.input` hooks (`register.ts`) record the element pressed or submitted, before its own closure runs; answering a confirm (`confirm`, `cancel`, `remember`, `always`) never moves it. `runner.ask` turns that into `state.origin` and clears the press, so a headless run (the palette, `/ruflo run`) has no origin.
+- **Placement.** While an origin waits, the page is drawn through a kit whose column Boxes watch for it: the first column holding the origin's element gets the **panel** (the confirm, then the outcome, then a lab's result) right after that child. Nothing reads the engine's element shapes beyond the `key` the tests already read. A quiet page is drawn with the plain kit, so it costs nothing.
+- **Lab results.** MetaHarness, Dev Tools, Vector, Self-Evolution, Security, Performance, Automation and the Learning Lab hand their result block to the panel (`slot`): the block is drawn once alone to find its rows (reused while the result, width, scroll and spinner are unchanged), the page is drawn with the panel placed and the block hidden. If the origin is not on screen (a hotkey, the palette, a folded section) the confirm goes to the top and the lab keeps its block at its foot.
+- **Indicator.** The confirm is headed `▶ CONFIRM NEEDED — click Yes or press y`, and the status row says `⚠ confirm needed: <what> — y yes · n cancel` wherever the confirm sits.
+- Tests: `tests/attention.test.ts` (MetaHarness and Dev Tools: the confirm is the very next buttons after the pressed one, the result follows, nothing is drawn twice; a headless ask goes to the top).
+
## 11. Answers open where they were asked (0.13.1)
Memory Lab no longer keeps one Result block far from what was clicked. Each action records where it was raised (`memoryLab.origin`: Browse, Search, Entry, or a lab group) and its confirm (scope `mem:<area>`) and its result are drawn in a bordered panel directly under that area; the pane no longer draws that confirm at the top (`confirmInline`). An area with nothing asked or answered draws no panel. The lab groups are collapsible sections; the group of the last action stays open.