Skip to content

Commit 6be0e0a

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 9bc2efc commit 6be0e0a

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
@@ -921,13 +921,15 @@ describe("macOS editor discovery through LaunchServices", () => {
921921
const binDir = path.join(root, "bin");
922922
const project = path.join(root, "project");
923923
const script = path.join(project, "deploy.sh");
924+
const source = path.join(project, "main.ts");
924925
const weztermApp = path.join(root, "WezTerm.app");
925926
const wezterm = path.join(weztermApp, "Contents/MacOS/wezterm");
926927
for (const name of ["osascript", "open", "xed"]) {
927928
yield* writeExecutable(path.join(binDir, name));
928929
}
929930
// Terminals run a script handed to them, so a file must open its folder.
930931
yield* writeExecutable(script);
932+
yield* fileSystem.writeFileString(source, "export {};\n");
931933
yield* writeExecutable(wezterm);
932934

933935
const spawned: ChildProcess.StandardCommand[] = [];
@@ -938,6 +940,8 @@ describe("macOS editor discovery through LaunchServices", () => {
938940
yield* launcher.launchEditor({ editor, cwd });
939941
}
940942
}
943+
// Warp edits a file that is not executable.
944+
yield* launcher.launchEditor({ editor: "warp", cwd: `${source}:3` });
941945
}).pipe(
942946
Effect.provide(
943947
layerTest({
@@ -967,6 +971,7 @@ describe("macOS editor discovery through LaunchServices", () => {
967971
[wezterm, "start", "--cwd", project],
968972
["xed", project],
969973
["xed", "--line", "12", script],
974+
["open", "-b", "dev.warp.Warp-Preview", source],
970975
],
971976
);
972977
}).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
@@ -508,11 +508,16 @@ export class ExternalLauncher extends Context.Service<
508508
}
509509
>()("t3/process/externalLauncher") {}
510510

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

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ it("checks revocation and regrant when a retained editor callback is invoked", a
7070

7171
it("opens files in an editor when the favorite is a terminal, without replacing it", async () => {
7272
state.allowed.add(secondary);
73-
state.getPreference.mockReturnValue("warp");
74-
const open = useOpenInPreferredEditor(secondary, ["vscode", "warp"]);
73+
state.getPreference.mockReturnValue("terminal");
74+
const open = useOpenInPreferredEditor(secondary, ["vscode", "terminal"]);
7575
expect(await open("/work/readme.md")).toMatchObject({ _tag: "Success", value: "vscode" });
7676
expect(state.run).toHaveBeenCalledExactlyOnceWith({
7777
environmentId: secondary,
@@ -82,8 +82,16 @@ it("opens files in an editor when the favorite is a terminal, without replacing
8282

8383
it("keeps a folder-only favorite when the caller passes only file editors", async () => {
8484
state.allowed.add(secondary);
85-
state.getPreference.mockReturnValue("warp");
85+
state.getPreference.mockReturnValue("terminal");
8686
const open = useOpenInPreferredEditor(secondary, ["vscode"]);
8787
expect(await open("/work/readme.md")).toMatchObject({ _tag: "Success", value: "vscode" });
8888
expect(state.setPreference).not.toHaveBeenCalled();
8989
});
90+
91+
it("opens files in Warp when it is the favorite, since Warp edits files", async () => {
92+
state.allowed.add(secondary);
93+
state.getPreference.mockReturnValue("warp");
94+
const open = useOpenInPreferredEditor(secondary, ["vscode", "warp"]);
95+
expect(await open("/work/readme.md")).toMatchObject({ _tag: "Success", value: "warp" });
96+
expect(state.setPreference).not.toHaveBeenCalled();
97+
});

‎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)