Files
paseo/packages/app/src/agent-stream/inline-path-open.test.ts
T
Moy 09b3dcf9a1 fix(app): open folders from inline path links in the file explorer
Clicking a folder path in an assistant message opened a file tab that
failed with "Requested path is not a file". Extension-less
workspace-relative paths without a line number are now probed with a
directory listing before opening: directories open the Files explorer
navigated to that folder, everything else opens as a file like before.
Lexical directories (trailing slash, workspace root) now navigate the
explorer to the folder instead of only preloading its listing.
2026-10-17 08:23:28 +02:00

53 lines
1.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { planInlinePathOpen } from "./inline-path-open";
describe("planInlinePathOpen", () => {
it("opens paths with a line number directly as files", () => {
expect(
planInlinePathOpen({
file: "src/moys-asr-workflow",
lineStart: 12,
workspaceRoot: "/repo",
}),
).toEqual({ kind: "file" });
});
it("opens paths with a file extension directly as files", () => {
expect(
planInlinePathOpen({ file: "src/components/message.tsx", workspaceRoot: "/repo" }),
).toEqual({ kind: "file" });
expect(planInlinePathOpen({ file: "README.md", workspaceRoot: "/repo" })).toEqual({
kind: "file",
});
});
it("treats a missing file segment as a directory", () => {
expect(planInlinePathOpen({ file: undefined, workspaceRoot: "/repo" })).toEqual({
kind: "directory",
directoryPath: ".",
});
});
it("probes extension-less workspace-relative paths", () => {
expect(
planInlinePathOpen({ file: "packages/app/moys-asr-workflow", workspaceRoot: "/repo" }),
).toEqual({ kind: "probe", directoryPath: "packages/app/moys-asr-workflow" });
expect(planInlinePathOpen({ file: "Makefile", workspaceRoot: "/repo" })).toEqual({
kind: "probe",
directoryPath: "Makefile",
});
});
it("opens extension-less absolute paths directly as files", () => {
expect(planInlinePathOpen({ file: "C:/Tools/some-folder", workspaceRoot: "C:/repo" })).toEqual({
kind: "file",
});
});
it("opens extension-less paths directly as files when there is no workspace root", () => {
expect(planInlinePathOpen({ file: "some-folder", workspaceRoot: " " })).toEqual({
kind: "file",
});
});
});