mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-24 16:04:21 +00:00
Refs #1083 (step B). A local project with a devcontainer.json can be reopened in its dev container (File › Reopen in Container, Find Action): the Dev Containers CLI brings the container up and the window connects to openidea-server inside it, as for WSL, so terminal, language servers, run, debug and git work in the container. The project's identity stays the local folder, so reopening from Recent Projects finds the same container. Missing CLI gives install guidance; trust of the local project carries over. Pure CLI output parsing lives in ide-remote; a failed connection no longer closes the current backend early, saved locations keep the container configuration, and Docker context precedence follows the CLI. Co-authored-by: andreabasile <7715018+andreabasile@users.noreply.github.com>
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
/** Reopen in Container: the local project's dev container, opened as a remote project. */
|
|
import { tx } from "@/platform/i18n";
|
|
import { isCancelled } from "@/platform/ipc";
|
|
import { useProject } from "@/platform/project";
|
|
import { isRemoteWindow } from "@/platform/remote";
|
|
import { notifications } from "@/workbench/contributions";
|
|
import { openRemoteProject } from "@/workbench/projectWindow";
|
|
|
|
/**
|
|
* 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> {
|
|
const project = useProject.getState().project;
|
|
if (!project || isRemoteWindow()) return;
|
|
try {
|
|
await openRemoteProject({ kind: "devContainer", folder: project.root, config: "" }, project.root);
|
|
} catch (e) {
|
|
if (isCancelled(e)) return;
|
|
notifications().notify({
|
|
group: "remote",
|
|
level: "error",
|
|
title: tx("Could not reopen the project in a container"),
|
|
body: e instanceof Error ? e.message : String(e),
|
|
});
|
|
}
|
|
}
|