Skip to content

Commit 0253b67

Browse files
levochkaaclaude
andcommitted
fix(editors): Warp opens files in its editor and only executables get their folder
Warp has its own editor and opens source and text files there, so treating it as folder-only hid it from file links and file menus. It runs a file with the executable bit, though, so an executable target still opens its folder. Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 2482156 commit 0253b67

4 files changed

Lines changed: 33 additions & 7 deletions

File tree

‎apps/server/src/process/externalLauncher.test.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1959,13 +1959,15 @@ describe("macOS editor discovery through LaunchServices", () => {
19591959
const binDir = path.join(root, "bin");
19601960
const project = path.join(root, "project");
19611961
const script = path.join(project, "deploy.sh");
1962+
const source = path.join(project, "main.ts");
19621963
const weztermApp = path.join(root, "WezTerm.app");
19631964
const wezterm = path.join(weztermApp, "Contents/MacOS/wezterm");
19641965
for (const name of ["osascript", "open", "xed"]) {
19651966
yield* writeExecutable(path.join(binDir, name));
19661967
}
19671968
// Terminals run a script handed to them, so a file must open its folder.
19681969
yield* writeExecutable(script);
1970+
yield* fileSystem.writeFileString(source, "export {};\n");
19691971
yield* writeExecutable(wezterm);
19701972

19711973
const spawned: ChildProcess.StandardCommand[] = [];
@@ -1976,6 +1978,8 @@ describe("macOS editor discovery through LaunchServices", () => {
19761978
yield* launcher.launchEditor({ editor, cwd });
19771979
}
19781980
}
1981+
// Warp edits a file that is not executable.
1982+
yield* launcher.launchEditor({ editor: "warp", cwd: `${source}:3` });
19791983
}).pipe(
19801984
Effect.provide(
19811985
layerTest({
@@ -2005,6 +2009,7 @@ describe("macOS editor discovery through LaunchServices", () => {
20052009
[wezterm, "start", "--cwd", project],
20062010
["xed", project],
20072011
["xed", "--line", "12", script],
2012+
["open", "-b", "dev.warp.Warp-Preview", source],
20082013
],
20092014
);
20102015
}).pipe(Effect.scoped, Effect.provide(NodeServices.layer)),

‎apps/server/src/process/externalLauncher.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -509,11 +509,16 @@ export class ExternalLauncher extends Context.Service<
509509
}
510510
>()("t3/process/externalLauncher") {}
511511

512-
// Terminals run a script they are handed, so folder-only apps get the folder.
513-
const folderOf = Effect.fn("externalLauncher.folderOf")(function* (target: string) {
512+
// Terminals run a script they are handed, so folder-only apps get the folder,
513+
// and apps that only run executable files get the folder of those.
514+
const folderOf = Effect.fn("externalLauncher.folderOf")(function* (
515+
target: string,
516+
only: "files" | "executables",
517+
) {
514518
const fs = yield* FileSystem.FileSystem;
515519
const info = yield* fs.stat(target).pipe(Effect.option);
516520
if (Option.isNone(info) || info.value.type === "Directory") return target;
521+
if (only === "executables" && (info.value.mode & 0o111) === 0) return target;
517522
const path = yield* Path.Path;
518523
return path.dirname(target);
519524
});
@@ -544,7 +549,12 @@ const resolveEditorLaunch = Effect.fn("resolveEditorLaunch")(function* (
544549
onNone: () => input.cwd,
545550
onSome: ({ path }) => path,
546551
});
547-
const folderTarget = "foldersOnly" in editorDef ? yield* folderOf(targetPath) : undefined;
552+
const folderTarget =
553+
"foldersOnly" in editorDef
554+
? yield* folderOf(targetPath, "files")
555+
: "runsExecutables" in editorDef
556+
? yield* folderOf(targetPath, "executables")
557+
: undefined;
548558
if (install?.kind === "mac-app") {
549559
return {
550560
editor: editorDef.id,

‎apps/web/src/editorPreferences.test.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ it("returns the existing failures for a missing environment or editor", async ()
8989

9090
it("opens files in an editor when the favorite is a terminal, without replacing it", async () => {
9191
state.allowed.add(secondary);
92-
state.getPreference.mockReturnValue("warp");
93-
const open = useOpenInPreferredEditor(secondary, ["vscode", "warp"]);
92+
state.getPreference.mockReturnValue("terminal");
93+
const open = useOpenInPreferredEditor(secondary, ["vscode", "terminal"]);
9494
expect(await open("/work/readme.md")).toMatchObject({ _tag: "Success", value: "vscode" });
9595
expect(state.run).toHaveBeenCalledExactlyOnceWith({
9696
environmentId: secondary,
@@ -101,8 +101,16 @@ it("opens files in an editor when the favorite is a terminal, without replacing
101101

102102
it("keeps a folder-only favorite when the caller passes only file editors", async () => {
103103
state.allowed.add(secondary);
104-
state.getPreference.mockReturnValue("warp");
104+
state.getPreference.mockReturnValue("terminal");
105105
const open = useOpenInPreferredEditor(secondary, ["vscode"]);
106106
expect(await open("/work/readme.md")).toMatchObject({ _tag: "Success", value: "vscode" });
107107
expect(state.setPreference).not.toHaveBeenCalled();
108108
});
109+
110+
it("opens files in Warp when it is the favorite, since Warp edits files", async () => {
111+
state.allowed.add(secondary);
112+
state.getPreference.mockReturnValue("warp");
113+
const open = useOpenInPreferredEditor(secondary, ["vscode", "warp"]);
114+
expect(await open("/work/readme.md")).toMatchObject({ _tag: "Success", value: "warp" });
115+
expect(state.setPreference).not.toHaveBeenCalled();
116+
});

‎packages/contracts/src/editor.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ type EditorDefinition = {
2828
* not offer these apps.
2929
*/
3030
readonly foldersOnly?: true;
31+
/** Opens files but runs an executable one, so an executable target opens its folder. */
32+
readonly runsExecutables?: true;
3133
};
3234

3335
export const EDITORS = [
@@ -305,7 +307,8 @@ export const EDITORS = [
305307
commands: null,
306308
launchStyle: "direct-path",
307309
macBundleIds: ["dev.warp.Warp-Stable", "dev.warp.Warp-Preview"],
308-
foldersOnly: true,
310+
// Warp edits files in its own editor, but runs a file with the executable bit.
311+
runsExecutables: true,
309312
},
310313
{
311314
id: "github-desktop",

0 commit comments

Comments
 (0)