From 18e16e76a409a03c59b96ab03f53ba747929d1bd Mon Sep 17 00:00:00 2001 From: arookieofc <2128194521@qq.com> Date: Tue, 3 Nov 2026 14:50:49 +0800 Subject: [PATCH] fix(desktop): pass the real window label to project-requiring commands (#960) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Interpreter (creating a virtualenv), the Python packages list and pip install/uninstall, Settings › Git › Test, JVM listen-mode debugging and Create Patch › Save to file failed with "no project is open in this window", or ran without the project. Their commands passed an empty window label to ops that resolve the calling window's project. They now pass the real window label, as the other project-scoped commands do. A sweep of every command that passes an empty label found exactly these seven ops using it: `sdk_locate_tools`, `sdk_python_create_venv`, `sdk_python_packages`, `sdk_python_pip`, `vcs_git_version`, `debug_listen_for_jvm` and `vcs_write_patch`. Without the window, the last one skipped the project's disk sync, so a patch saved inside the project showed up as an external change. Fixes #955. Co-authored-by: a-rookie-of-C-language <186315048+a-rookie-of-C-language@users.noreply.github.com> --- src-tauri/src/commands/debug.rs | 3 ++- src-tauri/src/commands/sdk.rs | 13 +++++++++---- src-tauri/src/commands/vcs.rs | 13 +++++++++---- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src-tauri/src/commands/debug.rs b/src-tauri/src/commands/debug.rs index d9cffa65e..eb2134609 100644 --- a/src-tauri/src/commands/debug.rs +++ b/src-tauri/src/commands/debug.rs @@ -261,12 +261,13 @@ pub async fn debug_attachable_processes(state: State<'_, AppState>) -> IdeResult #[tauri::command] #[specta::specta] pub async fn debug_listen_for_jvm( + window: Window, state: State<'_, AppState>, request: ide_core::RequestId, host: String, port: u16, ) -> IdeResult { - ide_host::ops::debug::debug_listen_for_jvm(&state.host, "", request, host, port).await + ide_host::ops::debug::debug_listen_for_jvm(&state.host, window.label(), request, host, port).await } /// HotSwap (Reload Changed Classes) in a java-debug session. diff --git a/src-tauri/src/commands/sdk.rs b/src-tauri/src/commands/sdk.rs index 92a8ea471..050c2c101 100644 --- a/src-tauri/src/commands/sdk.rs +++ b/src-tauri/src/commands/sdk.rs @@ -39,17 +39,19 @@ pub async fn sdk_project_libraries( #[tauri::command] #[specta::specta] pub async fn sdk_locate_tools( + window: Window, state: State<'_, AppState>, names: Vec, near: Option, ) -> IdeResult { - ide_host::ops::sdk::sdk_locate_tools(&state.host, "", names, near).await + ide_host::ops::sdk::sdk_locate_tools(&state.host, window.label(), names, near).await } /// `base -m venv location`; output lines stream through `on_output`. #[tauri::command] #[specta::specta] pub async fn sdk_python_create_venv( + window: Window, state: State<'_, AppState>, base: PathBuf, location: PathBuf, @@ -58,7 +60,7 @@ pub async fn sdk_python_create_venv( ) -> IdeResult { ide_host::ops::sdk::sdk_python_create_venv( &state.host, - "", + window.label(), base, location, request, @@ -70,17 +72,20 @@ pub async fn sdk_python_create_venv( #[tauri::command] #[specta::specta] pub async fn sdk_python_packages( + window: Window, state: State<'_, AppState>, python: PathBuf, request: RequestId, ) -> IdeResult> { - ide_host::ops::sdk::sdk_python_packages(&state.host, "", python, request).await + ide_host::ops::sdk::sdk_python_packages(&state.host, window.label(), python, request).await } /// Installs (`uninstall = false`) or removes a package; output streams through `on_output`. #[tauri::command] #[specta::specta] +#[allow(clippy::too_many_arguments)] pub async fn sdk_python_pip( + window: Window, state: State<'_, AppState>, python: PathBuf, requirement: String, @@ -91,7 +96,7 @@ pub async fn sdk_python_pip( ) -> IdeResult<()> { ide_host::ops::sdk::sdk_python_pip( &state.host, - "", + window.label(), python, requirement, uninstall, diff --git a/src-tauri/src/commands/vcs.rs b/src-tauri/src/commands/vcs.rs index 305fd0e8c..0e06e2f5e 100644 --- a/src-tauri/src/commands/vcs.rs +++ b/src-tauri/src/commands/vcs.rs @@ -371,8 +371,8 @@ pub async fn vcs_init(state: State<'_, AppState>, dir: PathBuf) -> IdeResult<()> /// executable when `path` is empty. #[tauri::command] #[specta::specta] -pub async fn vcs_git_version(state: State<'_, AppState>, path: String) -> IdeResult { - ide_host::ops::vcs::vcs_git_version(&state.host, "", path).await +pub async fn vcs_git_version(window: Window, state: State<'_, AppState>, path: String) -> IdeResult { + ide_host::ops::vcs::vcs_git_version(&state.host, window.label(), path).await } /// The auto-detected git executable (shown as the field's placeholder). @@ -656,8 +656,13 @@ pub fn vcs_changelists_save(window: Window, state: State<'_, AppState>, changeli /// Create Patch › Save to file. #[tauri::command] #[specta::specta] -pub async fn vcs_write_patch(state: State<'_, AppState>, path: PathBuf, patch: String) -> IdeResult<()> { - ide_host::ops::vcs::vcs_write_patch(&state.host, "", path, patch).await +pub async fn vcs_write_patch( + window: Window, + state: State<'_, AppState>, + path: PathBuf, + patch: String, +) -> IdeResult<()> { + ide_host::ops::vcs::vcs_write_patch(&state.host, window.label(), path, patch).await } #[tauri::command]