mirror of
https://github.com/ruvnet/ruflo.git
synced 2026-11-23 21:59:14 +09:00
fix(ruflo-console): the terminal field keeps the keys through a run and stays above the fold; tour GIF for 0.7.0
- A run starting or ending adds or drops rows above the field (spinner, last line), and the engine moved the focus ring off it, so the next keys left the pane. The ring is put back after the redraw. - The conversation window reserves the ~34 rows its frame needs, so long output never pushes the field below the fold (where the pane drops the keys). - The confirm row no longer doubles a trailing question mark. - Tour GIF: neon boot, grouped menu, swarm, Hive-Mind and Skills by mouse, x.ruv.io, the MetaHarness lab, a streamed framed terminal turn and a swarm session ask. Co-Authored-By: RuFlo <ruv@ruv.net>
This commit is contained in:
1 parent
5b5adeb188
commit
eb7771be77
4 files changed
+19
-3
No files matched your search
@@ -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()
|
||||
}
|
||||
}
|
||||
@@ -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' })]),
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in new issue
Block a user