Files
oh-my-pi/packages/coding-agent/test/tools/edit-renderer.test.ts
T
can1357 e3ca350f95 fix(coding-agent): added partial JSON path extraction for streamed edit calls
- Added helper utilities in the edit renderer to parse partial JSON fragments and extract the `path` field.
- Used the extracted path as a fallback when resolving the edit target file, enabling partial streamed edit calls to show the path.
- Built and stored the render context before call rendering, and added a test covering partial JSON edit path rendering.
2026-04-24 19:38:38 +02:00

28 lines
1023 B
TypeScript

import { describe, expect, it } from "bun:test";
import { editToolRenderer } from "@oh-my-pi/pi-coding-agent/edit/renderer";
import * as themeModule from "@oh-my-pi/pi-coding-agent/modes/theme/theme";
async function getUiTheme() {
await themeModule.initTheme(false, undefined, undefined, "dark", "light");
const theme = await themeModule.getThemeByName("dark");
expect(theme).toBeDefined();
return theme!;
}
describe("editToolRenderer", () => {
it("shows the target path from partial JSON while edit args stream", async () => {
const uiTheme = await getUiTheme();
const component = editToolRenderer.renderCall(
{
edits: [{}],
__partialJson: '{"edits":[{"path":"packages/coding-agent/src/edit/renderer.ts","old_text":"before',
},
{ expanded: false, isPartial: true, spinnerFrame: 0, renderContext: { editMode: "replace" } },
uiTheme,
);
const rendered = Bun.stripANSI(component.render(160).join("\n"));
expect(rendered).toContain("packages/coding-agent/src/edit/renderer.ts");
});
});