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(console): draw the tui at the default size when the terminal reports 0 columns

martinvladc0b5750a370a
diff --git a/plugins/ruflo-console/tests/tui-nav.spec.ts b/plugins/ruflo-console/tests/tui-nav.spec.ts
index 3fe9174101..5905e82303 100644
--- a/plugins/ruflo-console/tests/tui-nav.spec.ts
+++ b/plugins/ruflo-console/tests/tui-nav.spec.ts
@@ -158,6 +158,20 @@ describe('every page, on a host with no Claude session and no mouse', () => {
})
describe('the terminal loop', () => {
+ it('a terminal that reports 0 columns draws the page at the default width, not a repeated "T" (#4115)', async () => {
+ const t = terminal(0, 0)
+ const running = runTui({ cwd: project, home: join(root, 'home') }, t.io)
+
+ await settle()
+ t.press('q')
+ await expect(running).resolves.toBe(0)
+
+ const text = plain(t.out.join(''))
+
+ expect(text).toMatch(/1 Overview {1,3}2 Cost/)
+ expect(text).not.toContain('Too narrow')
+ })
+
it('jumps to a page on a digit, cycles with tab and shift-tab, and the page bar follows', async () => {
const t = terminal()
const running = runTui({ cwd: project, home: join(root, 'home') }, t.io)
diff --git a/plugins/ruflo-console/tui/run.ts b/plugins/ruflo-console/tui/run.ts
index e6f3e76097..6edac9f5fb 100644
--- a/plugins/ruflo-console/tui/run.ts
+++ b/plugins/ruflo-console/tui/run.ts
@@ -117,10 +117,13 @@ export function keyOf(chunk: string): Key {
}
}
+/** A terminal that reports 0 (or nothing) does not know its size; some `docker exec` without -t and CI `script` wrappers do. Use the default rather than calling it too narrow (#4115). */
+const sized = (value: number | undefined, fallback: number): number => (value !== undefined && Number.isFinite(value) && value > 0 ? value : fallback)
+
function paint(session: Session, io: TuiIO, depth: Depth, scroll: number, clear = false): number {
const ai = session.page === 'ai' ? session.ai : null
- const raw = io.stdout.columns ?? 100
- const rows = Math.max(5, io.stdout.rows ?? 30)
+ const raw = sized(io.stdout.columns, 100)
+ const rows = Math.max(5, sized(io.stdout.rows, 30))
const reset = clear ? `${ESC}[2J` : ''
// Too narrow for a page: say so in a line that fits, rather than a squeezed frame of broken cards.
@@ -157,7 +160,7 @@ function paint(session: Session, io: TuiIO, depth: Depth, scroll: number, clear
async function once(session: Session, io: TuiIO, view: TuiView): Promise<number> {
session.show(view)
await session.refresh()
- const columns = Math.max(MIN_COLUMNS, Math.min(200, io.stdout.columns ?? 100))
+ const columns = Math.max(MIN_COLUMNS, Math.min(200, sized(io.stdout.columns, 100)))
io.stdout.write(`${navLine(view, columns, 'none')}\n${session.frame(columns, 'none').join('\n')}\n`)
@@ -199,7 +202,7 @@ export async function runTui(options: TuiOptions, io: TuiIO): Promise<number> {
if (view === 'ai' && session.ai !== null && session.ai.press(chunk.toString()).consumed) return draw()
const key = keyOf(chunk.toString())
- const page = Math.max(1, (io.stdout.rows ?? 30) - 2)
+ const page = Math.max(1, sized(io.stdout.rows, 30) - 2)
if (key === 'quit') return finish()
if (typeof key === 'object' && key !== null) (view = key.page), (scroll = 0), session.show(view), view === 'ai' && session.ai?.enter()