fix: add support for fileOpener in config.json

This commit is contained in:
Michael Bolin
2025-05-12 23:04:19 -07:00
parent 05bb5d7d46
commit fa138db8fb
9 changed files with 127 additions and 11 deletions

View File

@@ -7,10 +7,25 @@ import { it, expect } from "vitest";
* We strip ANSI codes, so the output should contain the raw words. */
it("renders basic markdown", () => {
const { lastFrameStripped } = renderTui(
<Markdown>**bold** _italic_</Markdown>,
<Markdown fileOpener={undefined}>**bold** _italic_</Markdown>,
);
const frame = lastFrameStripped();
expect(frame).toContain("bold");
expect(frame).toContain("italic");
});
it("renders markdown with citations", () => {
const { lastFrame } = renderTui(
<Markdown fileOpener={"vscode"} cwd="/foo/bar">
File with TODO: F:src/approvals.tsL40
</Markdown>,
);
const outputWithAnsi = lastFrame();
expect(outputWithAnsi).toBe(
"File with TODO:" +
"\x1B[0m\x1B[34m\x1B]8;;vscode://file/foo/bar/src/approvals.ts:40\x07\x1B[34m\x1B[4msrc/approvals.ts\x1B[24m\x1B[39m\x1B[34m\x1B]8;;\x07\x1B[39m\x1B[0m\n" +
"\n",
);
});

View File

@@ -38,7 +38,10 @@ function assistantMessage(text: string) {
describe("TerminalChatResponseItem", () => {
it("renders a user message", () => {
const { lastFrameStripped } = renderTui(
<TerminalChatResponseItem item={userMessage("Hello world")} />,
<TerminalChatResponseItem
item={userMessage("Hello world")}
fileOpener={undefined}
/>,
);
const frame = lastFrameStripped();
@@ -48,7 +51,10 @@ describe("TerminalChatResponseItem", () => {
it("renders an assistant message", () => {
const { lastFrameStripped } = renderTui(
<TerminalChatResponseItem item={assistantMessage("Sure thing")} />,
<TerminalChatResponseItem
item={assistantMessage("Sure thing")}
fileOpener={undefined}
/>,
);
const frame = lastFrameStripped();