Files
oh-my-pi/packages/coding-agent/test/interactive-mode-status.test.ts
T
can1357 cb5bbbf382 refactor(coding-agent): flattened directory structure, eliminated core/ folder
- Eliminated core/ directory (252 files, 23 subdirs → distributed)
- Reduced max nesting from 9 levels to 5 levels
- Promoted tool subdirs to top level: exa/, lsp/, patch/, task/, web/
- Merged web-scrapers/ + web-search/ into web/{scrapers,search}/
- Flattened modes/interactive/ to modes/
- Split execution/ into: ipy/ (python), exec/ (bash), ssh/
- Renamed ipy/python-*.ts to ipy/*.ts (executor, kernel, etc.)
- Flattened cursor/exec-bridge.ts to cursor.ts
- Created logical groupings: config/, session/, extensibility/, export/
- Updated all imports across 500+ files
2026-01-23 12:24:47 +01:00

63 lines
2.4 KiB
TypeScript

import { beforeAll, describe, expect, test, vi } from "bun:test";
import { Container } from "@oh-my-pi/pi-tui";
import { InteractiveMode } from "$c/modes/interactive-mode";
import { initTheme } from "$c/modes/theme/theme";
import { UiHelpers } from "$c/modes/utils/ui-helpers";
function renderLastLine(container: Container, width = 120): string {
const last = container.children[container.children.length - 1];
if (!last) return "";
return last.render(width).join("\n");
}
describe("InteractiveMode.showStatus", () => {
beforeAll(() => {
// showStatus uses the global theme instance
initTheme("dark");
});
test("coalesces immediately-sequential status messages", () => {
const fakeThis: any = {
chatContainer: new Container(),
ui: { requestRender: vi.fn() },
isBackgrounded: false,
lastStatusSpacer: undefined,
lastStatusText: undefined,
};
fakeThis.uiHelpers = new UiHelpers(fakeThis);
(InteractiveMode as any).prototype.showStatus.call(fakeThis, "STATUS_ONE");
expect(fakeThis.chatContainer.children).toHaveLength(2);
expect(renderLastLine(fakeThis.chatContainer)).toContain("STATUS_ONE");
(InteractiveMode as any).prototype.showStatus.call(fakeThis, "STATUS_TWO");
// second status updates the previous line instead of appending
expect(fakeThis.chatContainer.children).toHaveLength(2);
expect(renderLastLine(fakeThis.chatContainer)).toContain("STATUS_TWO");
expect(renderLastLine(fakeThis.chatContainer)).not.toContain("STATUS_ONE");
});
test("appends a new status line if something else was added in between", () => {
const fakeThis: any = {
chatContainer: new Container(),
ui: { requestRender: vi.fn() },
isBackgrounded: false,
lastStatusSpacer: undefined,
lastStatusText: undefined,
};
fakeThis.uiHelpers = new UiHelpers(fakeThis);
(InteractiveMode as any).prototype.showStatus.call(fakeThis, "STATUS_ONE");
expect(fakeThis.chatContainer.children).toHaveLength(2);
// Something else gets added to the chat in between status updates
fakeThis.chatContainer.addChild({ render: () => ["OTHER"], invalidate: () => {} });
expect(fakeThis.chatContainer.children).toHaveLength(3);
(InteractiveMode as any).prototype.showStatus.call(fakeThis, "STATUS_TWO");
// adds spacer + text
expect(fakeThis.chatContainer.children).toHaveLength(5);
expect(renderLastLine(fakeThis.chatContainer)).toContain("STATUS_TWO");
});
});