Файли
openidea/src/features/remote-dev/model.ts
T
l0ng-ai f70f362a3d feat(ui): open New Project, Get from VCS and Remote Development in their own windows (#6208)
* feat(ui): open New Project, Get from VCS and Remote Development in their own windows

Each dialog gets a native window over its project window: a full-height
sidebar under the traffic lights, the title heading the content and the
buttons in its corner. The windows hand their result back to the project
window, which opens the created or cloned project or makes the remote
connection and reports its progress. Remote windows and the browser build
keep the dialogs in the page.

* feat(ui): show dialogs in the page as sheets without window buttons on macOS

The title heads the content instead of a title bar with drawn traffic
lights; Esc and Cancel close the dialog, and the title dims while the
window is inactive.

* fix(ui): give a macOS dialog without footer buttons a Close button

A sheet has no window buttons, so a dialog with neither buttons nor a
footer could only be closed with Esc. The Extract Interface members
table may shrink to two rows so the dialog still fits a short window
under the taller sheet title.
2026-11-27 08:59:33 +08:00

57 рядки
2.1 KiB
TypeScript
Неформатований Анотація Історія

Цей файл містить неоднозначні символи Юнікоду
Цей файл містить символи Юнікоду, які можна сплутати з іншими символами. Якщо ви вважаєте, що це зроблено навмисно, можете сміливо ігнорувати це попередження. Щоб показати їх, скористайтеся кнопкою Escape.
/** File › Remote Development…: state of the connect dialog and the folder browser helpers. */
import { create } from "zustand";
import type { RemoteEntry, RemoteStage } from "@/platform/ipc";
/** `open`: the dialog in this page. `inWindow`: connecting for the Remote Development window. */
export const useConnectDialog = create<{ open: boolean; inWindow: boolean }>(() => ({ open: false, inWindow: false }));
export function openConnectDialog() {
useConnectDialog.setState({ open: true });
}
export function closeConnectDialog() {
useConnectDialog.setState({ open: false });
}
/** The parent of absolute POSIX path `path` (`/` stays `/`). */
export function remoteParent(path: string): string {
const trimmed = path.replace(/\/+$/, "");
const i = trimmed.lastIndexOf("/");
return i <= 0 ? "/" : trimmed.slice(0, i);
}
/** The folders of a listing, sorted by name (hidden ones last). */
export function browsableFolders(entries: readonly RemoteEntry[]): RemoteEntry[] {
const hidden = (e: RemoteEntry) => e.name.startsWith(".");
return entries
.filter((e) => e.isDir)
.sort((a, b) => Number(hidden(a)) - Number(hidden(b)) || a.name.localeCompare(b.name));
}
/** The directory a listing of `requested` stands for (`~` resolves on the server). */
export function listedDirectory(requested: string, entries: readonly RemoteEntry[]): string {
if (requested.startsWith("/")) return requested.replace(/(.)\/+$/, "$1");
const first = entries[0];
return first ? remoteParent(first.path) : requested;
}
/** What the window is waiting for at each stage of connecting. */
export function stageLabel(stage: RemoteStage): string {
switch (stage) {
case "connecting":
return "Connecting to the host…";
case "container":
return "Starting the dev container…";
case "checking":
return "Checking the IDE backend on the host…";
case "downloading":
return "Downloading the IDE backend…";
case "uploading":
return "Installing the IDE backend on the host…";
case "starting":
return "Starting the IDE backend…";
case "opening":
return "Opening the project…";
}
}