Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 468118df57 fix(projects): offer New Tab when opening a remote project or from a remote window
The Open Project prompt gated Attach and New Tab on one flag that required a
local project in a local window, so opening an SSH/WSL project, or any
project from a remote window, offered only New Window and This Window, and
"Open project in: tab" fell back to a new window. Attach still needs a local
project in a local window, but a project tab is a window of its own joined to
this window's group, so it now applies whenever this window has a project:
a remote project opens in a new window that joins the group.

Fixes #6923
2026-11-30 18:36:21 +08:00
7 змінених файлів з 48 додано та 21 видалено

No files matched your search

+1
Переглянути файл
@@ -3740,6 +3740,7 @@
"Saving a Dart file of a running Flutter debug session reloads the app, unless the file has errors.": "Saving a Dart file of a running Flutter debug session reloads the app, unless the file has errors.",
"Hot reload on save failed: {0}": "Hot reload on save failed: {0}",
"Projects can be opened in a new window, replace the current project, be attached to the already opened projects, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "Projects can be opened in a new window, replace the current project, be attached to the already opened projects, or open as a new tab of this window.\nHow would you like to open \"{name}\"?",
"Projects can be opened in a new window, replace the current project, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "Projects can be opened in a new window, replace the current project, or open as a new tab of this window.\nHow would you like to open \"{name}\"?",
"New Tab": "New Tab",
"New tab in current window": "New tab in current window",
"Show Only Widgets": "Show Only Widgets",
+1
Переглянути файл
@@ -9762,6 +9762,7 @@
"Saving a Dart file of a running Flutter debug session reloads the app, unless the file has errors.": "Сохранение файла Dart во время запущенной сессии отладки Flutter перезагружает приложение, если в файле нет ошибок.",
"Hot reload on save failed: {0}": "Ошибка горячей перезагрузки при сохранении: {0}",
"Projects can be opened in a new window, replace the current project, be attached to the already opened projects, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "Проекты можно открывать в новом окне, вместо текущего проекта, присоединять к уже открытым проектам или открывать как новую вкладку в этом окне.\nКак открыть «{name}»?",
"Projects can be opened in a new window, replace the current project, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "Проекты можно открывать в новом окне, вместо текущего проекта или как новую вкладку в этом окне.\nКак открыть «{name}»?",
"Show Only Widgets": "Показывать только виджеты",
"Update failed": "Не удалось выполнить обновление",
"Updating branches": "Обновление веток",
+1
Переглянути файл
@@ -2668,6 +2668,7 @@
"Saving a Dart file of a running Flutter debug session reloads the app, unless the file has errors.": "Çalışan Flutter hata ayıklama oturumunda Dart dosyası kaydedildiğinde, dosyada hata yoksa uygulama yeniden yüklenir.",
"Hot reload on save failed: {0}": "Kaydetmede sıcak yeniden yükleme başarısız: {0}",
"Projects can be opened in a new window, replace the current project, be attached to the already opened projects, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "Projeler yeni pencerede açılabilir, geçerli projenin yerini alabilir, açık projelere bağlanabilir veya bu pencerede yeni sekmede açılabilir.\n\"{name}\" nasıl açılsın?",
"Projects can be opened in a new window, replace the current project, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "Projeler yeni pencerede açılabilir, geçerli projenin yerini alabilir veya bu pencerede yeni sekmede açılabilir.\n\"{name}\" nasıl açılsın?",
"New Tab": "Yeni sekme",
"New tab in current window": "Geçerli pencerede yeni sekme",
"Show Only Widgets": "Yalnızca Bileşenleri Göster",
+1
Переглянути файл
@@ -9195,6 +9195,7 @@
"Saving a Dart file of a running Flutter debug session reloads the app, unless the file has errors.": "儲存正在執行的 Flutter 偵錯工作階段裡的 Dart 檔案時重新載入應用,檔案有錯誤時跳過。",
"Hot reload on save failed: {0}": "儲存時熱過載失敗:{0}",
"Projects can be opened in a new window, replace the current project, be attached to the already opened projects, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "專案可以在新視窗中開啟、取代目前專案、附加到已開啟的專案,或以新分頁在目前視窗中開啟。\n要如何開啟「{name}」?",
"Projects can be opened in a new window, replace the current project, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "專案可以在新視窗中開啟、取代目前專案,或以新分頁在目前視窗中開啟。\n要如何開啟「{name}」?",
"Show Only Widgets": "僅顯示 Widget",
"Update failed": "更新失敗",
"Updating branches": "正在更新分支",
+1
Переглянути файл
@@ -10315,6 +10315,7 @@
"Saving a Dart file of a running Flutter debug session reloads the app, unless the file has errors.": "保存正在运行的 Flutter 调试会话里的 Dart 文件时重新加载应用,文件有错误时跳过。",
"Hot reload on save failed: {0}": "保存时热重载失败:{0}",
"Projects can be opened in a new window, replace the current project, be attached to the already opened projects, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "项目可以在新窗口中打开、替换当前项目、附加到已打开的项目,或以新标签页在当前窗口中打开。\n要如何打开“{name}”?",
"Projects can be opened in a new window, replace the current project, or open as a new tab of this window.\nHow would you like to open \"{name}\"?": "项目可以在新窗口中打开、替换当前项目,或以新标签页在当前窗口中打开。\n要如何打开“{name}”?",
"Show Only Widgets": "仅显示 Widget",
"Update failed": "更新失败",
"Updating branches": "正在更新分支",
+25 -5
Переглянути файл
@@ -7,9 +7,11 @@ import { ask } from "./messages";
import { commands } from "@/platform/ipc";
const windowOpenRemote = vi.fn();
const windowGroupJoin = vi.fn();
const remoteWindow = vi.hoisted(() => ({ value: false }));
vi.mock("./messages", () => ({ ask: vi.fn() }));
vi.mock("@/platform/remote", () => ({
isRemoteWindow: () => false,
isRemoteWindow: () => remoteWindow.value,
connectRemote: vi.fn(),
}));
vi.mock("@/platform/ipc", () => ({
@@ -18,10 +20,12 @@ vi.mock("@/platform/ipc", () => ({
commands: {
settingsSet: vi.fn(async () => ({ general: { openProjectIn: "attach" } })),
windowOpenRemote: (...a: unknown[]) => windowOpenRemote(...a),
windowGroupJoin: (...a: unknown[]) => windowGroupJoin(...a),
},
}));
beforeEach(() => {
vi.clearAllMocks();
remoteWindow.value = false;
useProject.setState({
project: { root: "/a", name: "A", settings: {}, trusted: true, isGit: false },
settings: {},
@@ -40,14 +44,20 @@ it("offers attach for this open without remembering it", async () => {
expect(await chooseProjectWindow("C")).toBe(button);
expect(ask).toHaveBeenCalledTimes(2);
});
it("does not attach without a project or when opening a remote project", async () => {
it("offers a new tab but no attach for a remote project or from a remote window", async () => {
useProject.setState({
settings: { general: { openProjectIn: "attach" } } as never,
});
vi.mocked(ask).mockResolvedValue({ button: "cancel", checked: false });
expect(await chooseProjectWindow("remote", false)).toBeNull();
expect(vi.mocked(ask).mock.calls[0]![0].buttons.map((b) => b.id)).toEqual(["cancel", "new", "same"]);
useProject.setState({ project: null });
expect(vi.mocked(ask).mock.calls[0]![0].buttons.map((b) => b.id)).toEqual(["cancel", "tab", "new", "same"]);
remoteWindow.value = true;
expect(await chooseProjectWindow("B")).toBeNull();
expect(vi.mocked(ask).mock.calls[1]![0].buttons.map((b) => b.id)).toEqual(["cancel", "tab", "new", "same"]);
useProject.setState({ project: null, lightEdit: true });
expect(await chooseProjectWindow("B")).toBeNull();
expect(vi.mocked(ask).mock.calls[2]![0].buttons.map((b) => b.id)).toEqual(["cancel", "new", "same"]);
useProject.setState({ project: null, lightEdit: false });
expect(await chooseProjectWindow("B")).toBe("same");
});
@@ -65,7 +75,7 @@ it("opens a project tab by policy, or a new window when this one can't take one"
useProject.setState({ settings: { general: { openProjectIn: "tab" } } } as never);
expect(openPolicy()).toBe("tab");
expect(await chooseProjectWindow("B")).toBe("tab");
expect(await chooseProjectWindow("remote", false)).toBe("new");
expect(await chooseProjectWindow("remote", false)).toBe("tab");
useProject.setState({ project: null, lightEdit: true });
expect(await chooseProjectWindow("B")).toBe("new");
expect(ask).not.toHaveBeenCalled();
@@ -91,6 +101,16 @@ describe("a recent project opened with a modifier key", () => {
usePlatform.setState({ os });
});
it("opens a remote project as a project tab of this window", async () => {
windowOpenRemote.mockResolvedValueOnce({ kind: "current" }).mockResolvedValueOnce({ kind: "opened", label: "w2" });
const here = vi.fn(async () => {});
useProject.setState({ settings: { general: { openProjectIn: "tab" } } as never });
expect(await openRemoteProject(target, "/home/me/app", here)).toBe(true);
expect(windowOpenRemote).toHaveBeenLastCalledWith(target, "/home/me/app", true);
expect(windowGroupJoin).toHaveBeenCalledWith("w2");
expect(here).not.toHaveBeenCalled();
});
it("opens a remote project in that window without asking", async () => {
windowOpenRemote.mockResolvedValue({ kind: "opened" });
const here = vi.fn(async () => {});
+18 -16
Переглянути файл
@@ -40,26 +40,26 @@ export async function chooseProjectWindow(
): Promise<"new" | "same" | "attach" | "tab" | null> {
const { project, lightEdit } = useProject.getState();
if (!project && !lightEdit) return "same";
// Both ways of keeping this window's project: a workspace folder, or a project tab of this window.
const canAdd = allowAttach && !!project && !isRemoteWindow();
// Attach adds a local folder to this local window's workspace; a project tab is a window of its
// own joined to this one's group, so it takes remote projects and remote windows too.
const canTab = !!project;
const canAttach = allowAttach && canTab && !isRemoteWindow();
const mode = openPolicy();
// A project tab needs this window's project beside it; without one, a new window is the closest.
if (mode === "tab") return canAdd ? "tab" : "new";
if (mode === "tab") return canTab ? "tab" : "new";
if (mode !== "ask") return mode;
const r = await ask({
title: t("app.window.askTitle"),
width: canAdd ? 640 : undefined,
body: canAdd
width: canAttach ? 640 : undefined,
body: canAttach
? tx`Projects can be opened in a new window, replace the current project, be attached to the already opened projects, or open as a new tab of this window.\nHow would you like to open "${name}"?`
: t("app.window.askBody", { name }),
: canTab
? tx`Projects can be opened in a new window, replace the current project, or open as a new tab of this window.\nHow would you like to open "${name}"?`
: t("app.window.askBody", { name }),
buttons: [
{ id: "cancel", label: t("common.cancel") },
...(canAdd
? [
{ id: "attach", label: t("app.window.askAttach") },
{ id: "tab", label: tx`New Tab` },
]
: []),
...(canAttach ? [{ id: "attach", label: t("app.window.askAttach") }] : []),
...(canTab ? [{ id: "tab", label: tx`New Tab` }] : []),
{ id: "new", label: t("app.window.askNew") },
{ id: "same", label: t("app.window.askThis"), primary: true },
],
@@ -81,8 +81,8 @@ export async function chooseProjectWindow(
/**
* Opens folder `path` of `target` (an SSH host or a WSL distribution): focuses the
* window that has it, else opens it in a new window or (`here`) this one per
* "Open project in", or where `override` says. `false`: cancelled.
* window that has it, else opens it in a new window, a project tab of this window or
* (`here`) this one per "Open project in", or where `override` says. `false`: cancelled.
*/
export async function openRemoteProject(
target: RemoteTarget,
@@ -93,8 +93,10 @@ export async function openRemoteProject(
if ((await call(commands.windowOpenRemote(target, path, false))).kind === "focused") return true;
const mode = override ?? (await chooseProjectWindow(path.replace(/\/+$/, "").split("/").pop() || path, false));
if (!mode) return false;
if (mode === "new") {
await call(commands.windowOpenRemote(target, path, true));
if (mode === "new" || mode === "tab") {
const outcome = await call(commands.windowOpenRemote(target, path, true));
// As a local project tab: the window holding the project, new or focused, joins this one's group.
if (mode === "tab" && outcome.kind !== "current") await call(commands.windowGroupJoin(outcome.label));
return true;
}
// The remote host's project doesn't take this window's untitled buffers.