Files
oh-my-pi/packages/tui/test/loader.test.ts
T
can1357 c3d0bd9773 feat(coding-agent): deferrable tools, LIFO pending-action stack, custom tool pushPendingAction
- Introduce `deferrable?: boolean` on AgentTool, CustomTool, and ToolDefinition.
  AstEditTool sets it to true; resolve is now injected only when at least one
  active tool is deferrable (previously unconditional).

- Replace single-slot PendingActionStore (set/get/clear) with a LIFO stack
  (push/peek/pop/clear). Multiple deferrable tools can stage independent
  preview actions; resolve always consumes the topmost one first.

- Wire pendingActionStore through discoverAndLoadCustomTools / loadCustomTools /
  CustomToolLoader so custom tools can call pushPendingAction(action) to
  register a resolve-compatible pending action with label, apply callback,
  optional details, and optional sourceToolName.

- Export HIDDEN_TOOLS and ResolveTool from the SDK for manual tool composition.

- Add CustomToolPendingAction type and pushPendingAction to CustomToolAPI.

- Update createAgentSession to re-inject or remove resolve after the deferrable
  audit, consistent with createTools behavior.

- Add LIFO resolve test, update existing tests (set -> push, get -> peek).

- Add docs/resolve-tool-runtime.md covering PendingActionStore internals,
  built-in producer example, and custom tool usage guide.
2026-03-01 02:57:31 +01:00

32 lines
759 B
TypeScript

import { describe, expect, it } from "bun:test";
import { TUI } from "@oh-my-pi/pi-tui";
import { Loader } from "@oh-my-pi/pi-tui/components/loader";
import { visibleWidth } from "@oh-my-pi/pi-tui/utils";
import { VirtualTerminal } from "./virtual-terminal";
describe("Loader component", () => {
it("clamps rendered lines to terminal width", async () => {
const term = new VirtualTerminal(1, 4);
const tui = new TUI(term);
const loader = new Loader(
tui,
text => text,
text => text,
"Checking",
["⠸"],
);
tui.addChild(loader);
tui.start();
await Bun.sleep(0);
await term.flush();
for (const line of term.getViewport()) {
expect(visibleWidth(line)).toBeLessThanOrEqual(1);
}
loader.stop();
tui.stop();
});
});