Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

fix(coding-agent): fill selector backgrounds to terminal edge (#366)

kt4aa06023dfd0
diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md
index 71e29dc58b..2087e7ffe4 100644
--- a/packages/coding-agent/CHANGELOG.md
+++ b/packages/coding-agent/CHANGELOG.md
@@ -8,6 +8,7 @@
- Fixed Escape repeats around autocomplete, queued draft restoration, whitespace-only drafts, and active background work ([ENG-4489](https://linear.app/primeintellect/issue/ENG-4489/rewire-prime-agent-shortcuts-to-match-claude-code-flow)).
- Fixed the agents-view splash shifting when opening an agent session ([ENG-4517](https://linear.app/primeintellect/issue/ENG-4517)).
- Changed `/model` to sort featured flagship models above a provider's long tail (with a numeric-aware alphabetical tiebreak), so the full Prime Inference catalog doesn't flood the picker.
+- Fixed selector prompts and choices filling their background through the terminal's right edge.
- Changed automatic harness refinement to be enabled by default while keeping `autoRefine.enabled: false` as the opt-out.
- Fixed non-numeric `autoRefine.turnInterval` and `autoRefine.cooldownMs` settings falling back to defaults instead of silently enabling a noisy auto-refine loop.
- Fixed all session-resume entry points to share a searchable full-screen picker, stream results while loading, and support renaming ([ENG-4513](https://linear.app/primeintellect/issue/ENG-4513/resume-in-agents-view-is-broken)).
diff --git a/packages/coding-agent/src/modes/interactive/components/menu-panel.ts b/packages/coding-agent/src/modes/interactive/components/menu-panel.ts
index 222edc209c..a75db104be 100644
--- a/packages/coding-agent/src/modes/interactive/components/menu-panel.ts
+++ b/packages/coding-agent/src/modes/interactive/components/menu-panel.ts
@@ -183,28 +183,30 @@ export function getMenuListLayout(options: MenuListLayoutOptions): MenuListLayou
: { compact: false, visibleItems: comfortableLayout.visibleItems };
}
-function surfaceLine(text: string, width: number, paddingX = PANEL_PADDING_X): string {
+function paddedBackgroundLine(
+ text: string,
+ width: number,
+ paddingX: number,
+ background: ((text: string) => string) | undefined,
+): string {
const innerWidth = Math.max(1, width - paddingX * 2);
const content = truncateToWidth(text, innerWidth, "");
const rightPadding = " ".repeat(Math.max(0, innerWidth - visibleWidth(content)));
- const line = " ".repeat(paddingX) + content + rightPadding + " ".repeat(paddingX);
- return theme.getEditorBackgroundColor()?.(line) ?? line;
+ const contentSpan = " ".repeat(paddingX) + content;
+ const trailingSpan = rightPadding + " ".repeat(paddingX);
+ if (!background) {
+ return contentSpan + trailingSpan;
+ }
+ return background(contentSpan) + background(trailingSpan);
}
-function surfaceWrappedLines(text: string, width: number, paddingX = PANEL_PADDING_X): string[] {
- const innerWidth = Math.max(1, width - paddingX * 2);
- return wrapTextWithAnsi(text, innerWidth).map((content) => {
- const rightPadding = " ".repeat(Math.max(0, innerWidth - visibleWidth(content)));
- const line = " ".repeat(paddingX) + content + rightPadding + " ".repeat(paddingX);
- return theme.getEditorBackgroundColor()?.(line) ?? line;
- });
+function surfaceLine(text: string, width: number, paddingX = PANEL_PADDING_X): string {
+ return paddedBackgroundLine(text, width, paddingX, theme.getEditorBackgroundColor());
}
-function padLine(text: string, width: number, paddingX: number): string {
+function surfaceWrappedLines(text: string, width: number, paddingX = PANEL_PADDING_X): string[] {
const innerWidth = Math.max(1, width - paddingX * 2);
- const content = truncateToWidth(text, innerWidth, "");
- const rightPadding = " ".repeat(Math.max(0, innerWidth - visibleWidth(content)));
- return " ".repeat(paddingX) + content + rightPadding + " ".repeat(paddingX);
+ return wrapTextWithAnsi(text, innerWidth).map((content) => surfaceLine(content, width, paddingX));
}
export class MenuPanel extends Container {
@@ -300,8 +302,7 @@ export class MenuSearchInput implements Component, Focusable, FullWidthMenuCompo
this.getValue() === "" && !this.focused
? theme.fg("dim", this.placeholder)
: this.stripInputPrompt(this.input.render(innerWidth + 2)[0] ?? "");
- const field = padLine(content, safeWidth, FIELD_PADDING_X);
- return [theme.getEditorBackgroundColor()?.(field) ?? field];
+ return [paddedBackgroundLine(content, safeWidth, FIELD_PADDING_X, theme.getEditorBackgroundColor())];
}
private stripInputPrompt(line: string): string {
@@ -369,11 +370,10 @@ export class MenuRow implements Component, FullWidthMenuComponent {
}
private rowLine(text: string, width: number, selected: boolean): string {
- const line = padLine(text, width, ROW_PADDING_X);
- if (selected) {
- return theme.bg("selectedBg", line);
- }
- return theme.getEditorBackgroundColor()?.(line) ?? line;
+ const background = selected
+ ? (content: string) => theme.bg("selectedBg", content)
+ : theme.getEditorBackgroundColor();
+ return paddedBackgroundLine(text, width, ROW_PADDING_X, background);
}
}
diff --git a/packages/coding-agent/test/extension-selector.test.ts b/packages/coding-agent/test/extension-selector.test.ts
index 0081792b37..ea45133ee3 100644
--- a/packages/coding-agent/test/extension-selector.test.ts
+++ b/packages/coding-agent/test/extension-selector.test.ts
@@ -4,6 +4,15 @@ import { beforeAll, describe, expect, it, vi } from "vitest";
import { ExtensionSelectorComponent } from "../src/modes/interactive/components/extension-selector.js";
import { initTheme } from "../src/modes/interactive/theme/theme.js";
+const BACKGROUND_START = /\x1b\[(?:4[0-8]|48;5;\d+|48;2;\d+;\d+;\d+)m/;
+
+function expectTrailingBackground(line: string | undefined, text: string): void {
+ const renderedLine = line ?? "";
+ const textEnd = renderedLine.indexOf(text) + text.length;
+ expect(textEnd).toBeGreaterThanOrEqual(text.length);
+ expect(renderedLine.slice(textEnd)).toMatch(BACKGROUND_START);
+}
+
describe("ExtensionSelectorComponent", () => {
beforeAll(() => {
initTheme("dark");
@@ -33,6 +42,12 @@ describe("ExtensionSelectorComponent", () => {
expect(output).toContain("Waiting preserves the current kernel state");
expect(waitIndex).toBeGreaterThan(-1);
expect(killIndex).toBe(waitIndex + 1);
+ expectTrailingBackground(
+ lines.find((line) => line.includes("Interrupted IPython cell is still running")),
+ "Interrupted IPython cell is still running",
+ );
+ expectTrailingBackground(lines[waitIndex], "Wait and preserve state");
+ expectTrailingBackground(lines[killIndex], "Kill kernel and restart");
for (const line of lines) {
expect(visibleWidth(line)).toBe(88);
}