Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
228 changes: 227 additions & 1 deletion apps/server/src/open.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,105 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
command: "idea",
args: ["/tmp/workspace"],
});

const aquaLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "aqua" },
"darwin",
);
assert.deepEqual(aquaLaunch, {
command: "aqua",
args: ["/tmp/workspace"],
});

const clionLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "clion" },
"darwin",
);
assert.deepEqual(clionLaunch, {
command: "clion",
args: ["/tmp/workspace"],
});

const datagripLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "datagrip" },
"darwin",
);
assert.deepEqual(datagripLaunch, {
command: "datagrip",
args: ["/tmp/workspace"],
});

const dataspellLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "dataspell" },
"darwin",
);
assert.deepEqual(dataspellLaunch, {
command: "dataspell",
args: ["/tmp/workspace"],
});

const golandLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "goland" },
"darwin",
);
assert.deepEqual(golandLaunch, {
command: "goland",
args: ["/tmp/workspace"],
});

const phpstormLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "phpstorm" },
"darwin",
);
assert.deepEqual(phpstormLaunch, {
command: "phpstorm",
args: ["/tmp/workspace"],
});

const pycharmLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "pycharm" },
"darwin",
);
assert.deepEqual(pycharmLaunch, {
command: "pycharm",
args: ["/tmp/workspace"],
});

const riderLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "rider" },
"darwin",
);
assert.deepEqual(riderLaunch, {
command: "rider",
args: ["/tmp/workspace"],
});

const rubymineLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "rubymine" },
"darwin",
);
assert.deepEqual(rubymineLaunch, {
command: "rubymine",
args: ["/tmp/workspace"],
});

const rustroverLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "rustrover" },
"darwin",
);
assert.deepEqual(rustroverLaunch, {
command: "rustrover",
args: ["/tmp/workspace"],
});

const webstormLaunch = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace", editor: "webstorm" },
"darwin",
);
assert.deepEqual(webstormLaunch, {
command: "webstorm",
args: ["/tmp/workspace"],
});
}),
);

Expand Down Expand Up @@ -207,6 +306,105 @@ it.layer(NodeServices.layer)("resolveEditorLaunch", (it) => {
command: "idea",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const aquaLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "aqua" },
"darwin",
);
assert.deepEqual(aquaLineAndColumn, {
command: "aqua",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const clionLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "clion" },
"darwin",
);
assert.deepEqual(clionLineAndColumn, {
command: "clion",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const datagripLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "datagrip" },
"darwin",
);
assert.deepEqual(datagripLineAndColumn, {
command: "datagrip",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const dataspellLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "dataspell" },
"darwin",
);
assert.deepEqual(dataspellLineAndColumn, {
command: "dataspell",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const golandLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "goland" },
"darwin",
);
assert.deepEqual(golandLineAndColumn, {
command: "goland",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const phpstormLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "phpstorm" },
"darwin",
);
assert.deepEqual(phpstormLineAndColumn, {
command: "phpstorm",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const pycharmLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "pycharm" },
"darwin",
);
assert.deepEqual(pycharmLineAndColumn, {
command: "pycharm",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const riderLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "rider" },
"darwin",
);
assert.deepEqual(riderLineAndColumn, {
command: "rider",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const rubymineLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "rubymine" },
"darwin",
);
assert.deepEqual(rubymineLineAndColumn, {
command: "rubymine",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const rustroverLineAndColumn = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/src/open.ts:71:5", editor: "rustrover" },
"darwin",
);
assert.deepEqual(rustroverLineAndColumn, {
command: "rustrover",
args: ["--line", "71", "--column", "5", "/tmp/workspace/src/open.ts"],
});

const webstormLineOnly = yield* resolveEditorLaunch(
{ cwd: "/tmp/workspace/AGENTS.md:48", editor: "webstorm" },
"darwin",
);
assert.deepEqual(webstormLineOnly, {
command: "webstorm",
args: ["--line", "48", "/tmp/workspace/AGENTS.md"],
});
}),
);

Expand Down Expand Up @@ -377,12 +575,40 @@ it.layer(NodeServices.layer)("resolveAvailableEditors", (it) => {
yield* fs.writeFileString(path.join(dir, "kiro.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "code-insiders.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "codium.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "aqua.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "clion.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "datagrip.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "dataspell.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "goland.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "phpstorm.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "pycharm.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "rider.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "rubymine.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "rustrover.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "webstorm.CMD"), "@echo off\r\n");
yield* fs.writeFileString(path.join(dir, "explorer.CMD"), "MZ");
const editors = resolveAvailableEditors("win32", {
PATH: dir,
PATHEXT: ".COM;.EXE;.BAT;.CMD",
});
assert.deepEqual(editors, ["trae", "kiro", "vscode-insiders", "vscodium", "file-manager"]);
assert.deepEqual(editors, [
"trae",
"kiro",
"vscode-insiders",
"vscodium",
"aqua",
"clion",
"datagrip",
"dataspell",
"goland",
"phpstorm",
"pycharm",
"rider",
"rubymine",
"rustrover",
"webstorm",
"file-manager",
]);
}),
);

Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/ChatMarkdown.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe("ChatMarkdown", () => {
try {
const link = page.getByRole("link", { name: "PermissionRule.ts · L1" });
await expect.element(link).toBeInTheDocument();
await expect.element(link).toHaveAttribute("href", `${filePath}#L1`);
await expect.element(link).toHaveAttribute("href", `${filePath}:1`);

await link.click();

Expand All @@ -87,7 +87,7 @@ describe("ChatMarkdown", () => {
try {
const link = page.getByRole("link", { name: "PermissionRule.ts · L1:C7" });
await expect.element(link).toBeInTheDocument();
await expect.element(link).toHaveAttribute("href", `${filePath}#L1C7`);
await expect.element(link).toHaveAttribute("href", `${filePath}:1:7`);

await link.click();

Expand Down
11 changes: 8 additions & 3 deletions apps/web/src/components/ChatMarkdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ import { resolveDiffThemeName, type DiffThemeName } from "../lib/diffRendering";
import { fnv1a32 } from "../lib/diffRendering";
import { LRUCache } from "../lib/lruCache";
import { useTheme } from "../hooks/useTheme";
import { resolveMarkdownFileLinkMeta, rewriteMarkdownFileUriHref } from "../markdown-links";
import {
normalizeMarkdownLinkDestination,
resolveMarkdownFileLinkMeta,
rewriteMarkdownFileUriHref,
} from "../markdown-links";
import { readLocalApi } from "../localApi";
import { cn } from "../lib/utils";

Expand Down Expand Up @@ -328,7 +332,8 @@ function extractMarkdownLinkHrefs(text: string): string[] {
}

function normalizeMarkdownLinkHrefKey(href: string): string {
return rewriteMarkdownFileUriHref(href.trim()) ?? href.trim();
const normalizedHref = normalizeMarkdownLinkDestination(href);
return rewriteMarkdownFileUriHref(normalizedHref) ?? normalizedHref;
}

const MarkdownFileLink = memo(function MarkdownFileLink({
Expand Down Expand Up @@ -523,7 +528,7 @@ function ChatMarkdown({ text, cwd, isStreaming = false }: ChatMarkdownProps) {

return (
<MarkdownFileLink
href={href ?? fileLinkMeta.targetPath}
href={fileLinkMeta.targetPath}
targetPath={fileLinkMeta.targetPath}
displayPath={fileLinkMeta.displayPath}
filePath={fileLinkMeta.filePath}
Expand Down
Loading
Loading