Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(chat): thread path:line through the plugin file-manager open

ZxlDragonDoctor1676e721e5fc
diff --git a/apps/desktop/src/hooks/use-preview-target.ts b/apps/desktop/src/hooks/use-preview-target.ts
index 0f7a9f858..81a8c4338 100644
--- a/apps/desktop/src/hooks/use-preview-target.ts
+++ b/apps/desktop/src/hooks/use-preview-target.ts
@@ -175,7 +175,9 @@ export function useOpenChatFileRef() {
return;
}
if (resolved.inProject && fileViewAvailable) {
- openTab(fileManagerPluginTab(resolved.path));
+ // Thread path:line into the plugin tab so the bundled file view can
+ // scroll to the line (#681 / #1149 review). Host fallback uses openFile.
+ openTab(fileManagerPluginTab(resolved.path, { line, column }));
return;
}
openFile(resolved.path, mimeType, { line, column });
diff --git a/apps/desktop/src/lib/work-panel-tabs.ts b/apps/desktop/src/lib/work-panel-tabs.ts
index 37b6200f0..3fc3e240a 100644
--- a/apps/desktop/src/lib/work-panel-tabs.ts
+++ b/apps/desktop/src/lib/work-panel-tabs.ts
@@ -154,14 +154,19 @@ export const FILE_MANAGER_PLUGIN_TAB = {
viewId: "manager",
} as const;
-/** The file view, asked to show one file. */
-export function fileManagerPluginTab(location: string): WorkPanelTab {
+/** The file view, asked to show one file (optional chat `path:line` position). */
+export function fileManagerPluginTab(
+ location: string,
+ position?: { line?: number; column?: number },
+): WorkPanelTab {
return {
...pluginWorkPanelTab(
FILE_MANAGER_PLUGIN_TAB.pluginId,
FILE_MANAGER_PLUGIN_TAB.viewId,
),
location,
+ ...(position?.line != null ? { line: position.line } : {}),
+ ...(position?.column != null ? { column: position.column } : {}),
};
}
diff --git a/apps/desktop/test/chat-links.test.mjs b/apps/desktop/test/chat-links.test.mjs
index 58f2be7b9..ad6ece572 100644
--- a/apps/desktop/test/chat-links.test.mjs
+++ b/apps/desktop/test/chat-links.test.mjs
@@ -108,6 +108,7 @@ test("resolvePreviewTarget classifies urls and workspace files", () => {
assert.deepEqual(resolvePreviewTarget("src/a.ts:10", ROOT), {
kind: "file",
path: "src/a.ts",
+ line: 10,
});
assert.deepEqual(resolvePreviewTarget("./README.md", ROOT, "docs"), {
kind: "file",
diff --git a/apps/desktop/test/transcript-file-chips.test.mjs b/apps/desktop/test/transcript-file-chips.test.mjs
index cd37a0945..75d27bd5f 100644
--- a/apps/desktop/test/transcript-file-chips.test.mjs
+++ b/apps/desktop/test/transcript-file-chips.test.mjs
@@ -25,7 +25,7 @@ test("sent user-message file refs render as composer-like chips", () => {
assert.match(transcript, /composer-chip-name/);
assert.match(styles, /\.chat-file-chip[\s\S]*?appearance: none/);
assert.match(transcript, /mimeType=\{attachment\.mimeType\}/);
- assert.match(transcript, /onOpen\(path, undefined, mimeType\)/);
+ assert.match(transcript, /onOpen\(path, undefined, mimeType, \{ line, column \}\)/);
});
test("a file chip is routed by where the reference resolved, never optimistically", () => {
@@ -47,7 +47,7 @@ test("a file chip is routed by where the reference resolved, never optimisticall
// A project file prefers the bundled file view; without that plugin the
// host file tab is the same surface this hook used before.
assert.match(hook, /FILE_MANAGER_PLUGIN_TAB/);
- assert.match(hook, /fileManagerPluginTab\(resolved\.path\)/);
+ assert.match(hook, /fileManagerPluginTab\(resolved\.path, \{ line, column \}\)/);
// Session scratch and attachment files live outside the plugin's project
// roots, so completion hands them back as an absolute path.
assert.match(hook, /inProject: false/);