дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 09:11:10 +02:00
feat(remote): open a dev container from the Welcome screen and from devcontainer.json (#7565)
The Welcome screen lists local dev container configurations and an open devcontainer.json offers Open in Container, both through the existing Reopen in Container flow with trust and host checks; the reopen prompt remembers dismissal per project. Fixes #7417
Цей коміт міститься в:
1 джерело
3c8acf8ee3
коміт
7fa280e9e0
23 files changed
+454
-97
No files matched your search
@@ -21,30 +21,28 @@ tool window.
|
||||
is bind-mounted into the container, so a daemon on another machine doesn't work.
|
||||
- The Dev Containers CLI (`devcontainer`). Install **Dev Containers CLI** from
|
||||
**Settings › Languages & Frameworks › Language Servers** (it needs Node.js), or put `devcontainer` on your `PATH`.
|
||||
- A `.devcontainer/devcontainer.json` or `.devcontainer.json` in the project folder.
|
||||
- A `.devcontainer/devcontainer.json`, `.devcontainer.json`, or `.devcontainer/<name>/devcontainer.json` in the project folder.
|
||||
- The project must be trusted: building the container runs the project's commands (`initializeCommand`, the
|
||||
Dockerfile build).
|
||||
- A Linux container on x86_64 or aarch64.
|
||||
|
||||
### Reopen a project in its container
|
||||
### Open a project in its container
|
||||
|
||||
<Steps>
|
||||
<Step title="Open the project locally">Open the folder that contains the `devcontainer.json` and trust it.</Step>
|
||||
<Step title="Reopen in the container">
|
||||
Choose **File › Reopen in Container**, then **This Window** or **New Window** if asked.
|
||||
</Step>
|
||||
<Step title="Wait for the container">
|
||||
OpenIDEA runs `devcontainer up` for the folder, which builds or starts the container. The first build can take a
|
||||
while. Then it installs and starts [`openidea-server`](/en/guide/remote/server) in the container and opens the
|
||||
project folder there.
|
||||
</Step>
|
||||
</Steps>
|
||||
- From the Welcome screen, select **Remote Development › Dev Container** and choose the project folder. If the
|
||||
folder has several configurations, select the one to use. Click **Open** and trust the folder if prompted.
|
||||
- From a local project, use the **Reopen in Container** action in the editor banner for the configuration you want
|
||||
to use. You can also choose **File › Reopen in Container** to use the default configuration.
|
||||
- When you open a trusted local project with a dev container configuration, the IDE offers **Reopen in Container**.
|
||||
Choose **Don't ask again** to hide the notification for that project.
|
||||
|
||||
OpenIDEA runs `devcontainer up` to build or start the container, then installs and starts
|
||||
[`openidea-server`](/en/guide/remote/server) inside it. The first build can take a while.
|
||||
|
||||
The project then opens at the container's `remoteWorkspaceFolder`, as its `remoteUser`. The status bar shows
|
||||
**Dev Container: `<folder name>`**, and the project appears in the recent projects list on the Welcome screen.
|
||||
|
||||
If something fails (no `devcontainer.json`, Docker not installed, the build failed), a notification
|
||||
**Could not reopen the project in a container** shows the reason, including the end of the CLI's log.
|
||||
The Welcome dialog shows connection errors inline. In a local project, **Reopen in Container** reports failures in
|
||||
a notification. The message includes the end of the CLI's log when available.
|
||||
|
||||
### What applies from `devcontainer.json`
|
||||
|
||||
@@ -75,8 +73,8 @@ Language servers and debuggers that OpenIDEA installs go into the container, und
|
||||
|
||||
### Limits
|
||||
|
||||
- Only the default configuration is used (`.devcontainer/devcontainer.json`, then `.devcontainer.json`). There is no
|
||||
picker for several configurations in subfolders of `.devcontainer/`.
|
||||
- **File › Reopen in Container** uses `.devcontainer/devcontainer.json`, then `.devcontainer.json`. To select a
|
||||
configuration in a subfolder of `.devcontainer/`, use the Welcome screen or the editor banner.
|
||||
- **Reopen in Container** is available for local projects only, not from an SSH or WSL window.
|
||||
- There is no command to attach to an arbitrary running container; the container always comes from the project's
|
||||
`devcontainer.json`.
|
||||
|
||||
@@ -18,25 +18,24 @@ OpenIDEA 以两种方式使用容器:
|
||||
- 本机已安装 Docker,且当前 Docker 上下文的守护进程运行在本机。项目文件夹要绑定挂载进容器,所以其他机器上的守护进程不行。
|
||||
- Dev Containers CLI(`devcontainer`)。可以在**设置 › 语言和框架 › 语言服务器**中安装 **Dev Containers CLI**(需要 Node.js),
|
||||
也可以自己把 `devcontainer` 放到 `PATH` 中。
|
||||
- 项目文件夹中有 `.devcontainer/devcontainer.json` 或 `.devcontainer.json`。
|
||||
- 项目文件夹中有 `.devcontainer/devcontainer.json`、`.devcontainer.json` 或 `.devcontainer/<名称>/devcontainer.json`。
|
||||
- 项目必须已受信任:构建容器会执行项目自带的命令(`initializeCommand`、Dockerfile 构建)。
|
||||
- 容器为 x86_64 或 aarch64 上的 Linux。
|
||||
|
||||
### 在容器中重新打开项目
|
||||
### 在容器中打开项目
|
||||
|
||||
<Steps>
|
||||
<Step title="在本地打开项目">打开包含 `devcontainer.json` 的文件夹,并信任它。</Step>
|
||||
<Step title="在容器中重新打开">选择**文件 › 在容器中重新打开**,如有提示再选择**当前窗口**或**新窗口**。</Step>
|
||||
<Step title="等待容器就绪">
|
||||
OpenIDEA 会对该文件夹运行 `devcontainer up` 来构建或启动容器,首次构建可能需要一段时间。随后在容器中安装并启动
|
||||
[`openidea-server`](/zh/guide/remote/server),再打开容器里的项目文件夹。
|
||||
</Step>
|
||||
</Steps>
|
||||
- 在欢迎页中选择**远程开发 › 开发容器**,然后选择项目文件夹。如果该文件夹有多个配置,请选择要使用的配置。
|
||||
点击**打开**,并在提示时信任该文件夹。
|
||||
- 在本地项目中,打开要使用的配置,然后点击编辑器横幅中的**在容器中重新打开**。也可以选择**文件 › 在容器中重新打开**以使用默认配置。
|
||||
- 打开含有开发容器配置的受信任本地项目时,IDE 会提示**在容器中重新打开**。选择**不再询问**可隐藏此项目的通知。
|
||||
|
||||
OpenIDEA 会运行 `devcontainer up` 来构建或启动容器,然后在其中安装并启动
|
||||
[`openidea-server`](/zh/guide/remote/server)。首次构建可能需要一段时间。
|
||||
|
||||
项目会以容器的 `remoteUser` 身份、在 `remoteWorkspaceFolder` 中打开。状态栏显示 **Dev Container: `<folder name>`**,
|
||||
该项目也会出现在欢迎页的最近项目列表中。
|
||||
|
||||
如果失败(没有 `devcontainer.json`、未安装 Docker、构建出错等),会弹出**无法在容器中重新打开项目**通知,说明原因并附上 CLI 日志的末尾部分。
|
||||
欢迎页的对话框会直接显示连接错误。在本地项目中,**在容器中重新打开**操作会通过通知报告失败。如果有 CLI 日志,错误消息会附上日志末尾的内容。
|
||||
|
||||
### `devcontainer.json` 中哪些内容生效
|
||||
|
||||
@@ -55,7 +54,8 @@ OpenIDEA 安装的语言服务器和调试器会装进容器,位于容器用
|
||||
|
||||
### 限制
|
||||
|
||||
- 只使用默认配置(先找 `.devcontainer/devcontainer.json`,再找 `.devcontainer.json`),不能在 `.devcontainer/` 子文件夹中的多个配置之间选择。
|
||||
- **文件 › 在容器中重新打开**优先使用 `.devcontainer/devcontainer.json`,其次使用 `.devcontainer.json`。
|
||||
如需选择 `.devcontainer/` 子文件夹中的配置,请使用欢迎页或编辑器横幅。
|
||||
- **在容器中重新打开**只适用于本地项目,在 SSH 或 WSL 窗口中不可用。
|
||||
- 没有附加到任意运行中容器的命令;容器总是来自项目的 `devcontainer.json`。
|
||||
|
||||
|
||||
@@ -13,11 +13,13 @@ import styles from "./trust.module.css";
|
||||
const usePrompt = create<{
|
||||
path: string | null;
|
||||
scope: ProjectTrustScope;
|
||||
requireTrust: boolean;
|
||||
folder: boolean;
|
||||
finish: ((open: boolean) => void) | null;
|
||||
}>(() => ({
|
||||
path: null,
|
||||
scope: "current",
|
||||
requireTrust: false,
|
||||
folder: false,
|
||||
finish: null,
|
||||
}));
|
||||
@@ -34,7 +36,7 @@ function PathLine({ path }: { path: string }) {
|
||||
}
|
||||
|
||||
function TrustDialog() {
|
||||
const { path, folder } = usePrompt();
|
||||
const { path, folder, requireTrust } = usePrompt();
|
||||
return (
|
||||
<Dialog
|
||||
open={!!path}
|
||||
@@ -45,12 +47,16 @@ function TrustDialog() {
|
||||
title="Trust and Open Project?"
|
||||
onClose={() => void executeAction("project.dontOpen")}
|
||||
buttons={[
|
||||
{
|
||||
label: "Preview in Restricted Mode",
|
||||
autoFocus: true,
|
||||
onClick: () => void executeAction("project.previewRestricted"),
|
||||
},
|
||||
{ label: "Don't Open", role: "cancel" },
|
||||
...(requireTrust
|
||||
? []
|
||||
: [
|
||||
{
|
||||
label: "Preview in Restricted Mode",
|
||||
autoFocus: true,
|
||||
onClick: () => void executeAction("project.previewRestricted"),
|
||||
},
|
||||
]),
|
||||
{ label: "Don't Open", role: "cancel", autoFocus: requireTrust },
|
||||
{
|
||||
label: folder ? "Trust Folder" : "Trust Project",
|
||||
role: "default",
|
||||
@@ -78,12 +84,14 @@ function TrustDialog() {
|
||||
<p>
|
||||
<T>Loading, running or building a project may execute potentially malicious code from its build scripts.</T>
|
||||
</p>
|
||||
<p className={styles.restrictedPreview}>
|
||||
<T>
|
||||
If you don't trust the source, preview the project in Restricted Mode, where project commands and tools
|
||||
can't run.
|
||||
</T>
|
||||
</p>
|
||||
{!requireTrust && (
|
||||
<p className={styles.restrictedPreview}>
|
||||
<T>
|
||||
If you don't trust the source, preview the project in Restricted Mode, where project commands and tools
|
||||
can't run.
|
||||
</T>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
@@ -234,7 +242,7 @@ function TrustSettings() {
|
||||
async function decide(trusted: boolean) {
|
||||
const pending = usePrompt.getState();
|
||||
const path = pending.path ?? useProject.getState().project?.root;
|
||||
if (!path) return;
|
||||
if (!path || (pending.requireTrust && !trusted)) return;
|
||||
const folder = trusted && pending.folder;
|
||||
if (pending.scope === "local") {
|
||||
await callDesktop("project_trust_set", { path, trusted, folder });
|
||||
@@ -247,17 +255,19 @@ async function decide(trusted: boolean) {
|
||||
pending.finish?.(true);
|
||||
}
|
||||
|
||||
function promptForTrust(status: TrustStatus, scope: ProjectTrustScope): Promise<boolean> {
|
||||
function promptForTrust(status: TrustStatus, scope: ProjectTrustScope, requireTrust = false): Promise<boolean> {
|
||||
usePrompt.getState().finish?.(false);
|
||||
const answer = new Promise<boolean>((resolve) =>
|
||||
usePrompt.setState({
|
||||
path: status.root,
|
||||
scope,
|
||||
requireTrust,
|
||||
folder: false,
|
||||
finish: (open) => {
|
||||
usePrompt.setState({
|
||||
path: null,
|
||||
scope: "current",
|
||||
requireTrust: false,
|
||||
finish: null,
|
||||
folder: false,
|
||||
});
|
||||
@@ -283,10 +293,11 @@ async function trustProject() {
|
||||
export function activate(): () => void {
|
||||
initializeRemoteTrustMigration();
|
||||
const disposers = [
|
||||
provideProjectTrustPrompt(async (path, scope) => {
|
||||
provideProjectTrustPrompt(async (path, scope, requireTrust) => {
|
||||
const status = await (scope === "local"
|
||||
? callDesktop<TrustStatus>("project_trust_status", { path })
|
||||
: call(commands.projectTrustStatus(path)));
|
||||
if (requireTrust) return status.trusted || promptForTrust(status, scope, true);
|
||||
if (scope === "current" && isRemoteRoot(path)) {
|
||||
// The server's answer covers what runs there; commands run here need this machine's own.
|
||||
const desktop = await call(commands.remoteTrustStatus());
|
||||
|
||||
@@ -6,22 +6,31 @@ import { useRemoteProgress } from "@/platform/remote";
|
||||
import { ConnectDialog, ConnectHost } from "./ConnectDialog";
|
||||
import { closeConnectDialog, openConnectDialog, useConnectDialog } from "./model";
|
||||
|
||||
const { list, distros, globalSettings, openRemote, executeAction } = vi.hoisted(() => ({
|
||||
const { list, distros, globalSettings, openRemote, executeAction, readDir, pickFolder } = vi.hoisted(() => ({
|
||||
list: vi.fn(),
|
||||
distros: vi.fn(),
|
||||
globalSettings: vi.fn(),
|
||||
openRemote: vi.fn(),
|
||||
executeAction: vi.fn(),
|
||||
readDir: vi.fn(),
|
||||
pickFolder: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("@/platform/ipc", async (importOriginal) => {
|
||||
const real = await importOriginal<typeof import("@/platform/ipc")>();
|
||||
return {
|
||||
...real,
|
||||
commands: { ...real.commands, remoteBootstrapList: list, wslDistros: distros, settingsGetGlobal: globalSettings },
|
||||
commands: {
|
||||
...real.commands,
|
||||
remoteBootstrapList: list,
|
||||
wslDistros: distros,
|
||||
settingsGetGlobal: globalSettings,
|
||||
fsReadDir: readDir,
|
||||
},
|
||||
};
|
||||
});
|
||||
vi.mock("@/workbench/projectWindow", () => ({ openRemoteProject: openRemote }));
|
||||
vi.mock("@/platform/dialog", () => ({ open: pickFolder }));
|
||||
vi.mock("@/platform/actions", async (importOriginal) => ({
|
||||
...(await importOriginal<typeof import("@/platform/actions")>()),
|
||||
executeAction,
|
||||
@@ -136,7 +145,44 @@ it("offers SSH configuration and disables Browse until one exists, then lists th
|
||||
it("hides the WSL choice when no distribution is installed", async () => {
|
||||
render(<ConnectHost />);
|
||||
await waitFor(() => expect(distros).toHaveBeenCalled());
|
||||
expect(screen.queryByRole("button", { name: "Connect through" })).toBeNull();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Connect through" }));
|
||||
expect(screen.queryByRole("option", { name: "WSL" })).toBeNull();
|
||||
expect(screen.getByRole("option", { name: "Dev Container" })).toBeVisible();
|
||||
});
|
||||
|
||||
it("hands off the selected local dev container configuration from the Welcome window", async () => {
|
||||
const connect = vi.fn().mockResolvedValue(true);
|
||||
pickFolder.mockResolvedValue("C:\\dev\\app");
|
||||
const listings: Record<string, Array<{ name: string; path: string; kind: string }>> = {
|
||||
"C:/dev/app": [{ name: ".devcontainer", path: "C:/dev/app/.devcontainer", kind: "dir" }],
|
||||
"C:/dev/app/.devcontainer": [
|
||||
{ name: "devcontainer.json", path: "C:/dev/app/.devcontainer/devcontainer.json", kind: "file" },
|
||||
{ name: "python", path: "C:/dev/app/.devcontainer/python", kind: "dir" },
|
||||
],
|
||||
"C:/dev/app/.devcontainer/python": [
|
||||
{ name: "devcontainer.json", path: "C:/dev/app/.devcontainer/python/devcontainer.json", kind: "file" },
|
||||
],
|
||||
};
|
||||
readDir.mockImplementation(async (path: string) => ({ status: "ok", data: listings[path] ?? [] }));
|
||||
|
||||
render(<ConnectDialog standalone onConnect={connect} onClose={() => {}} />);
|
||||
fireEvent.click(screen.getByRole("button", { name: "Connect through" }));
|
||||
fireEvent.click(screen.getByRole("option", { name: "Dev Container" }));
|
||||
expect(screen.getByRole("button", { name: "Open" })).toBeDisabled();
|
||||
fireEvent.change(screen.getByLabelText("Project directory:"), { target: { value: "/empty" } });
|
||||
await screen.findByText("No dev container configuration found in this folder.");
|
||||
expect(screen.getByRole("button", { name: "Open" })).toBeDisabled();
|
||||
fireEvent.click(screen.getByRole("button", { name: "Browse" }));
|
||||
fireEvent.click(await screen.findByRole("button", { name: "Dev container configuration" }));
|
||||
fireEvent.click(screen.getByRole("option", { name: ".devcontainer/python/devcontainer.json" }));
|
||||
fireEvent.click(screen.getByRole("button", { name: "Open" }));
|
||||
await waitFor(() =>
|
||||
expect(connect).toHaveBeenCalledWith(
|
||||
{ kind: "devContainer", folder: "C:/dev/app", config: ".devcontainer/python/devcontainer.json" },
|
||||
"C:/dev/app",
|
||||
),
|
||||
);
|
||||
expect(openRemote).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("opens a folder of the chosen WSL distribution, without browsing over SFTP", async () => {
|
||||
|
||||
@@ -1,17 +1,21 @@
|
||||
/**
|
||||
* Picks an SSH configuration and a folder on that host, then opens it in this or a new window.
|
||||
* Picks a remote project, then opens it in this or a new window.
|
||||
* In the desktop app it has its own window (`connectWindow.tsx`).
|
||||
*/
|
||||
import { useEffect, useState, type ReactNode } from "react";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { open } from "@/platform/dialog";
|
||||
import { useTx } from "@/platform/i18n";
|
||||
import { call, commands, isCancelled, onIdeEvent, type RemoteEntry, type RemoteTarget } from "@/platform/ipc";
|
||||
import { localGlobalSettings, useRemoteProgress } from "@/platform/remote";
|
||||
import { ipcPath } from "@/platform/paths";
|
||||
import { isRemoteWindow, localGlobalSettings, useRemoteProgress } from "@/platform/remote";
|
||||
import { sshLabel, type SshConfigValid, validateRemote } from "@/platform/remoteSettings";
|
||||
import { isWebMode } from "@/platform/webBridge";
|
||||
import { Button, Dialog, Icon, Input, ProgressBar, Select, Spinner, type DialogButton } from "@/ui";
|
||||
import { openRemoteProject } from "@/workbench/projectWindow";
|
||||
import { windowBackgroundHex } from "@/workbench/theme";
|
||||
import { WindowDialogFrame } from "@/workbench/WindowDialogFrame";
|
||||
import { devContainerTargetConfig, findDevContainerConfigs, openDevContainer } from "./container";
|
||||
import {
|
||||
browsableFolders,
|
||||
closeConnectDialog,
|
||||
@@ -28,6 +32,7 @@ export function ConnectHost() {
|
||||
}
|
||||
|
||||
const SSH_SETTINGS_PAGE = "tools.sshConfigurations";
|
||||
const absolutePath = (path: string) => path.startsWith("/") || /^[A-Za-z]:\//.test(path);
|
||||
|
||||
/**
|
||||
* This machine's SSH configurations: the connection is made from here. A remote project's
|
||||
@@ -99,13 +104,18 @@ export function ConnectDialog({
|
||||
const [distros, setDistros] = useState<string[]>([]);
|
||||
const [distro, setDistro] = useState("");
|
||||
const [path, setPath] = useState("~");
|
||||
const [localPath, setLocalPath] = useState("");
|
||||
const [containerFolder, setContainerFolder] = useState<{ path: string; configs: string[]; error?: string } | null>(
|
||||
null,
|
||||
);
|
||||
const [pickedConfig, setPickedConfig] = useState("");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [browse, setBrowse] = useState<{ dir: string; folders: RemoteEntry[] } | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let live = true;
|
||||
// Detection is a convenience: any failure just leaves SSH as the only choice.
|
||||
// Detection is a convenience: a failure leaves WSL unavailable.
|
||||
void call(commands.wslDistros())
|
||||
.then((found) => {
|
||||
if (!live) return;
|
||||
@@ -119,9 +129,46 @@ export function ConnectDialog({
|
||||
}, []);
|
||||
|
||||
const wsl = kind === "wsl";
|
||||
const container = kind === "devContainer";
|
||||
const canUseContainer = !isRemoteWindow() && !isWebMode();
|
||||
const folder = container ? ipcPath(localPath.trim()) : "";
|
||||
const scanned = containerFolder?.path === folder ? containerFolder : null;
|
||||
const containerConfigs = scanned?.configs ?? [];
|
||||
const config = containerConfigs.includes(pickedConfig) ? pickedConfig : containerConfigs[0];
|
||||
const name = wsl ? distro : ssh;
|
||||
const target: RemoteTarget = wsl ? { kind: "wsl", distro } : { kind: "ssh", config: ssh };
|
||||
|
||||
useEffect(() => {
|
||||
if (!absolutePath(folder)) return;
|
||||
let live = true;
|
||||
const timer = setTimeout(() => {
|
||||
void findDevContainerConfigs(folder).then(
|
||||
(configs) => live && setContainerFolder({ path: folder, configs }),
|
||||
(e: unknown) => live && setContainerFolder({ path: folder, configs: [], error: String(e) }),
|
||||
);
|
||||
}, 150);
|
||||
return () => {
|
||||
clearTimeout(timer);
|
||||
live = false;
|
||||
};
|
||||
}, [folder]);
|
||||
|
||||
const changeFolder = (value: string) => {
|
||||
setLocalPath(value);
|
||||
setPickedConfig("");
|
||||
setError(null);
|
||||
};
|
||||
|
||||
const browseLocal = async () => {
|
||||
setError(null);
|
||||
try {
|
||||
const picked = await open({ directory: true, defaultPath: absolutePath(folder) ? folder : undefined });
|
||||
if (picked) changeFolder(ipcPath(picked));
|
||||
} catch (e) {
|
||||
setError(e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
};
|
||||
|
||||
const list = async (dir: string) => {
|
||||
setError(null);
|
||||
setBusy(true);
|
||||
@@ -141,8 +188,17 @@ export function ConnectDialog({
|
||||
setError(null);
|
||||
setBusy(true);
|
||||
try {
|
||||
const dir = path.trim() || "~";
|
||||
if (await (onConnect ? onConnect(target, dir) : openRemoteProject(target, dir))) onClose();
|
||||
const dir = container ? folder : path.trim() || "~";
|
||||
const destination: RemoteTarget =
|
||||
container && config
|
||||
? { kind: "devContainer", folder, config: devContainerTargetConfig(containerConfigs, config) }
|
||||
: target;
|
||||
const opened = onConnect
|
||||
? await onConnect(destination, dir)
|
||||
: destination.kind === "devContainer"
|
||||
? await openDevContainer(dir, destination.config)
|
||||
: await openRemoteProject(destination, dir);
|
||||
if (opened) onClose();
|
||||
else setBusy(false);
|
||||
} catch (e) {
|
||||
if (!isCancelled(e)) setError(e instanceof Error ? e.message : String(e));
|
||||
@@ -157,7 +213,7 @@ export function ConnectDialog({
|
||||
label: c.name.trim() || sshLabel(c),
|
||||
detail: sshLabel(c),
|
||||
}));
|
||||
const ready = !!name && !busy && !!path.trim();
|
||||
const ready = !busy && (container ? Boolean(config) : Boolean(name && path.trim()));
|
||||
const connecting = useRemoteProgress((s) => s.progress !== null);
|
||||
|
||||
const configure = () =>
|
||||
@@ -187,26 +243,30 @@ export function ConnectDialog({
|
||||
}}
|
||||
>
|
||||
<p className={styles.hint}>
|
||||
{tx("The project runs on the remote host; the IDE backend is installed there on first use.")}
|
||||
{container
|
||||
? tx("Select a local project folder to build or start its dev container.")
|
||||
: tx("The project runs on the remote host; the IDE backend is installed there on first use.")}
|
||||
</p>
|
||||
{distros.length > 0 && (
|
||||
{(distros.length > 0 || canUseContainer) && (
|
||||
<>
|
||||
<label className={styles.label}>{tx("Connect through:")}</label>
|
||||
<Select
|
||||
value={kind}
|
||||
options={[
|
||||
{ value: "ssh", label: "SSH" },
|
||||
{ value: "wsl", label: "WSL" },
|
||||
...(distros.length ? [{ value: "wsl", label: "WSL" }] : []),
|
||||
...(canUseContainer ? [{ value: "devContainer", label: "Dev Container" }] : []),
|
||||
]}
|
||||
onChange={(k) => {
|
||||
setKind(k as RemoteTarget["kind"]);
|
||||
setBrowse(null);
|
||||
setError(null);
|
||||
}}
|
||||
aria-label={tx("Connect through")}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{wsl ? (
|
||||
{container ? null : wsl ? (
|
||||
<>
|
||||
<label className={styles.label}>{tx("WSL distribution:")}</label>
|
||||
<Select
|
||||
@@ -243,17 +303,41 @@ export function ConnectDialog({
|
||||
id="remote-dev-path"
|
||||
className={styles.grow}
|
||||
data-autofocus
|
||||
value={path}
|
||||
value={container ? localPath : path}
|
||||
spellCheck={false}
|
||||
onChange={(e) => setPath(e.target.value)}
|
||||
disabled={container && busy}
|
||||
onChange={(e) => (container ? changeFolder(e.target.value) : setPath(e.target.value))}
|
||||
/>
|
||||
{/* Browsing lists over SFTP; a WSL distribution has no such session before connecting. */}
|
||||
{!wsl && (
|
||||
<Button disabled={!ssh || busy} onClick={() => void list(path.trim() || "~")}>
|
||||
<Button
|
||||
disabled={busy || (!container && !ssh)}
|
||||
onClick={() => void (container ? browseLocal() : list(path.trim() || "~"))}
|
||||
>
|
||||
{tx("Browse")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
{container && containerConfigs.length > 1 && (
|
||||
<>
|
||||
<label className={styles.label}>{tx("Dev container configuration:")}</label>
|
||||
<Select
|
||||
value={config ?? null}
|
||||
options={containerConfigs.map((value) => ({ value, label: value, verbatim: true }))}
|
||||
disabled={busy}
|
||||
onChange={setPickedConfig}
|
||||
aria-label={tx("Dev container configuration")}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{container && folder && !absolutePath(folder) && (
|
||||
<p className={styles.hint}>{tx("Enter an absolute folder path.")}</p>
|
||||
)}
|
||||
{container && scanned && !scanned.error && !config && (
|
||||
<p className={styles.hint} role="status">
|
||||
{tx("No dev container configuration found in this folder.")}
|
||||
</p>
|
||||
)}
|
||||
{browse && (
|
||||
<ul className={styles.folders} aria-label={tx("Remote folders")}>
|
||||
{browse.dir !== "/" && (
|
||||
@@ -275,9 +359,9 @@ export function ConnectDialog({
|
||||
</ul>
|
||||
)}
|
||||
<ConnectProgress />
|
||||
{error && (
|
||||
{(error || (container && scanned?.error)) && (
|
||||
<div className={styles.error} role="alert">
|
||||
{error}
|
||||
{error || scanned?.error}
|
||||
</div>
|
||||
)}
|
||||
</form>
|
||||
|
||||
@@ -17,6 +17,7 @@ import { openRemoteProject } from "@/workbench/projectWindow";
|
||||
import { useApplyTheme, windowBackgroundHex } from "@/workbench/theme";
|
||||
import { WindowResizeHandles } from "@/workbench/WindowResizeHandles";
|
||||
import { ConnectDialog } from "./ConnectDialog";
|
||||
import { openDevContainer } from "./container";
|
||||
import { openConnectDialog, useConnectDialog } from "./model";
|
||||
|
||||
const REQUEST = "openidea://connect/request";
|
||||
@@ -61,11 +62,19 @@ export function installConnectHandoff(): () => void {
|
||||
const relay = useRemoteProgress.subscribe((s) => void emitTo(from, PROGRESS, s.progress).catch(() => {}));
|
||||
useConnectDialog.setState({ inWindow: true });
|
||||
const reply = async (result: ConnectResult) => {
|
||||
if (await Window.getByLabel(from)) return emitTo(from, RESULT, result);
|
||||
const dialog = await Window.getByLabel(from);
|
||||
if (dialog) {
|
||||
if (!result.opened) await dialog.setFocus().catch(() => {});
|
||||
return emitTo(from, RESULT, result);
|
||||
}
|
||||
// The window is gone (closed, or with this window's old project): tell it here.
|
||||
if (result.error) await showError("Cannot connect to the remote host", result.error);
|
||||
};
|
||||
void openRemoteProject(target, path)
|
||||
void (
|
||||
target.kind === "devContainer"
|
||||
? openDevContainer(target.folder, target.config)
|
||||
: openRemoteProject(target, path)
|
||||
)
|
||||
.then(
|
||||
(opened) => reply({ id, opened }),
|
||||
(e: unknown) => reply(isCancelled(e) ? { id, opened: false } : { id, opened: false, error: errorText(e) }),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { beforeEach, expect, it, vi } from "vitest";
|
||||
import { IpcError } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { provideProjectTrustPrompt } from "@/platform/projectTrust";
|
||||
import { useRemote } from "@/platform/remote";
|
||||
|
||||
const mocks = vi.hoisted(() => ({
|
||||
@@ -8,6 +9,7 @@ const mocks = vi.hoisted(() => ({
|
||||
notify: vi.fn(),
|
||||
confirm: vi.fn(),
|
||||
checkRequirements: vi.fn(),
|
||||
readDir: vi.fn(),
|
||||
tauri: false,
|
||||
}));
|
||||
vi.mock("@/workbench/projectWindow", () => ({ openRemoteProject: mocks.open }));
|
||||
@@ -21,13 +23,14 @@ vi.mock("@/platform/ipc", async (original) => {
|
||||
commands: {
|
||||
...actual.commands,
|
||||
remoteDevcontainerCheckRequirements: mocks.checkRequirements,
|
||||
fsReadDir: mocks.readDir,
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
import { reopenInContainer } from "./container";
|
||||
import { installDevContainerNotifications, openDevContainer, reopenInContainer } from "./container";
|
||||
|
||||
const project = (root: string) => ({ root, name: "app", trusted: true }) as never;
|
||||
const project = (root: string, trusted = true) => ({ root, name: "app", trusted }) as never;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
@@ -46,6 +49,60 @@ it("opens the local project's dev container", async () => {
|
||||
expect(mocks.notify).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("requires trust before checking requirements or starting the container", async () => {
|
||||
mocks.tauri = true;
|
||||
const trust = vi.fn().mockResolvedValue(false);
|
||||
const dispose = provideProjectTrustPrompt(trust);
|
||||
try {
|
||||
await expect(openDevContainer("/unknown", ".devcontainer/special/devcontainer.json")).rejects.toMatchObject({
|
||||
kind: "cancelled",
|
||||
});
|
||||
expect(trust).toHaveBeenCalledWith("/unknown", "local", true);
|
||||
expect(mocks.checkRequirements).not.toHaveBeenCalled();
|
||||
expect(mocks.open).not.toHaveBeenCalled();
|
||||
} finally {
|
||||
dispose();
|
||||
}
|
||||
});
|
||||
|
||||
it("opens the configuration from the editor and ignores unrelated paths", async () => {
|
||||
const root = "/Users/me/app";
|
||||
const config = ".devcontainer/python/devcontainer.json";
|
||||
mocks.readDir.mockResolvedValue({ status: "ok", data: [] });
|
||||
await reopenInContainer(`${root}/example/devcontainer.json`);
|
||||
expect(mocks.open).not.toHaveBeenCalled();
|
||||
await reopenInContainer(`${root}/${config}`);
|
||||
expect(mocks.open).toHaveBeenCalledWith({ kind: "devContainer", folder: root, config }, root);
|
||||
});
|
||||
|
||||
it("offers a trusted project once and remembers Don't ask again", async () => {
|
||||
const root = "/container-notifications";
|
||||
const preference = `openidea.devContainer.ignore:${root}`;
|
||||
localStorage.removeItem(preference);
|
||||
useProject.setState({ project: project(root, false) });
|
||||
mocks.readDir.mockResolvedValue({ status: "ok", data: [{ name: ".devcontainer.json", kind: "file" }] });
|
||||
const dispose = installDevContainerNotifications();
|
||||
try {
|
||||
expect(mocks.readDir).not.toHaveBeenCalled();
|
||||
useProject.setState({ project: project(root) });
|
||||
await vi.waitFor(() => expect(mocks.notify).toHaveBeenCalledTimes(1));
|
||||
useProject.setState({ project: null });
|
||||
useProject.setState({ project: project(root) });
|
||||
expect(mocks.readDir).toHaveBeenCalledTimes(1);
|
||||
mocks.notify.mock.calls[0]![0].actions[1].run();
|
||||
expect(localStorage.getItem(preference)).toBe("1");
|
||||
} finally {
|
||||
dispose();
|
||||
}
|
||||
const restart = installDevContainerNotifications();
|
||||
try {
|
||||
expect(mocks.readDir).toHaveBeenCalledTimes(1);
|
||||
} finally {
|
||||
restart();
|
||||
localStorage.removeItem(preference);
|
||||
}
|
||||
});
|
||||
|
||||
it("does nothing in a remote window or without a project", async () => {
|
||||
useRemote.setState({
|
||||
session: { target: { kind: "ssh", config: "a" }, root: "/srv/app", host: "a", os: "linux", commands: [] },
|
||||
|
||||
@@ -1,12 +1,54 @@
|
||||
/** Reopen in Container: the local project's dev container, opened as a remote project. */
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { call, commands, isCancelled, isTauri } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { isRemoteWindow } from "@/platform/remote";
|
||||
import { notifications } from "@/workbench/contributions";
|
||||
import { executeAction } from "@/platform/actions";
|
||||
import { t, tx } from "@/platform/i18n";
|
||||
import { call, callDesktop, commands, isCancelled, isTauri, type FileEntry } from "@/platform/ipc";
|
||||
import { projectFolder, useProject } from "@/platform/project";
|
||||
import { confirmProjectTrust } from "@/platform/projectTrust";
|
||||
import { isRemoteWindow, useRemote } from "@/platform/remote";
|
||||
import { isWebMode } from "@/platform/webBridge";
|
||||
import { notifications, registerEditorBanner } from "@/workbench/contributions";
|
||||
import { confirm } from "@/workbench/messages";
|
||||
import { openRemoteProject } from "@/workbench/projectWindow";
|
||||
|
||||
const DIRECTORY = ".devcontainer";
|
||||
const FILE = "devcontainer.json";
|
||||
const DEFAULT_CONFIG = `${DIRECTORY}/${FILE}`;
|
||||
const ROOT_CONFIG = ".devcontainer.json";
|
||||
const REOPEN = "remote.reopenInContainer";
|
||||
|
||||
function readLocalDir(path: string): Promise<FileEntry[]> {
|
||||
return isTauri() ? callDesktop("fs_read_dir", { path }) : call(commands.fsReadDir(path));
|
||||
}
|
||||
|
||||
export async function findDevContainerConfigs(folder: string): Promise<string[]> {
|
||||
const entries = await readLocalDir(folder);
|
||||
const dir = entries.find((entry) => entry.name === DIRECTORY && (entry.targetKind ?? entry.kind) === "dir");
|
||||
const rootFile = entries.some((entry) => entry.name === ROOT_CONFIG && (entry.targetKind ?? entry.kind) === "file");
|
||||
if (!dir) return rootFile ? [ROOT_CONFIG] : [];
|
||||
const contents = await readLocalDir(dir.path);
|
||||
const configs: string[] = [];
|
||||
if (contents.some((entry) => entry.name === FILE && (entry.targetKind ?? entry.kind) === "file")) {
|
||||
configs.push(DEFAULT_CONFIG);
|
||||
}
|
||||
if (rootFile) configs.push(ROOT_CONFIG);
|
||||
const groups = await Promise.all(
|
||||
contents
|
||||
.filter((entry) => (entry.targetKind ?? entry.kind) === "dir")
|
||||
.map(async (entry) => {
|
||||
const files = await readLocalDir(entry.path).catch(() => []);
|
||||
return files.some((file) => file.name === FILE && (file.targetKind ?? file.kind) === "file")
|
||||
? `${DIRECTORY}/${entry.name}/${FILE}`
|
||||
: null;
|
||||
}),
|
||||
);
|
||||
return configs.concat(groups.filter((config) => config !== null).sort());
|
||||
}
|
||||
|
||||
// Keep the existing target identity for the default configuration.
|
||||
export function devContainerTargetConfig(configs: readonly string[], selected: string): string {
|
||||
return configs[0] === selected && (selected === DEFAULT_CONFIG || selected === ROOT_CONFIG) ? "" : selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks `hostRequirements` (`cpus`, `memory`, `storage`) in `devcontainer.json` against
|
||||
* this machine and the Docker VM before building. Returns `false` when the user cancels.
|
||||
@@ -29,16 +71,33 @@ async function confirmHostRequirements(folder: string, config = ""): Promise<boo
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds or starts the dev container of this window's local project (its `devcontainer.json`)
|
||||
* and opens the project there. The folder must be trusted: building it runs the project's commands.
|
||||
*/
|
||||
export async function reopenInContainer(): Promise<void> {
|
||||
export async function openDevContainer(folder: string, config: string): Promise<boolean> {
|
||||
await confirmProjectTrust(folder, "local", true);
|
||||
if (!(await confirmHostRequirements(folder, config))) return false;
|
||||
return openRemoteProject({ kind: "devContainer", folder, config }, folder);
|
||||
}
|
||||
|
||||
function editorConfig(path: string, folder: string): string | null {
|
||||
const prefix = folder.endsWith("/") ? folder : folder + "/";
|
||||
if (!path.startsWith(prefix)) return null;
|
||||
const relative = path.slice(prefix.length);
|
||||
if (relative === ROOT_CONFIG || relative === DEFAULT_CONFIG) return relative;
|
||||
const [dir, group, file, ...rest] = relative.split("/");
|
||||
return dir === DIRECTORY && group && group !== "." && group !== ".." && file === FILE && !rest.length
|
||||
? relative
|
||||
: null;
|
||||
}
|
||||
|
||||
export async function reopenInContainer(fromFile?: string): Promise<void> {
|
||||
const project = useProject.getState().project;
|
||||
if (!project || isRemoteWindow()) return;
|
||||
const folder = fromFile ? projectFolder(project, fromFile)?.root : project.root;
|
||||
if (!folder) return;
|
||||
const selected = fromFile ? editorConfig(fromFile, folder) : null;
|
||||
if (fromFile && !selected) return;
|
||||
try {
|
||||
if (!(await confirmHostRequirements(project.root))) return;
|
||||
await openRemoteProject({ kind: "devContainer", folder: project.root, config: "" }, project.root);
|
||||
const configs = selected ? await findDevContainerConfigs(folder) : [];
|
||||
await openDevContainer(folder, selected ? devContainerTargetConfig(configs, selected) : "");
|
||||
} catch (e) {
|
||||
if (isCancelled(e)) return;
|
||||
notifications().notify({
|
||||
@@ -49,3 +108,74 @@ export async function reopenInContainer(): Promise<void> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function registerDevContainerBanner(): () => void {
|
||||
return registerEditorBanner({
|
||||
id: "remote.devContainer",
|
||||
useBanner(path) {
|
||||
const project = useProject((state) => state.project);
|
||||
const remote = useRemote((state) => state.session !== null);
|
||||
const folder = projectFolder(project, path)?.root;
|
||||
if (remote || isWebMode() || !folder || !editorConfig(path, folder)) return null;
|
||||
return {
|
||||
text: "This file configures a dev container.",
|
||||
actions: [{ label: "Reopen in Container", run: () => void executeAction(REOPEN, path) }],
|
||||
};
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function installDevContainerNotifications(): () => void {
|
||||
if (isWebMode()) return () => {};
|
||||
const shown = new Set<string>();
|
||||
let current: string | null = null;
|
||||
const sync = () => {
|
||||
const project = useProject.getState().project;
|
||||
const root = !isRemoteWindow() && project?.trusted ? project.root : null;
|
||||
if (root === current) return;
|
||||
current = root;
|
||||
notifications().expire?.("remote.devContainer");
|
||||
if (!root || shown.has(root)) return;
|
||||
const preference = `openidea.devContainer.ignore:${root}`;
|
||||
if (localStorage.getItem(preference)) return;
|
||||
void findDevContainerConfigs(root)
|
||||
.then(([config]) => {
|
||||
if (!config || root !== current || shown.has(root)) return;
|
||||
shown.add(root);
|
||||
const reopen = `${root.endsWith("/") ? root : root + "/"}${config}`;
|
||||
const dismiss = () => notifications().expire?.("remote.devContainer");
|
||||
notifications().notify({
|
||||
group: "remote",
|
||||
key: "remote.devContainer",
|
||||
level: "info",
|
||||
suppressGroupAction: false,
|
||||
title: "Dev container configuration detected",
|
||||
actions: [
|
||||
{
|
||||
label: "Reopen in Container",
|
||||
run: () => {
|
||||
dismiss();
|
||||
void executeAction(REOPEN, reopen);
|
||||
},
|
||||
},
|
||||
{
|
||||
label: t("app.window.askRemember"),
|
||||
run: () => {
|
||||
localStorage.setItem(preference, "1");
|
||||
dismiss();
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
})
|
||||
.catch(() => {});
|
||||
};
|
||||
const unproject = useProject.subscribe(sync);
|
||||
const unremote = useRemote.subscribe(sync);
|
||||
sync();
|
||||
return () => {
|
||||
current = null;
|
||||
unproject();
|
||||
unremote();
|
||||
};
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import { tx } from "@/platform/i18n";
|
||||
import { confirmLeaveProject, useProject } from "@/platform/project";
|
||||
import { ConnectHost } from "./ConnectDialog";
|
||||
import { installConnectHandoff, showConnect } from "./connectWindow";
|
||||
import { reopenInContainer } from "./container";
|
||||
import { installDevContainerNotifications, registerDevContainerBanner, reopenInContainer } from "./container";
|
||||
import { installDirenvNotifications, reloadEnvironment } from "./environment";
|
||||
import { REMOTE_RESOURCES_WIDGET, RemoteResources } from "./RemoteResources";
|
||||
import { RemoteStatus } from "./RemoteStatus";
|
||||
@@ -88,6 +88,8 @@ export function activate(): () => void {
|
||||
trackPortsWindow(),
|
||||
installReconnect(),
|
||||
installDirenvNotifications(),
|
||||
installDevContainerNotifications(),
|
||||
registerDevContainerBanner(),
|
||||
registerOverlay({ id: "remote.connect", component: ConnectHost }),
|
||||
installConnectHandoff(),
|
||||
registerStatusItem({
|
||||
@@ -124,7 +126,7 @@ export function activate(): () => void {
|
||||
{
|
||||
id: "remote.connect",
|
||||
title: "Remote Development…",
|
||||
description: "Opens a project folder on an SSH host; the IDE backend runs on that host.",
|
||||
description: "Opens a project on an SSH host, in WSL, or in a dev container.",
|
||||
category: "File",
|
||||
icon: "remote",
|
||||
keywords: ["ssh", "remote", "server", "gateway", "connect", "host"],
|
||||
@@ -193,7 +195,7 @@ export function activate(): () => void {
|
||||
icon: "folder",
|
||||
keywords: ["devcontainer", "dev container", "docker", "container", "remote"],
|
||||
when: "projectOpen",
|
||||
run: () => reopenInContainer(),
|
||||
run: ({ arg }) => reopenInContainer(typeof arg === "string" ? arg : undefined),
|
||||
},
|
||||
{
|
||||
id: "remote.reloadEnvironment",
|
||||
|
||||
@@ -1593,6 +1593,15 @@
|
||||
"Command-line tool": "Command-line tool",
|
||||
"Could not reopen the project in a container": "Could not reopen the project in a container",
|
||||
"Reopen in Container": "Reopen in Container",
|
||||
"Dev Container": "Dev Container",
|
||||
"Select a local project folder to build or start its dev container.": "Select a local project folder to build or start its dev container.",
|
||||
"Dev container configuration:": "Dev container configuration:",
|
||||
"Dev container configuration": "Dev container configuration",
|
||||
"Enter an absolute folder path.": "Enter an absolute folder path.",
|
||||
"No dev container configuration found in this folder.": "No dev container configuration found in this folder.",
|
||||
"This file configures a dev container.": "This file configures a dev container.",
|
||||
"Dev container configuration detected": "Dev container configuration detected",
|
||||
"Opens a project on an SSH host, in WSL, or in a dev container.": "Opens a project on an SSH host, in WSL, or in a dev container.",
|
||||
"Builds or starts the project's dev container (devcontainer.json) with the Dev Containers CLI and opens the project in it.": "Builds or starts the project's dev container (devcontainer.json) with the Dev Containers CLI and opens the project in it.",
|
||||
"devcontainer up exited with {status}": "devcontainer up exited with {status}",
|
||||
"Select an item to view details": "Select an item to view details",
|
||||
|
||||
@@ -4447,7 +4447,6 @@
|
||||
"No SSH configurations": "No hay configuraciones SSH",
|
||||
"Project directory:": "Directorio del proyecto:",
|
||||
"Remote Development…": "Desarrollo remoto…",
|
||||
"Opens a project folder on an SSH host; the IDE backend runs on that host.": "Abre una carpeta de proyecto en un host SSH; el backend del IDE se ejecuta en ese host.",
|
||||
"Disconnect from Remote Host": "Desconectar del host remoto",
|
||||
"Reload Environment": "Recargar entorno",
|
||||
"Reads the login shell's environment (and devcontainer.json remoteEnv on a remote host) again for new terminals and processes.": "Vuelve a leer el entorno del shell de inicio de sesión (y remoteEnv de devcontainer.json en un host remoto) para nuevas terminales y procesos.",
|
||||
|
||||
@@ -4334,7 +4334,6 @@
|
||||
"No SSH configurations": "Aucune configuration SSH",
|
||||
"Project directory:": "Répertoire du projet :",
|
||||
"Remote Development…": "Développement à distance…",
|
||||
"Opens a project folder on an SSH host; the IDE backend runs on that host.": "Ouvre un dossier de projet sur un hôte SSH ; le backend de l'IDE s'exécute sur cet hôte.",
|
||||
"Disconnect from Remote Host": "Se déconnecter de l'hôte distant",
|
||||
"Reload Environment": "Recharger l'environnement",
|
||||
"Reads the login shell's environment (and devcontainer.json remoteEnv on a remote host) again for new terminals and processes.": "Relit l'environnement du shell de connexion (et le remoteEnv de devcontainer.json sur un hôte distant) pour les nouveaux terminaux et processus.",
|
||||
|
||||
@@ -4513,7 +4513,6 @@
|
||||
"No SSH configurations": "SSH 구성 없음",
|
||||
"Project directory:": "프로젝트 디렉터리:",
|
||||
"Remote Development…": "원격 개발…",
|
||||
"Opens a project folder on an SSH host; the IDE backend runs on that host.": "SSH 호스트에서 프로젝트 폴더를 엽니다. IDE 백엔드는 해당 호스트에서 실행됩니다.",
|
||||
"Disconnect from Remote Host": "원격 호스트에서 연결 해제",
|
||||
"Reload Environment": "환경 다시 로드",
|
||||
"Reads the login shell's environment (and devcontainer.json remoteEnv on a remote host) again for new terminals and processes.": "새 터미널과 프로세스를 위해 로그인 셸의 환경(원격 호스트에서는 devcontainer.json의 remoteEnv 포함)을 다시 읽습니다.",
|
||||
|
||||
@@ -4399,7 +4399,6 @@
|
||||
"No SSH configurations": "Brak konfiguracji SSH",
|
||||
"Project directory:": "Katalog projektu:",
|
||||
"Remote Development…": "Zdalne programowanie…",
|
||||
"Opens a project folder on an SSH host; the IDE backend runs on that host.": "Otwiera folder projektu na hoście SSH; zaplecze IDE działa na tym hoście.",
|
||||
"Disconnect from Remote Host": "Rozłącz ze zdalnym hostem",
|
||||
"Reload Environment": "Przeładuj środowisko",
|
||||
"Reads the login shell's environment (and devcontainer.json remoteEnv on a remote host) again for new terminals and processes.": "Odczytuje ponownie środowisko powłoki logowania (oraz zmienną remoteEnv z devcontainer.json na zdalnym hoście) dla nowych terminali i procesów.",
|
||||
|
||||
@@ -4413,7 +4413,6 @@
|
||||
"No SSH configurations": "Nenhuma configuração SSH",
|
||||
"Project directory:": "Diretório do projeto:",
|
||||
"Remote Development…": "Desenvolvimento remoto…",
|
||||
"Opens a project folder on an SSH host; the IDE backend runs on that host.": "Abre uma pasta de projeto em um host SSH; o back-end da IDE é executado nesse host.",
|
||||
"Disconnect from Remote Host": "Desconectar do host remoto",
|
||||
"Reload Environment": "Recarregar ambiente",
|
||||
"Reads the login shell's environment (and devcontainer.json remoteEnv on a remote host) again for new terminals and processes.": "Lê novamente o ambiente do shell de login (e o remoteEnv de devcontainer.json em um host remoto) para novos terminais e processos.",
|
||||
|
||||
@@ -5967,7 +5967,6 @@
|
||||
"No SSH configurations": "Нет конфигураций SSH",
|
||||
"Project directory:": "Каталог проекта:",
|
||||
"Remote Development…": "Удалённая разработка…",
|
||||
"Opens a project folder on an SSH host; the IDE backend runs on that host.": "Открывает папку проекта на хосте SSH; бэкенд IDE работает на этом хосте.",
|
||||
"Disconnect from Remote Host": "Отключиться от удалённого хоста",
|
||||
"Reload Environment": "Перезагрузить окружение",
|
||||
"Reads the login shell's environment (and devcontainer.json remoteEnv on a remote host) again for new terminals and processes.": "Повторно считывает окружение оболочки входа (и remoteEnv из devcontainer.json на удалённом хосте) для новых терминалов и процессов.",
|
||||
|
||||
@@ -7110,7 +7110,6 @@
|
||||
"No SSH configurations": "SSH yapılandırması yok",
|
||||
"Project directory:": "Proje dizini:",
|
||||
"Remote Development…": "Uzaktan Geliştirme…",
|
||||
"Opens a project folder on an SSH host; the IDE backend runs on that host.": "SSH ana makinesinde proje klasörü açar; IDE arka ucu bu makinede çalışır.",
|
||||
"Disconnect from Remote Host": "Uzak Ana Makine Bağlantısını Kes",
|
||||
"Reload Environment": "Ortamı Yeniden Yükle",
|
||||
"Reads the login shell's environment (and devcontainer.json remoteEnv on a remote host) again for new terminals and processes.": "Yeni terminaller ve işlemler için oturum açma kabuğunun ortamını (uzak ana makinede devcontainer.json remoteEnv dahil) yeniden okur.",
|
||||
|
||||
@@ -5577,7 +5577,6 @@
|
||||
"No SSH configurations": "沒有 SSH 組態",
|
||||
"Project directory:": "專案目錄:",
|
||||
"Remote Development…": "遠端開發…",
|
||||
"Opens a project folder on an SSH host; the IDE backend runs on that host.": "開啟 SSH 主機上的專案資料夾;IDE 後端在該主機上執行。",
|
||||
"Disconnect from Remote Host": "斷開與遠端主機的連線",
|
||||
"Reload Environment": "重新載入環境",
|
||||
"Reads the login shell's environment (and devcontainer.json remoteEnv on a remote host) again for new terminals and processes.": "為新的終端機和處理程序重新讀取登入 shell 的環境(遠端主機上還包括 devcontainer.json 的 remoteEnv)。",
|
||||
|
||||
@@ -6418,7 +6418,6 @@
|
||||
"No SSH configurations": "没有 SSH 配置",
|
||||
"Project directory:": "项目目录:",
|
||||
"Remote Development…": "远程开发…",
|
||||
"Opens a project folder on an SSH host; the IDE backend runs on that host.": "打开 SSH 主机上的项目文件夹;IDE 后端在该主机上运行。",
|
||||
"Disconnect from Remote Host": "断开与远程主机的连接",
|
||||
"Reload Environment": "重新加载环境",
|
||||
"Reads the login shell's environment (and devcontainer.json remoteEnv on a remote host) again for new terminals and processes.": "为新的终端和进程重新读取登录 shell 的环境(远程主机上还包括 devcontainer.json 的 remoteEnv)。",
|
||||
@@ -8522,6 +8521,15 @@
|
||||
"Command-line tool": "命令行工具",
|
||||
"Could not reopen the project in a container": "无法在容器中重新打开项目",
|
||||
"Reopen in Container": "在容器中重新打开",
|
||||
"Dev Container": "开发容器",
|
||||
"Select a local project folder to build or start its dev container.": "选择本地项目文件夹以构建或启动其开发容器。",
|
||||
"Dev container configuration:": "开发容器配置:",
|
||||
"Dev container configuration": "开发容器配置",
|
||||
"Enter an absolute folder path.": "请输入文件夹的绝对路径。",
|
||||
"No dev container configuration found in this folder.": "此文件夹中未找到开发容器配置。",
|
||||
"This file configures a dev container.": "此文件用于配置开发容器。",
|
||||
"Dev container configuration detected": "检测到开发容器配置",
|
||||
"Opens a project on an SSH host, in WSL, or in a dev container.": "打开 SSH 主机、WSL 或开发容器中的项目。",
|
||||
"Builds or starts the project's dev container (devcontainer.json) with the Dev Containers CLI and opens the project in it.": "使用 Dev Containers CLI 构建或启动项目的开发容器(devcontainer.json),并在其中打开项目。",
|
||||
"Read-only: the table schema could not be identified in the result database.": "只读:无法确定结果所在数据库中的表架构。",
|
||||
"devcontainer up exited with {status}": "devcontainer up 已退出,状态为 {status}",
|
||||
|
||||
@@ -2,10 +2,10 @@ import { IpcError } from "./ipc";
|
||||
|
||||
export type ProjectTrustScope = "current" | "local";
|
||||
|
||||
let prompt: ((path: string, scope: ProjectTrustScope) => Promise<boolean>) | null = null;
|
||||
let prompt: ((path: string, scope: ProjectTrustScope, requireTrust: boolean) => Promise<boolean>) | null = null;
|
||||
|
||||
export function provideProjectTrustPrompt(
|
||||
value: (path: string, scope: ProjectTrustScope) => Promise<boolean>,
|
||||
value: (path: string, scope: ProjectTrustScope, requireTrust: boolean) => Promise<boolean>,
|
||||
): () => void {
|
||||
prompt = value;
|
||||
return () => {
|
||||
@@ -13,8 +13,12 @@ export function provideProjectTrustPrompt(
|
||||
};
|
||||
}
|
||||
|
||||
export async function confirmProjectTrust(path: string, scope: ProjectTrustScope = "current"): Promise<void> {
|
||||
if (prompt && !(await prompt(path, scope))) {
|
||||
export async function confirmProjectTrust(
|
||||
path: string,
|
||||
scope: ProjectTrustScope = "current",
|
||||
requireTrust = false,
|
||||
): Promise<void> {
|
||||
if (prompt && !(await prompt(path, scope, requireTrust))) {
|
||||
throw new IpcError({ kind: "cancelled", message: "Project opening cancelled" });
|
||||
}
|
||||
}
|
||||
@@ -573,6 +573,9 @@ describe("Don't Show Again", () => {
|
||||
"Don't Show Again",
|
||||
]);
|
||||
expect(notificationActions({ ...base, level: "error", group: "vcs" })).toEqual([]);
|
||||
expect(
|
||||
notificationActions({ ...base, level: "info", group: "vcs", actions: own, suppressGroupAction: false }),
|
||||
).toEqual(own);
|
||||
useProject.setState({ settings: { notifications: { groups: { vcs: { display: "none" } } } } as never });
|
||||
try {
|
||||
expect(canSuppress({ level: "warning", group: "vcs" })).toBe(false);
|
||||
|
||||
@@ -961,6 +961,8 @@ export interface NotificationService {
|
||||
actions?: Array<{ label: string; run: () => void }>;
|
||||
/** Keep the balloon until dismissed (errors are sticky by default). */
|
||||
sticky?: boolean;
|
||||
/** Set to false when the notification provides its own dismissal preference. */
|
||||
suppressGroupAction?: boolean;
|
||||
/** Replaces an earlier notification with the same key. */
|
||||
key?: string;
|
||||
/** Title, body and action labels come from outside the IDE (a plugin) and are shown as written. */
|
||||
|
||||
@@ -23,6 +23,7 @@ export interface IdeNotification {
|
||||
/** Currently shown as a balloon. */
|
||||
balloon: boolean;
|
||||
sticky: boolean;
|
||||
suppressGroupAction?: boolean;
|
||||
group: string;
|
||||
/** Listed in the Notifications tool window (the group's "Show in tool window"). */
|
||||
logged: boolean;
|
||||
@@ -60,8 +61,8 @@ export function notificationPrefs(group: string): NotificationPrefs {
|
||||
}
|
||||
|
||||
/** Errors always show; other notifications offer "Don't Show Again" for their group. */
|
||||
export function canSuppress(n: Pick<IdeNotification, "level" | "group">): boolean {
|
||||
return n.level !== "error" && notificationPrefs(n.group).display !== "none";
|
||||
export function canSuppress(n: Pick<IdeNotification, "level" | "group" | "suppressGroupAction">): boolean {
|
||||
return n.suppressGroupAction !== false && n.level !== "error" && notificationPrefs(n.group).display !== "none";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,6 +195,7 @@ export function notify(n: Parameters<NotificationService["notify"]>[0]): number
|
||||
read: false,
|
||||
balloon,
|
||||
sticky,
|
||||
suppressGroupAction: n.suppressGroupAction,
|
||||
group,
|
||||
logged: prefs.log,
|
||||
};
|
||||
|
||||
Reference in new issue
Заблокувати користувача