Skip to content
Merged
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
23 changes: 23 additions & 0 deletions components/MessageView.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,29 @@ test("read paths with an internal URL scheme are not file links", () => {
assert.match(render("src/foo.ts:10"), /activity-file-link/);
});

test("tool-row file links keep Windows drive paths and colon filenames intact", () => {
const cases = [
// Drive-letter colon is not a line suffix: splitting on ":" opened "C".
["C:\\Users\\me\\proj\\src\\file.ts", "C:\\Users\\me\\proj\\src\\file.ts"],
["C:/Users/me/proj/src/file.ts:42", "C:/Users/me/proj/src/file.ts"],
["src/my:file.txt", "src/my:file.txt"],
];
for (const [path, expected] of cases) {
const openedFiles = [];
const { container } = render(React.createElement(MessageView, {
onOpenFile(file) { openedFiles.push(file); },
message: {
role: "assistant",
content: [{ type: "toolCall", toolCallId: "call-1", toolName: "read", input: { path } }],
},
}));
// File links render as a clickable span (role="button"), unlike web URLs.
fireEvent.click(container.querySelector(".activity-file-link"));
assert.deepEqual(openedFiles, [expected], path);
cleanup();
}
});

test("read paths with a web URL open the fetched page in a new tab without toggling the row", () => {
const opened = [];
const originalOpen = window.open;
Expand Down
5 changes: 4 additions & 1 deletion components/MessageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,10 @@ const ToolCallBlock = memo(function ToolCallBlock({
// `history://`, `proc://`, `local://`, ... are resolved by omp, not files the viewer can open.
const hasUrlScheme = rawFilePath !== null && /^[a-z][a-z0-9+.-]*:\/\//i.test(rawFilePath);
const webUrl = hasUrlScheme && /^https?:\/\//i.test(rawFilePath) ? readTargetWebUrl(rawFilePath) : null;
const cleanFilePath = rawFilePath && !hasUrlScheme ? rawFilePath.split(":")[0] : null;
// Strip only a trailing :<line> suffix. Splitting on the first ":" broke
// every Windows absolute path (C:\... -> "C") and POSIX filenames
// containing a colon; a drive-letter colon is never a line suffix.
const cleanFilePath = rawFilePath && !hasUrlScheme ? rawFilePath.replace(/:\d+$/, "") : null;

return (
<div className="activity-row" data-activity-operation="true">
Expand Down
Loading