Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

Use Cursor --goto for file targets with line and column

Julius Marminge24c842936bc2
diff --git a/apps/server/src/open.test.ts b/apps/server/src/open.test.ts
index 617ed5535..2ab65b90e 100644
--- a/apps/server/src/open.test.ts
+++ b/apps/server/src/open.test.ts
@@ -18,6 +18,28 @@ describe("resolveEditorLaunch", () => {
}),
);
+ it.effect("uses --goto when cursor target includes line/column suffixes", () =>
+ Effect.gen(function* () {
+ const lineOnly = yield* resolveEditorLaunch(
+ { cwd: "/tmp/workspace/AGENTS.md:48", editor: "cursor" },
+ "darwin",
+ );
+ assert.deepEqual(lineOnly, {
+ command: "cursor",
+ args: ["--goto", "/tmp/workspace/AGENTS.md:48"],
+ });
+
+ const lineAndColumn = yield* resolveEditorLaunch(
+ { cwd: "/tmp/workspace/src/open.ts:71:5", editor: "cursor" },
+ "darwin",
+ );
+ assert.deepEqual(lineAndColumn, {
+ command: "cursor",
+ args: ["--goto", "/tmp/workspace/src/open.ts:71:5"],
+ });
+ }),
+ );
+
it.effect("maps file-manager editor to OS open commands", () =>
Effect.gen(function* () {
const launch1 = yield* resolveEditorLaunch(
diff --git a/apps/server/src/open.ts b/apps/server/src/open.ts
index 7e318b042..a3ce1e87a 100644
--- a/apps/server/src/open.ts
+++ b/apps/server/src/open.ts
@@ -30,6 +30,12 @@ interface EditorLaunch {
readonly args: ReadonlyArray<string>;
}
+const LINE_COLUMN_SUFFIX_PATTERN = /:\d+(?::\d+)?$/;
+
+function shouldUseGotoFlag(editorId: EditorId, target: string): boolean {
+ return editorId === "cursor" && LINE_COLUMN_SUFFIX_PATTERN.test(target);
+}
+
/**
* OpenShape - Service API for browser and editor launch actions.
*/
@@ -66,7 +72,9 @@ export const resolveEditorLaunch = Effect.fnUntraced(function* (
}
if (editorDef.command) {
- return { command: editorDef.command, args: [input.cwd] };
+ return shouldUseGotoFlag(editorDef.id, input.cwd)
+ ? { command: editorDef.command, args: ["--goto", input.cwd] }
+ : { command: editorDef.command, args: [input.cwd] };
}
if (editorDef.id !== "file-manager") {