fix(coding-agent): wrap tree help on narrow terminals

closes #5055
This commit is contained in:
Armin Ronacher
2026-06-15 01:25:27 +02:00
parent 24053eab66
commit bb959aae01
3 changed files with 123 additions and 22 deletions

View File

@@ -1,4 +1,5 @@
import { setKeybindings } from "@earendil-works/pi-tui";
import { stripVTControlCharacters } from "node:util";
import { setKeybindings, visibleWidth } from "@earendil-works/pi-tui";
import { beforeAll, beforeEach, describe, expect, test } from "vitest";
import { KeybindingsManager } from "../src/core/keybindings.ts";
import type {
@@ -248,6 +249,29 @@ describe("TreeSelectorComponent", () => {
});
});
describe("help", () => {
test("renders semantic help rows without truncating narrow terminal controls", () => {
const entries = [userMessage("user-1", null, "hello"), assistantMessage("asst-1", "user-1", "hi")];
const tree = buildTree(entries);
const selector = new TreeSelectorComponent(
tree,
"asst-1",
24,
() => {},
() => {},
);
const plainLines = selector.render(30).map(stripVTControlCharacters);
const plain = plainLines.join("\n");
expect(plain).toContain("branch");
expect(plain).toContain("filters");
expect(plain).toContain("cycle");
expect(plain).toContain("label time");
expect(plain).not.toContain("...");
expect(plainLines.every((line) => visibleWidth(line) <= 30)).toBe(true);
});
});
describe("label timestamps", () => {
test("toggles label timestamps for labeled nodes", () => {
const entries = [userMessage("user-1", null, "hello"), assistantMessage("asst-1", "user-1", "hi")];