дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 19:25:54 +02:00
feat(remote-dev): Remote Development in the project popup, opened in a new or this window
- The title bar project popup lists Remote Development… next to Open… and Clone Repository…. - Opening a remote project follows "Open project in" (new window / this window / ask) when this window already has a project, and confirms leaving the current one first. - A remote project already open in another window focuses that window. - A new window connects to the host itself and shows the connection progress on its welcome screen. - Recent remote projects get Open in New Window.
Цей коміт міститься в:
1 джерело
45c7f43c02
коміт
0222c84ace
15 files changed
+210
-62
No files matched your search
@@ -0,0 +1,66 @@
|
||||
/** Where a project opens when this window already has one: System Settings › Project › "Open project in". */
|
||||
import { t } from "@/platform/i18n";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { confirmLeaveProject, useProject } from "@/platform/project";
|
||||
import { connectRemote } from "@/platform/remote";
|
||||
import { ask } from "./messages";
|
||||
|
||||
/** "Open project in": `new` | `same` | `ask`. */
|
||||
export function openPolicy(): "ask" | "new" | "same" {
|
||||
const v = useProject.getState().settings?.general?.openProjectIn;
|
||||
return v === "new" || v === "same" ? v : "ask";
|
||||
}
|
||||
|
||||
/**
|
||||
* The window to open project `name` in: this one when it has no project, else
|
||||
* per "Open project in", asking when set to (and remembering "Don't ask again").
|
||||
* `null`: cancelled.
|
||||
*/
|
||||
export async function chooseProjectWindow(name: string): Promise<"new" | "same" | null> {
|
||||
if (!useProject.getState().project) return "same";
|
||||
const mode = openPolicy();
|
||||
if (mode !== "ask") return mode;
|
||||
const r = await ask({
|
||||
title: t("app.window.askTitle"),
|
||||
body: t("app.window.askBody", { name }),
|
||||
buttons: [
|
||||
{ id: "new", label: t("app.window.askNew") },
|
||||
{ id: "same", label: t("app.window.askThis"), primary: true },
|
||||
{ id: "cancel", label: t("common.cancel") },
|
||||
],
|
||||
checkbox: t("app.window.askRemember"),
|
||||
});
|
||||
if (r.button !== "same" && r.button !== "new") return null;
|
||||
if (r.checked) {
|
||||
try {
|
||||
useProject.setState({
|
||||
settings: await call(commands.settingsSet("global", "general.openProjectIn", JSON.stringify(r.button))),
|
||||
});
|
||||
} catch {
|
||||
/* the choice still applies to this open */
|
||||
}
|
||||
}
|
||||
return r.button;
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens folder `path` on the host of SSH configuration `sshConfig`: focuses the
|
||||
* window that has it, else opens it in a new window or (`here`) this one per
|
||||
* "Open project in". `false`: cancelled.
|
||||
*/
|
||||
export async function openRemoteProject(
|
||||
sshConfig: string,
|
||||
path: string,
|
||||
here: () => Promise<unknown> = () => connectRemote(sshConfig, path),
|
||||
): Promise<boolean> {
|
||||
if ((await call(commands.windowOpenRemote(sshConfig, path, false))).kind === "focused") return true;
|
||||
const mode = await chooseProjectWindow(path.replace(/\/+$/, "").split("/").pop() || path);
|
||||
if (!mode) return false;
|
||||
if (mode === "new") {
|
||||
await call(commands.windowOpenRemote(sshConfig, path, true));
|
||||
return true;
|
||||
}
|
||||
if (!(await confirmLeaveProject())) return false;
|
||||
await here();
|
||||
return true;
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача