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(console): control tab, Conversation board, truthful stop/message wording (ADR-465 wip)

ruvdd4026281d38
diff --git a/plugins/ruflo-console/hooks/data/wf-alerts.ts b/plugins/ruflo-console/hooks/data/wf-alerts.ts
index 80a23e72b6..8b22ba5e6f 100644
--- a/plugins/ruflo-console/hooks/data/wf-alerts.ts
+++ b/plugins/ruflo-console/hooks/data/wf-alerts.ts
@@ -1,7 +1,7 @@
/**
* The Workflows page's guards (ADR-462): two spend ceilings and the person's own alert rules, as plain options and one pure
- * evaluator. A guard only SAYS: it returns alerts for the notice ring and never stops, pauses or messages anything (the console has no
- * verb for that; Claude Code's Workflows panel and TaskStop do).
+ * evaluator. A guard only SAYS: it returns alerts for the notice ring and never stops, pauses or messages anything (stopping is the
+ * control tab's action, ADR-465, and always the person's own confirmed press).
*
* Options (all optional; the defaults leave every guard off):
* wfBudgetRunUsd number, 0 off, else 0.01 to 10000: one run's spend that raises a notice
diff --git a/plugins/ruflo-console/hooks/data/wf-control.ts b/plugins/ruflo-console/hooks/data/wf-control.ts
index e64fb130d6..5feb865e17 100644
--- a/plugins/ruflo-console/hooks/data/wf-control.ts
+++ b/plugins/ruflo-console/hooks/data/wf-control.ts
@@ -50,6 +50,12 @@ export type ControlInput = {
isRunPath: (path: string) => boolean
}
+/** The id of the inspector tab this module registers (views/wf-control.ts); a page that says where Stop is done asks whether it exists. */
+export const CONTROL_TAB = 'control'
+
+/** The sentence a page says about stopping and messaging a workflow, true to whether the control tab is switched on. */
+export const controlLine = (isOn: boolean): string => (isOn ? 'Stop, message and redirect: the control tab calls the engine\'s own TaskStop and SendMessage, behind its permission check, after showing the exact call.' : 'Stop and message from this page need the control tab, which is not switched on in this build: use Claude Code\'s Workflows panel or TaskStop.')
+
/** An id the engine hands out is letters, digits, dash and underscore; anything else is not passed to a tool. */
export const ENGINE_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{5,63}$/
diff --git a/plugins/ruflo-console/hooks/data/wf-guide.ts b/plugins/ruflo-console/hooks/data/wf-guide.ts
index 880f86616e..4cccf7e69a 100644
--- a/plugins/ruflo-console/hooks/data/wf-guide.ts
+++ b/plugins/ruflo-console/hooks/data/wf-guide.ts
@@ -7,7 +7,7 @@
* and no worker is interrupted; a task or claim edit changes a record an agent sees only when it reads the store; a consensus proposal
* binds nobody; a memory note is found by whoever searches memory. So no action here makes a running agent do something, and the card
* says so. Claude Code workflow agents have no ruflo record at all: the only honest paths are the memory note and a prepared prompt for
- * the main session (resume or redirect), and the console cannot stop or message a running workflow.
+ * the main session (resume or redirect), and stopping and messaging a running workflow are the control tab's real calls (data/wf-control.ts, ADR-465), not these.
*/
import { handoffClaim, type ActionSpec } from '../actions'
import { hiveBroadcast, hivePropose } from '../hive'
@@ -175,7 +175,7 @@ export function guideActions(input: GuideInput): GuideAction[] {
if (input.run.kind === 'workflow') {
const prompt = redirectText(input.run, input.agent, text, input.isRunPath)
- add('redirect', 'prepare a redirect for the main session', 'prompt-only', prompt === null ? null : { label: 'prepare the redirect text in the main session\'s prompt box', args: [], shows: prompt.slice(0, 160), expect: 'the text in the prompt box (it is not sent)', note: 'Text only: it goes to the main Claude session, never to the running workflow. The console cannot stop or message a workflow; resuming applies to a stopped run.', run: () => input.prepare(prompt) }, 'Prepares text in your prompt box; you press Enter. The running workflow is not touched: stopping it is done in Claude Code\'s Workflows panel.', 'this run has no id the console can pass on')
+ add('redirect', 'prepare a redirect for the main session', 'prompt-only', prompt === null ? null : { label: 'prepare the redirect text in the main session\'s prompt box', args: [], shows: prompt.slice(0, 160), expect: 'the text in the prompt box (it is not sent)', note: 'Text only: it goes to the main Claude session, never to the running workflow. This route is the prompt-box fallback: the control tab\'s Redirect calls the engine\'s TaskStop first (where it is switched on), and resuming applies to a stopped run.', run: () => input.prepare(prompt) }, 'Prepares text in your prompt box; you press Enter. The running workflow is not touched by this text: the control tab\'s Stop (the engine\'s TaskStop) or Claude Code\'s Workflows panel stops it.', 'this run has no id the console can pass on')
}
return out
diff --git a/plugins/ruflo-console/hooks/data/wf-targets.ts b/plugins/ruflo-console/hooks/data/wf-targets.ts
index 3a8e652ee7..f0d6097ccb 100644
--- a/plugins/ruflo-console/hooks/data/wf-targets.ts
+++ b/plugins/ruflo-console/hooks/data/wf-targets.ts
@@ -35,7 +35,7 @@ export type Config = { endpoints: Endpoint[]; rooms: string[]; channels: string[
export const OPENROUTER: Endpoint = { name: 'openrouter', baseUrl: 'https://openrouter.ai/api/v1', keyEnv: 'OPENROUTER_API_KEY', model: 'openrouter/auto' }
-const NAME = /^[a-z][a-z0-9-]{1,23}$/
+const NAME = /^[a-z][a-z0-9-]{0,23}$/
const ENV_NAME = /^[A-Z_][A-Z0-9_]{0,63}$/
const ROOM = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/
const CHANNEL = /^(pub:[a-z0-9][a-z0-9._-]{0,63}|prv:[0-9a-f]{16})$/
diff --git a/plugins/ruflo-console/hooks/views/wf-control.ts b/plugins/ruflo-console/hooks/views/wf-control.ts
new file mode 100644
index 0000000000..6691b6dd2f
--- /dev/null
+++ b/plugins/ruflo-console/hooks/views/wf-control.ts
@@ -0,0 +1,106 @@
+/**
+ * Stop, Message and Redirect on the Workflows page (ADR-465), through the page's slot registry only: one inspector tab (`control`) and one
+ * action button (`ctl-stop`), no hotkey, no edit of any shared file. Importing this module registers them (the merge owner adds
+ * `import './wf-control'` to views/wf-register.ts and calls `wireWfControl(state, host)` from hooks/wf-wire.ts). Each action draws the EXACT
+ * engine call it will make and how far that path is proven; the engine's own permission check and dialog decide it, and its answer is what the
+ * footer outcome row says. Where this build binds no tool calls, the tab says so and offers the prompt-box text instead.
+ */
+import type { RenderElement } from 'claude-code'
+
+import { cleanText } from '../data/wf-clean'
+import { controlActions, type ControlAction, type ControlInput } from '../data/wf-control'
+import { tidy } from '../data/wf-send'
+import type { Host } from '../host'
+import type { State } from '../state'
+import { isRunPath } from '../wf-actions'
+import { button, col, kv, text, THEME, type Ctx } from './common'
+import { registerSlot, type SlotEnv } from './wf-slots'
+
+const hosts = new WeakMap<State, Host>()
+const drafts = new WeakMap<State, { text: string }>()
+
+/** The wiring: the host whose tool bridge the actions call. A slot is handed none, so this is bound once per console state. */
+export const wireWfControl = (state: State, host: Host): void => void hosts.set(state, host)
+
+/** For tests. */
+export function resetControl(state: State): void {
+ hosts.delete(state)
+ drafts.delete(state)
+}
+
+const draftOf = (state: State): { text: string } => {
+ let held = drafts.get(state)
+
+ if (held === undefined) {
+ held = { text: '' }
+ drafts.set(state, held)
+ }
+
+ return held
+}
+
+const COLOR: Record<ControlAction['proof'], string | undefined> = { verified: THEME.ok, 'queued-only': THEME.warn, unverified: THEME.warn, prefill: undefined }
+
+/** The inputs the data module needs, from the page's cursor; null where there is no run or no host to act through. */
+export function inputOf(env: Pick<SlotEnv, 'ctx' | 'run' | 'agent'>, text: string): ControlInput | null {
+ const host = hosts.get(env.ctx.state)
+
+ if (env.run === null || host === undefined) return null
+
+ const { state } = env.ctx
+
+ return {
+ run: env.run,
+ agent: env.agent,
+ text,
+ bridge: { toolCall: host.toolCall, toolCheck: host.toolCheck, fillPrompt: host.fillPrompt },
+ report: (label, ok, detail) => {
+ state.outcome = { label: tidy(label, 80), ok, verified: 'n/a', detail: tidy(detail, 240), atMs: Date.now() }
+ host.invalidate()
+ },
+ isRunPath: path => isRunPath(path, state.configDir),
+ }
+}
+
+function controlTab(env: SlotEnv): RenderElement[] {
+ const { ctx, run, agent } = env
+ const input = inputOf(env, draftOf(ctx.state).text)
+
+ if (run === null) return [text(ctx, 'No run picked.', { dimColor: true })]
+ if (input === null) return [text(ctx, 'The console is not wired to a host here: nothing can be called.', { dimColor: true })]
+
+ const draft = draftOf(ctx.state)
+ const actions = controlActions(input)
+ const host = hosts.get(ctx.state)
+ const field = ctx.kit.Input === undefined ? text(ctx, 'this surface has no text field: message and redirect need one', { dimColor: true }) : ctx.kit.Input({ key: 'wf-control-text', label: 'message', placeholder: 'what to tell the agent, or what to change on a redirect', submitLabel: 'set', onSubmit: value => { draft.text = value; ctx.act.workflows.setUi({}) } })
+ const rows: RenderElement[] = [kv(ctx, 'run', cleanText(run.name)), kv(ctx, 'agent', agent === null ? 'none picked: stop and message need one' : cleanText(agent.label)), kv(ctx, 'tool calls', host?.toolCall === undefined ? 'not bound in this build: only the prompt-box text is offered' : 'bound: each call goes through the engine\'s permission check and dialog', host?.toolCall === undefined ? THEME.warn : undefined), field, text(ctx, draft.text === '' ? 'message: none typed yet' : `message: ${draft.text}`, { color: draft.text === '' ? undefined : THEME.info })]
+
+ for (const action of actions) {
+ rows.push(button(ctx, `wf-control-${action.id}`, action.label, () => ctx.act.workflows.ask(action.spec, action.why)))
+ rows.push(text(ctx, ` call: ${action.spec === null ? `none (${action.why})` : action.call}`, { dimColor: true }))
+ rows.push(text(ctx, ` proof: ${action.proof} · ${action.proofText}`, { ...(COLOR[action.proof] === undefined ? { dimColor: true } : { color: COLOR[action.proof] as string }) }))
+ }
+
+ rows.push(text(ctx, 'A refusal by the engine is shown and nothing else is tried in its place. Stopping is not undone by resuming.', { dimColor: true }))
+
+ return [col(ctx, rows, 'wf-control')]
+}
+
+/** The stop action of the extras row: the picked agent if one is picked, else the run. Null (with the reason on the confirm row) where it cannot be made. */
+export function stopSlotSpec(env: SlotEnv): ReturnType<typeof controlActions>[number]['spec'] {
+ const input = inputOf(env, '')
+
+ if (input === null) return null
+
+ const actions = controlActions(input)
+
+ return (env.agent === null ? actions.find(action => action.id === 'stop-run') : actions.find(action => action.id === 'stop-agent'))?.spec ?? null
+}
+
+/** Registers this module's slots; a repeat is refused harmlessly (the registry keeps the first). */
+export function registerControlSlots(): void {
+ registerSlot({ kind: 'tab', id: 'control', label: 'control', when: env => env.run !== null && env.run.kind === 'workflow', render: controlTab })
+ registerSlot({ kind: 'action', id: 'ctl-stop', label: 'stop', why: 'nothing to stop: a ruflo swarm run (use x), an id the engine would not accept, or a build with no tool bridge', spec: stopSlotSpec })
+}
+
+registerControlSlots()
diff --git a/plugins/ruflo-console/hooks/views/wf-convo.ts b/plugins/ruflo-console/hooks/views/wf-convo.ts
new file mode 100644
index 0000000000..003898a479
--- /dev/null
+++ b/plugins/ruflo-console/hooks/views/wf-convo.ts
@@ -0,0 +1,157 @@
+/**
+ * The Conversation board (ADR-465): talk to Claude, its agents, the ruflo hive, federation, Codex and any OpenAI-compatible endpoint from one
+ * place, in one thread per target. A board slot of the Workflows page (views/wf-slots.ts), folded closed by default so the page stays short;
+ * importing this module registers it (the merge owner adds `import './wf-convo'` to views/wf-register.ts and calls
+ * `wireWfConvo(state, host, <the convoTargets option>)` from hooks/wf-wire.ts). `conversationRows(env)` is also exported so the Swarm page
+ * can draw it where it lives. Each target shows what leaves the machine, its cost class and how a reply arrives BEFORE anything is sent; every
+ * send goes through the confirm card with the exact payload. Nothing here sends on its own, and every cell is masked text.
+ */
+import type { RenderElement } from 'claude-code'
+
+import { cleanText } from '../data/wf-clean'
+import { compareOf, lastAnswer, MAX_MSGS, POLL_MAX, POLL_MS, statsOf, type Msg } from '../data/wf-convo'
+import { fanOutOf } from '../data/wf-convo'
+import { parseMentions, type Target } from '../data/wf-targets'
+import type { Host } from '../host'
+import type { State } from '../state'
+import { hostOf, liveOf, refreshFacts, relaySpec, saveTranscript, sendSpec, stopWatch, targetsFor, watchSpec, wireConvo } from '../wf-convo-live'
+import { button, clip, col, kv, row, text, THEME, type Ctx } from './common'
+import { fold } from './wf-fold'
+import { registerSlot, type SlotEnv } from './wf-slots'
+
+/** The wiring (`optionText` is the `convoTargets` option: endpoint:, bbs: and x: entries; keys are named, never held). */
+export const wireWfConvo = (state: State, host: Host, optionText?: string): void => wireConvo(state, host, optionText)
+
+const STATE_COLOR: Partial<Record<Msg['state'], string>> = { reply: THEME.ok, received: THEME.ok, queued: THEME.warn, sent: THEME.warn, error: THEME.bad, refused: THEME.bad }
+const SHOWN = 10
+const LINES = 6
+
+const clock = (atMs: number): string => new Date(atMs).toISOString().slice(11, 19)
+
+/** The answer's first lines, wrapped to the width; the rest is counted, never silently dropped. */
+function wrap(value: string, width: number, max: number): string[] {
+ const out: string[] = []
+
+ for (const raw of value.split('\n')) {
+ for (let at = 0; at < Math.max(raw.length, 1); at += width) out.push(raw.slice(at, at + width))
+ }
+
+ return out.length <= max ? out : [...out.slice(0, max), `… ${out.length - max} more lines (the transcript keeps them)`]
+}
+
+function targetRows(ctx: Ctx, targets: readonly Target[], pickedId: string | null, onPick: (id: string) => void): RenderElement[] {
+ const rows: RenderElement[] = []
+
+ for (const target of targets) {
+ const isPicked = target.id === pickedId
+
+ rows.push(row(ctx, [button(ctx, `wf-convo-pick-${target.id}`, `${isPicked ? '●' : '○'} @${target.id}`, () => onPick(target.id)), text(ctx, ` ${cleanText(target.label)} · ${target.transport} · leaves: ${target.leaves} · ${target.cost}`, { dimColor: true })], `wf-convo-t-${target.id}`))
+
+ if (isPicked) {
+ rows.push(text(ctx, ` sends: ${target.leavesText}`, { dimColor: true }))
+ rows.push(text(ctx, ` cost: ${target.costText}`, { dimColor: true }))
+ rows.push(text(ctx, ` reply: ${target.arrivalText}`, { dimColor: true }))
+ }
+ }
+
+ return rows
+}
+
+function threadRows(ctx: Ctx, target: Target, convoOf: ReturnType<typeof liveOf>): RenderElement[] {
+ const thread = convoOf.convo.threads.get(target.id)
+
+ if (thread === undefined || thread.msgs.length === 0) return [text(ctx, `No messages with @${target.id} yet.`, { dimColor: true })]
+
+ const stats = statsOf(thread)
+ const rows: RenderElement[] = [text(ctx, `${stats.sent} sent · ${stats.answered} answered · ${stats.failed} failed · tokens ${stats.tokensIn === 0 && stats.tokensOut === 0 ? 'n/a' : `${stats.tokensIn} in / ${stats.tokensOut} out`} · cost ${stats.usd === null ? 'n/a (no billed figure reported)' : `$${stats.usd.toFixed(4)} billed`}${thread.dropped > 0 ? ` · ${thread.dropped} oldest dropped at the ${MAX_MSGS}-message cap` : ''}`, { dimColor: true })]
+
+ for (const msg of thread.msgs.slice(-SHOWN)) {
+ const color = msg.who === 'you' ? THEME.info : STATE_COLOR[msg.state]
+
+ rows.push(text(ctx, `${clock(msg.atMs)} ${msg.who === 'you' ? 'you' : `@${target.id}`}${msg.who === 'you' ? '' : ` [${msg.state}]`}`, { bold: true, ...(color === undefined ? {} : { color }) }))
+
+ for (const line of wrap(msg.text, Math.max(20, ctx.columns - 6), LINES)) rows.push(text(ctx, ` ${line}`))
+ }
+
+ if (thread.msgs.length > SHOWN) rows.push(text(ctx, `${thread.msgs.length - SHOWN} earlier messages are in the transcript, not drawn`, { dimColor: true }))
+
+ return rows
+}
+
+/** The answers of several targets next to each other (stacked where the page is narrow). */
+function compareRows(ctx: Ctx, targets: readonly Target[], convoOf: ReturnType<typeof liveOf>): RenderElement[] {
+ const cells = compareOf(convoOf.convo, targets)
+ const side = ctx.columns >= 100 && cells.length > 1
+ const width = side ? Math.max(24, Math.floor((ctx.columns - 2) / cells.length) - 2) : Math.max(24, ctx.columns - 4)
+ const blocks = cells.map(cell => ctx.kit.Box({ flexDirection: 'column', ...(side && { width }), key: `wf-cmp-${cell.target}`, children: [text(ctx, clip(`@${cell.target} [${cell.state}]`, width), { bold: true }), text(ctx, clip(`${cell.tokens} · ${cell.usd}`, width), { dimColor: true }), ...wrap(cleanText(cell.text), width, LINES).map(line => text(ctx, clip(line, width)))] }))
+
+ return [text(ctx, 'Answers side by side', { bold: true }), side ? row(ctx, blocks, 'wf-compare') : col(ctx, blocks, 'wf-compare')]
+}
+
+/** The whole board body; exported so another page can draw the Conversation too. */
+export function conversationRows(env: SlotEnv): RenderElement[] {
+ const { ctx } = env
+ const { state } = ctx
+ const live = liveOf(state)
+
+ if (hostOf(state) === null) return [text(ctx, 'The console is not wired to a host here: nothing can be sent.', { dimColor: true })]
+
+ void refreshFacts(state, env.nowMs)
+
+ const targets = targetsFor(state, env.runs)
+ const redraw = (): void => ctx.act.workflows.setUi({})
+ const picked = targets.find(target => target.id === live.convo.picked) ?? targets[0] ?? null
+ const asked = parseMentions(live.draft, targets)
+ const fan = fanOutOf(asked.targets, asked.unknown)
+ const recipients = fan.targets.length > 0 ? fan.targets : picked === null ? [] : [picked]
+ const body = fan.targets.length > 0 ? asked.body : live.draft.trim()
+ const rows: RenderElement[] = [...targetRows(ctx, targets, picked?.id ?? null, id => { live.convo.picked = id; redraw() })]
+
+ if (live.config.errors.length > 0) rows.push(text(ctx, `convoTargets option: ${live.config.errors[0] ?? ''}${live.config.errors.length > 1 ? ` (+${live.config.errors.length - 1} more)` : ''}`, { color: THEME.warn }))
+
+ rows.push(ctx.kit.Input === undefined ? text(ctx, 'this surface has no text field: the composer needs one', { dimColor: true }) : ctx.kit.Input({ key: 'wf-convo-text', label: 'message', placeholder: '@claude @openrouter what do you think? (@all = agents, hive, rooms)', submitLabel: 'set', onSubmit: value => { live.draft = value.slice(0, 1500); redraw() } }))
+ rows.push(text(ctx, live.draft === '' ? 'message: none typed yet' : `message: ${cleanText(live.draft)}`, { color: live.draft === '' ? undefined : THEME.info }))
+ if (fan.why !== '') rows.push(text(ctx, fan.why, { color: THEME.warn }))
+
+ const verb = recipients.length === 0 ? 'no one to send to' : recipients.length === 1 ? `Send to @${recipients[0]?.id ?? ''}` : `Ask ${recipients.length} targets at once`
+ const buttons: RenderElement[] = [button(ctx, 'wf-convo-send', verb, () => { const made = sendSpec(state, recipients, body); ctx.act.workflows.ask(made.spec, made.why) })]
+
+ if (picked !== null && lastAnswer(live.convo, picked.id) !== null) buttons.push(button(ctx, 'wf-convo-relay', `Relay @${picked.id}'s answer to the @mentioned`, () => { const made = relaySpec(state, picked, fan.targets, body); ctx.act.workflows.ask(made.spec, made.why) }))
+ if (picked !== null && (picked.transport === 'bbs' || picked.transport === 'x-channel')) {
+ const thread = live.convo.threads.get(picked.id)
+
+ buttons.push(thread?.isWatching === true ? button(ctx, 'wf-convo-unwatch', `Stop watching @${picked.id}`, () => stopWatch(state, picked.id)) : button(ctx, 'wf-convo-watch', `Watch @${picked.id} for replies`, () => { const made = watchSpec(state, picked); ctx.act.workflows.ask(made.spec, made.why) }))
+ }
+
+ if (picked !== null) buttons.push(button(ctx, 'wf-convo-save', 'Save transcript', () => void saveTranscript(state, picked, (spec, why) => ctx.act.workflows.ask(spec, why))))
+ rows.push(row(ctx, buttons, 'wf-convo-actions'))
+
+ if (picked !== null) {
+ const watching = live.convo.threads.get(picked.id)?.isWatching === true
+
+ rows.push(kv(ctx, 'reply polling', watching ? `on: a read every ${POLL_MS / 1000}s, ${live.convo.threads.get(picked.id)?.polls ?? 0} of ${POLL_MAX} done` : picked.arrival === 'polled' ? `off (a read every ${POLL_MS / 1000}s, at most ${POLL_MAX}, when you start it)` : `not used: ${picked.arrivalText}`))
+ rows.push(...threadRows(ctx, picked, live))
+ }
+
+ const withAnswers = targets.filter(target => lastAnswer(live.convo, target.id) !== null)
+ const compared = fan.targets.length > 1 ? fan.targets : withAnswers.length > 1 ? withAnswers.slice(0, 6) : []
+
+ if (compared.length > 1) rows.push(...compareRows(ctx, compared, live))
+
+ return [col(ctx, rows, 'wf-convo')]
+}
+
+function board(env: SlotEnv): RenderElement[] {
+ const { ctx } = env
+ const live = liveOf(ctx.state)
+ const threads = [...live.convo.threads.values()].filter(thread => thread.msgs.length > 0).length
+
+ return fold(ctx, 'convo', `talk to Claude, its agents, the hive, federation, Codex and other models · ${threads} thread${threads === 1 ? '' : 's'} · every send is confirmed with its exact payload`, () => conversationRows(env))
+}
+
+/** Registers this module's slot; a repeat is refused harmlessly (the registry keeps the first). */
+export function registerConvoSlots(): void {
+ registerSlot({ kind: 'board', id: 'conversation', title: 'Conversation', order: 60, render: board })
+}
+
+registerConvoSlots()
diff --git a/plugins/ruflo-console/hooks/views/wf-guide.ts b/plugins/ruflo-console/hooks/views/wf-guide.ts
index db8d4a332b..c430d00051 100644
--- a/plugins/ruflo-console/hooks/views/wf-guide.ts
+++ b/plugins/ruflo-console/hooks/views/wf-guide.ts
@@ -18,7 +18,8 @@ import type { Host } from '../host'
import type { State } from '../state'
import { isRunPath } from '../wf-actions'
import { button, clip, col, kv, row, section, text, THEME, type Ctx } from './common'
-import { registerSlot, type Registered, type SlotEnv } from './wf-slots'
+import { CONTROL_TAB, controlLine } from '../data/wf-control'
+import { registerSlot, slotsFor, type Registered, type SlotEnv } from './wf-slots'
const GLYPH: Record<NestKind, string> = { swarm: '◎', hive: '⬡', queen: '♛', worker: '●', claim: '⚑', task: '▪', note: '·' }
/** The script review shows at most this many lines; the full text is what the launch prepares, and the page says how many it holds. */
@@ -102,7 +103,7 @@ export function launchSpec(state: State, draft: Extract<Draft, { ok: true }>, mi
args: [],
shows: `${draft.path}: ${draft.estimate.agents} agents in ${draft.estimate.levels} levels, ${draft.source.split('\n').length} lines, prepared in the prompt box`,
expect: 'the script text in the prompt box (it is not sent)',
- note: 'Starts nothing here: the text waits in your prompt box. When you press Enter, Claude writes the file and runs the workflow, and every agent bills as a subagent does. The console cannot stop it afterwards.',
+ note: 'Starts nothing here: the text waits in your prompt box. When you press Enter, Claude writes the file and runs the workflow, and every agent bills as a subagent does. It can be stopped afterwards with the control tab (the engine\'s TaskStop, where that tab is switched on) or from Claude Code\'s Workflows panel.',
run: () => prepareIn(state, 'workflow script')(prompt),
}
}
@@ -152,7 +153,7 @@ function guideRows(ctx: Ctx, actions: readonly GuideAction[], run: WfRun): Rende
if (action.acts !== '') rows.push(line(ctx, ` acts: ${action.acts}`, { dimColor: true }))
}
- rows.push(line(ctx, run.kind === 'workflow' ? 'A running Claude Code workflow cannot be stopped or messaged from here: the console only reads it. The note is found by a memory search; the redirect is text for the main session.' : 'ruflo agents are not interrupted by any of these: each writes a record that an agent sees when it reads that store.', { dimColor: true }))
+ rows.push(line(ctx, run.kind === 'workflow' ? `${controlLine(slotsFor('tab').some(slot => slot.id === CONTROL_TAB))} The note here is found by a memory search; the redirect here is text for the main session.` : 'ruflo agents are not interrupted by any of these: each writes a record that an agent sees when it reads that store.', { dimColor: true }))
return rows
}
diff --git a/plugins/ruflo-console/hooks/views/wf-page.ts b/plugins/ruflo-console/hooks/views/wf-page.ts
index 35c2096501..2cf14ec7f8 100644
--- a/plugins/ruflo-console/hooks/views/wf-page.ts
+++ b/plugins/ruflo-console/hooks/views/wf-page.ts
@@ -2,6 +2,7 @@ import type { RenderElement } from 'claude-code'
import { plain } from '../data/parse'
import { cleanText } from '../data/wf-clean'
+import { CONTROL_TAB, controlLine } from '../data/wf-control'
import { pick } from '../data/workflows-nav'
import { workflowsModelOf } from '../wf-live'
import { ago, button, clip, col, row, rule, text, THEME, type Ctx } from './common'
@@ -68,8 +69,8 @@ export function workflowsPage(ctx: Ctx): RenderElement {
if (extras.length > 0) rows.push(row(ctx, extras, 'wf-extras'))
- // The console reads workflow runs; it has no verb that stops or messages one, so this says where that is done instead of a dead button.
- if (env.run.kind === 'workflow') rows.push(text(ctx, 'Stop and message belong to Claude Code (its Workflows panel, TaskStop): this page only reads the run.', { dimColor: true }))
+ // Stop and message are the control tab's (ADR-465) where it is registered; where it is not, this says where that is done instead of a dead button.
+ if (env.run.kind === 'workflow') rows.push(text(ctx, controlLine(slotsFor('tab').some(slot => slot.id === CONTROL_TAB)), { dimColor: true }))
}
if (env !== null && tabs.length > 0) {
diff --git a/plugins/ruflo-console/hooks/views/wf-replay.ts b/plugins/ruflo-console/hooks/views/wf-replay.ts
index 21b983202f..a159ad661c 100644
--- a/plugins/ruflo-console/hooks/views/wf-replay.ts
+++ b/plugins/ruflo-console/hooks/views/wf-replay.ts
@@ -5,7 +5,7 @@
*
* import './wf-replay'
*
- * The console reads runs; it cannot rewind or message one, so this replays what the files say happened and nothing else.
+ * The replay reads run files; it cannot rewind a run, so it replays what the files say happened and nothing else (stopping or messaging a live run is the control tab's, ADR-465, on the run itself).
*/
import type { RenderElement } from 'claude-code'
@@ -122,7 +122,7 @@ export function replayBody(env: SlotEnv, run: WfRun): RenderElement[] {
...boardRows(ctx, board),
...(tl.untimed.length > 0 ? [text(ctx, ` ${tl.untimed.length} agent${tl.untimed.length === 1 ? '' : 's'} left off: no start time (or no span) in the run's files, so there is no moment to place ${tl.untimed.length === 1 ? 'it' : 'them'} at`, { color: THEME.warn })] : []),
text(ctx, step >= n ? ' This is the run\'s real final board.' : ' Tokens show n/a until an agent ends: only its final figure is recorded. A running agent\'s time is measured to this step.', { dimColor: true }),
- text(ctx, ' The console reads and replays the files; it cannot rewind, stop or message a Claude Code workflow.', { dimColor: true }),
+ text(ctx, ' This replay cannot rewind a run; stop or message one from its control tab.', { dimColor: true }),
]
}
diff --git a/plugins/ruflo-console/hooks/views/wf-triage.ts b/plugins/ruflo-console/hooks/views/wf-triage.ts
index ad5f6f47f5..de875839d6 100644
--- a/plugins/ruflo-console/hooks/views/wf-triage.ts
+++ b/plugins/ruflo-console/hooks/views/wf-triage.ts
@@ -2,7 +2,7 @@
* Cost, triage and guards on the Workflows page (ADR-462), as three slots of views/wf-slots.ts: a Triage board section, a Cost board
* section and a notice slot for the guards. Nothing here reads a disk: the figures come from the store `wf-cost-live.ts` fills, and a
* section whose figures are not there says why instead of drawing a number. Cost is shown as `$` only where a price was found;
- * tokens without one read "no price". The console cannot stop or message a running workflow, so the page says where that is done.
+ * tokens without one read "no price". Stop and message are the control tab's (ADR-465), and the page says where that is done.
*/
import type { RenderElement } from 'claude-code'
diff --git a/plugins/ruflo-console/hooks/views/workflows.ts b/plugins/ruflo-console/hooks/views/workflows.ts
index a237352c2d..075043eedd 100644
--- a/plugins/ruflo-console/hooks/views/workflows.ts
+++ b/plugins/ruflo-console/hooks/views/workflows.ts
@@ -3,8 +3,10 @@ import type { RenderElement } from 'claude-code'
import type { ActionSpec } from '../actions'
import { fmtElapsed, fmtTokens, modelName, currentPhase, shortId, type AgentState, type WfAgent, type WfPhase, type WfRun } from '../data/workflows'
import { pick, type WfUi } from '../data/workflows-nav'
+import { CONTROL_TAB, controlLine } from '../data/wf-control'
import { spawnAgent, stopAgent } from '../ops'
import { button, clip, col, kv, row, rule, text, THEME, type Ctx } from './common'
+import { slotsFor } from './wf-slots'
/** What the workflows view asks of the controller: a confirm-gated ruflo verb, or to name a transcript's path. */
export type WorkflowsHooks = { ask: (spec: ActionSpec) => void; show: (path: string) => void }
@@ -112,7 +114,7 @@ function inspect(ctx: Ctx, run: WfRun, agent: WfAgent, hooks: WorkflowsHooks): R
rows.push(row(ctx, [button(ctx, 'wf-open', 'Open transcript', () => hooks.show(path), { hotkey: 'o' })]))
}
- rows.push(text(ctx, run.kind === 'workflow' ? 'The console cannot stop a Claude Code workflow: stop it from Claude Code (its Workflows panel, or TaskStop).' : '', { dimColor: true }))
+ rows.push(text(ctx, run.kind === 'workflow' ? controlLine(slotsFor('tab').some(slot => slot.id === CONTROL_TAB)) : '', { dimColor: true }))
return rows
}
diff --git a/plugins/ruflo-console/hooks/wf-actions.ts b/plugins/ruflo-console/hooks/wf-actions.ts
index c8d74c061c..92f35bc0c6 100644
--- a/plugins/ruflo-console/hooks/wf-actions.ts
+++ b/plugins/ruflo-console/hooks/wf-actions.ts
@@ -1,7 +1,7 @@
/**
* What the Workflows page's buttons call (ADR-464). Keys move the cursor through the pure reducer in data/workflows-nav;
* the one write the page has, stopping or spawning a ruflo agent, goes through the runner's confirm card as a fixed argv.
- * Nothing here can stop or message a running Claude Code workflow: the console has no verb for it, so the page says so.
+ * Nothing in THIS file stops or messages a running Claude Code workflow: that is the control tab (views/wf-control.ts, ADR-465), which calls the engine's own tools through the host.
*/
import type { ActionSpec } from './actions'
import { walk, type WfKey, type WfUi } from './data/workflows-nav'
diff --git a/plugins/ruflo-console/hooks/wf-convo-live.ts b/plugins/ruflo-console/hooks/wf-convo-live.ts
new file mode 100644
index 0000000000..a5824b19ad
--- /dev/null
+++ b/plugins/ruflo-console/hooks/wf-convo-live.ts
@@ -0,0 +1,253 @@
+/**
+ * The Conversation's live half (ADR-465): one conversation per console state, the facts it reads once (the peers file, whether the codex CLI
+ * exists, the home folder), and the `ActionSpec`s that send, fan out, relay, watch and save. The pure rules are in data/wf-targets.ts,
+ * data/wf-send.ts and data/wf-convo.ts; this binds them to the host. Every spec's card shows the exact payload (data/wf-send.ts
+ * `payloadOf`, the same strings `sendTo` sends), a send that leaves the machine says so, and nothing runs before the person confirms.
+ */
+import type { ActionSpec } from './actions'
+import { cleanText } from './data/wf-clean'
+import { addMessage, applyFetch, fromBbs, fromChannel, newConvo, pollParams, POLL_MAX, POLL_MS, recordSend, relayBody, lastAnswer, threadOf, transcriptMarkdown, transcriptName, type Convo } from './data/wf-convo'
+import { checkNoLinks, EXPORT_DIR, resolveExportPath } from './data/wf-file'
+import { exportSpec } from './data/wf-export'
+import { payloadOf, sendTo, type SendDeps, tidy } from './data/wf-send'
+import { parseConfig, peersOf, targetsOf, type Config, type PeerRef, type Target } from './data/wf-targets'
+import { jsonAfter } from './data/cli'
+import { plain } from './data/parse'
+import type { WfRun } from './data/workflows'
+import type { Host } from './host'
+import { CLI_PREFIXES, type State } from './state'
+
+export type Live = { convo: Convo; draft: string; relayDraft: string; config: Config; peers: PeerRef[]; hasCodex: boolean; home: string | null; checkedAtMs: number; said: string | null; timers: Map<string, { cancel: () => void }> }
+
+const lives = new WeakMap<State, Live>()
+const hosts = new WeakMap<State, Host>()
+
+const fresh = (): Live => ({ convo: newConvo(), draft: '', relayDraft: '', config: parseConfig(''), peers: [], hasCodex: false, home: null, checkedAtMs: 0, said: null, timers: new Map() })
+
+export function liveOf(state: State): Live {
+ let held = lives.get(state)
+
+ if (held === undefined) {
+ held = fresh()
+ lives.set(state, held)
+ }
+
+ return held
+}
+
+/** The wiring: the host, and the option string that names the endpoints, rooms and channels (nothing secret: a key is a variable's name). */
+export function wireConvo(state: State, host: Host, optionText?: string): void {
+ hosts.set(state, host)
+ if (optionText !== undefined) liveOf(state).config = parseConfig(optionText)
+}
+
+export const hostOf = (state: State): Host | null => hosts.get(state) ?? null
+
+const SAY_MAX = 200
+
+const say = (state: State, label: string, ok: boolean, detail: string): void => {
+ state.outcome = { label, ok, verified: 'n/a', detail: tidy(plain(detail, SAY_MAX), SAY_MAX), atMs: Date.now() }
+ hosts.get(state)?.invalidate()
+}
+
+/**
+ * Reads what the target list depends on, at most once a minute and only while the Conversation is open: the federation helper's peers
+ * file and whether `codex` is on the PATH. Each read is bounded and a failure is an empty list, not an error.
+ */
+export async function refreshFacts(state: State, nowMs: number): Promise<void> {
+ const host = hosts.get(state)
+ const live = liveOf(state)
+
+ if (host === undefined || nowMs - live.checkedAtMs < 60_000) return
+
+ live.checkedAtMs = nowMs
+ live.home = (await host.home().catch(() => undefined)) ?? live.home
+
+ if (live.home !== null) live.peers = peersOf(await host.fs.read(`${live.home}/.claude/federation/peers.json`).then(text => (text.length > 200_000 ? null : text), () => null))
+
+ const found = await host.run(['which', 'codex'], 3000).catch(() => undefined)
+
+ live.hasCodex = found !== undefined && found.exitCode === 0
+ host.invalidate()
+}
+
+/** The targets now: the running agents of the runs on the page, the hive if one exists, and what the facts and the option added. */
+export function targetsFor(state: State, runs: readonly WfRun[]): Target[] {
+ const live = liveOf(state)
+ const agents = runs.filter(run => run.kind === 'workflow').flatMap(run => run.phases.flatMap(phase => phase.agents)).filter(agent => agent.state === 'running' && /^[A-Za-z0-9][A-Za-z0-9_-]{5,63}$/.test(agent.id)).map(agent => ({ id: agent.id, name: agent.label }))
+
+ return targetsOf({ agents, peers: live.peers, config: live.config, hasHive: state.snapshot?.hive != null, hasCodex: live.hasCodex })
+}
+
+/** What `sendTo` needs from the host, for this state. Null where there is no host. */
+export function depsOf(state: State): SendDeps | null {
+ const host = hosts.get(state)
+ const live = liveOf(state)
+
+ if (host === undefined) return null
+
+ return {
+ toolCall: host.toolCall,
+ toolCheck: host.toolCheck,
+ run: host.run,
+ httpSend: host.httpSend,
+ submitPrompt: host.submitPrompt,
+ cli: CLI_PREFIXES[state.options.cli],
+ helper: `${live.home ?? '~'}/.claude/helpers/federation.sh`,
+ trustedPeers: new Set(live.peers.filter(peer => peer.trusted).map(peer => peer.host)),
+ cwd: state.cwd,
+ hive: state.snapshot?.hive ?? null,
+ config: live.config,
+ }
+}
+
+/**
+ * One confirm card for asking one or several targets the same thing. The card's `shows` lists every payload (what leaves the machine is named
+ * per target); `run` sends them one after another so a refusal or a slow peer does not hide the others, and each answer lands in its own thread.
+ */
+export function sendSpec(state: State, targets: readonly Target[], body: string): { spec: ActionSpec | null; why: string } {
+ const deps = depsOf(state)
+ const live = liveOf(state)
+
+ if (deps === null) return { spec: null, why: 'the console is not wired to a host here' }
+ if (targets.length === 0) return { spec: null, why: 'pick a target, or name one with @name' }
+
+ const made = targets.map(target => ({ target, built: payloadOf(target, body, deps) }))
+ const bad = made.find(entry => !entry.built.ok)
+
+ if (bad !== undefined && !bad.built.ok) return { spec: null, why: `${bad.target.id}: ${bad.built.why}` }
+
+ const leaving = targets.filter(target => target.leaves !== 'machine')
+ const shows = made.map(entry => (entry.built.ok ? `${entry.target.id}: ${entry.built.payload.shows}` : '')).join('\n')
+ const spec: ActionSpec = {
+ label: targets.length === 1 ? `ask ${targets[0]?.id ?? 'target'}` : `ask ${targets.length} targets at once (${targets.map(target => target.id).join(', ')})`,
+ args: [],
+ shows: shows.slice(0, 1800),
+ expect: 'each target\'s answer, or why it did not answer, in its own thread',
+ declared: leaving.length > 0 ? 'network' : 'write',
+ note: `${leaving.length > 0 ? `LEAVES THIS MACHINE for ${leaving.map(target => `${target.id} (${target.leaves})`).join(', ')}. ` : 'Stays on this machine. '}${made.map(entry => (entry.built.ok ? `${entry.target.id}: ${entry.built.payload.note} Cost: ${entry.target.costText}.` : '')).join(' ')}`.slice(0, 900),
+ timeoutMs: 600_000,
+ run: async () => {
+ let answered = 0
+
+ for (const target of targets) {
+ const result = await sendTo(deps, target, body).catch((error: unknown) => ({ ok: false, state: 'error' as const, text: error instanceof Error ? error.message : 'refused' }))
+
+ recordSend(live.convo, target, body, result, Date.now())
+ if (result.ok) answered++
+ hosts.get(state)?.invalidate()
+ }
+
+ live.convo.picked = targets[0]?.id ?? live.convo.picked
+ say(state, targets.length === 1 ? `ask ${targets[0]?.id ?? ''}` : 'ask several targets', answered === targets.length, `${answered} of ${targets.length} went through; each answer or failure is in its thread`)
+ },
+ }
+
+ return { spec, why: '' }
+}
+
+/** A relay: one thread's newest answer, attributed, sent to other targets through the same card. */
+export function relaySpec(state: State, from: Target, to: readonly Target[], instruction: string): { spec: ActionSpec | null; why: string } {
+ const answer = lastAnswer(liveOf(state).convo, from.id)
+
+ if (answer === null) return { spec: null, why: `${from.id} has not answered yet: nothing to relay` }
+ if (to.some(target => target.id === from.id)) return { spec: null, why: 'a relay goes to another target, not back to the one that answered' }
+
+ const sent = sendSpec(state, to, relayBody(from, answer, instruction))
+
+ return sent.spec === null ? sent : { spec: { ...sent.spec, label: `relay ${from.id}'s answer to ${to.map(target => target.id).join(', ')}` }, why: '' }
+}
+
+/** Starts a bounded watch on a polled target: a read every POLL_MS, at most POLL_MAX times, stopped by Stop or the cap. The card names the read and the cadence. */
+export function watchSpec(state: State, target: Target): { spec: ActionSpec | null; why: string } {
+ const host = hosts.get(state)
+ const live = liveOf(state)
+ const first = pollParams(target, undefined, Date.now())
+
+ if (host === undefined) return { spec: null, why: 'the console is not wired to a host here' }
+ if (first === null) return { spec: null, why: `${target.id} is not polled: ${target.arrivalText}` }
+
+ const thread = threadOf(live.convo, target.id)
+
+ if (thread === null) return { spec: null, why: 'too many threads open' }
+
+ return {
+ spec: {
+ label: `watch ${target.id} for replies every ${POLL_MS / 1000}s`,
+ args: [],
+ shows: `ruflo mcp exec -t ${first.tool} -p ${JSON.stringify(first.params)} (every ${POLL_MS / 1000}s, at most ${POLL_MAX} times)`,
+ expect: 'new messages appear in the thread',
+ declared: target.leaves === 'internet' ? 'network' : 'write',
+ note: `${target.leaves === 'internet' ? 'Each read goes to the relay. ' : 'Reads only. '}It stops by itself after ${POLL_MAX} reads (${Math.round((POLL_MAX * POLL_MS) / 60_000)} minutes), or when you stop it.`,
+ run: async () => {
+ live.timers.get(target.id)?.cancel()
+ thread.isWatching = true
+ thread.polls = 0
+
+ const poll = async (): Promise<void> => {
+ const read = pollParams(target, thread.cursor, Date.now())
+
+ if (read === null) return
+
+ const out = await host.run([...CLI_PREFIXES[state.options.cli], 'mcp', 'exec', '-t', read.tool, '-p', JSON.stringify(read.params)], 30_000).catch(() => undefined)
+
+ if (out === undefined || out.exitCode !== 0 || jsonAfter(out.stdout) === null) {
+ addMessage(live.convo, target.id, { atMs: Date.now(), who: 'target', text: `the read failed: ${tidy(out?.stderr || 'no answer', 120)}`, state: 'error' })
+ thread.polls++
+ if (thread.polls >= POLL_MAX) thread.isWatching = false
+ } else applyFetch(live.convo, target.id, target.transport === 'bbs' ? fromBbs(out.stdout, Date.now()) : fromChannel(out.stdout, thread.cursor))
+
+ if (!thread.isWatching) stopWatch(state, target.id)
+
+ host.invalidate()
+ }
+
+ live.timers.set(target.id, host.every(POLL_MS, () => void poll()))
+ await poll()
+ say(state, `watch ${target.id}`, true, `reading every ${POLL_MS / 1000}s, up to ${POLL_MAX} times`)
+ },
+ },
+ why: '',
+ }
+}
+
+export function stopWatch(state: State, targetId: string): void {
+ const live = liveOf(state)
+
+ live.timers.get(targetId)?.cancel()
+ live.timers.delete(targetId)
+
+ const thread = live.convo.threads.get(targetId)
+
+ if (thread !== undefined) thread.isWatching = false
+ hosts.get(state)?.invalidate()
+}
+
+/** The transcript as a confirm-gated new file under the console's exports folder (never overwrites, no link on the way, masked and capped). */
+export async function saveTranscript(state: State, target: Target, ask: (spec: ActionSpec | null, why: string) => void): Promise<void> {
+ const host = hosts.get(state)
+ const thread = liveOf(state).convo.threads.get(target.id)
+
+ if (host === undefined || thread === undefined || thread.msgs.length === 0) return ask(null, 'this thread has nothing to save yet')
+
+ const roots = { cwd: state.cwd, scratch: null }
+ const wanted = resolveExportPath(`${state.cwd.replace(/\/+$/, '')}/${EXPORT_DIR}/${transcriptName(target.id, Date.now())}`, roots)
+
+ if (!wanted.ok) return ask(null, wanted.why)
+
+ const clear = await checkNoLinks(host.fs, wanted.path, roots)
+
+ if (!clear.ok) return ask(null, clear.why)
+
+ const made = transcriptMarkdown(thread, target, Date.now())
+ const hasDir = (await host.fs.stat(clear.path.slice(0, Math.max(1, clear.path.lastIndexOf('/')))).catch(() => undefined)) !== undefined
+
+ ask({ ...exportSpec(clear.path, made.text, cleanText(target.id), hasDir), label: `save the ${target.id} conversation${made.isCut ? ' (cut at the cap)' : ''}` }, 'that transcript cannot be written')
+}
+
+/** For tests: drops the held conversation and host of a state, and stops its timers. */
+export function resetConvo(state: State): void {
+ for (const timer of lives.get(state)?.timers.values() ?? []) timer.cancel()
+ lives.delete(state)
+ hosts.delete(state)
+}
diff --git a/plugins/ruflo-console/tests/wf-control-views.spec.ts b/plugins/ruflo-console/tests/wf-control-views.spec.ts
new file mode 100644
index 0000000000..deeabf0ee2
--- /dev/null
+++ b/plugins/ruflo-console/tests/wf-control-views.spec.ts
@@ -0,0 +1,383 @@
+/**
+ * The control tab and the Conversation board on the Workflows page (ADR-465): the slots register beside every other feature, the exact call
+ * and payload are on the card, and a send, a fan-out, a relay, a watch and a save work end to end against fake hosts. Run with
+ * npx vitest run plugins/ruflo-console/tests/wf-control-views.spec.ts --testTimeout=30000
+ */
+import { beforeEach, describe, expect, it } from 'vitest'
+
+import type { ActionSpec } from '../hooks/actions'
+import type { WfAgent, WfRun } from '../hooks/data/workflows'
+import type { Host } from '../hooks/host'
+import { newState, type State } from '../hooks/state'
+import type { Actions, Ctx, Kit } from '../hooks/views/common'
+import '../hooks/views/wf-register'
+import { conversationRows, wireWfConvo } from '../hooks/views/wf-convo'
+import { resetFolds } from '../hooks/views/wf-fold'
+import { resetControl, stopSlotSpec, wireWfControl } from '../hooks/views/wf-control'
+import { workflowsPage } from '../hooks/views/wf-page'
+import { slotsFor, type SlotEnv } from '../hooks/views/wf-slots'
+import { workflowsActions } from '../hooks/wf-actions'
+import { liveOf, resetConvo, saveTranscript, stopWatch, watchSpec } from '../hooks/wf-convo-live'
+import { targetsFor } from '../hooks/wf-convo-live'
+
+type El = { kind: string; props: Record<string, unknown> }
+
+const kit = { Box: (props: Record<string, unknown>): El => ({ kind: 'Box', props }), Text: (props: Record<string, unknown>): El => ({ kind: 'Text', props }), Button: (props: Record<string, unknown>): El => ({ kind: 'Button', props }), Input: (props: Record<string, unknown>): El => ({ kind: 'Input', props }) } as unknown as Kit
+const flat = (node: unknown, out: El[] = []): El[] => {
+ if (Array.isArray(node)) node.forEach(child => flat(child, out))
+ else if (typeof node === 'object' && node !== null) {
+ out.push(node as El)
+ flat((node as El).props?.children, out)
+ }
+
+ return out
+}
+const words = (tree: unknown): string => flat(tree).filter(el => el.kind === 'Text' && typeof el.props.children === 'string').map(el => el.props.children as string).join('\n')
+const press = (tree: unknown, key: string): void => void (flat(tree).find(el => el.kind === 'Button' && el.props.key === key)?.props.onPress as () => void)()
+const type = (tree: unknown, key: string, value: string): void => void (flat(tree).find(el => el.kind === 'Input' && el.props.key === key)?.props.onSubmit as (value: string) => void)(value)
+
+const AGENT = 'acf991387298086c7'
+const agent = (over: Partial<WfAgent> = {}): WfAgent => ({ id: AGENT, label: 'sleeper', phase: 'Build', state: 'running', hasWorktree: false, ...over })
+const wfRun = (over: Partial<WfRun> = {}): WfRun => ({ id: 'wf_abc12345', name: 'my flow', kind: 'workflow', state: 'running', phases: [{ title: 'Build', agents: [agent()], done: 0, total: 1, running: 1, failed: 0 }], running: 1, done: 0, failed: 0, idle: 0, total: 1, totalTokens: null, isTokensPartial: false, hasRecord: false, dir: '/home/u/.claude/projects/-p/sess/subagents/workflows/wf_abc12345', ...over })
+
+type Fake = { host: Host; tools: Record<string, unknown>[]; runs: { argv: readonly string[]; stdin?: string }[]; http: { url: string; headers: Record<string, string>; body: string }[]; prompts: string[]; every: { ms: number; fn: () => void; cancelled: boolean }[]; invalidated: () => number; bbs: { text: string }[] }
+
+function fake(over: { tool?: boolean; peers?: string; stat?: boolean } = {}): Fake {
+ const out: Fake = { host: undefined as never, tools: [], runs: [], http: [], prompts: [], every: [], invalidated: () => 0, bbs: [] }
+ let invalidated = 0
+ const host = {
+ home: async () => '/home/u',
+ fs: { read: async (path: string) => (path.endsWith('peers.json') ? (over.peers ?? '{"peers":[{"host":"zenbook","trusted":true}]}') : Promise.reject(new Error('ENOENT'))), stat: async () => (over.stat === true ? { size: 1 } : Promise.reject(new Error('ENOENT'))), list: async () => [] },
+ run: async (argv: readonly string[], _ms: number, stdin?: string) => {
+ out.runs.push({ argv, ...(stdin !== undefined && { stdin }) })
+
+ if (argv[0] === 'which') return { exitCode: 0, stdout: '/usr/bin/codex', stderr: '' }
+ if (argv[0] === 'printenv') return { exitCode: 0, stdout: 'key-value-1234567\n', stderr: '' }
+ if (argv.includes('federation_bbs_watch')) return { exitCode: 0, stdout: `Result:\n${JSON.stringify({ envelopes: [{ envelopeId: 'e1', payload: { text: 'peer: use sharding' }, timestamp: '2026-10-05T00:00:00Z' }] })}`, stderr: '' }
+
+ return { exitCode: 0, stdout: 'Result:\n{"success":true}', stderr: '' }
+ },
+ every: (ms: number, fn: () => void) => {
+ const timer = { ms, fn, cancelled: false }
+
+ out.every.push(timer)
+
+ return { cancel: () => void (timer.cancelled = true) }
+ },
+ invalidate: () => void (invalidated += 1),
+ submitPrompt: async (text: string) => void out.prompts.push(text),
+ fillPrompt: async () => true,
+ httpSend: async (url: string, init: { headers: Record<string, string>; body: string }) => {
+ out.http.push({ url, headers: init.headers, body: init.body })
+
+ return { ok: true, status: 200, text: JSON.stringify({ model: 'm', choices: [{ message: { content: `answer from ${url.includes('a.example') ? 'A' : 'B'}` } }], usage: { prompt_tokens: 3, completion_tokens: 4 } }) }
+ },
+ ...(over.tool === false ? {} : { toolCall: async (input: Record<string, unknown>) => { out.tools.push(input); return { text: '{"message":"Successfully stopped task: acf991387298086c7 (sleeper)"}' } }, toolCheck: async () => ({ decision: 'allow' as const }) }),
+ } as unknown as Host
+
+ out.host = host
+ out.invalidated = () => invalidated
+
+ return out
+}
+
+const world = (): { state: State; ctx: Ctx; asked: { spec: ActionSpec | null; why: string }[] } => {
+ const state = newState({})
+ const asked: { spec: ActionSpec | null; why: string }[] = []
+ const act = { workflows: { ask: (spec: ActionSpec | null, why = '') => void asked.push({ spec, why }), setUi: () => undefined } } as unknown as Actions
+
+ return { state, ctx: { kit, state, nowMs: 1_000, columns: 120, pictures: new Map(), act }, asked }
+}
+const envOf = (ctx: Ctx, run: WfRun = wfRun()): SlotEnv => ({ ctx, runs: [run], run, phase: run.phases[0] ?? null, agent: run.phases[0]?.agents[0] ?? null, ui: { run: 0, phase: 0, agent: 0, column: 'agents', isInspecting: true }, nowMs: 1_700_000_000_000 })
+const tab = (id: string) => slotsFor('tab').find(slot => slot.id === id) as unknown as { render: (env: SlotEnv) => unknown[]; when?: (env: SlotEnv) => boolean }
+
+describe('registration beside the other features', () => {
+ it('adds a tab, an action and a board with no hotkey, and the existing hotkeys are untouched', () => {
+ expect(slotsFor('tab').map(slot => slot.id)).toEqual(expect.arrayContaining(['control', 'mission', 'guide']))
+ expect(slotsFor('action').find(slot => slot.id === 'ctl-stop')?.hotkey).toBeUndefined()
+ expect(slotsFor('board').find(slot => slot.id === 'conversation')?.order).toBe(60)
+
+ const hotkeys = [...slotsFor('key').map(slot => slot.key), ...slotsFor('action').flatMap(slot => (slot.hotkey === undefined ? [] : [slot.hotkey]))]
+
+ expect(new Set(hotkeys).size).toBe(hotkeys.length)
+ })
+
+ it('the control tab is for a Claude Code workflow run only', () => {
+ const { ctx } = world()
+
+ expect(tab('control').when?.(envOf(ctx))).toBe(true)
+ expect(tab('control').when?.(envOf(ctx, wfRun({ kind: 'ruflo-swarm' })))).toBe(false)
+ })
+})
+
+describe('the control tab', () => {
+ beforeEach(() => resetFolds())
+
+ it('draws the exact call and the proof of each action, and the stop button asks with a card that shows the call', async () => {
+ const { ctx, asked } = world()
+ const f = fake()
+
+ wireWfControl(ctx.state, f.host)
+
+ const tree = tab('control').render(envOf(ctx))
+ const text = words(tree)
+
+ expect(text).toContain(`call: TaskStop {"task_id":"${AGENT}"}`)
+ expect(text).toMatch(/proof: verified · TaskStop worked on a real background agent/)
+ expect(text).toMatch(/proof: unverified · TaskStop with a workflow run's id was not tried/)
+ expect(text).toMatch(/proof: queued-only/)
+ expect(text).toContain('bound: each call goes through the engine')
+ press(tree, 'wf-control-stop-agent')
+ expect(asked[0]?.spec?.shows).toBe(`TaskStop {"task_id":"${AGENT}"}`)
+ expect(f.tools).toHaveLength(0)
+ await asked[0]?.spec?.run?.()
+ expect(f.tools).toEqual([{ tool: 'TaskStop', task_id: AGENT }])
+ expect(ctx.state.outcome).toMatchObject({ ok: true, detail: expect.stringContaining('Successfully stopped task') })
+ resetControl(ctx.state)
+ })
+
+ it('typing the message makes Message and Redirect real, with the exact SendMessage on the card', () => {
+ const { ctx, asked } = world()
+
+ wireWfControl(ctx.state, fake().host)
+ type(tab('control').render(envOf(ctx)), 'wf-control-text', 'use the cache')
+
+ const tree = tab('control').render(envOf(ctx))
+
+ expect(words(tree)).toContain(`call: SendMessage {"to":"${AGENT}","message":"use the cache"}`)
+ press(tree, 'wf-control-message')
+ expect(asked[0]?.spec?.shows).toContain('SendMessage')
+ expect(asked[0]?.spec?.declared).toBe('write')
+ })
+
+ it('a build with no tool bridge says so and offers only the text: no stop spec', () => {
+ const { ctx, asked } = world()
+
+ wireWfControl(ctx.state, fake({ tool: false }).host)
+
+ const tree = tab('control').render(envOf(ctx))
+
+ expect(words(tree)).toMatch(/not bound in this build/)
+ press(tree, 'wf-control-stop-agent')
+ expect(asked[0]?.spec).toBeNull()
+ expect(asked[0]?.why).toMatch(/does not bind tool calls/)
+ })
+
+ it('without a wired host nothing can be called, and the extras-row stop gives no spec', () => {
+ const { ctx } = world()
+
+ expect(words(tab('control').render(envOf(ctx)))).toMatch(/not wired to a host/)
+ expect(stopSlotSpec(envOf(ctx))).toBeNull()
+ })
+
+ it('the stop button of the extras row stops the picked agent, or the run when none is picked', () => {
+ const { ctx } = world()
+
+ wireWfControl(ctx.state, fake().host)
+ expect(stopSlotSpec(envOf(ctx))?.shows).toContain(AGENT)
+ expect(stopSlotSpec({ ...envOf(ctx), agent: null })?.shows).toContain('wf_abc12345')
+ })
+
+ it('draws on the real page: the control tab and the stop button, beside the Conversation rule', () => {
+ const { state } = world()
+ const f = fake()
+
+ wireWfControl(state, f.host)
+ state.view = 'workflows'
+ state.wf.read = { runs: [wfRun()], root: '/r', capBytes: 1, skipped: 0, more: 0 }
+ state.wf.ui = { run: 0, phase: 0, agent: 0, column: 'agents', isInspecting: true }
+ state.wf.tab = 'control'
+
+ const act = { workflows: workflowsActions(state, f.host, { ask: () => undefined } as never) } as unknown as Actions
+ const tree = workflowsPage({ kit, state, nowMs: 1_000, columns: 120, pictures: new Map(), act })
+ const text = words(tree)
+
+ expect(text).toMatch(/call: TaskStop/)
+ expect(text).toMatch(/Conversation/)
+ expect(flat(tree).some(el => el.kind === 'Button' && el.props.label === 'stop')).toBe(true)
+ expect(text).toMatch(/the control tab calls the engine.s own TaskStop and SendMessage/)
+ expect(text).not.toMatch(/not switched on/)
+ })
+})
+
+describe('the Conversation board', () => {
+ beforeEach(() => resetFolds())
+
+ const open = (config?: string): { ctx: Ctx; state: State; asked: ReturnType<typeof world>['asked']; f: Fake } => {
+ const w = world()
+ const f = fake()
+
+ resetConvo(w.state)
+ wireWfConvo(w.state, f.host, config)
+
+ return { ctx: w.ctx, state: w.state, asked: w.asked, f }
+ }
+ const draw = (ctx: Ctx, run: WfRun = wfRun()): unknown => conversationRows(envOf(ctx, run))
+ const settle = async (): Promise<void> => void (await new Promise(resolve => setTimeout(resolve, 5)))
+
+ it('lists the targets with what leaves the machine, the cost class and how the reply arrives, once the facts are read', async () => {
+ const { ctx, state } = open('bbs:ops; endpoint:a=https://a.example.com/v1|NONE|m1')
+
+ draw(ctx)
+ await settle()
+
+ const ids = targetsFor(state, [wfRun()]).map(target => target.id)
+
+ expect(ids).toEqual(expect.arrayContaining(['claude', 'sleeper', 'task', 'bbs-ops', 'peer-zenbook', 'codex', 'a', 'openrouter']))
+
+ const text = words(draw(ctx))
+
+ expect(text).toMatch(/@claude/)
+ expect(text).toMatch(/sends: nothing beyond what a turn of this session sends/)
+ expect(text).toMatch(/cost: a visible turn of this session/)
+ expect(text).toMatch(/reply: its answer is the next turn/)
+ expect(text).toMatch(/message: none typed yet/)
+ })
+
+ it('a send to an endpoint asks first with the exact request, then sends it, and the answer lands in its own thread with its tokens', async () => {
+ const { ctx, state, asked, f } = open('endpoint:a=https://a.example.com/v1|KEY_A|m1')
+
+ draw(ctx)
+ await settle()
+ type(draw(ctx), 'wf-convo-text', '@a what is raft?')
+
+ const tree = draw(ctx)
+
+ expect(words(tree)).toContain('message: @a what is raft?')
+ press(tree, 'wf-convo-send')
+ expect(asked).toHaveLength(1)
+ expect(asked[0]?.spec?.shows).toContain('a: POST https://a.example.com/v1/chat/completions Authorization: Bearer ‹from $KEY_A›')
+ expect(asked[0]?.spec?.shows).toContain('"content":"what is raft?"')
+ expect(asked[0]?.spec?.shows).not.toContain('key-value-1234567')
+ expect(asked[0]?.spec?.declared).toBe('network')
+ expect(asked[0]?.spec?.note).toMatch(/LEAVES THIS MACHINE for a \(internet\)/)
+ expect(f.http).toHaveLength(0)
+
+ await asked[0]?.spec?.run?.()
+ expect(f.http).toHaveLength(1)
+ expect(f.http[0]?.headers.authorization).toBe('Bearer key-value-1234567')
+ expect(liveOf(state).convo.threads.get('a')?.msgs.map(msg => msg.text)).toEqual(['what is raft?', 'answer from A'])
+
+ const text = words(draw(ctx))
+
+ expect(text).toContain('answer from A')
+ expect(text).toContain('tokens 3 in / 4 out')
+ expect(text).toContain('cost n/a (no billed figure reported)')
+ expect(text).not.toContain('key-value-1234567')
+ })
+
+ it('a fan-out is ONE card listing every payload, sends to each, and the answers appear side by side', async () => {
+ const { ctx, state, asked, f } = open('endpoint:a=https://a.example.com/v1|NONE|m1; endpoint:b=https://b.example.com/v1|NONE|m2')
+
+ draw(ctx)
+ await settle()
+ type(draw(ctx), 'wf-convo-text', '@a @b @claude compare raft and paxos')
+ press(draw(ctx), 'wf-convo-send')
+
+ const spec = asked[0]?.spec
+
+ expect(spec?.label).toBe('ask 3 targets at once (a, b, claude)')
+ expect(spec?.shows).toMatch(/a: POST [\s\S]*\nb: POST [\s\S]*\nclaude: to Claude in this session/)
+ await spec?.run?.()
+ expect(f.prompts).toEqual(['compare raft and paxos'])
+ expect(f.http.map(call => call.url)).toEqual(['https://a.example.com/v1/chat/completions', 'https://b.example.com/v1/chat/completions'])
+
+ const text = words(draw(ctx))
+
+ expect(text).toContain('Answers side by side')
+ expect(text).toContain('answer from A')
+ expect(text).toContain('answer from B')
+ expect(text).toMatch(/@claude \[sent\]|@claude \[none\]/)
+ expect(liveOf(state).convo.threads.size).toBe(3)
+ })
+
+ it('a relay carries one answer, attributed, to another target through a card; with no answer it says so', async () => {
+ const { ctx, state, asked } = open('endpoint:a=https://a.example.com/v1|NONE|m1; endpoint:b=https://b.example.com/v1|NONE|m2')
+
+ draw(ctx)
+ await settle()
+ type(draw(ctx), 'wf-convo-text', '@a hello there')
+ press(draw(ctx), 'wf-convo-send')
+ await asked[0]?.spec?.run?.()
+ liveOf(state).convo.picked = 'a'
+ type(draw(ctx), 'wf-convo-text', '@b do you agree?')
+ press(draw(ctx), 'wf-convo-relay')
+
+ expect(asked[1]?.spec?.label).toBe('relay a\'s answer to b')
+ expect(asked[1]?.spec?.shows).toContain('Another assistant (a (m1)) answered: \\"answer from A\\" do you agree?')
+ liveOf(state).convo.picked = 'b'
+ expect(flat(draw(ctx)).some(el => el.kind === 'Button' && el.props.key === 'wf-convo-relay')).toBe(false)
+ })
+
+ it('a message with a credential in it is refused on the card, naming the target and the reason', async () => {
+ const { ctx, asked } = open('endpoint:a=https://a.example.com/v1|NONE|m1')
+
+ draw(ctx)
+ await settle()
+ type(draw(ctx), 'wf-convo-text', '@a use api_key=sk-live-AAAABBBBCCCCDDDD')
+ press(draw(ctx), 'wf-convo-send')
+ expect(asked[0]?.spec).toBeNull()
+ expect(asked[0]?.why).toMatch(/a: .*credential/)
+ })
+
+ it('a watch is confirmed first, reads on a timer, shows what peers wrote, and stops by itself at the cap or on Stop', async () => {
+ const { ctx, state, asked, f } = open('bbs:ops')
+
+ draw(ctx)
+ await settle()
+ liveOf(state).convo.picked = 'bbs-ops'
+ press(draw(ctx), 'wf-convo-watch')
+
+ const spec = asked[0]?.spec
+
+ expect(spec?.shows).toMatch(/federation_bbs_watch -p \{"roomId":"ops","limit":20\} \(every 20s, at most 30 times\)/)
+ expect(f.every).toHaveLength(0)
+ await spec?.run?.()
+ expect(f.every).toHaveLength(1)
+ expect(f.every[0]?.ms).toBe(20_000)
+ expect(liveOf(state).convo.threads.get('bbs-ops')?.msgs.map(msg => `${msg.state}:${msg.text}`)).toEqual(['received:peer: use sharding'])
+ expect(words(draw(ctx))).toMatch(/reply polling\s+on: a read every 20s, 1 of 30 done/)
+ expect(liveOf(state).convo.threads.get('bbs-ops')?.cursor).toBe('e1')
+ stopWatch(state, 'bbs-ops')
+ expect(f.every[0]?.cancelled).toBe(true)
+ expect(liveOf(state).convo.threads.get('bbs-ops')?.isWatching).toBe(false)
+ expect(watchSpec(state, targetsFor(state, [wfRun()]).find(target => target.id === 'claude') as never).why).toMatch(/not polled/)
+ })
+
+ it('saving the transcript is a confirm-gated NEW file under the exports folder, masked, never an overwrite', async () => {
+ const { ctx, state, asked } = open('endpoint:a=https://a.example.com/v1|NONE|m1')
+
+ state.cwd = '/work/proj'
+ draw(ctx)
+ await settle()
+ type(draw(ctx), 'wf-convo-text', '@a question one')
+ press(draw(ctx), 'wf-convo-send')
+ await asked[0]?.spec?.run?.()
+
+ const target = targetsFor(state, [wfRun()]).find(candidate => candidate.id === 'a') as never
+ const saved: { spec: ActionSpec | null; why: string }[] = []
+
+ await saveTranscript(state, target, (spec, why) => void saved.push({ spec, why }))
+ expect(saved[0]?.spec?.argv?.[0]).toMatch(/^(dd|install)$/)
+ expect(saved[0]?.spec?.shows).toMatch(/^write \/work\/proj\/\.claude-flow\/console\/exports\/convo-a-.*\.md \(\d+ bytes; never overwrites\)$/)
+ expect(saved[0]?.spec?.stdin).toContain('# Conversation with a (m1)')
+ expect(saved[0]?.spec?.stdin).toContain('answer from A')
+
+ await saveTranscript(state, { ...(target as object), id: 'nothing' } as never, (spec, why) => void saved.push({ spec, why }))
+ expect(saved[1]).toMatchObject({ spec: null, why: expect.stringMatching(/nothing to save/) })
+ })
+
+ it('with no host wired, or no tool at all, the board says so instead of drawing dead buttons', () => {
+ const { ctx } = world()
+
+ expect(words(conversationRows(envOf(ctx)))).toMatch(/not wired to a host/)
+ })
+
+ it('a bad convoTargets option is reported on the board, not thrown', async () => {
+ const { ctx } = open('endpoint:x=http://evil.example.com/v1|KEY|m')
+
+ draw(ctx)
+ await settle()
+ expect(words(draw(ctx))).toMatch(/convoTargets option: endpoint x: the base URL must be https/)
+ })
+})
diff --git a/plugins/ruflo-console/tests/wf-extras-page.spec.ts b/plugins/ruflo-console/tests/wf-extras-page.spec.ts
index 32b6ccb1d4..5e27147b40 100644
--- a/plugins/ruflo-console/tests/wf-extras-page.spec.ts
+++ b/plugins/ruflo-console/tests/wf-extras-page.spec.ts
@@ -111,7 +111,7 @@ describe('the extras on the page', () => {
expect(text).toContain('Workflow templates (dry run, then a confirmed launch)')
expect(text).toContain('Project Anatole, per agent (reported by the mod)')
expect(hotkeys(tree)).toEqual(expect.arrayContaining(['w', 't', 'c', 'g']))
- expect(text).toContain('Stop and message belong to Claude Code')
+ expect(text).toContain('need the control tab, which is not switched on')
})
it('the page\'s read drives the worktree read once, never the process check, and a failing git is a line, not a crash', () => {
diff --git a/plugins/ruflo-console/tests/wf-guide.spec.ts b/plugins/ruflo-console/tests/wf-guide.spec.ts
index de09d6a88f..2cba2ff823 100644
--- a/plugins/ruflo-console/tests/wf-guide.spec.ts
+++ b/plugins/ruflo-console/tests/wf-guide.spec.ts
@@ -139,13 +139,13 @@ describe('guideActions on a Claude Code workflow', () => {
expect(actions.map(action => action.id)).toEqual(['memory', 'redirect'])
})
- it('the redirect only prepares text for the main session, and says the console cannot stop or message the run', async () => {
+ it('the redirect only prepares text for the main session, and says it is the prompt-box fallback for the control tab', async () => {
const sent: string[] = []
const redirect = byId(guideActions(input({ run: wfRun(), prepare: async text => void sent.push(text) })), 'redirect')
const spec = redirect?.spec as ActionSpec
expect(spec.args).toEqual([])
- expect(spec.note).toMatch(/cannot stop or message a workflow/)
+ expect(spec.note).toMatch(/prompt-box fallback.*control tab/)
expect(redirect?.kind).toBe('prompt-only')
await spec.run?.()
expect(sent).toHaveLength(1)
@@ -297,7 +297,7 @@ describe('the slots', () => {
expect(words(slot('board', 'mission-run').render(envOf(ctx, wfRun())))).toMatch(/\d+ more lines are not drawn here/)
})
- it('the guide tab lists each action with what it sends and whether it acts, and says a workflow cannot be stopped from here', () => {
+ it('the guide tab lists each action with what it sends and whether it acts, and says where a workflow is stopped (the control tab, or Claude Code where it is not switched on)', () => {
registerGuide()
const { ctx } = world()
@@ -306,7 +306,7 @@ describe('the slots', () => {
expect(flat(tree).some(el => el.kind === 'Input')).toBe(true)
expect(text).toMatch(/guidance: none typed yet/)
- expect(text).toMatch(/cannot be stopped or messaged from here/)
+ expect(text).toMatch(/need the control tab, which is not switched on/)
})
it('draws on the real page: the boards under the run board, and the tabs once the inspector is open', () => {
diff --git a/plugins/ruflo-console/tests/wf-replay-views.spec.ts b/plugins/ruflo-console/tests/wf-replay-views.spec.ts
index f6b39efdbf..b1121ff30c 100644
--- a/plugins/ruflo-console/tests/wf-replay-views.spec.ts
+++ b/plugins/ruflo-console/tests/wf-replay-views.spec.ts
@@ -119,11 +119,11 @@ describe('replay', () => {
expect(words(w.page())).toMatch(/64x/)
})
- it('says the console cannot rewind or message a run', () => {
+ it('says the replay cannot rewind a run, and that stopping or messaging is not done from it', () => {
const w = world()
press(w.page(), 'wf-replay-fold')
- expect(words(w.page())).toMatch(/cannot rewind, stop or message a Claude Code workflow/)
+ expect(words(w.page())).toMatch(/cannot rewind a run; stop or message one from its control tab/)
})
it('has nothing to replay for the ruflo swarm, and says so', () => {
diff --git a/plugins/ruflo-console/tests/wf-wire.spec.ts b/plugins/ruflo-console/tests/wf-wire.spec.ts
index 4034a05f27..5fad244331 100644
--- a/plugins/ruflo-console/tests/wf-wire.spec.ts
+++ b/plugins/ruflo-console/tests/wf-wire.spec.ts
@@ -309,14 +309,14 @@ describe('the page', () => {
expect(words(pageOf(world.state, world.host).tree)).toMatch(/No workflow runs for this project/)
})
- it('says the console cannot stop or message a workflow, with no button for it', async () => {
+ it('says where a workflow is stopped while the control tab is not switched on, with no button for it', async () => {
const world = worldOf(live())
await refreshWorkflows(world.state, world.host, true, NOW)
const { tree } = pageOf(world.state, world.host)
- expect(words(tree)).toMatch(/Stop and message belong to Claude Code/)
+ expect(words(tree)).toMatch(/need the control tab, which is not switched on/)
expect(buttons(tree).some(el => /stop|message/i.test(String(el.props.label)))).toBe(false)
})
diff --git a/plugins/ruflo-console/tests/workflows.spec.ts b/plugins/ruflo-console/tests/workflows.spec.ts
index 2f88fa5f2f..bfb5af6348 100644
--- a/plugins/ruflo-console/tests/workflows.spec.ts
+++ b/plugins/ruflo-console/tests/workflows.spec.ts
@@ -391,14 +391,14 @@ describe('view', () => {
expect(out.join('\n')).toContain('1 Build')
})
- it('inspect shows the transcript path and open fires the hook; a workflow cannot be stopped from here', () => {
+ it('inspect shows the transcript path and open fires the hook; a workflow is stopped from the control tab where it is on, else Claude Code', () => {
const shown: string[] = []
const ui = { ...startOn(newWfUi(), live), column: 'agents' as const, isInspecting: true }
const tree = workflowsView(ctxOf(110), model(), ui, { ask: () => undefined, show: path => shown.push(path) })
const buttons = walkEls(tree).filter(n => n.kind === 'Button')
expect(lines(tree).join('\n')).toContain('/d/agent-a1.jsonl')
- expect(lines(tree).join('\n')).toContain('cannot stop a Claude Code workflow')
+ expect(lines(tree).join('\n')).toContain('need the control tab, which is not switched on')
expect(buttons.map(b => b.props.label)).toEqual(['Open transcript'])
;(buttons[0]?.props.onPress as () => void)()
expect(shown).toEqual(['/d/agent-a1.jsonl'])