From 563004d4a476328573bd474a7fbeede526f7f004 Mon Sep 17 00:00:00 2001 From: Thomas Mustier <6326440+tmustier@users.noreply.github.com> Date: Thu, 1 Oct 2026 23:59:15 +0100 Subject: [PATCH] refactor: tidy embedded status border rendering --- editor-render.ts | 16 ++++++---------- index.ts | 10 +++------- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/editor-render.ts b/editor-render.ts index b925f35..37f17e7 100644 --- a/editor-render.ts +++ b/editor-render.ts @@ -128,16 +128,6 @@ function stripOuterFrameAndPadding(line: string, paddingX: number): string { * add side borders and padding. The queue already provides that frame, so an * active row should inherit only the live editor content and cursor. */ -/** - * Keep an editor's top border only when it carries an embedded status such as - * Pi's working spinner, so the status stays visible while a queued row is edited inline. - */ -export function extractEmbeddedStatusBorder(lines: readonly string[]): string[] { - const top = lines[0] ?? ""; - const label = stripAnsi(top).replace(/↑ \d+ more/, "").replace(/─/g, "").trim(); - return label ? [top] : []; -} - export function extractInlineEditorLines(lines: readonly string[], paddingX = 0): string[] { if (lines.length === 0) return [""]; if (!isEditorFrame(lines[0] ?? "")) return [...lines]; @@ -157,3 +147,9 @@ export function extractInlineEditorLines(lines: readonly string[], paddingX = 0) const auxiliary = lines.slice(bottomFrameIndex + 1); return [...editorBody, ...auxiliary].length > 0 ? [...editorBody, ...auxiliary] : [""]; } + +/** Keep the editor's top border only while it carries an embedded status such as Pi's working spinner. */ +export function extractEmbeddedStatusBorder([top = ""]: readonly string[]): string[] { + const label = stripAnsi(top).replace(/↑ \d+ more/, "").replace(/─/g, "").trim(); + return label ? [top] : []; +} diff --git a/index.ts b/index.ts index 252c66c..72b0b80 100644 --- a/index.ts +++ b/index.ts @@ -582,9 +582,7 @@ export default function queueSteerExtension(pi: ExtensionAPI) { if (features.has(QUEUE_STEER_FEATURE)) return; const factory = ((tui, theme, keybindings) => { - const editor = previousFactory?.(tui, theme, keybindings) ?? new CustomEditor(tui, theme, keybindings, { - embedWorkingStatus: true, - }); + const editor = previousFactory?.(tui, theme, keybindings) ?? new CustomEditor(tui, theme, keybindings, { embedWorkingStatus: true }); installSubmitGuard(editor, ctx); const handleInput = editor.handleInput.bind(editor); const renderEditor = editor.render.bind(editor); @@ -606,10 +604,8 @@ export default function queueSteerExtension(pi: ExtensionAPI) { const embedsWorkingStatus = "embedWorkingStatus" in editor && editor.embedWorkingStatus === true; editor.render = (width: number): string[] => { - if (editSession && !renderingInline) { - return embedsWorkingStatus ? extractEmbeddedStatusBorder(renderEditor(width)) : []; - } - return renderEditor(width); + if (!editSession || renderingInline) return renderEditor(width); + return embedsWorkingStatus ? extractEmbeddedStatusBorder(renderEditor(width)) : []; }; editor.handleInput = (data: string): void => {