feat(remote): Reload the environment and apply devcontainer settings on the remote server (#183)

The remote server read the login shell's PATH once and cached it, had no project-level environment, and changed environment variables only took effect after reinstalling or a manual restart.

- Every openidea-server start re-reads the remote login shell's full environment (`$SHELL -ilc env -0`), with the cached PATH only as a fallback when the shell doesn't answer.
- A project's `.devcontainer/devcontainer.json` (or `.devcontainer.json`) applies on remote hosts: `remoteEnv` (with `${localEnv|containerEnv|env:X[:default]}`, workspace variables and `null` to unset) reaches every child process through one environment overlay (terminals, run configurations, language servers, debuggers, build tools, git), and `postStartCommand` (string, array or parallel object) runs once per server start in the project root as a cancellable background task; a failure raises a notification with the exit code and the last output lines without blocking the project.
- Reload Environment (`remote.reloadEnvironment`, File menu and Find Action) re-resolves the login shell and `remoteEnv` without restarting the server, starting from the process's original environment so prepended PATH entries don't pile up; it lists the changed variables, notes that running processes keep their environment, and offers to restart language servers.
- The JSONC reader moves to `ide_core::jsonc` and is shared with ide-run.

Claude-Session: https://claude.ai/code/session_01Dq6jQQn8ZhRfkkyj3PRutA
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-10-29 09:28:18 +08:00
1 джерело b6a371559a
коміт 1f9be73174
28 files changed
+1527 -123

No files matched your search

+14
Переглянути файл
@@ -0,0 +1,14 @@
//! IPC commands of `ide_host::ops::env` (the shared implementation).
use crate::state::AppState;
use ide_core::IdeResult;
use ide_host::environment::EnvReloaded;
use tauri::{State, Window};
/// Reload Environment: new child processes get the login shell's current environment
/// (and the project's `remoteEnv` on a remote host); running ones keep theirs.
#[tauri::command]
#[specta::specta]
pub async fn env_reload(window: Window, state: State<'_, AppState>) -> IdeResult<EnvReloaded> {
ide_host::ops::env::reload(&state.host, window.label()).await
}
+2
Переглянути файл
@@ -19,6 +19,7 @@ pub mod debug;
pub mod deploy;
pub mod doc;
pub mod docker;
pub mod env;
pub mod fs;
pub mod github;
pub mod history;
@@ -423,6 +424,7 @@ pub fn builder() -> tauri_specta::Builder<tauri::Wry> {
crate::remote_dev::remote_current,
crate::remote_dev::remote_disconnect,
crate::remote_dev::remote_invoke,
env::env_reload,
db::db_test,
db::db_connected,
db::db_connect,
+1
Переглянути файл
@@ -219,6 +219,7 @@ pub fn spec(os: Os) -> Vec<Entry> {
SEP,
act("remote.connect", "Remote Development…"),
act("remote.disconnect", "Disconnect from Remote Host"),
act("remote.reloadEnvironment", "Reload Environment"),
SEP,
act("file.save", "Save All"),
act("file.reloadAllFromDisk", "Reload All from Disk"),
+1
Переглянути файл
@@ -84,6 +84,7 @@ impl AppState {
}),
owner: Self::owner_window,
runtime: tauri::async_runtime::handle().inner().clone(),
project_environment: false,
}));
Ok(Self {
recent: RecentProjects::load(&config_dir),