Файли
openidea/src/features/vcs/openWorktree.ts
T
leenтаleen2175 7850429174 fix(vcs): open existing worktrees over SSH (#4465)
Opening a linked worktree from an SSH or WSL project treated the remote directory as a local path. The Worktrees toolbar, row double-click and the checkout prompt's Open now go through openWorktree, which reuses the session's remote target and opens a remote window; local projects are unchanged. Verified with vcs and remote-dev vitest and typecheck on macOS (local path); the SSH flow was verified by the author in the native Linux app.

Co-authored-by: leen2175 <[email protected]>
2026-11-20 10:17:09 +08:00

30 рядки
1.0 KiB
TypeScript

import { executeAction } from "@/platform/actions";
import { t } from "@/platform/i18n";
import { call, commands, isCancelled } from "@/platform/ipc";
import { useRemote } from "@/platform/remote";
import { notifications } from "@/workbench/contributions";
/**
* Opens worktree `path` in a new window. In an SSH or WSL session the path is on that
* machine, so the window connects there instead of opening it as a local folder.
*/
export async function openWorktree(path: string): Promise<void> {
const target = useRemote.getState().session?.target;
if (target?.kind !== "ssh" && target?.kind !== "wsl") {
await executeAction("file.openProjectPath", path);
return;
}
try {
await call(commands.windowOpenRemote(target, path, true));
} catch (error) {
if (isCancelled(error)) return;
notifications().notify({
level: "error",
group: "vcs",
userInitiated: true,
title: t("app.window.openFailed", { name: path }),
body: error instanceof Error ? error.message : String(error),
});
}
}