chore(vendor): import pi 1.3.0

Imported as a linear vendor commit so forge rebases do not replay the upstream root tree.

git-subtree-dir: third_party/pi

git-subtree-split: 71023aec1546d6d677a65669c5665c0927ce0dd0
This commit is contained in:
2026-10-15 17:58:48 -04:00
parent 719370c8f7
commit 6081e3e325
1743 changed files with 205460 additions and 131705 deletions

View File

@@ -59,6 +59,29 @@ class InputOverlay extends Container {
}
}
/** A settings submenu that routes keys to its nested list, like the coding agent's theme submenu. */
class SubmenuHost extends Container {
readonly list = new SelectList(
[
{ value: "first", label: "First" },
{ value: "second", label: "Second" },
],
5,
selectTheme,
);
constructor(done: (value?: string) => void) {
super();
this.list.onSelect = (item) => done(item.value);
this.list.onCancel = () => done();
this.addChild(this.list);
}
handleInput(data: string): void {
this.list.handleInput(data);
}
}
describe("mouse-aware components", () => {
it("positions a single-line input cursor on press", () => {
const input = new Input();
@@ -202,6 +225,45 @@ describe("mouse-aware components", () => {
tui.stop();
});
it("keeps a settings list focused when a click in its submenu closes the submenu", async () => {
const terminal = new VirtualTerminal(30, 6);
const tui = new TuiAltScreen(terminal);
const changes: Array<{ id: string; value: string }> = [];
const list = new SettingsList(
[
{ id: "theme", label: "Theme", currentValue: "first", submenu: (_value, done) => new SubmenuHost(done) },
{ id: "other", label: "Other", currentValue: "off", values: ["off", "on"] },
],
5,
settingsTheme,
(id, value) => changes.push({ id, value }),
() => {},
);
tui.addChild(list);
tui.setFocus(list);
tui.start();
await terminal.waitForRender();
terminal.sendInput("\r");
await terminal.waitForRender();
// Press and release on the submenu's second row selects it and closes the submenu.
terminal.sendInput("\x1b[<0;3;2M");
terminal.sendInput("\x1b[<0;3;2m");
await terminal.waitForRender();
assert.deepStrictEqual(changes, [{ id: "theme", value: "second" }]);
assert.strictEqual(tui.getFocusedComponent(), list);
// Keys reach the visible list again instead of the closed submenu.
terminal.sendInput("\x1b[B");
terminal.sendInput("\r");
await terminal.waitForRender();
assert.deepStrictEqual(changes, [
{ id: "theme", value: "second" },
{ id: "other", value: "on" },
]);
tui.stop();
});
it("positions and focuses the multiline editor through alternate-screen dispatch", async () => {
const terminal = new VirtualTerminal(20, 6);
const tui = new TuiAltScreen(terminal);