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

fix(ruflo-console): the terminal field keeps the keys through a run and stays above the fold; tour GIF for 0.7.0

ruveb7771be77bb
diff --git a/docs/assets/ruflo-console-tour.gif b/docs/assets/ruflo-console-tour.gif
index 4a5cd3ffbe..78edefbac8 100644
Binary files a/docs/assets/ruflo-console-tour.gif and b/docs/assets/ruflo-console-tour.gif differ
diff --git a/plugins/ruflo-console/hooks/harness.ts b/plugins/ruflo-console/hooks/harness.ts
index e5b2c7f760..fa47a745bc 100644
--- a/plugins/ruflo-console/hooks/harness.ts
+++ b/plugins/ruflo-console/hooks/harness.ts
@@ -10,7 +10,7 @@
*/
import type { ActionSpec } from './actions'
import type { Host } from './host'
-import { CLI_PREFIXES, push, termStoreKeyOf, type AgentId, type HarnessId, type State, type TermLine } from './state'
+import { CLI_PREFIXES, PANE_ID, push, termStoreKeyOf, type AgentId, type HarnessId, type State, type TermLine } from './state'
import { claudeParser, codexEvent, eventOf, type Sink } from './stream'
export const TERM_MAX_LINES = 600
@@ -85,6 +85,17 @@ function note(state: State, kind: TermLine['kind'], text: string, from?: AgentId
const persist = (state: State, host: Host) => void host.storeSet(termStoreKeyOf(state.cwd), state.terminal.sessions).catch(() => undefined)
+/**
+ * A run starting or ending adds or drops rows above the field (the spinner, the turn's last line), and the engine
+ * does not keep the focus ring on the field across that: the person's next keys would leave it. Put it back after
+ * the redraw, while the terminal is in front and the pane holds the keys.
+ */
+function keepField(state: State, host: Host): void {
+ host.after(80, () => {
+ if (state.view === 'terminal' && state.pane.isFocused) void host.focus(PANE_ID, 'term-input').catch(() => undefined)
+ })
+}
+
/** Why the field's text cannot be sent now, or null when it can. */
export function whyNotRun(state: State, text: string): string | null {
const harness = harnessOf(state.terminal.harness)
@@ -224,6 +235,7 @@ async function runAgent(state: State, host: Host, agent: AgentId, prompt: string
const partial = { stdout: '', stderr: '' }
term.runs.set(agent, { label: agent, startedAtMs, stop })
+ keepField(state, host)
note(state, 'head', agent, tag)
host.invalidate()
@@ -266,6 +278,7 @@ async function runAgent(state: State, host: Host, agent: AgentId, prompt: string
} finally {
cap.cancel()
term.runs.delete(agent)
+ keepField(state, host)
host.invalidate()
}
}
diff --git a/plugins/ruflo-console/hooks/views/pane.ts b/plugins/ruflo-console/hooks/views/pane.ts
index 9fec22150d..585f47c21c 100644
--- a/plugins/ruflo-console/hooks/views/pane.ts
+++ b/plugins/ruflo-console/hooks/views/pane.ts
@@ -133,7 +133,7 @@ function confirmRow(ctx: Ctx): RenderElement | null {
return col(
ctx,
[
- text(ctx, `Confirm: ${pending.label}?`, { bold: true, color: THEME.warn }),
+ text(ctx, `Confirm: ${pending.label.replace(/\?+$/, '')}?`, { bold: true, color: THEME.warn }),
text(ctx, `runs: ${pending.shows ?? `ruflo ${pending.args.join(' ')}`}`, { dimColor: true }),
...(pending.note !== undefined ? [text(ctx, pending.note, { bold: /money|models/i.test(pending.note), color: /money|models/i.test(pending.note) ? THEME.bad : THEME.warn })] : []),
row(ctx, [button(ctx, 'confirm', 'Yes, run it (y)', ctx.act.confirm, { hotkey: 'y', primary: true }), button(ctx, 'cancel', 'Cancel (n)', ctx.act.cancel, { hotkey: 'n' })]),
diff --git a/plugins/ruflo-console/hooks/views/terminal.ts b/plugins/ruflo-console/hooks/views/terminal.ts
index fb1ba95d77..6bb803e192 100644
--- a/plugins/ruflo-console/hooks/views/terminal.ts
+++ b/plugins/ruflo-console/hooks/views/terminal.ts
@@ -130,7 +130,10 @@ export function terminalView(ctx: Ctx): RenderElement {
// The window: the newest screen rows, or `scroll` rows up from them.
const width = Math.max(10, ctx.columns - 6)
const screen = screenOf(term.lines, width)
- const height = state.pane.rows > 0 ? Math.max(8, Math.min(48, state.pane.rows - 26)) : TERM_ROWS
+ // The frame around the window (banner, strips, tabs, title, picker, rules, buttons, field, hint, footer, a confirm row)
+ // takes about 34 rows: the window gets the rest, so the field is never pushed below the fold (the pane drops the keys
+ // when the focused field scrolls out of sight).
+ const height = state.pane.rows > 0 ? Math.max(6, Math.min(48, state.pane.rows - 34 - term.runs.size)) : TERM_ROWS
const maxScroll = Math.max(0, screen.length - height)
const scroll = Math.min(term.scroll, maxScroll)
const start = Math.max(0, screen.length - height - scroll)