diff --git a/crates/ide-host/src/plugins/api.rs b/crates/ide-host/src/plugins/api.rs index fd151a4994..608a469017 100644 --- a/crates/ide-host/src/plugins/api.rs +++ b/crates/ide-host/src/plugins/api.rs @@ -161,6 +161,10 @@ pub trait PluginWorkspace: Send + Sync { fn repositories(&self, _root: &Path) -> Result { Err(HostError::NotFound("no open project repositories".into())) } + /// The invoking window's project, mapped Git roots, and project-close token. + fn git_comparison_project(&self, _window: &str) -> Result<(PathBuf, ide_vcs::Repos, CancellationToken), HostError> { + Err(HostError::NotFound("no open project repositories".into())) + } /// The git executable of the project at `root` (see [`crate::Project::git_executable`]). fn git_executable(&self, _root: &Path) -> Option { None @@ -1364,6 +1368,14 @@ impl PluginApi { self.pkg.id() } + fn project_view_pane(&self, view: &str, allow_project: bool) -> Result<(), HostError> { + let panes = self.shared.ui.items(super::ui_points::PROJECT_VIEW_PANES, Some(self.id())); + if (allow_project && view == "project" && !panes.is_empty()) || panes.iter().any(|pane| pane.key == view) { + return Ok(()); + } + Err(HostError::NotFound(format!("the plugin declares no project view pane {view:?}"))) + } + /// The storage directory, after moving a `storage.json` written by an /// older version into it. fn storage(&self) -> Result { @@ -2278,6 +2290,15 @@ impl HostApi for PluginApi { self.shared.sink.emit(Some(client), PluginEvent::OpenDiff { plugin_id: self.id().into(), diff, file_name }); Ok(()) } + fn open_revision_comparison( + &self, + invocation: &ide_plugin::Invocation, + comparison: ide_plugin::RevisionComparison, + cancel: &CancellationToken, + timeout: Duration, + ) -> Result<(), HostError> { + self.open_git_comparison(invocation, comparison, cancel, timeout) + } fn reply_content_tab( &self, client: &str, @@ -3963,6 +3984,50 @@ impl HostApi for PluginApi { .emit(None, PluginEvent::ViewChanged { plugin_id: self.id().to_owned(), view: view.to_owned() }); } + fn refresh_project_view( + &self, + client: Option<&str>, + root: Option<&Path>, + view: &str, + directory: Option, + ) -> Result<(), HostError> { + self.project_view_pane(view, false)?; + let directory = directory + .map(|directory| { + let root = root.ok_or_else(|| HostError::NotFound("the invoking project is closed".into()))?; + let path = super::project_view::resolve_path(root, &directory)?; + if !path.is_dir() { + return Err(HostError::Invalid("project view refresh requires a directory".into())); + } + Ok(path.into()) + }) + .transpose()?; + self.shared.sink.emit( + client, + PluginEvent::ProjectViewRefresh { plugin_id: self.id().into(), view_id: view.into(), directory }, + ); + Ok(()) + } + + fn select_in_project_view(&self, client: &str, view: &str, path: String, focus: bool) -> Result<(), HostError> { + self.project_view_pane(view, true)?; + let root = self + .shared + .project_of(client) + .ok_or_else(|| HostError::NotFound("the window's project is closed".into()))?; + let path = super::project_view::resolve_path(&root, &path)?; + self.shared.sink.emit( + Some(client), + PluginEvent::ProjectViewSelect { + plugin_id: self.id().into(), + view_id: view.into(), + path: path.into(), + focus, + }, + ); + Ok(()) + } + fn post_view_message(&self, view: &str, message: String) -> Result<(), HostError> { let declared = super::ui_points::WEB_POINTS .iter() @@ -4561,6 +4626,18 @@ impl PluginWorkspace for HostWorkspace { .repos()) } + fn git_comparison_project(&self, window: &str) -> Result<(PathBuf, ide_vcs::Repos, CancellationToken), HostError> { + let host = self.0.upgrade().ok_or(HostError::Cancelled)?; + let project = host.project(window).map_err(|error| HostError::NotFound(error.message))?; + if !project.is_trusted() { + return Err(HostError::Denied("the project is not trusted".into())); + } + if !project.git_enabled() { + return Err(HostError::NotFound("Git integration is disabled".into())); + } + Ok((project.root.clone(), project.repos(), project.closed.clone())) + } + fn git_executable(&self, root: &Path) -> Option { HostWorkspace::project_covering(self, root)?.git_executable() } diff --git a/crates/ide-host/src/plugins/commands.rs b/crates/ide-host/src/plugins/commands.rs index 9cf3de6b14..635edbf8ab 100644 --- a/crates/ide-host/src/plugins/commands.rs +++ b/crates/ide-host/src/plugins/commands.rs @@ -9,7 +9,7 @@ use crate::Host; use crate::ops::blocking; use ide_command::command; use ide_core::{DocId, IdeError, IdeResult, Range, RequestId}; -use ide_plugin::{Invocation, ProviderDocument, SyntaxDecorationBatch, SyntaxNodeSnapshot}; +use ide_plugin::{GitActionContext, Invocation, ProviderDocument, SyntaxDecorationBatch, SyntaxNodeSnapshot}; use ide_workspace::settings::SettingsScope; use std::collections::BTreeMap; use std::path::PathBuf; @@ -79,6 +79,7 @@ pub async fn plugin_run_command( editor: editor.map(PluginEditor::context), selected_paths: paths.unwrap_or_default(), global_settings: matches!(settings_scope, Some(SettingsScope::Global)), + git_action: None, }; let cancel = request.map(|id| host.begin_project_read_request(window, id)); let result = host @@ -92,6 +93,70 @@ pub async fn plugin_run_command( result } +/// Runs a declared Git menu command with the menu's repository and branch snapshot. +#[command(trust = trusted)] +pub async fn plugin_run_git_command( + host: &Host, + plugins: &Arc, + window: &str, + plugin_id: String, + command_id: String, + context: GitActionContext, + editor: Option, +) -> IdeResult> { + let project = host.project(window)?; + let plugins = plugins.clone(); + let invocation = Invocation { + client: Some(window.to_owned()), + workspace_root: Some(project.root.clone()), + editor: editor.map(PluginEditor::context), + ..Default::default() + }; + host.blocking(move || { + if !project.git_enabled() { + return Err(IdeError::not_found("Git integration is disabled")); + } + plugins.run_git_command(&plugin_id, &command_id, invocation, context, &project.repos()) + }) + .await +} + +/// Rearranges native children for one plugin-owned Project pane. +#[allow(clippy::too_many_arguments)] +#[command(trust = trusted)] +pub async fn plugin_project_view_modify( + host: &Host, + plugins: &Arc, + window: &str, + plugin_id: String, + view_id: String, + parent: ide_plugin::ProjectViewNativeNode, + children: Vec, + settings: String, + request: Option, +) -> IdeResult>> { + let root = host.project(window)?.root.clone(); + let invocation = Invocation { workspace_root: Some(root), client: Some(window.to_owned()), ..Default::default() }; + let input = Arc::new(super::project_view::ModifyProjectView { view: view_id, parent, children, settings }); + let plugins = plugins.clone(); + let cancel = request.map(|id| host.begin_project_read_request(window, id)).unwrap_or_default(); + let work_cancel = cancel.clone(); + let result = tokio::select! { + _ = cancel.cancelled() => Err(IdeError::cancelled()), + result = tokio::time::timeout(super::project_view::CALL_BUDGET, host.blocking(move || { + plugins.modify_project_view(&plugin_id, invocation, input, &work_cancel) + })) => match result { + Ok(result) => result, + Err(_) => Err(IdeError::new(ide_core::error::ErrorKind::TimedOut, "project view provider timed out")), + }, + }; + cancel.cancel(); + if let Some(request) = request { + host.end_request(request); + } + result +} + /// Run Anything entries of the plugin declaring `prefix` for the field's `text` (API 1.18). #[command(trust = trusted)] pub async fn plugin_run_anything_suggest( @@ -534,11 +599,13 @@ ide_command::domain!( plugin_parse_test_results, plugin_post_events, plugin_prepare_debug_run, + plugin_project_view_modify, plugin_program, plugin_run_anything_run, plugin_run_anything_suggest, plugin_run_command, plugin_run_configuration_complete, + plugin_run_git_command, plugin_run_log_tail, plugin_select_tests, plugin_set_active_file, diff --git a/crates/ide-host/src/plugins/execution.rs b/crates/ide-host/src/plugins/execution.rs index eed7bcb781..56f4dfda0c 100644 --- a/crates/ide-host/src/plugins/execution.rs +++ b/crates/ide-host/src/plugins/execution.rs @@ -246,13 +246,24 @@ impl PluginApi { request: WindowRequest, cancel: &CancellationToken, timeout: Duration, + ) -> Result, HostError> { + self.window_request_until(client, request, cancel, timeout, || false) + } + + pub(super) fn window_request_until( + &self, + client: &str, + request: WindowRequest, + cancel: &CancellationToken, + timeout: Duration, + project_closed: impl Fn() -> bool, ) -> Result, HostError> { let id = self.shared.next_prompt.fetch_add(1, Ordering::Relaxed); let (tx, rx) = std::sync::mpsc::sync_channel(1); { let closed = self.shared.closed_clients.lock(); let blocked = self.shared.prompts_blocked.lock(); - if closed.contains(client) || blocked.contains(self.pkg.id()) { + if closed.contains(client) || blocked.contains(self.pkg.id()) || project_closed() { return Err(HostError::Cancelled); } self.shared.prompts.lock().insert( @@ -266,7 +277,12 @@ impl PluginApi { ); let deadline = Instant::now() + timeout; loop { - match rx.recv_timeout(Duration::from_millis(20)) { + let answer = rx.recv_timeout(Duration::from_millis(20)); + if project_closed() { + self.shared.prompts.lock().remove(&id); + return Err(HostError::Cancelled); + } + match answer { Ok(CommandAnswer::Value(value)) => return Ok(value), Ok(CommandAnswer::NotFound) => return Err(HostError::NotFound("window service unavailable".into())), Ok(CommandAnswer::Failed(error)) => return Err(HostError::Failed(error)), diff --git a/crates/ide-host/src/plugins/git_actions.rs b/crates/ide-host/src/plugins/git_actions.rs new file mode 100644 index 0000000000..9da60d0bf0 --- /dev/null +++ b/crates/ide-host/src/plugins/git_actions.rs @@ -0,0 +1,313 @@ +//! Git context menu invocations and native revision comparisons for plugins. + +use super::api::PluginApi; +use super::ui_points::{GIT_BRANCH_CONTEXT_MENU, GIT_BRANCHES_POPUP_MENU, MENUS}; +use super::{PluginHost, WindowRequest}; +use ide_core::{CancellationToken, IdeError, IdeResult, ipc_path::to_ipc}; +use ide_plugin::{GitActionBranch, GitActionContext, HostError, Invocation, RevisionComparison}; +use ide_vcs::{Repo, Repos}; +use std::{collections::HashSet, path::Path, time::Duration}; + +fn repository<'a>(repos: &'a Repos, path: &str) -> Option<&'a Repo> { + let path = Path::new(path); + if !path.is_absolute() { + return None; + } + repos.at_root(path).filter(|repo| !repo.is_stale()).map(AsRef::as_ref) +} + +fn valid_branch(branch: &GitActionBranch) -> bool { + let namespace = if branch.remote { "refs/remotes/" } else { "refs/heads/" }; + !branch.name.is_empty() + && branch.full_ref.len() <= 4096 + && branch.full_ref.strip_prefix(namespace) == Some(branch.name.as_str()) + && ide_vcs::is_valid_reference_name(&branch.full_ref) +} + +fn validated_context(mut context: GitActionContext, repos: &Repos) -> IdeResult { + if context.repositories.is_empty() || context.branch.as_ref().is_some_and(|branch| !valid_branch(branch)) { + return Err(IdeError::invalid("invalid Git menu context")); + } + let mut seen = HashSet::new(); + let mut repositories = Vec::with_capacity(context.repositories.len()); + for path in &context.repositories { + let repo = + repository(repos, path).ok_or_else(|| IdeError::not_found("Git repository is outside this project"))?; + let root = to_ipc(repo.root()); + if seen.insert(root.clone()) { + repositories.push(root); + } + } + context.repositories = repositories; + Ok(context) +} + +impl PluginHost { + pub(super) fn run_git_command( + &self, + plugin: &str, + command: &str, + mut invocation: Invocation, + context: GitActionContext, + repos: &Repos, + ) -> IdeResult> { + let menu = if context.branch.is_some() { GIT_BRANCH_CONTEXT_MENU } else { GIT_BRANCHES_POPUP_MENU }; + let key = format!("{menu}/{command}"); + if !self.ui.items(MENUS, Some(plugin)).iter().any(|item| item.key == key) { + return Err(IdeError::not_found("the plugin does not declare this Git menu command")); + } + invocation.git_action = Some(validated_context(context, repos)?); + self.run_command(plugin, command, None, invocation) + } +} + +fn validated_comparison(mut comparison: RevisionComparison, repos: &Repos) -> Result { + for id in [&mut comparison.left, &mut comparison.right] { + if !ide_vcs::is_full_commit_id(id) { + return Err(HostError::Invalid("expected full Git commit object IDs".into())); + } + id.make_ascii_lowercase(); + } + for label in [&comparison.left_label, &comparison.right_label].into_iter().flatten() { + super::execution::label(label, 256)?; + } + let repo = repository(repos, &comparison.repository) + .ok_or_else(|| HostError::NotFound("Git repository is outside this project".into()))?; + for id in [&comparison.left, &comparison.right] { + if !repo.contains_commit_id(id).map_err(|error| HostError::Failed(error.message))? { + return Err(HostError::NotFound(format!("commit {id} is not in this repository"))); + } + } + comparison.repository = to_ipc(repo.root()); + Ok(comparison) +} + +impl PluginApi { + pub(super) fn open_git_comparison( + &self, + invocation: &Invocation, + comparison: RevisionComparison, + cancel: &CancellationToken, + timeout: Duration, + ) -> Result<(), HostError> { + let workspace = self.shared.workspace().ok_or_else(|| HostError::NotFound("window project".into()))?; + let client = invocation.client.as_deref().ok_or_else(|| HostError::NotFound("invoking window".into()))?; + let (root, repos, closed) = workspace.git_comparison_project(client)?; + // The window has opened another project since the plugin was invoked. + if invocation.workspace_root.as_deref() != Some(&root) { + return Err(HostError::Cancelled); + } + let comparison = validated_comparison(comparison, &repos)?; + let request = WindowRequest::RevisionComparison { comparison, project: to_ipc(&root) }; + self.window_request_until(client, request, cancel, timeout, || { + closed.is_cancelled() || workspace.project_of(client).as_deref() != Some(&root) + }) + .map(|_| ()) + } +} + +#[cfg(test)] +mod tests { + use super::*; + use crate::plugins::{CommandAnswer, HostWorkspace, PluginEvent, PluginWorkspace}; + use std::sync::Arc; + + fn git(root: &Path, args: &[&str]) -> String { + let output = std::process::Command::new("git").current_dir(root).args(args).output().unwrap(); + assert!(output.status.success(), "{}", String::from_utf8_lossy(&output.stderr)); + String::from_utf8(output.stdout).unwrap().trim().into() + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn git_comparison_opens_in_the_invoking_window() { + let temp = tempfile::tempdir().unwrap(); + let root = temp.path().join("project"); + std::fs::create_dir(&root).unwrap(); + ide_vcs::init(&root).unwrap(); + for subject in ["first", "second"] { + git( + &root, + &[ + "-c", + "user.name=Test", + "-c", + "user.email=test@example.com", + "-c", + "commit.gpgsign=false", + "commit", + "--allow-empty", + "-qm", + subject, + ], + ); + } + let left = git(&root, &["rev-parse", "HEAD~1"]); + let right = git(&root, &["rev-parse", "HEAD"]); + let host = Arc::new(crate::Host::new(crate::HostConfig::for_test(temp.path()))); + host.trust.decide(&root, true, false).unwrap(); + let project = host.open_project("main", &root).unwrap(); + project.refresh_repositories(); + let (tx, rx) = std::sync::mpsc::channel(); + let plugins = PluginHost::new( + temp.path().join("plugins"), + Arc::new(move |client: Option<&str>, event| { + if let PluginEvent::WindowRequest { request_id, request, .. } = event { + tx.send((client.map(str::to_owned), request_id, request)).unwrap(); + } + }), + ide_plugin::Limits::default(), + ) + .unwrap(); + plugins.set_workspace(Some(Arc::new(HostWorkspace(Arc::downgrade(&host))))); + let manifest = ide_extension::Manifest::parse( + "id = \"test\"\nname = \"Test\"\nversion = \"1.0.0\"\nengines.openidea = \"^1.21\"\n", + ) + .unwrap(); + let api = + PluginApi { pkg: ide_extension::Package::new(manifest, root.clone()), shared: plugins.shared.clone() }; + let canonical_root = to_ipc(project.repos().primary().unwrap().root()); + let invocation = Invocation { + client: Some("main".into()), + workspace_root: Some(project.root.clone()), + ..Default::default() + }; + let comparison = RevisionComparison { + repository: to_ipc(&root.join(".")), + left: left.to_ascii_uppercase(), + right: right.clone(), + left_label: Some("Base".into()), + right_label: None, + }; + for answer in [CommandAnswer::Value(None), CommandAnswer::Failed("compare tool unavailable".into())] { + std::thread::scope(|scope| { + let request = comparison.clone(); + let api = &api; + let invocation = &invocation; + let result = scope.spawn(move || { + api.open_git_comparison(invocation, request, &CancellationToken::new(), Duration::from_secs(10)) + }); + let (client, id, request) = rx.recv_timeout(Duration::from_secs(2)).unwrap(); + assert_eq!(client.as_deref(), Some("main")); + assert_eq!( + request, + WindowRequest::RevisionComparison { + comparison: RevisionComparison { + repository: canonical_root.clone(), + left: left.clone(), + ..comparison.clone() + }, + project: to_ipc(&project.root), + }, + ); + assert!(!result.is_finished()); + assert!(!plugins.answer_command("other", &id, CommandAnswer::Value(None))); + let expected = match &answer { + CommandAnswer::Failed(error) => Err(HostError::Failed(error.clone())), + _ => Ok(()), + }; + assert!(plugins.answer_command("main", &id, answer)); + assert_eq!(result.join().unwrap(), expected); + }); + } + // The window has switched projects since the plugin was invoked. + let stale_invocation = Invocation { workspace_root: Some(temp.path().join("previous")), ..invocation.clone() }; + assert!(matches!( + api.open_git_comparison(&stale_invocation, comparison.clone(), &CancellationToken::new(), Duration::ZERO), + Err(HostError::Cancelled) + )); + assert!(rx.try_recv().is_err()); + // Closing the project ends a request the window has not answered yet. + std::thread::scope(|scope| { + let (api, invocation, comparison) = (&api, &invocation, &comparison); + let waiting = scope.spawn(move || { + api.open_git_comparison( + invocation, + comparison.clone(), + &CancellationToken::new(), + Duration::from_secs(30), + ) + }); + let (_, id, _) = rx.recv_timeout(Duration::from_secs(10)).unwrap(); + host.close_project("main"); + let deadline = std::time::Instant::now() + Duration::from_secs(2); + while !waiting.is_finished() && std::time::Instant::now() < deadline { + std::thread::sleep(Duration::from_millis(5)); + } + assert!(waiting.is_finished()); + assert_eq!(waiting.join().unwrap(), Err(HostError::Cancelled)); + assert!(!plugins.answer_command("main", &id, CommandAnswer::Value(None))); + }); + assert!(matches!( + api.open_git_comparison(&invocation, comparison, &CancellationToken::new(), Duration::ZERO), + Err(HostError::NotFound(_)) + )); + assert!(rx.try_recv().is_err()); + } + + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] + async fn git_comparison_repositories_follow_the_invoking_window_for_a_shared_member() { + let temp = tempfile::tempdir().unwrap(); + let project = temp.path().join("project"); + let member = temp.path().join("member"); + let host = Arc::new(crate::Host::new(crate::HostConfig::for_test(temp.path()))); + for root in [&project, &member] { + std::fs::create_dir(root).unwrap(); + ide_vcs::init(root).unwrap(); + host.trust.decide(root, true, false).unwrap(); + } + host.open_project("group", &project).unwrap(); + crate::ops::project::attach_workspace(&host, "group", &member).unwrap(); + host.open_project("direct", &member).unwrap(); + let workspace = HostWorkspace(Arc::downgrade(&host)); + let (_, group, _) = workspace.git_comparison_project("group").unwrap(); + let (_, direct, _) = workspace.git_comparison_project("direct").unwrap(); + assert!(group.at_root(&project).is_some()); + assert!(group.at_root(&member).is_some()); + assert!(direct.at_root(&member).is_some()); + assert!(direct.at_root(&project).is_none()); + host.close_project("direct"); + assert!(matches!(workspace.git_comparison_project("direct"), Err(HostError::NotFound(_)))); + } + + #[test] + fn git_action_context_keeps_the_full_ref_and_known_roots() { + let project = tempfile::tempdir().unwrap(); + let outside = tempfile::tempdir().unwrap(); + ide_vcs::init(project.path()).unwrap(); + ide_vcs::init(outside.path()).unwrap(); + let repos = Repos::discover(project.path(), &|_| false).unwrap(); + let root = to_ipc(repos.primary().unwrap().root()); + let mut context = GitActionContext { + repositories: vec![root.clone(), root.clone()], + branch: Some(GitActionBranch { + name: "origin/release".into(), + full_ref: "refs/remotes/origin/release".into(), + remote: true, + }), + }; + let checked = validated_context(context.clone(), &repos).unwrap(); + assert_eq!(checked.repositories, [root]); + assert_eq!(checked.branch, context.branch); + context.branch.as_mut().unwrap().full_ref = "refs/heads/origin/release".into(); + assert!(validated_context(context, &repos).is_err()); + let other = GitActionContext { repositories: vec![to_ipc(outside.path())], branch: None }; + assert!(validated_context(other, &repos).is_err()); + } + + #[test] + fn git_comparisons_reject_refs_and_missing_objects() { + let project = tempfile::tempdir().unwrap(); + ide_vcs::init(project.path()).unwrap(); + let repos = Repos::discover(project.path(), &|_| false).unwrap(); + let mut comparison = RevisionComparison { + repository: to_ipc(repos.primary().unwrap().root()), + left: "HEAD~1".into(), + right: "b".repeat(40), + left_label: None, + right_label: None, + }; + assert!(matches!(validated_comparison(comparison.clone(), &repos), Err(HostError::Invalid(_)))); + comparison.left = "a".repeat(40); + assert!(matches!(validated_comparison(comparison, &repos), Err(HostError::NotFound(_)))); + } +} diff --git a/crates/ide-host/src/plugins/index_ops.rs b/crates/ide-host/src/plugins/index_ops.rs index 10e4593d27..2e6eb83b47 100644 --- a/crates/ide-host/src/plugins/index_ops.rs +++ b/crates/ide-host/src/plugins/index_ops.rs @@ -199,6 +199,7 @@ pub async fn plugin_navigation_index( editor: None, selected_paths: Vec::new(), global_settings: false, + git_action: None, }, Some(&cancel), ) { diff --git a/crates/ide-host/src/plugins/mod.rs b/crates/ide-host/src/plugins/mod.rs index 477fdf43b2..5c8f971d48 100644 --- a/crates/ide-host/src/plugins/mod.rs +++ b/crates/ide-host/src/plugins/mod.rs @@ -32,6 +32,7 @@ mod event_wake; mod execution; mod external_watch; mod files_changed; +mod git_actions; mod hover; mod http_stream; mod icon_extensions; @@ -52,6 +53,7 @@ mod mcp; pub mod navigation; mod network_inbox; mod points; +mod project_view; mod providers; pub mod remote; pub mod remote_host; @@ -2653,6 +2655,7 @@ impl PluginHost { selected_paths: Vec::new(), global_settings: false, command_chain: Vec::new(), + git_action: None, }; let kinds: BTreeSet = queue.events.iter().map(WorkbenchEvent::kind).collect(); let filesystem = kinds.contains(&EventKind::FilesChanged); diff --git a/crates/ide-host/src/plugins/points.rs b/crates/ide-host/src/plugins/points.rs index 6b04ede48c..b862e986ab 100644 --- a/crates/ide-host/src/plugins/points.rs +++ b/crates/ide-host/src/plugins/points.rs @@ -96,6 +96,7 @@ pub fn register_builtin_points( registry.register(Arc::new(UiPoint::new(p::STATUS_BAR, ui.clone(), p::status_item)))?; registry.register(Arc::new(UiPoint::new(p::SETTINGS, ui.clone(), p::settings)))?; registry.register(Arc::new(UiPoint::new(p::VIEWS, ui.clone(), p::view)))?; + registry.register(Arc::new(UiPoint::new(p::PROJECT_VIEW_PANES, ui.clone(), p::project_view_pane)))?; registry.register(Arc::new(UiPoint::new(p::CUSTOM_EDITORS, ui.clone(), p::custom_editor)))?; registry.register(Arc::new(UiPoint::new(p::EDITOR_PANELS, ui.clone(), p::editor_panel)))?; registry.register(Arc::new(UiPoint::new(p::OVERLAYS, ui.clone(), p::overlay)))?; @@ -111,3 +112,63 @@ pub fn register_builtin_points( registry.register(Arc::new(UiPoint::new(ide_extension::LOCALES_POINT, ui.clone(), p::locales)))?; Ok(()) } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn registers_project_view_panes_as_native_ui_contributions() { + let registry = ExtensionRegistry::new(); + let ui = Arc::new(UiStore::default()); + register_builtin_points( + ®istry, + &ui, + &Arc::default(), + &Arc::default(), + &Arc::default(), + &Arc::default(), + &Arc::default(), + &Arc::default(), + ) + .unwrap(); + let source = r#" + id = "go-folders" + name = "Go Folder Groups" + version = "0.1.0" + engines.openidea = "^1.21" + wasm = "plugin.wasm" + [capabilities] + required = ["project.read"] + [[contributes.projectViewPanes]] + id = "grouped" + title = "Go Folder Groups" + weight = 10 + [[contributes.commands]] + id = "inspect" + title = "Inspect Node" + [[contributes.menus]] + menu = "projectView.context" + command = "inspect" + projectViewContext = true + "#; + let package = + |source: &str| Package::new(ide_extension::Manifest::parse(source).unwrap(), std::env::temp_dir()); + registry.commit(registry.prepare(&package(source)).unwrap()).unwrap(); + let panes = ui.items("projectViewPanes", Some("go-folders")); + assert_eq!(panes.len(), 1); + assert_eq!(panes[0].key, "grouped"); + assert_eq!(panes[0].decl["weight"], 10); + assert_eq!(ui.items("menus", Some("go-folders"))[0].decl["projectViewContext"], true); + + for (bad, expected) in [ + (source.replace("^1.21", "^1.20"), "1.21"), + (source.replace("wasm = \"plugin.wasm\"", ""), "wasm"), + (source.replace("required = [\"project.read\"]", ""), "project.read"), + (source.replace("projectView.context", "editor.context"), "projectViewContext"), + (format!("{source}\n[[contributes.projectViewPanes]]\nid = 'grouped'\ntitle = 'Duplicate'\n"), "duplicate"), + ] { + assert!(registry.prepare(&package(&bad)).err().unwrap().contains(expected)); + } + } +} diff --git a/crates/ide-host/src/plugins/project_view.rs b/crates/ide-host/src/plugins/project_view.rs new file mode 100644 index 0000000000..7baf0f518f --- /dev/null +++ b/crates/ide-host/src/plugins/project_view.rs @@ -0,0 +1,209 @@ +use super::{PluginHost, ui_points::PROJECT_VIEW_PANES}; +use ide_core::{CancellationToken, IdeError, IdeResult}; +use ide_extension::Capability; +use ide_plugin::{HostError, Invocation, ProjectViewNativeNode, ProjectViewNodeKind, ProjectViewProjectionNode}; +use std::path::{Component, Path, PathBuf}; +use std::sync::Arc; +use std::time::Duration; + +pub(super) const CALL_BUDGET: Duration = Duration::from_secs(2); +const GUEST_BUDGET: Duration = Duration::from_millis(300); +const MAX_CHILDREN: usize = 4096; +const MAX_PATH: usize = 16 * 1024; +const MAX_ID: usize = 16 * 1024; +const MAX_BYTES: usize = 2 * 1024 * 1024; + +pub(super) fn resolve_path(root: &Path, path: &str) -> Result { + let requested = Path::new(path); + if path.is_empty() + || path.len() > MAX_PATH + || path.contains('\0') + || requested.components().any(|part| matches!(part, Component::ParentDir)) + { + return Err(HostError::Invalid("invalid project view path".into())); + } + let native_path = |base: &Path| { + // Validate the real target but keep the alias displayed in the Project tree. + let alias: PathBuf = base.join(requested).components().collect(); + ide_plugin::resolve_in_root(base, &ide_core::ipc_path::to_ipc(&alias)).map(|_| alias) + }; + native_path(root) + .or_else(|project_error| { + crate::project::workspace_member_roots(root) + .iter() + .find_map(|member| native_path(member).ok()) + .ok_or(project_error) + }) + .map_err(HostError::Invalid) +} + +fn native_bytes(node: &ProjectViewNativeNode) -> usize { + node.id.len() + node.path.len() + node.label.len() +} + +fn valid_request(parent: &ProjectViewNativeNode, children: &[ProjectViewNativeNode], settings: &str) -> bool { + let path = Path::new(&parent.path); + let valid = |node: &ProjectViewNativeNode| { + let p = Path::new(&node.path); + !node.id.is_empty() + && node.id.len() <= MAX_ID + && node.path.len() <= MAX_PATH + && !node.path.contains('\0') + && p.is_absolute() + && p.components().all(|c| !matches!(c, Component::ParentDir)) + }; + parent.kind == ProjectViewNodeKind::Directory + && valid(parent) + && children.len() <= MAX_CHILDREN + && settings.len() <= MAX_PATH + && serde_json::from_str::(settings).is_ok_and(|v| v.is_object()) + && children.iter().all(|n| valid(n) && Path::new(&n.path) != path && Path::new(&n.path).starts_with(path)) + && native_bytes(parent) + children.iter().map(native_bytes).sum::() <= MAX_BYTES +} + +fn valid_result(nodes: &[ProjectViewProjectionNode]) -> bool { + let mut bytes = 0; + for node in nodes { + let (id, parent) = match node { + ProjectViewProjectionNode::ExistingNode { id, parent } => (id, parent), + ProjectViewProjectionNode::VirtualFolder { id, parent, label, icon } => { + if id.contains('\0') + || label.trim().is_empty() + || label.len() > 1024 + || label.chars().any(char::is_control) + || icon.as_ref().is_some_and(|icon| icon.len() > 128) + { + return false; + } + bytes += label.len() + icon.as_ref().map_or(0, String::len); + (id, parent) + } + }; + let parent_bytes = parent.as_ref().map_or(0, String::len); + if id.is_empty() || id.len() > MAX_ID || parent_bytes > MAX_ID { + return false; + } + bytes += id.len() + parent_bytes; + if bytes > MAX_BYTES { + return false; + } + } + true +} + +pub(super) struct ModifyProjectView { + pub view: String, + pub parent: ProjectViewNativeNode, + pub children: Vec, + pub settings: String, +} + +impl PluginHost { + pub(super) fn modify_project_view( + self: &Arc, + plugin: &str, + invocation: Invocation, + input: Arc, + cancel: &CancellationToken, + ) -> IdeResult>> { + let loaded = self.get(plugin)?; + let Some(root) = invocation.workspace_root.as_deref() else { return Ok(None) }; + let eligible = || { + let allowed = { + let meta = loaded.meta.lock(); + meta.status.is_live() && meta.pending.is_empty() && meta.granted.contains(&Capability::ProjectRead) + }; + allowed + && loaded.dev_root.as_deref().is_none_or(|p| p == root) + && self.shared.workspace().is_some_and(|w| w.trusted(root)) + && self.ui.items(PROJECT_VIEW_PANES, Some(plugin)).iter().any(|pane| pane.key == input.view) + && self.plugins.read().get(plugin).is_some_and(|p| Arc::ptr_eq(p, &loaded)) + }; + if !valid_request(&input.parent, &input.children, &input.settings) || !eligible() { + return Ok(None); + } + if !resolve_path(root, &input.parent.path).is_ok_and(|p| p.is_dir()) { + return Ok(None); + } + let request = input.clone(); + let expected_plugin = loaded.clone(); + let dispatch_host = self.clone(); + let plugin_id = plugin.to_owned(); + let result = self.code_call_with_budget( + plugin, + invocation.clone(), + "grouping project view children", + Some(cancel), + Some(CALL_BUDGET), + move |runtime, context| { + let current = + dispatch_host.plugins.read().get(&plugin_id).is_some_and(|p| Arc::ptr_eq(p, &expected_plugin)); + if !current { + return Ok(None); + } + runtime.modify_project_view_children( + &request.view, + &request.parent, + &request.children, + &request.settings, + context, + GUEST_BUDGET, + ) + }, + )?; + if !eligible() || cancel.is_cancelled() { + return Err(IdeError::cancelled()); + } + Ok(result.filter(|nodes| valid_result(nodes))) + } +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn providers_only_receive_children_below_the_native_parent() { + let tmp = tempfile::tempdir().unwrap(); + let parent = tmp.path().join("src"); + let native = |path: PathBuf, kind| ProjectViewNativeNode { + id: ide_core::ipc_path::to_ipc(&path), + path: ide_core::ipc_path::to_ipc(&path), + label: path.file_name().unwrap().to_string_lossy().into_owned(), + kind, + }; + let directory = native(parent.clone(), ProjectViewNodeKind::Directory); + let child = native(parent.join("main.go"), ProjectViewNodeKind::File); + assert!(valid_request(&directory, &[child], "{}")); + let sibling = native(tmp.path().join("main.go"), ProjectViewNodeKind::File); + assert!(!valid_request(&directory, &[sibling], "{}")); + let traversal = native(parent.join("../main.go"), ProjectViewNodeKind::File); + assert!(!valid_request(&directory, &[traversal], "{}")); + assert!(!valid_request(&directory, &[], "[]")); + } + + #[test] + fn project_view_positions_use_paths_from_the_native_tree() { + let tmp = tempfile::tempdir().unwrap(); + let file = tmp.path().join("src").join("main.go"); + std::fs::create_dir(file.parent().unwrap()).unwrap(); + std::fs::write(&file, "package main").unwrap(); + assert_eq!(resolve_path(tmp.path(), "./src//main.go").unwrap(), file); + assert_eq!(resolve_path(tmp.path(), &ide_core::ipc_path::to_ipc(&file)).unwrap(), file); + } + + #[cfg(unix)] + #[test] + fn project_view_paths_keep_native_aliases_within_workspace() { + let tmp = tempfile::tempdir().unwrap(); + let target = tmp.path().join("original.go"); + let alias = tmp.path().join("alias.go"); + std::fs::write(&target, "package main").unwrap(); + std::os::unix::fs::symlink(&target, &alias).unwrap(); + assert_eq!(resolve_path(tmp.path(), "alias.go").unwrap(), alias); + + let outside = tempfile::NamedTempFile::new().unwrap(); + std::os::unix::fs::symlink(outside.path(), tmp.path().join("external.go")).unwrap(); + assert!(resolve_path(tmp.path(), "external.go").is_err()); + } +} diff --git a/crates/ide-host/src/plugins/remote_host.rs b/crates/ide-host/src/plugins/remote_host.rs index 2d279397ad..4db38add94 100644 --- a/crates/ide-host/src/plugins/remote_host.rs +++ b/crates/ide-host/src/plugins/remote_host.rs @@ -159,6 +159,8 @@ pub fn forwarded(event: &PluginEvent) -> bool { | PluginEvent::SubscriptionsChanged | PluginEvent::WebsocketReady { .. } | PluginEvent::ViewChanged { .. } + | PluginEvent::ProjectViewRefresh { .. } + | PluginEvent::ProjectViewSelect { .. } | PluginEvent::ViewMessage { .. } | PluginEvent::OpenTerminal { .. } | PluginEvent::OpenLocation { .. } diff --git a/crates/ide-host/src/plugins/types.rs b/crates/ide-host/src/plugins/types.rs index b863eed8b0..23ae06d480 100644 --- a/crates/ide-host/src/plugins/types.rs +++ b/crates/ide-host/src/plugins/types.rs @@ -350,6 +350,10 @@ pub enum PluginEvent { /// A view (or the custom editors) of a plugin must be rendered again. #[serde(rename_all = "camelCase")] ViewChanged { plugin_id: String, view: String }, + #[serde(rename_all = "camelCase")] + ProjectViewRefresh { plugin_id: String, view_id: String, directory: Option }, + #[serde(rename_all = "camelCase")] + ProjectViewSelect { plugin_id: String, view_id: String, path: ide_core::IpcPath, focus: bool }, /// For the script of a view's `html` body. #[serde(rename_all = "camelCase")] ViewMessage { plugin_id: String, view: String, message: String }, @@ -592,6 +596,8 @@ pub enum WindowRequest { DatabaseConnect { id: String }, /// Open and acknowledge validation by the shared content editor. ContentTab { tab: ide_plugin::ContentTab }, + /// Open the native comparison of two commits in this window's Compare tool window. + RevisionComparison { comparison: ide_plugin::RevisionComparison, project: String }, #[serde(rename_all = "camelCase")] Run { operation: String, config: Box, debug: bool }, #[serde(rename_all = "camelCase")] diff --git a/crates/ide-host/src/plugins/ui_points.rs b/crates/ide-host/src/plugins/ui_points.rs index 940fc5edd7..d6240dcd8d 100644 --- a/crates/ide-host/src/plugins/ui_points.rs +++ b/crates/ide-host/src/plugins/ui_points.rs @@ -104,6 +104,7 @@ pub const KEYMAPS: &str = "keymaps"; pub const STATUS_BAR: &str = "statusBar"; pub const SETTINGS: &str = "settings"; pub const VIEWS: &str = "views"; +pub const PROJECT_VIEW_PANES: &str = "projectViewPanes"; pub const CUSTOM_EDITORS: &str = "customEditors"; pub const EDITOR_PANELS: &str = "editorPanels"; pub const OVERLAYS: &str = "overlays"; @@ -137,7 +138,9 @@ const DATABASE_SCHEMA_MENU: &str = "database.schema.context"; const DATABASE_COLUMN_MENU: &str = "database.column.context"; /// Toolbar of the Run and Debug consoles (API 1.21). const RUN_CONSOLE_TOOLBAR_MENU: &str = "runConsole.toolbar"; -const MENU_IDS: [&str; 18] = [ +pub(super) const GIT_BRANCHES_POPUP_MENU: &str = "git.branches.popup"; +pub(super) const GIT_BRANCH_CONTEXT_MENU: &str = "git.branch.context"; +const MENU_IDS: [&str; 20] = [ "editor.context", "projectView.context", "editorTab.context", @@ -156,6 +159,8 @@ const MENU_IDS: [&str; 18] = [ DATABASE_SCHEMA_MENU, DATABASE_COLUMN_MENU, RUN_CONSOLE_TOOLBAR_MENU, + GIT_BRANCHES_POPUP_MENU, + GIT_BRANCH_CONTEXT_MENU, ]; const MAX_TITLE: usize = 256; const MAX_SETTINGS: usize = 200; @@ -193,6 +198,39 @@ fn json(v: &T) -> Result { serde_json::to_value(v).map_err(|e| e.to_string()) } +#[derive(Deserialize, Serialize)] +#[serde(deny_unknown_fields)] +struct ProjectViewPaneDecl { + id: String, + title: String, + #[serde(default)] + weight: i32, +} + +pub(super) fn project_view_pane(pkg: &Package, decl: toml::Value) -> Result { + let pane: ProjectViewPaneDecl = decode(PROJECT_VIEW_PANES, decl)?; + pkg.manifest.needs_api("contributes.projectViewPanes", 21)?; + validate_item_id(&pane.id, "project view pane id")?; + if pane.id == "project" { + return Err("contributes.projectViewPanes: `project` is the built-in pane id".into()); + } + if pkg + .manifest + .declarations(PROJECT_VIEW_PANES) + .iter() + .filter(|value| value.get("id").and_then(toml::Value::as_str) == Some(&pane.id)) + .nth(1) + .is_some() + { + return Err(format!("contributes.projectViewPanes: duplicate pane id {:?}", pane.id)); + } + title(PROJECT_VIEW_PANES, &pane.title)?; + if pkg.manifest.wasm.is_none() || !pkg.manifest.declares(&ide_extension::Capability::ProjectRead) { + return Err("contributes.projectViewPanes needs `wasm` and the `project.read` capability".into()); + } + Ok(UiDecl::new(pane.id.clone(), pane.title.clone(), json(&pane)?)) +} + #[derive(Debug, Deserialize, Serialize)] #[serde(deny_unknown_fields)] struct MenuDecl { @@ -206,6 +244,8 @@ struct MenuDecl { /// submenu under it. #[serde(default, skip_serializing_if = "Option::is_none")] submenu: Option, + #[serde(rename = "projectViewContext", default, skip_serializing_if = "Option::is_none")] + project_view_context: Option, } pub(super) fn menu(pkg: &Package, decl: toml::Value) -> Result { @@ -213,6 +253,12 @@ pub(super) fn menu(pkg: &Package, decl: toml::Value) -> Result { if !MENU_IDS.contains(&d.menu.as_str()) { return Err(format!("contributes.menus: unknown menu {:?} (one of {})", d.menu, MENU_IDS.join(", "))); } + if d.project_view_context.is_some() { + if d.menu != "projectView.context" { + return Err("contributes.menus: projectViewContext only applies to projectView.context".into()); + } + pkg.manifest.needs_api("contributes.menus.projectViewContext", 21)?; + } declared_command(pkg, MENUS, &d.command)?; if ["editor.title", "mainToolbar", "problems.context", "searchResults.context"].contains(&d.menu.as_str()) { pkg.manifest.needs_api("contributes.menus: language workbench menus", 4)?; @@ -226,6 +272,12 @@ pub(super) fn menu(pkg: &Package, decl: toml::Value) -> Result { if d.menu == DATABASE_TABLE_MENU { pkg.manifest.needs_api(&format!("contributes.menus: {DATABASE_TABLE_MENU}"), 20)?; } + if [GIT_BRANCHES_POPUP_MENU, GIT_BRANCH_CONTEXT_MENU].contains(&d.menu.as_str()) { + pkg.manifest.needs_api(&format!("contributes.menus: {}", d.menu), 21)?; + if d.submenu.is_some() { + return Err(format!("contributes.menus: `submenu` is not supported by {:?}", d.menu)); + } + } if [DATABASE_SOURCE_MENU, DATABASE_SCHEMA_MENU, DATABASE_COLUMN_MENU].contains(&d.menu.as_str()) { pkg.manifest.needs_api(&format!("contributes.menus: {}", d.menu), 21)?; } @@ -1939,6 +1991,21 @@ pub(super) fn locales(pkg: &Package, _decl: toml::Value) -> Result Invocation { editor: None, selected_paths: Vec::new(), global_settings: false, + git_action: None, } } diff --git a/crates/ide-host/tests/plugin_indexing.rs b/crates/ide-host/tests/plugin_indexing.rs index 3d0801f912..042b5b6f2e 100644 --- a/crates/ide-host/tests/plugin_indexing.rs +++ b/crates/ide-host/tests/plugin_indexing.rs @@ -244,6 +244,7 @@ fn two_windows_of_same_root_keep_unsaved_snapshots_isolated() { editor: None, selected_paths: Vec::new(), global_settings: false, + git_action: None, }, ) .unwrap(); diff --git a/crates/ide-host/tests/plugin_project_view.rs b/crates/ide-host/tests/plugin_project_view.rs new file mode 100644 index 0000000000..a39192bf93 --- /dev/null +++ b/crates/ide-host/tests/plugin_project_view.rs @@ -0,0 +1,108 @@ +//! API 1.21 Project view panes and Git branch menus, through the fixture plugin. +mod common; + +use ide_core::ipc_path::to_ipc; +use ide_host::plugins::commands::{plugin_project_view_modify, plugin_run_git_command}; +use ide_host::plugins::{Consent, HostWorkspace, PluginHost}; +use ide_host::{Host, ops}; +use ide_plugin::{ + GitActionBranch, GitActionContext, Limits, ProjectViewNativeNode, ProjectViewNodeKind, ProjectViewProjectionNode, +}; +use std::path::{Path, PathBuf}; +use std::sync::Arc; + +fn fixture() -> PathBuf { + Path::new(env!("CARGO_MANIFEST_DIR")).join("../ide-plugin/tests/fixtures/project-view") +} + +fn node(path: &Path, kind: ProjectViewNodeKind) -> ProjectViewNativeNode { + ProjectViewNativeNode { + id: to_ipc(path), + path: to_ipc(path), + label: path.file_name().unwrap().to_string_lossy().into_owned(), + kind, + } +} + +async fn setup(tmp: &Path) -> (Arc, Arc, PathBuf) { + let root = dunce::canonicalize(tmp).unwrap().join("project"); + std::fs::create_dir_all(root.join("src")).unwrap(); + for file in ["mod_a.go", "mod_b.go", "main.go"] { + std::fs::write(root.join("src").join(file), "package main\n").unwrap(); + } + ide_vcs::init(&root).unwrap(); + let host = Arc::new(Host::new(common::host_config(tmp))); + host.open_project("main", &root).unwrap(); + ops::project::project_trust_set(&host, root.clone(), true, false).await.unwrap(); + host.project("main").unwrap().refresh_repositories(); + let plugins = + Arc::new(PluginHost::new(tmp.join("plugins"), Arc::new(|_: Option<&str>, _| {}), Limits::default()).unwrap()); + plugins.set_workspace(Some(Arc::new(HostWorkspace(Arc::downgrade(&host))))); + plugins.install_from_dir(&fixture(), &Consent::all()).unwrap(); + (host, plugins, root) +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn a_pane_groups_native_children_under_a_virtual_folder() { + let tmp = tempfile::tempdir().unwrap(); + let (host, plugins, root) = setup(tmp.path()).await; + let src = root.join("src"); + let parent = node(&src, ProjectViewNodeKind::Directory); + let children: Vec<_> = + ["mod_a.go", "mod_b.go", "main.go"].map(|file| node(&src.join(file), ProjectViewNodeKind::File)).into(); + let modify = |view: &str, settings: &str| { + plugin_project_view_modify( + &host, + &plugins, + "main", + "test.project-view".into(), + view.into(), + parent.clone(), + children.clone(), + settings.into(), + None, + ) + }; + + let nodes = modify("grouped", "{}").await.unwrap().expect("the pane rearranges the children"); + assert_eq!( + nodes, + [ + ProjectViewProjectionNode::VirtualFolder { + id: "mod".into(), + parent: None, + label: "mod".into(), + icon: None + }, + ProjectViewProjectionNode::ExistingNode { id: children[0].id.clone(), parent: Some("mod".into()) }, + ProjectViewProjectionNode::ExistingNode { id: children[1].id.clone(), parent: Some("mod".into()) }, + ] + ); + assert_eq!(modify("grouped", r#"{"plain":true}"#).await.unwrap(), None, "the plugin keeps the native list"); + assert_eq!(modify("other", "{}").await.unwrap(), None, "a pane the plugin does not declare"); + assert_eq!(modify("grouped", "[]").await.unwrap(), None, "settings must be a JSON object"); +} + +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn a_git_branch_menu_command_receives_the_repository_and_full_ref() { + let tmp = tempfile::tempdir().unwrap(); + let (host, plugins, _root) = setup(tmp.path()).await; + let repo = to_ipc(host.project("main").unwrap().repos().primary().unwrap().root()); + let context = |repositories: Vec| GitActionContext { + repositories, + branch: Some(GitActionBranch { name: "main".into(), full_ref: "refs/heads/main".into(), remote: false }), + }; + let run = |context: GitActionContext| { + plugin_run_git_command(&host, &plugins, "main", "test.project-view".into(), "branch".into(), context, None) + }; + + let answer = run(context(vec![repo.clone(), repo.clone()])).await.unwrap(); + assert_eq!(answer.as_deref(), Some(format!("{repo}|refs/heads/main").as_str())); + + let outside = tempfile::tempdir().unwrap(); + ide_vcs::init(outside.path()).unwrap(); + assert!(run(context(vec![to_ipc(outside.path())])).await.is_err(), "a repository outside the project"); + let mut wrong_ref = context(vec![repo]); + wrong_ref.branch.as_mut().unwrap().full_ref = "refs/remotes/main".into(); + assert!(run(wrong_ref).await.is_err(), "the full ref must name the branch"); +} diff --git a/crates/ide-host/tests/plugins.rs b/crates/ide-host/tests/plugins.rs index 4516bb0f72..ac66116ea4 100644 --- a/crates/ide-host/tests/plugins.rs +++ b/crates/ide-host/tests/plugins.rs @@ -428,6 +428,7 @@ impl Fixture { editor: None, selected_paths: Vec::new(), global_settings: false, + git_action: None, } } diff --git a/crates/ide-plugin/src/runtime.rs b/crates/ide-plugin/src/runtime.rs index 6a261e1f28..6d1b93f4e6 100644 --- a/crates/ide-plugin/src/runtime.rs +++ b/crates/ide-plugin/src/runtime.rs @@ -22,6 +22,7 @@ use crate::wit_host::completion_resolve_bindings::exports::openidea::plugin::com use crate::wit_host::hover_actions_bindings::exports::openidea::plugin::hover_actions as wit_hia; use crate::wit_host::injections_bindings::exports::openidea::plugin::injections as wit_inj; use crate::wit_host::language_features_bindings::exports::openidea::plugin::language_features as wit_lf; +use crate::wit_host::project_view_bindings::exports::openidea::plugin::project_view_provider as wit_pvp; use crate::wit_host::rename_bindings::exports::openidea::plugin::rename_provider as wit_rename; use crate::wit_host::run_anything_bindings::exports::openidea::plugin::run_anything_provider as wit_ra; use crate::wit_host::run_config_completion_bindings::exports::openidea::plugin::run_configuration_completion as wit_rcc; @@ -40,7 +41,7 @@ use std::path::{Path, PathBuf}; use std::sync::Arc; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::time::{Duration, Instant}; -use wasmtime::component::{Component, HasSelf, Linker, ResourceTable}; +use wasmtime::component::{Component, HasSelf, Linker, Resource, ResourceTable}; use wasmtime::{Config, Engine, Store, StoreLimits, StoreLimitsBuilder, UpdateDeadline}; use wasmtime_wasi::p2::pipe::MemoryOutputPipe; use wasmtime_wasi::{WasiCtx, WasiCtxView, WasiView}; @@ -51,6 +52,7 @@ use crate::wit_host::launch_configurations_bindings::exports::openidea::plugin:: use crate::wit_host::run_configurations_bindings::exports::openidea::plugin::run_configurations as wit_configs; use crate::wit_host::test_results_bindings::exports::openidea::plugin::test_results as wit_tests; use bindings::openidea::plugin::events as wit_events; +use bindings::openidea::plugin::project_view_types as wit_pv; use bindings::openidea::plugin::run as wit_run; use bindings::openidea::plugin::types as wit_types; use commit_checks_bindings::exports::openidea::plugin::commit_checker as wit_cc; @@ -361,6 +363,16 @@ pub trait HostApi: Send + Sync { ) -> Result<(), HostError>; /// Opens a diff of two texts in the invoking window; a `None` side doesn't exist. fn open_diff(&self, client: &str, diff: crate::FileDiff, file_name: Option) -> Result<(), HostError>; + /// Opens the native comparison of two commits in the invoking window. + fn open_revision_comparison( + &self, + _invocation: &Invocation, + _comparison: crate::RevisionComparison, + _cancel: &CancellationToken, + _timeout: Duration, + ) -> Result<(), HostError> { + Err(HostError::NotFound("revision comparison is unavailable on this host".into())) + } /// Answers a content action in the invoking window. fn reply_content_tab(&self, client: &str, request: &str, reply: crate::ContentTabReply) -> Result<(), HostError>; /// The invoking window's editors. @@ -713,6 +725,14 @@ pub trait HostApi: Send + Sync { fn task_end(&self, id: u64); /// The plugin's view (or custom editors) `view` must be rendered again. fn refresh_view(&self, view: &str); + fn refresh_project_view( + &self, + client: Option<&str>, + root: Option<&Path>, + view: &str, + directory: Option, + ) -> Result<(), HostError>; + fn select_in_project_view(&self, client: &str, view: &str, path: String, focus: bool) -> Result<(), HostError>; /// A message for the script of the `html` body of `view`. fn post_view_message(&self, view: &str, message: String) -> Result<(), HostError>; /// Opens a terminal in `client`'s window running the approved file of @@ -1141,6 +1161,7 @@ struct Exports { indexer: Option, file_actions: Option, views: Option, + project_view: Option, semantic: Option, details: Option, diagnostics: Option, @@ -1323,6 +1344,7 @@ impl Runtime { let syntax_decoration_indices = wit_syn::GuestIndices::new(&pre).ok(); let endpoint_indices = wit_endpoints::GuestIndices::new(&pre).ok(); let search_indices = wit_search::GuestIndices::new(&pre).ok(); + let project_view_indices = wit_pvp::GuestIndices::new(&pre).ok(); let hover_actions_indices = wit_hia::GuestIndices::new(&pre).ok(); let completion_list_indices = wit_cl::GuestIndices::new(&pre).ok(); let completion_resolve_indices = wit_cr::GuestIndices::new(&pre).ok(); @@ -1404,6 +1426,7 @@ impl Runtime { None => None, }; let search = search_indices.map(|i| i.load(&mut store, &instance)).transpose().map_err(api_hint)?; + let project_view = project_view_indices.map(|i| i.load(&mut store, &instance)).transpose().map_err(api_hint)?; let hover_actions = hover_actions_indices.map(|i| i.load(&mut store, &instance)).transpose().map_err(api_hint)?; let completion_list = @@ -1427,6 +1450,7 @@ impl Runtime { syntax, providers, views, + project_view, indexer, semantic, details, @@ -2296,6 +2320,41 @@ impl Runtime { .collect()) } + /// Project pane providers reuse native model ids and have no interactive host context. + pub fn modify_project_view_children( + &mut self, + view: &str, + parent: &crate::ProjectViewNativeNode, + children: &[crate::ProjectViewNativeNode], + settings: &str, + invocation: Invocation, + timeout: Duration, + ) -> Result>, CallError> { + if !self.store.data().granted.iter().any(|grant| grant.covers(&Capability::ProjectRead)) { + return Ok(None); + } + if self.exports.project_view.is_none() { + return Err(CallError::missing_export("project-view-provider")); + } + let parent = project_view_node_to_wit(parent); + let children: Vec<_> = children.iter().map(project_view_node_to_wit).collect(); + let result = self.call(invocation, timeout, |exports, store| { + let ctx = store.data_mut().new_invocation()?; + let result = exports.project_view.as_ref().expect("checked").call_modify_children( + &mut *store, + view, + &parent, + &children, + settings, + Resource::new_borrow(ctx.rep()), + ); + store.data_mut().drop_invocation(ctx); + result + })?; + let Some(nodes) = result.filter(|nodes| nodes.len() <= MAX_PROVIDER_ITEMS) else { return Ok(None) }; + Ok(Some(nodes.into_iter().map(project_view_node_from_wit).collect())) + } + pub fn activate(&mut self) -> Result<(), CallError> { let data = self.store.data(); let ctx = wit_types::Context { @@ -2603,6 +2662,29 @@ fn doc_to_wit(d: &ProviderDocument) -> wit_prov::Document { wit_prov::Document { path: to_ipc(&d.path), language: d.language.clone(), version: d.version, text: d.text.clone() } } +fn project_view_node_to_wit(node: &crate::ProjectViewNativeNode) -> wit_pv::NativeNode { + wit_pv::NativeNode { + id: node.id.clone(), + path: node.path.clone(), + label: node.label.clone(), + kind: match node.kind { + crate::ProjectViewNodeKind::File => wit_pv::NodeKind::File, + crate::ProjectViewNodeKind::Directory => wit_pv::NodeKind::Directory, + }, + } +} + +fn project_view_node_from_wit(node: wit_pv::ProjectionNode) -> crate::ProjectViewProjectionNode { + use crate::ProjectViewProjectionNode::{ExistingNode, VirtualFolder}; + let wit_pv::ProjectionNode { id, parent, kind } = node; + match kind { + wit_pv::ProjectionKind::ExistingNode => ExistingNode { id, parent }, + wit_pv::ProjectionKind::VirtualFolder(folder) => { + VirtualFolder { id, parent, label: folder.label, icon: folder.icon } + } + } +} + /// Resets the budgets for the next call: fuel, deadline, cancellation. fn arm(store: &mut Store, limits: &Limits, timeout: Duration) -> wasmtime::Result<()> { store.set_fuel(limits.fuel)?; @@ -3463,6 +3545,28 @@ impl Runtime { mod tests { use super::*; + #[test] + fn the_revision_comparison_import_links() { + let engine = PluginEngine::new().unwrap(); + let fixture = r#"(component + (import "openidea:plugin/types@1.21.0" (instance $types + (type $error (variant (case "denied" string) (case "stale") + (case "not-found" string) (case "invalid" string) + (case "cancelled") (case "failed" string))) + (export "error" (type (eq $error))))) + (alias export $types "error" (type $error)) + (import "openidea:plugin/views@1.21.0" (instance + (export "error" (type $view-error (eq $error))) + (type $comparison (record (field "repository" string) + (field "left" string) (field "right" string) + (field "left-label" (option string)) (field "right-label" (option string)))) + (export "revision-comparison" (type $view-comparison (eq $comparison))) + (export "open-revision-comparison" (func (param "comparison" $view-comparison) + (result (result (error $view-error))))))))"#; + let component = engine.compile_bytes(&wat::parse_str(fixture).unwrap()).unwrap(); + engine.linker.instantiate_pre(&component).unwrap(); + } + /// The second compile of the same component loads the cached one instead of compiling and /// writing it again (a failed load deletes and rewrites the file). #[test] diff --git a/crates/ide-plugin/src/types.rs b/crates/ide-plugin/src/types.rs index 8d408562db..470b059d28 100644 --- a/crates/ide-plugin/src/types.rs +++ b/crates/ide-plugin/src/types.rs @@ -36,6 +36,54 @@ pub struct Invocation { pub editor: Option, /// Files and folders the command was run on. pub selected_paths: Vec, + /// Git menu selection captured by the invoking workbench. + pub git_action: Option, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct GitActionBranch { + pub name: String, + pub full_ref: String, + pub remote: bool, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +pub struct GitActionContext { + pub repositories: Vec, + pub branch: Option, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Type)] +#[serde(rename_all = "camelCase")] +pub struct RevisionComparison { + pub repository: String, + pub left: String, + pub right: String, + pub left_label: Option, + pub right_label: Option, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, specta::Type)] +#[serde(rename_all = "camelCase")] +pub enum ProjectViewNodeKind { + File, + Directory, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, specta::Type)] +pub struct ProjectViewNativeNode { + pub id: String, + pub path: String, + pub label: String, + pub kind: ProjectViewNodeKind, +} + +#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, specta::Type)] +#[serde(tag = "kind", rename_all = "camelCase")] +pub enum ProjectViewProjectionNode { + ExistingNode { id: String, parent: Option }, + VirtualFolder { id: String, parent: Option, label: String, icon: Option }, } /// A failed host call, as the plugin sees it (WIT `types.error`). diff --git a/crates/ide-plugin/src/wit_host.rs b/crates/ide-plugin/src/wit_host.rs index 7ce75462e1..8a54aedbb2 100644 --- a/crates/ide-plugin/src/wit_host.rs +++ b/crates/ide-plugin/src/wit_host.rs @@ -1496,6 +1496,25 @@ impl invocation::HostInvocation for StoreData { Ok(self.invocation.selected_paths.iter().take(MAX_FIND as usize).map(|p| to_ipc(p)).collect()) } + fn git_action_context( + &mut self, + _this: Resource, + ) -> wasmtime::Result> { + if self.require(Capability::VcsRead).is_err() + || self.host.require_api("invocation.git-action-context", 21).is_err() + { + return Ok(None); + } + Ok(self.invocation.git_action.as_ref().map(|context| invocation::GitActionContext { + repositories: context.repositories.clone(), + branch: context.branch.as_ref().map(|branch| invocation::GitActionBranch { + name: branch.name.clone(), + full_ref: branch.full_ref.clone(), + remote: branch.remote, + }), + })) + } + fn drop(&mut self, rep: Resource) -> wasmtime::Result<()> { // Owned by the host for the duration of the call. let _ = rep; @@ -2446,6 +2465,30 @@ impl process::HostChild for StoreData { } impl StoreData { + fn request_revision_comparison(&self, comparison: views::RevisionComparison) -> Fallible<()> { + if let Err(e) = self.require_window().and_then(|()| self.require(Capability::VcsRead)) { + return Ok(Err(e)); + } + if let Err(e) = self.host.require_api("views.open-revision-comparison", 21) { + return Ok(Err(to_wit(e))); + } + Ok(self + .host + .open_revision_comparison( + &self.invocation, + crate::RevisionComparison { + repository: comparison.repository, + left: comparison.left, + right: comparison.right, + left_label: comparison.left_label, + right_label: comparison.right_label, + }, + &self.cancel.token(), + self.remaining(), + ) + .map_err(to_wit)) + } + fn open_keyed_terminal( &mut self, key: String, @@ -2536,6 +2579,9 @@ impl views::Host for StoreData { } Ok(self.host.open_diff(self.invocation.client.as_deref().unwrap(), diff.into(), file_name).map_err(to_wit)) } + fn open_revision_comparison(&mut self, comparison: views::RevisionComparison) -> Fallible<()> { + self.request_revision_comparison(comparison) + } fn reply_content_tab(&mut self, request_id: String, reply: views::ContentTabReply) -> Fallible<()> { if let Err(e) = self.require_window() { return Ok(Err(e)); @@ -2882,6 +2928,43 @@ pub(crate) mod search_bindings { }); } +pub(crate) mod project_view_bindings { + wasmtime::component::bindgen!({ + world: "project-view-exports", path: "../../wit", + with: { + "openidea:plugin/types": super::bindings::openidea::plugin::types, + "openidea:plugin/workspace": super::bindings::openidea::plugin::workspace, + "openidea:plugin/editor": super::bindings::openidea::plugin::editor, + "openidea:plugin/invocation": super::bindings::openidea::plugin::invocation, + "openidea:plugin/project-view-types": super::bindings::openidea::plugin::project_view_types, + }, + }); +} + +impl bindings::openidea::plugin::project_view_types::Host for StoreData {} + +impl bindings::openidea::plugin::project_view::Host for StoreData { + fn refresh(&mut self, view_id: String, directory: Option) -> Fallible<()> { + if let Err(error) = self.require(Capability::ProjectRead).and_then(|_| self.require_interactive()) { + return Ok(Err(error)); + } + Ok(self + .host + .refresh_project_view(self.client(), self.invocation.workspace_root.as_deref(), &view_id, directory) + .map_err(to_wit)) + } + + fn select_in(&mut self, view_id: String, path: String, focus: Option) -> Fallible<()> { + if let Err(error) = self.require(Capability::ProjectRead).and_then(|_| self.require_window()) { + return Ok(Err(error)); + } + Ok(self + .host + .select_in_project_view(self.client().expect("checked"), &view_id, path, focus.unwrap_or(true)) + .map_err(to_wit)) + } +} + /// The optional `file-actions` export. pub(crate) mod file_actions_bindings { wasmtime::component::bindgen!({ diff --git a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm index 6173e9df97..b815d17087 100644 Binary files a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources index 4ebca3d4ed..5d9ebe7d75 100644 --- a/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/api14/dist/plugin.wasm.sources @@ -1 +1 @@ -fb42c489a763c38528faae4f7d46dfde6bbe192b6e6c3f6459b73869d9ccfea7 +e1a347e0a46d2070ef47a0981cf1bfeff8fa18927761b783fc4398c100fa4c70 diff --git a/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm index 1870b51f4b..302ded0b49 100644 Binary files a/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm.sources index 471ca280c6..9ff94c2350 100644 --- a/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/build-graph/dist/plugin.wasm.sources @@ -1 +1 @@ -46a14028b6d2f23dd0142f5c181ad9a0c1cb5773fd668c3f7a768cdc431dca0c +e0ab3ccc8803f0ff237247af18470b2f2f2a8c7ae26773f03a5535c779e79ee5 diff --git a/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm index fb782e05e6..357311c794 100644 Binary files a/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm.sources index 88e1105403..fe2a97f055 100644 --- a/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/clipboard/dist/plugin.wasm.sources @@ -1 +1 @@ -ae96924ed394bbd54a53f083cf1e55c55f20c2f01ee8563685269478b1bee344 +42060867cbd7f9ea386c51ff592945c325d859de0ffbd346d2fd44213b1bfd12 diff --git a/crates/ide-plugin/tests/fixtures/code-semantics/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/code-semantics/dist/plugin.wasm index c750923605..ca088c859c 100644 Binary files a/crates/ide-plugin/tests/fixtures/code-semantics/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/code-semantics/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/code-semantics/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/code-semantics/dist/plugin.wasm.sources index a58ffa631e..8bc17392a8 100644 --- a/crates/ide-plugin/tests/fixtures/code-semantics/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/code-semantics/dist/plugin.wasm.sources @@ -1 +1 @@ -8ae340de9f7562d607b0de6477b8875dfc7849f0a462862883daf76d1c5abbd9 +afc5796cc6a8d9e9c6cfc906cb4fe24718bdc0461ca0dd1270db291fdc87240e diff --git a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm index 617cc34faf..0e636468d2 100644 Binary files a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources index f16ff16b91..746cbe4dd8 100644 --- a/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/commit/dist/plugin.wasm.sources @@ -1 +1 @@ -ed8c0953d070e21aa426f1b9a897cf97a670c2b1b62e6adc716a0c9589a381d0 +fed095032428deb380a5240716fd8d9269be025eec33233f23895002e84d3d6a diff --git a/crates/ide-plugin/tests/fixtures/completion-list/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/completion-list/dist/plugin.wasm index 2811139230..789cdd5aba 100644 Binary files a/crates/ide-plugin/tests/fixtures/completion-list/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/completion-list/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/completion-list/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/completion-list/dist/plugin.wasm.sources index 7f61464204..0282a79e5a 100644 --- a/crates/ide-plugin/tests/fixtures/completion-list/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/completion-list/dist/plugin.wasm.sources @@ -1 +1 @@ -882ca569d56569a6110d525b76663bfc7ad35acc0004fa291265a5e02a4525a0 +47b272d0697770654b4a262ca39a3613692d23c83906e522561c1d911e864ad0 diff --git a/crates/ide-plugin/tests/fixtures/completion-resolve/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/completion-resolve/dist/plugin.wasm index 92f339c283..0490ae7690 100644 Binary files a/crates/ide-plugin/tests/fixtures/completion-resolve/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/completion-resolve/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/completion-resolve/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/completion-resolve/dist/plugin.wasm.sources index ca9e516b5e..62850f0dd3 100644 --- a/crates/ide-plugin/tests/fixtures/completion-resolve/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/completion-resolve/dist/plugin.wasm.sources @@ -1 +1 @@ -bb50cdabd486309b3675424bf59f38340ae61cdd6bee974845bb181d428bb18a +73c2603e57ff568b281db2f80dbc9ee9a9c471c7dd51136fd0dadfb4ed89a736 diff --git a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm index 93da70661c..a298c050a1 100644 Binary files a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources index b04c26f2cc..01bef645b6 100644 --- a/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/data-tools/dist/plugin.wasm.sources @@ -1 +1 @@ -eec563d70e0f026239573807bd9e7072d9f3c9a91d580a594b817edaeb4375fa +20702ddef376e762a3c5dba0a2eebf29ec8404a354fe387126646ffec870f667 diff --git a/crates/ide-plugin/tests/fixtures/database-open/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/database-open/dist/plugin.wasm index 3726e28dd8..96cdb90604 100644 Binary files a/crates/ide-plugin/tests/fixtures/database-open/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/database-open/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/database-open/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/database-open/dist/plugin.wasm.sources index 56b7545cd3..bef7304853 100644 --- a/crates/ide-plugin/tests/fixtures/database-open/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/database-open/dist/plugin.wasm.sources @@ -1 +1 @@ -62dd4fa287c01eb231e434303589faa1a73d22797fb255c8b0fd1c213a030d8b +e450fa53d1a68e7abf001405ba5e0dfa7451ee5e5c79495c13cee211d34b8e7f diff --git a/crates/ide-plugin/tests/fixtures/decorations/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/decorations/dist/plugin.wasm index d851abdf93..e0c202cdff 100644 Binary files a/crates/ide-plugin/tests/fixtures/decorations/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/decorations/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/decorations/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/decorations/dist/plugin.wasm.sources index 9bc4cd0e00..1d309eb285 100644 --- a/crates/ide-plugin/tests/fixtures/decorations/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/decorations/dist/plugin.wasm.sources @@ -1 +1 @@ -07da400055a9ac7d262dd46ae93d11cc4da0f97bcb7d0984f20f68f03a97f3bf +13808d05b2fabec23fd1bf39e7cf0e61839e77e76a7ef4ed9d44e1a353e90a97 diff --git a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm index ec96f0d99c..061dc88dc2 100644 Binary files a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources index d7942e3701..18cc747b95 100644 --- a/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/detail-views/dist/plugin.wasm.sources @@ -1 +1 @@ -32a7e422fe6fc82e02f5ccb1e8c368c2ba34994fccb1039388bbbf1c0a4e30c0 +c81cd4a68e4a3f560afd6cb1e486483c1c2baf997dd3f04a43ee4bbc1d55a29e diff --git a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm index a6c8d162c2..75f42fee73 100644 Binary files a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources index 5b66c95f36..6181a71786 100644 --- a/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/diagnostics/dist/plugin.wasm.sources @@ -1 +1 @@ -3554a3705a870165925c21ab732a9813bc3ee94d44f9c60b62cf0f76b9d1d44c +73067aa8f964a539388266ce606d6f678a9393f40583d672ead38a2e4c6fa64c diff --git a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm index c0d9ab442d..bed33a6fff 100644 Binary files a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources index 4026b9198d..8d3740d34a 100644 --- a/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/endpoints/dist/plugin.wasm.sources @@ -1 +1 @@ -0f673811ac240ae6894eba412932f2962cc6b5671dc55eb0b039983ef39a02a8 +2ccbcbafabfcbe853fe6aa3575f71af8483e516e09fab95428469bd8a7d5da02 diff --git a/crates/ide-plugin/tests/fixtures/execution-output/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/execution-output/dist/plugin.wasm index 6874740ee1..15e1a0f503 100644 Binary files a/crates/ide-plugin/tests/fixtures/execution-output/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/execution-output/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/execution-output/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/execution-output/dist/plugin.wasm.sources index bdde641d18..0ebb16829e 100644 --- a/crates/ide-plugin/tests/fixtures/execution-output/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/execution-output/dist/plugin.wasm.sources @@ -1 +1 @@ -37cf4ee118c1f46a831b852b12306a7fa3e3d919ddf1fdef01064293d97a1ba6 +1bc694b2574304c694c0a85fc7e2083d5a9e01f8dcd07280c24eef88d00a4286 diff --git a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm index 427184c708..4e47bb7c52 100644 Binary files a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources index e3f134b5d3..1f63ff8ac1 100644 --- a/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/execution/dist/plugin.wasm.sources @@ -1 +1 @@ -7aa7cd595054241777fe2f953b12e386ab58ade816c968ebc6cd0f4da1a00ecd +a2be66c49163955ea14abde1720a2f3624d225422978f1413f42ae64e86d231e diff --git a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm index 8b16f3de8c..88f6f29006 100644 Binary files a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources index 8e04895a4d..eb34b674de 100644 --- a/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/ext-owner/dist/plugin.wasm.sources @@ -1 +1 @@ -0ca98809772ef9609532dc7b8fd6904dfb3420a6947ab591417f177b9eee5dea +ecba604e70ed814fdfb38676a59cb119496279fd290faaf8ff3d3949bcf0cd91 diff --git a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm index 674a6289e4..8bbe21daee 100644 Binary files a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources index 82bcbeef0a..d91931c281 100644 --- a/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/file-templates/dist/plugin.wasm.sources @@ -1 +1 @@ -ad590e2109c277ec256de9d682544f1ab5af8328f280dff96885bb94e04520c6 +968165359ca514f4179305d6dc5c9c835dc2626d6f0bd4446909aa28299627e2 diff --git a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm index 961c637aec..f6ef9eb19c 100644 Binary files a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources index 895bc09732..0220f091d9 100644 --- a/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/files-events/dist/plugin.wasm.sources @@ -1 +1 @@ -ced86a481cdab49a10c5035ef9b45c541adf04dd53d182a68df7a5a2f5c7555c +8815550ebdad8e5a85be73f10f2df0952aeaba0c83faf1f1ffec13e998cba7ef diff --git a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm index 48c24c2d4c..c14ab0daa0 100644 Binary files a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources index 030e381760..9537f41d50 100644 --- a/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/grouped-views/dist/plugin.wasm.sources @@ -1 +1 @@ -772c5514b14a6510f24b44187ec639294aa0e92d797c08afffa7804b74e6849c +8c44243cffd802476787e4923f2d251eae028ca403476f51bfaacb2282332a06 diff --git a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm index 67f5eabfe8..7fdc151612 100644 Binary files a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources index 7e583c663d..fe5a1ebae6 100644 --- a/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/hello/dist/plugin.wasm.sources @@ -1 +1 @@ -69118ba53e95cd1ee4f7a76ec850a73382dbc92995910931756be84949ded88f +8c29696aafa860321fe48b608606c5d6754e32b65522adaa525c852ad51a0c85 diff --git a/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm index 2b7bdf6117..b911a1c39e 100644 Binary files a/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm.sources index 000bac9086..0a73a59a7a 100644 --- a/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/hover-actions/dist/plugin.wasm.sources @@ -1 +1 @@ -47ffe9183dab375a63f2701740ff60b95d7876b0334b78aaba3ef764bfec6137 +a4246103cecf529590c55a6f2c42b47ac226c476cc6ddda0c0ba1d79b6f50cab diff --git a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm index f48dd65812..5f339c337b 100644 Binary files a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources index 3db2f5bb1b..1711483b9d 100644 --- a/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/hover/dist/plugin.wasm.sources @@ -1 +1 @@ -5f4be603d2ab1f58a37fa956562bc074ad98de2fece895fd51be0c2ed4e09693 +f738c392ff54a51dbfb40ad610c04104e217f171da80a071888ecdc6ba0d0eef diff --git a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm index 3a04a320cd..86d9958e87 100644 Binary files a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources index 839f48942c..587b6e6959 100644 --- a/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/indexer/dist/plugin.wasm.sources @@ -1 +1 @@ -0a574cee59fba2ca8a56047b803f7b8dfda44eb89e40cad5cac7258a3aada6f4 +42f710a4ce7021940954fd5a47507abc46b24cde43999ec7b65fcc89a38be69f diff --git a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm index d87ff03c35..755278c854 100644 Binary files a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources index 95e411046d..843729d7b8 100644 --- a/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/inlay-hints/dist/plugin.wasm.sources @@ -1 +1 @@ -dcc6c63c6627b383ede8afd46f49d4e6ce2c72ffcf4965cf3aea9bf347e7ac28 +1100040f719b68d4830af2a6258cf4d4c0c5a9b3c52f6a2227735836c7e589f4 diff --git a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm index 8fb0cddb88..8784b373f7 100644 Binary files a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources index 4c457d0dcd..b15f4d193b 100644 --- a/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/jobs/dist/plugin.wasm.sources @@ -1 +1 @@ -4897e01ccc7bae20887c18f09768bb21f090ef9d6b3f5c753631c82b092fcdcd +fdd7dcaf1669f50b35fbc7416210571403834b8bd1b30646e1eb5ebe6ca29963 diff --git a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm index 956eb83122..b719bd5050 100644 Binary files a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources index 7f5045dd22..64cc805cc9 100644 --- a/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/language-features/dist/plugin.wasm.sources @@ -1 +1 @@ -1c083813d241283b06162483c32d651845fee61a5510781a36f0a7222617e322 +768d2248a14f87a97b20cd7911fcc135d12e5226e5e434a02e8b8c40596f3d36 diff --git a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm index 6921bd87ec..b841a1181a 100644 Binary files a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources index 66a2ebfcd2..1adca336e3 100644 --- a/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/lsp-requests/dist/plugin.wasm.sources @@ -1 +1 @@ -251ed6c52e194bf765e3f5b142b67ef2cacadafb8a949c4a456ae9279a9c3390 +07924e411a8870ba1937d61f304e962aeb6715360df414201f4ba43f92d939ae diff --git a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm index ea56cbce8a..f9a366deb5 100644 Binary files a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources index 1b6c922aa1..a5febd3465 100644 --- a/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/misbehave/dist/plugin.wasm.sources @@ -1 +1 @@ -7403453bb71817bffc0b09d39d0e2b8c3b50509d07ab28cdcc00c900b4ab665c +2204e040f617aa3fc1a47c18af96226574c60cd25b90a96fc3c327365a19a3dc diff --git a/crates/ide-plugin/tests/fixtures/net-setting/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/net-setting/dist/plugin.wasm index 1c2c147e45..957a1ac468 100644 Binary files a/crates/ide-plugin/tests/fixtures/net-setting/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/net-setting/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/net-setting/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/net-setting/dist/plugin.wasm.sources index 359ad85ac6..2747dc538a 100644 --- a/crates/ide-plugin/tests/fixtures/net-setting/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/net-setting/dist/plugin.wasm.sources @@ -1 +1 @@ -e0271196b348d9c463c86326f09223df4e7846a47666d4b88f570713981b1284 +b2c4bf766c66afc72758f30803d91c3258fc4ff2d80e3a4f60f09876db5578a1 diff --git a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm index e606961205..9c44aa9288 100644 Binary files a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources index 082444cf63..a897e26416 100644 --- a/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/path-events/dist/plugin.wasm.sources @@ -1 +1 @@ -816ed04e60eaee776b2bd56d2f688138fb2b8260e46e9d4f2eaa86bdfc40141a +81daf9773437f80d42129fd000790074128f87a441bd3263d16d1c712b296395 diff --git a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm index 5c78117b82..6e583a63ee 100644 Binary files a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources index aaf49778af..abc72079f2 100644 --- a/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/private-dir/dist/plugin.wasm.sources @@ -1 +1 @@ -207f46222a0032485f38b7433e2ac88c9d0dc4c89a9c9dff0a142e1f3c8c5f95 +43ed5bf5c7bd2a64fab09fe1c32f9083066c00d735599e3104ed7b8d3f92ee54 diff --git a/crates/ide-plugin/tests/fixtures/project-view/Cargo.lock b/crates/ide-plugin/tests/fixtures/project-view/Cargo.lock new file mode 100644 index 0000000000..fde1c4cf24 --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/project-view/Cargo.lock @@ -0,0 +1,336 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "anyhow" +version = "1.0.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2cb931c189b85683d69a5cfad41d4d418671e1ac413dd209f3f2fc31e3cfd902" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "hashbrown" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc" +dependencies = [ + "foldhash", +] + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "id-arena" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown", + "serde", + "serde_core", +] + +[[package]] +name = "itoa" +version = "1.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4" + +[[package]] +name = "leb128fmt" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" + +[[package]] +name = "log" +version = "0.4.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c" + +[[package]] +name = "macro-string" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e7b3a5bbb2f63aaa223a671ea1bd0e7bc16bd30ce387324cf63995deaddbbd2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "openidea-plugin" +version = "0.1.0" +dependencies = [ + "serde", + "serde_json", + "wit-bindgen", +] + +[[package]] +name = "openidea-test-project-view" +version = "0.1.0" +dependencies = [ + "openidea-plugin", +] + +[[package]] +name = "prettyplease" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0" +dependencies = [ + "proc-macro2", + "syn", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "syn" +version = "3.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "wasm-encoder" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4495a6f85dd94c411c749303efcbc5defade0b0cbdbc0541495241ab917a9b5a" +dependencies = [ + "leb128fmt", + "wasmparser", +] + +[[package]] +name = "wasm-metadata" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c86ff6668190d9fb70372b306b4f9fe8930f0e2f57ce72e4922bf2f117900949" +dependencies = [ + "anyhow", + "indexmap", + "wasm-encoder", + "wasmparser", +] + +[[package]] +name = "wasmparser" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "974d643b125b272607e2fff8012ea14a8328acd7621e4bafa7afb32500052b1b" +dependencies = [ + "bitflags", + "hashbrown", + "indexmap", + "semver", +] + +[[package]] +name = "wit-bindgen" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b85a987ab61d365382d25c7d47e26edd48941b3bf6e3fbf76eff918bc71dab06" +dependencies = [ + "bitflags", + "wit-bindgen-rust-macro", +] + +[[package]] +name = "wit-bindgen-core" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "775e122e390603abfacd548027016cd0113a6e2bf2f8ce6bdd3658b013456ea8" +dependencies = [ + "anyhow", + "heck", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "84e26e13b9d972026778d2ffb7985736de116026fdc8d9464f966e12df2eb240" +dependencies = [ + "anyhow", + "heck", + "indexmap", + "prettyplease", + "syn", + "wasm-metadata", + "wit-bindgen-core", + "wit-component", +] + +[[package]] +name = "wit-bindgen-rust-macro" +version = "0.63.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16a008a0d6b4840677326beb4edbeb210a2f1b7d0183fb7cc33f466b90fd7fb6" +dependencies = [ + "anyhow", + "macro-string", + "prettyplease", + "proc-macro2", + "quote", + "syn", + "wit-bindgen-core", + "wit-bindgen-rust", +] + +[[package]] +name = "wit-component" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "078def49fdb49cab405c3006e05793b3fdaf7069126ba6b9c97d01ec8c98fe4c" +dependencies = [ + "anyhow", + "bitflags", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "wasm-encoder", + "wasm-metadata", + "wasmparser", + "wit-parser", +] + +[[package]] +name = "wit-parser" +version = "0.262.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00f0dc051466ffe46787721fca3d088536f158ae400be044f1b1c386ba9397ad" +dependencies = [ + "anyhow", + "hashbrown", + "id-arena", + "indexmap", + "log", + "semver", + "serde", + "serde_derive", + "serde_json", + "unicode-ident", + "wasmparser", +] + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" diff --git a/crates/ide-plugin/tests/fixtures/project-view/Cargo.toml b/crates/ide-plugin/tests/fixtures/project-view/Cargo.toml new file mode 100644 index 0000000000..02f3999f67 --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/project-view/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "openidea-test-project-view" +version = "0.1.0" +edition = "2024" +publish = false + +[workspace] + +[lib] +crate-type = ["cdylib", "rlib"] + +[dependencies] +openidea-plugin = { path = "../../../../../sdk/rust/openidea-plugin" } + +[profile.release] +opt-level = "s" +lto = true +strip = true +codegen-units = 1 +panic = "abort" diff --git a/crates/ide-plugin/tests/fixtures/project-view/README.md b/crates/ide-plugin/tests/fixtures/project-view/README.md new file mode 100644 index 0000000000..f0ec419c75 --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/project-view/README.md @@ -0,0 +1,7 @@ +# Project view fixture + +Proves the `project-view-provider` export and the Git branch menu context. The +`grouped` pane puts every child named `mod_*` under a virtual `mod` folder and +leaves the rest unchanged; `{"plain": true}` settings keep the native children. +The `branch` command answers with the menu's repositories and full ref, and +`compare` opens `repository|left|right` with `views.open-revision-comparison`. diff --git a/crates/ide-plugin/tests/fixtures/project-view/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/project-view/dist/plugin.wasm new file mode 100644 index 0000000000..513319981a Binary files /dev/null and b/crates/ide-plugin/tests/fixtures/project-view/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/project-view/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/project-view/dist/plugin.wasm.sources new file mode 100644 index 0000000000..ea72e0da1f --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/project-view/dist/plugin.wasm.sources @@ -0,0 +1 @@ +2fb3927fd769bf2edb8beabd7d3498f461d388cf85c5f6339c973d12bee0c9f8 diff --git a/crates/ide-plugin/tests/fixtures/project-view/plugin.toml b/crates/ide-plugin/tests/fixtures/project-view/plugin.toml new file mode 100644 index 0000000000..086ea8b490 --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/project-view/plugin.toml @@ -0,0 +1,24 @@ +id = "test.project-view" +name = "Project view fixture" +version = "0.1.0" +engines.openidea = "^1.21" +wasm = "dist/plugin.wasm" + +[capabilities] +required = ["project.read", "vcs.read"] + +[[contributes.projectViewPanes]] +id = "grouped" +title = "Grouped" + +[[contributes.commands]] +id = "branch" +title = "Show Branch" + +[[contributes.commands]] +id = "compare" +title = "Compare Commits" + +[[contributes.menus]] +menu = "git.branch.context" +command = "branch" diff --git a/crates/ide-plugin/tests/fixtures/project-view/src/lib.rs b/crates/ide-plugin/tests/fixtures/project-view/src/lib.rs new file mode 100644 index 0000000000..490940fdb4 --- /dev/null +++ b/crates/ide-plugin/tests/fixtures/project-view/src/lib.rs @@ -0,0 +1,56 @@ +use openidea_plugin::project_view::{NativeNode, ProjectViewProvider, ProjectionKind, ProjectionNode}; +use openidea_plugin::{Error, Invocation, Plugin, RevisionComparison, host, register_plugin}; + +#[derive(Default)] +struct Fixture; + +impl Plugin for Fixture { + fn run_command(&mut self, id: &str, ctx: &Invocation, arg: Option<&str>) -> Result, Error> { + if id == "compare" { + // `repository|left|right` + let mut parts = arg.unwrap_or_default().split('|').map(str::to_owned); + let (Some(repository), Some(left), Some(right)) = (parts.next(), parts.next(), parts.next()) else { + return Err(Error::Invalid("expected repository|left|right".into())); + }; + let comparison = + RevisionComparison { repository, left, right, left_label: Some("Base".into()), right_label: None }; + host::open_revision_comparison(&comparison)?; + return Ok(None); + } + if id != "branch" { + return Err(Error::NotFound(id.into())); + } + let context = ctx.git_action_context().ok_or_else(|| Error::NotFound("git menu context".into()))?; + let branch = context.branch.map(|branch| branch.full_ref).unwrap_or_default(); + Ok(Some(format!("{}|{branch}", context.repositories.join(",")))) + } +} + +impl ProjectViewProvider for Fixture { + fn modify_children( + &mut self, + _view_id: &str, + _parent: &NativeNode, + children: &[NativeNode], + settings: &str, + _ctx: &Invocation<'_>, + ) -> Option> { + if settings.contains("\"plain\":true") { + return None; + } + let grouped: Vec<_> = children.iter().filter(|node| node.label.starts_with("mod_")).collect(); + if grouped.is_empty() { + return None; + } + let folder = ProjectionKind::VirtualFolder { label: "mod".into(), icon: None }; + let mut nodes = vec![ProjectionNode { id: "mod".into(), parent: None, kind: folder }]; + nodes.extend(grouped.into_iter().map(|node| ProjectionNode { + id: node.id.clone(), + parent: Some("mod".into()), + kind: ProjectionKind::ExistingNode, + })); + Some(nodes) + } +} + +register_plugin!(Fixture, project_view); diff --git a/crates/ide-plugin/tests/fixtures/rename/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/rename/dist/plugin.wasm index 4c1b811165..2b85a7fced 100644 Binary files a/crates/ide-plugin/tests/fixtures/rename/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/rename/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/rename/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/rename/dist/plugin.wasm.sources index 88ea895774..42a620bbf1 100644 --- a/crates/ide-plugin/tests/fixtures/rename/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/rename/dist/plugin.wasm.sources @@ -1 +1 @@ -463d3fda155ee87f8ec95d9dc38da060da513fb6ade2305b45c067a73a6b34f1 +c11ffdbdfd871a2f6ac7bbbfece97ac58b5162051351236e33049221cae6fb19 diff --git a/crates/ide-plugin/tests/fixtures/run-anything/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/run-anything/dist/plugin.wasm index b50fc77ca7..67bcfd0376 100644 Binary files a/crates/ide-plugin/tests/fixtures/run-anything/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/run-anything/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/run-anything/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/run-anything/dist/plugin.wasm.sources index 0b52694b34..20e779559c 100644 --- a/crates/ide-plugin/tests/fixtures/run-anything/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/run-anything/dist/plugin.wasm.sources @@ -1 +1 @@ -18333ac68547a277306b7bc4e33321423c417399dd63d046f20b50a9a37d0fdf +02f53d543c5f07c2c1afd54447c26bada486e36e4c560f6ed712e315ab898b40 diff --git a/crates/ide-plugin/tests/fixtures/run-output/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/run-output/dist/plugin.wasm index 8bc5c95c7e..68de83cc86 100644 Binary files a/crates/ide-plugin/tests/fixtures/run-output/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/run-output/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/run-output/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/run-output/dist/plugin.wasm.sources index 87209960aa..953aa2315e 100644 --- a/crates/ide-plugin/tests/fixtures/run-output/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/run-output/dist/plugin.wasm.sources @@ -1 +1 @@ -e2cb367c7df57766676fcf7ecd34e6ee78d541662fb1ed80fc0c36140b12bf7e +501d55f3b0befb95d956f34b6334ef0b1aa5dcd851403644c68027eb83b74290 diff --git a/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm index 6501829af9..a28e256057 100644 Binary files a/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm.sources index b801759ee0..d5d57d354f 100644 --- a/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/search/dist/plugin.wasm.sources @@ -1 +1 @@ -c4e910f2f4582d436851242fb4a0ecdfb3140262ee18e7dfbca064ac724b5388 +88b0ed7663311accef6e2019ef1256bee191227d157ad4c6b70a23a30655d75d diff --git a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm index 8289295bd0..50a5e84d2c 100644 Binary files a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources index 29ce74e934..5819ca855f 100644 --- a/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/semantic-tokens/dist/plugin.wasm.sources @@ -1 +1 @@ -ed38663014507490713c3b2161ec40b85b574309f34f8de8c8230f44e7b27e68 +d9bc7c65f445c44f748d8578282311bc0e975a8379c1d2447591d69863c027dd diff --git a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm index 96141a1c76..2331b0d612 100644 Binary files a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources index 5afbc8ed0a..8e7a8aec9b 100644 --- a/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/settings-pages/dist/plugin.wasm.sources @@ -1 +1 @@ -fd4b4702801cecf9ad5e7cb20a1a14e33bd47d1056e0b0599ffdc3e3c12d602a +b9ba467dac9a4d4d00548c142867148d54b69a4c6c5a4bac101e5ca804001659 diff --git a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm index 489e2670fa..57b7f63956 100644 Binary files a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources index 4af0a6b947..fad6941cdd 100644 --- a/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/storage/dist/plugin.wasm.sources @@ -1 +1 @@ -707c1cae57b3fe5793980e51be4ee7e8eae3e096b2a22f1d6d6992f17184f253 +73220abbde537220bdd81e3e06d691faf03d4f59a7ac73a002d94b74ee6f7c69 diff --git a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm index e9f9554d29..26c24469f6 100644 Binary files a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources index 7493593ecb..49a40a2f31 100644 --- a/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/symbols/dist/plugin.wasm.sources @@ -1 +1 @@ -ac4599f535c3036ac923c200990892659b40c89fcc2c4e03433bae99c4c8e0cb +b909f95da09137e2345777420d9c0ef682037ff8378822f45ae83c81b9486f8e diff --git a/crates/ide-plugin/tests/fixtures/syntax-decorations/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/syntax-decorations/dist/plugin.wasm index 092234a542..6581579b5a 100644 Binary files a/crates/ide-plugin/tests/fixtures/syntax-decorations/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/syntax-decorations/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/syntax-decorations/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/syntax-decorations/dist/plugin.wasm.sources index c6add51647..53fe2d4cb6 100644 --- a/crates/ide-plugin/tests/fixtures/syntax-decorations/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/syntax-decorations/dist/plugin.wasm.sources @@ -1 +1 @@ -51b464c093e9dae9b76f0c495a018241b0a92a1a538f2bbd8dbe4a1e28719b2e +19a5d6698bd6d5f29e611700ab43f6a5c6a71578be1430300b6d6c1862314847 diff --git a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm index e56310b5d2..5d3d390c13 100644 Binary files a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources index e4059ddf91..7c1d28f83f 100644 --- a/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/tables/dist/plugin.wasm.sources @@ -1 +1 @@ -9137548d7f702130ae7532730395bbcc9528cfa71d40b3dcb8892b7fad468580 +657c3ab43080200952e6e0bfef0c093ae97fa69b0100a157b9302fd72d52c3b7 diff --git a/crates/ide-plugin/tests/fixtures/watch-paths/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/watch-paths/dist/plugin.wasm index 8de1760a6b..a50c04edd4 100644 Binary files a/crates/ide-plugin/tests/fixtures/watch-paths/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/watch-paths/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/watch-paths/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/watch-paths/dist/plugin.wasm.sources index 87742adaba..d3aa88d1a5 100644 --- a/crates/ide-plugin/tests/fixtures/watch-paths/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/watch-paths/dist/plugin.wasm.sources @@ -1 +1 @@ -bba64387e8549a57180f2229643fad42edf7ec4b1b721a8971cc5aa765f792cb +b66391a67c81c81c08bac4f555700b0b505c702c2f26a28cf79a5cb9a21d65af diff --git a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm index 6d8bfb4371..c3596aa299 100644 Binary files a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources index e5193707eb..dae3cfb68c 100644 --- a/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/web-content/dist/plugin.wasm.sources @@ -1 +1 @@ -252e125661221d90fd442e857cf5fe85b4cc9c107884c6c41bf25cffec2aad0d +158d9571167816fd8256b8743f8b9857cb0248d278344a88aa4e4e4088558337 diff --git a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm index a6c693e39c..ba3b642064 100644 Binary files a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources index 40837d9001..e9fe151fe7 100644 --- a/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/web-log/dist/plugin.wasm.sources @@ -1 +1 @@ -5aaacae105dbb30e7a250ce16788fd9e4079fbbc23bf07dd28b6234c44cdecd7 +687872e0895cf85697e6d855a211ec5453867a063d0565de26e1466d4eda9a81 diff --git a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm index 20ed8623a0..b854f54ee3 100644 Binary files a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm and b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm differ diff --git a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources index c3ed29be73..2a8fd1745a 100644 --- a/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources +++ b/crates/ide-plugin/tests/fixtures/web-pty/dist/plugin.wasm.sources @@ -1 +1 @@ -a989869e6c76d929bc418fbd56b7477efc2120c9b090f7a76c2c9c632e9bbf26 +259ab86c076df084c7ac052271fbe940018dc72b206564887480c5ea034aca61 diff --git a/crates/ide-vcs/src/lib.rs b/crates/ide-vcs/src/lib.rs index 9c03890c64..00dafd0ba7 100644 --- a/crates/ide-vcs/src/lib.rs +++ b/crates/ide-vcs/src/lib.rs @@ -1185,6 +1185,16 @@ pub fn init(dir: &Path) -> IdeResult<()> { cli::run(dir, &["init", "-q"], None).map(|_| ()) } +/// Checks a complete reference name using Git's reference naming rules. +pub fn is_valid_reference_name(reference: &str) -> bool { + gix::validate::reference::name(reference.into()).is_ok() +} + +/// Whether `id` is a complete hexadecimal Git object ID. +pub fn is_full_commit_id(id: &str) -> bool { + matches!(id.len(), 40 | 64) && id.bytes().all(|b| b.is_ascii_hexdigit()) +} + /// Line hunks of `new_text` against `old_text` (CRLF-normalised, Histogram diff), in the /// order [`build_partial_patch`] indexes them. pub fn diff_hunks(old_text: &str, new_text: &str) -> Vec { @@ -1240,6 +1250,12 @@ impl Repo { pub fn is_stale(&self) -> bool { self.stale.load(std::sync::atomic::Ordering::Acquire) } + /// Whether the full object ID identifies a commit in this repository. + pub fn contains_commit_id(&self, id: &str) -> IdeResult { + let _scope = self.execution_scope(); + let id = gix::ObjectId::from_hex(id.as_bytes()).map_err(repo::gx)?; + Ok(self.gix()?.try_find_header(id).map_err(repo::gx)?.is_some_and(|h| h.kind() == gix::object::Kind::Commit)) + } /// git's own folders for this worktree: its git dir and the common one (they differ for a /// linked worktree, whose `.git` file points into the main repository). pub fn metadata_dirs(&self) -> IdeResult<[PathBuf; 2]> { diff --git a/docs/en/plugins/versioning.mdx b/docs/en/plugins/versioning.mdx index 17cf76417c..8f64e25944 100644 --- a/docs/en/plugins/versioning.mdx +++ b/docs/en/plugins/versioning.mdx @@ -1,9 +1,9 @@ --- title: "API versions and compatibility" -description: "engines.openidea, the plugin API versions from 1.0 to 1.21, and the rules that keep released plugins loading in newer IDEs." +description: "engines.openidea, the plugin API versions from 1.0 to 1.23, and the rules that keep released plugins loading in newer IDEs." --- -The plugin API has one version number: the version of the WIT package in [`wit/`](https://github.com/l0ng-ai/openidea/tree/main/wit) (`openidea:plugin@1.21.0` on `main`). The host's engine version and the SDK's `API_VERSION` always agree with it, and the SDK carries an identical copy of the WIT files. +The plugin API has one version number: the version of the WIT package in [`wit/`](https://github.com/l0ng-ai/openidea/tree/main/wit) (`openidea:plugin@1.21.0` in this source tree). The host's engine version and the SDK's `API_VERSION` always agree with it, and the SDK carries an identical copy of the WIT files. The plugin system is a preview. The compatibility rules below hold for released 1.x versions; what is still unreleased @@ -12,30 +12,30 @@ The plugin API has one version number: the version of the WIT package in [`wit/` ## Versions -| API | Shipped with | Highlights | -| ------ | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 1.0.0 | OpenIDEA 0.1.36 | The base API: commands, events, storage, tasks, project and editor access, VCS, diagnostics, network and secrets, processes, declarative views and custom editors, settings, editor providers, syntax provider | -| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`, `ui.copy-to-clipboard`, `ui.open-url`, opening a project file at a line from a view | -| 1.2.0 | OpenIDEA 0.1.38 | Background document indexers, pickers, input boxes and confirmations, plugin context keys for `when` clauses, the files selected in the Project view, a manifest `icon`, the `viewItem.context` menu | -| 1.3.0 | OpenIDEA 0.1.39 | Commit message and before-commit checks, Services detail panes, diagnostics while typing, hover, inlay hints, semantic tokens, file-changing code actions, HTTP endpoints, files outside the project (`fs.read`/`fs.write`, `project.write`, private plugin directory), batched `files-changed` events and path filters, workspace symbols, long-running processes, notifications with buttons, translations, multi-page settings, file template variables, web view PTYs, log tabs and content tabs | -| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`, `ipc:`, `ide.commands` and `database.sources` capabilities; editor and project snapshots, decorations, text search, Problems, Git log/blame/diff; output channels; OAuth loopback; runs, terminal sessions, run configurations, test result parsing and run targets; formatting and other language features; embedded languages; snippets; more menu locations; database sources; MCP tools | -| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify` (a notification in one project's window), the `net:ask` capability, run target validation, per-command run target working-directory arguments | -| 1.6.0 | OpenIDEA 0.1.43 | Bounded, project-bound background WebSockets for event-stream plugins | -| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`: two texts in the diff viewer, such as a review's file before and after | -| 1.8.0 | OpenIDEA 0.1.45 | The `problems-changed` workbench event: the host keeps every producer's diagnostics per file, so an annotation follows the file rather than the invoking window | -| 1.9.0 | OpenIDEA 0.1.46 | Run configurations with an environment and a debugger, requests to a running language server (`lsp:`), server commands routed to plugins, editor panels | -| 1.10.0 | OpenIDEA 0.1.47 | `build.dependencies`: the Maven / Gradle dependency graph the IDE resolved (`build.read`) | -| 1.11.0 | OpenIDEA 0.1.48 | `ui.read-clipboard`: the clipboard's text and image in commands the user ran (`clipboard.read`) | -| 1.12.0 | OpenIDEA 0.1.49 | `ui.set-console-rules`: highlight rules (regex, palette colours, styles) for Run and Debug console output | -| 1.13.0 | OpenIDEA 0.1.49 | Optional `search-provider` export and `searchCategories`: custom Search Everywhere tabs with cancellable queries | -| 1.14.0 | OpenIDEA 0.1.50 | Optional `hover-actions` export: left-edge line actions revealed by line-edge hover, with an anchor line and inclusive trigger range; `[[contributes.javaAgents]]` `vmOptions` / `jdk`: JVM flags (optionally JetBrains Runtime–only) before `-javaagent:`; `ui.set-status-item-menu` / `set-window-status-item-menu`: a menu on a status bar item | -| 1.15.0 | OpenIDEA 0.1.51 | `caret-moved` event; declarative `[[contributes.skills]]` (`path = "skills//SKILL.md"`) for bundling agent skills in plugins | -| 1.16.0 | OpenIDEA 0.1.52 | Optional `completion-list-provider` export: completion marked incomplete is asked again while typing on, without re-asking the language server or other plugins; `decorations.set-markdown`: line-end decorations whose hover is a Markdown card | -| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`: editor decorations with their own `#rrggbb` / `#rrggbbaa` foreground and background, for colors outside the theme palette | -| 1.18.0 | OpenIDEA 0.1.54 | `[[contributes.overlays]]`: a package web page floating over the workbench that never takes the keyboard focus, placed and resized through `openidea.overlay`; `[[contributes.dialogs]]`: a package web page in a modal, resizable IDE dialog opened with `views.reveal`, with a `closed` view event and `openidea.dialog.close()`; `events.subscribe-paths-with-options` (`debounce-ms`), `workspace.project.generation` and `FilesChanged` project/generation fields, stale run target/configuration rejection, and the `project-closed` lifecycle event; `execution-configurations`, `run.start-with-options` and `runDetectors.outputMode`: `pipes` or `pty` console output for plugin run configurations; `[[contributes.runAnything]]` with the `run-anything-provider` export: Run Anything lines starting with the plugin's prefix; `views.open-terminal-session-in`: a keyed terminal in a project directory; `workspace.invoking-project`: the project of the window a call serves, also in `gutter-actions` and `hover-actions`; `events.watch-paths` and the `watched-files-changed` event: files and directories outside the project, within `fs.read` grants; the `run-configuration-completion` export: completion in the Arguments field of the plugin's own run configurations; `services.context` and `services.toolbar` menus on the IDE's own Services nodes, with the selected services as the command argument; `executor` on `[[contributes.javaAgents]]`: "Run/Debug '\' with \" beside Run and Debug, the only launches that get that agent, also startable from the plugin's own commands with a configuration id; grant-scoped `agents.fork-session`: fork a recorded native agent session (`claude`, `codex`, or `copilot`) into a new task in the invoking window's project (`agents` capability), with the host validating the session and building the fork invocation itself | -| 1.19.0 | OpenIDEA 0.1.56 | `[capabilities.reasons]`: the plugin's own sentence on why it asks for a capability, shown below the host's description in the permission dialog and Settings › Plugins; `settings.open` / `settings.open-permissions`: open Settings at one of the plugin's own pages or at its permissions; `net.fetch-stream`: a response whose body is read as it arrives (server-sent events, streamed model replies), with the SDK's `host::fetch_stream` and `sse` parser; `editor.open-as-text`: open a file in the built-in text editor even when a custom editor claims it (the SDK's `host::open_editor_as_text`); the `openIn` menu: the **Open In** submenu of the editor, its tab and the Project view | -| 1.20.0 | OpenIDEA 0.1.57 | Database table context menus and read-only table schema inspection (`database.schema`). Optional `syntax-decorations-provider` export: foreground marks on an open text editor, in the theme tokens `rainbow-1` … `rainbow-5` or its own `#rrggbb` colours for dark and light themes, and a bounded slice of the editor's syntax tree. | -| 1.21.0 | In development | Run lifecycle & Run Config extensions: `run-started` event, `run-exited` for user-launched plugin runs, `run.stop`, `"java"` in `attach-child`, `prepareCommand` `mode` (`"run"` / `"debug"`) and loopback `javaDebug` JDWP attach, `run.upsert-configuration`, `run.open-edit-configurations`, `ownsBeforeLaunch`, transient `logFiles` log-tail tabs (`project.read` / `fs.read`), and the `runConsole.toolbar` menu. Settings controls: `presentation` (`radio`, `segmented`, `slider`, `color`, `checkbox-list`), `enumOptions` labels, hints and icons for `enum` values, `minimum` / `maximum` / `step`, and `when` conditions that hide a setting. `build.sdks` and `build.artifacts` under `build.read`: read installed JDKs/Maven/toolchains (`active` marking the project selection), build-model Maven/Gradle WAR artifacts, and Project Structure › Artifacts definitions (with `id`, `origin`, and `tool`) in trusted projects. `TextEditor::visible_lines` under `editor.read`: the first and last document line on screen when the command or event was invoked. `cloneSources`: plugin pages in the Clone Repository dialog's source list. `popup = true` on `[[contributes.dialogs]]`: a lightweight popup that closes on a click outside it or when the window loses focus. Database discovery and SQL execution in trusted projects: `database.connected-sources`, `database.list-schemas`, and `database.list-tables` under `database.schema`, plus bounded `database.execute-query` under the separate high-risk `database.query` capability. Run devices: `[[contributes.devices]]` lists emulators, simulators and phones in a title bar chooser for the configurations it applies to. | +| API | Shipped with | Highlights | +| ------ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 1.0.0 | OpenIDEA 0.1.36 | The base API: commands, events, storage, tasks, project and editor access, VCS, diagnostics, network and secrets, processes, declarative views and custom editors, settings, editor providers, syntax provider | +| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`, `ui.copy-to-clipboard`, `ui.open-url`, opening a project file at a line from a view | +| 1.2.0 | OpenIDEA 0.1.38 | Background document indexers, pickers, input boxes and confirmations, plugin context keys for `when` clauses, the files selected in the Project view, a manifest `icon`, the `viewItem.context` menu | +| 1.3.0 | OpenIDEA 0.1.39 | Commit message and before-commit checks, Services detail panes, diagnostics while typing, hover, inlay hints, semantic tokens, file-changing code actions, HTTP endpoints, files outside the project (`fs.read`/`fs.write`, `project.write`, private plugin directory), batched `files-changed` events and path filters, workspace symbols, long-running processes, notifications with buttons, translations, multi-page settings, file template variables, web view PTYs, log tabs and content tabs | +| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`, `ipc:`, `ide.commands` and `database.sources` capabilities; editor and project snapshots, decorations, text search, Problems, Git log/blame/diff; output channels; OAuth loopback; runs, terminal sessions, run configurations, test result parsing and run targets; formatting and other language features; embedded languages; snippets; more menu locations; database sources; MCP tools | +| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify` (a notification in one project's window), the `net:ask` capability, run target validation, per-command run target working-directory arguments | +| 1.6.0 | OpenIDEA 0.1.43 | Bounded, project-bound background WebSockets for event-stream plugins | +| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`: two texts in the diff viewer, such as a review's file before and after | +| 1.8.0 | OpenIDEA 0.1.45 | The `problems-changed` workbench event: the host keeps every producer's diagnostics per file, so an annotation follows the file rather than the invoking window | +| 1.9.0 | OpenIDEA 0.1.46 | Run configurations with an environment and a debugger, requests to a running language server (`lsp:`), server commands routed to plugins, editor panels | +| 1.10.0 | OpenIDEA 0.1.47 | `build.dependencies`: the Maven / Gradle dependency graph the IDE resolved (`build.read`) | +| 1.11.0 | OpenIDEA 0.1.48 | `ui.read-clipboard`: the clipboard's text and image in commands the user ran (`clipboard.read`) | +| 1.12.0 | OpenIDEA 0.1.49 | `ui.set-console-rules`: highlight rules (regex, palette colours, styles) for Run and Debug console output | +| 1.13.0 | OpenIDEA 0.1.49 | Optional `search-provider` export and `searchCategories`: custom Search Everywhere tabs with cancellable queries | +| 1.14.0 | OpenIDEA 0.1.50 | Optional `hover-actions` export: left-edge line actions revealed by line-edge hover, with an anchor line and inclusive trigger range; `[[contributes.javaAgents]]` `vmOptions` / `jdk`: JVM flags (optionally JetBrains Runtime–only) before `-javaagent:`; `ui.set-status-item-menu` / `set-window-status-item-menu`: a menu on a status bar item | +| 1.15.0 | OpenIDEA 0.1.51 | `caret-moved` event; declarative `[[contributes.skills]]` (`path = "skills//SKILL.md"`) for bundling agent skills in plugins | +| 1.16.0 | OpenIDEA 0.1.52 | Optional `completion-list-provider` export: completion marked incomplete is asked again while typing on, without re-asking the language server or other plugins; `decorations.set-markdown`: line-end decorations whose hover is a Markdown card | +| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`: editor decorations with their own `#rrggbb` / `#rrggbbaa` foreground and background, for colors outside the theme palette | +| 1.18.0 | OpenIDEA 0.1.54 | `[[contributes.overlays]]`: a package web page floating over the workbench that never takes the keyboard focus, placed and resized through `openidea.overlay`; `[[contributes.dialogs]]`: a package web page in a modal, resizable IDE dialog opened with `views.reveal`, with a `closed` view event and `openidea.dialog.close()`; `events.subscribe-paths-with-options` (`debounce-ms`), `workspace.project.generation` and `FilesChanged` project/generation fields, stale run target/configuration rejection, and the `project-closed` lifecycle event; `execution-configurations`, `run.start-with-options` and `runDetectors.outputMode`: `pipes` or `pty` console output for plugin run configurations; `[[contributes.runAnything]]` with the `run-anything-provider` export: Run Anything lines starting with the plugin's prefix; `views.open-terminal-session-in`: a keyed terminal in a project directory; `workspace.invoking-project`: the project of the window a call serves, also in `gutter-actions` and `hover-actions`; `events.watch-paths` and the `watched-files-changed` event: files and directories outside the project, within `fs.read` grants; the `run-configuration-completion` export: completion in the Arguments field of the plugin's own run configurations; `services.context` and `services.toolbar` menus on the IDE's own Services nodes, with the selected services as the command argument; `executor` on `[[contributes.javaAgents]]`: "Run/Debug '\' with \" beside Run and Debug, the only launches that get that agent, also startable from the plugin's own commands with a configuration id; grant-scoped `agents.fork-session`: fork a recorded native agent session (`claude`, `codex`, or `copilot`) into a new task in the invoking window's project (`agents` capability), with the host validating the session and building the fork invocation itself | +| 1.19.0 | OpenIDEA 0.1.56 | `[capabilities.reasons]`: the plugin's own sentence on why it asks for a capability, shown below the host's description in the permission dialog and Settings › Plugins; `settings.open` / `settings.open-permissions`: open Settings at one of the plugin's own pages or at its permissions; `net.fetch-stream`: a response whose body is read as it arrives (server-sent events, streamed model replies), with the SDK's `host::fetch_stream` and `sse` parser; `editor.open-as-text`: open a file in the built-in text editor even when a custom editor claims it (the SDK's `host::open_editor_as_text`); the `openIn` menu: the **Open In** submenu of the editor, its tab and the Project view | +| 1.20.0 | OpenIDEA 0.1.57 | Database table context menus and read-only table schema inspection (`database.schema`). Optional `syntax-decorations-provider` export: foreground marks on an open text editor, in the theme tokens `rainbow-1` … `rainbow-5` or its own `#rrggbb` colours for dark and light themes, and a bounded slice of the editor's syntax tree. | +| 1.21.0 | In development | Run lifecycle & Run Config extensions: `run-started` event, `run-exited` for user-launched plugin runs, `run.stop`, `"java"` in `attach-child`, `prepareCommand` `mode` (`"run"` / `"debug"`) and loopback `javaDebug` JDWP attach, `run.upsert-configuration`, `run.open-edit-configurations`, `ownsBeforeLaunch`, transient `logFiles` log-tail tabs (`project.read` / `fs.read`), and the `runConsole.toolbar` menu. Settings controls: `presentation` (`radio`, `segmented`, `slider`, `color`, `checkbox-list`), `enumOptions` labels, hints and icons for `enum` values, `minimum` / `maximum` / `step`, and `when` conditions that hide a setting. `build.sdks` and `build.artifacts` under `build.read`: read installed JDKs/Maven/toolchains (`active` marking the project selection), build-model Maven/Gradle WAR artifacts, and Project Structure › Artifacts definitions (with `id`, `origin`, and `tool`) in trusted projects. `TextEditor::visible_lines` under `editor.read`: the first and last document line on screen when the command or event was invoked. `cloneSources`: plugin pages in the Clone Repository dialog's source list. `popup = true` on `[[contributes.dialogs]]`: a lightweight popup that closes on a click outside it or when the window loses focus. Database discovery and SQL execution in trusted projects: `database.connected-sources`, `database.list-schemas`, and `database.list-tables` under `database.schema`, plus bounded `database.execute-query` under the separate high-risk `database.query` capability. Run devices: `[[contributes.devices]]` lists emulators, simulators and phones in a title bar chooser for the configurations it applies to. Project view panes (`[[contributes.projectViewPanes]]`, the `project-view-provider` export, `project-view.refresh` / `select-in`, `projectViewContext` menu items) under `project.read`; `git.branches.popup` / `git.branch.context` menus with `invocation.git-action-context` and `views.open-revision-comparison` under `vcs.read`. | The full list of what each version added is in [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md). diff --git a/docs/zh/plugins/versioning.mdx b/docs/zh/plugins/versioning.mdx index f54254f4b9..defa7ef61f 100644 --- a/docs/zh/plugins/versioning.mdx +++ b/docs/zh/plugins/versioning.mdx @@ -1,38 +1,38 @@ --- title: "API 版本与兼容" -description: "engines.openidea、插件 API 从 1.0 到 1.21 的各个版本,以及让已发布插件在新 IDE 中继续加载的规则。" +description: "engines.openidea、插件 API 从 1.0 到 1.23 的各个版本,以及让已发布插件在新 IDE 中继续加载的规则。" --- -插件 API 只有一个版本号:[`wit/`](https://github.com/l0ng-ai/openidea/tree/main/wit) 中 WIT 包的版本(`main` 上是 `openidea:plugin@1.21.0`)。宿主的引擎版本和 SDK 的 `API_VERSION` 始终与它一致,SDK 里也带着一份完全相同的 WIT 文件。 +插件 API 只有一个版本号:[`wit/`](https://github.com/l0ng-ai/openidea/tree/main/wit) 中 WIT 包的版本(当前为 `openidea:plugin@1.21.0`)。宿主的引擎版本和 SDK 的 `API_VERSION` 始终与它一致,SDK 里也带着一份完全相同的 WIT 文件。 插件系统目前是预览版。下面的兼容规则适用于已发布的 1.x 版本;`main` 上尚未发布的内容在发布前仍可能变化。 ## 版本历史 -| API | 随哪个版本发布 | 主要内容 | -| ------ | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| 1.0.0 | OpenIDEA 0.1.36 | 基础 API:命令、事件、存储、任务、项目和编辑器访问、VCS、诊断、网络与密钥、进程、声明式视图和自定义编辑器、设置、编辑器 provider、syntax provider | -| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`、`ui.copy-to-clipboard`、`ui.open-url`,从视图中打开项目文件的指定行 | -| 1.2.0 | OpenIDEA 0.1.38 | 后台文档索引器;选择器、输入框和确认框;插件自定义的 `when` 上下文键;项目视图中选中的文件;清单 `icon`;`viewItem.context` 菜单 | -| 1.3.0 | OpenIDEA 0.1.39 | 提交信息和提交前检查、Services 详情面板、输入时诊断、悬停、内嵌提示、语义 token、改动文件的代码操作、HTTP 端点、项目外文件(`fs.read`/`fs.write`、`project.write`、插件私有目录)、批量 `files-changed` 事件和路径过滤、工作区符号、长时间运行的进程、带按钮的通知、翻译、多页设置、文件模板变量、Web 视图 PTY、日志标签页和内容标签页 | -| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`、`ipc:`、`ide.commands` 和 `database.sources` 能力;编辑器与项目快照、装饰、文本搜索、问题视图、Git log/blame/diff;输出通道;OAuth 回环;运行、终端会话、运行配置、测试结果解析和运行目标;格式化等语言功能;嵌入语言;代码片段;更多菜单位置;数据库数据源;MCP 工具 | -| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify`(只在某个项目的窗口中显示通知)、`net:ask` 能力、运行目标启动前校验、运行目标按命令设置工作目录参数 | -| 1.6.0 | OpenIDEA 0.1.43 | 面向事件流插件、受容量限制且绑定项目的后台 WebSocket | -| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`:在差异查看器中对比两段文本,例如评审中某个文件的修改前后 | -| 1.8.0 | OpenIDEA 0.1.45 | `problems-changed` 工作台事件:宿主按文件保存每个生产者的诊断,注解跟着文件走,而不是跟着调用它的窗口 | -| 1.9.0 | OpenIDEA 0.1.46 | 带环境变量和调试器的运行配置、向正在运行的语言服务器发送请求(`lsp:`)、交给插件处理的服务器命令、编辑器面板 | -| 1.10.0 | OpenIDEA 0.1.47 | `build.dependencies`:IDE 已解析的 Maven / Gradle 依赖图(`build.read`) | -| 1.11.0 | OpenIDEA 0.1.48 | `ui.read-clipboard`:在用户运行的命令中读取剪贴板的文本和图片(`clipboard.read`) | -| 1.12.0 | OpenIDEA 0.1.49 | `ui.set-console-rules`:Run/Debug 控制台输出的高亮规则(正则、调色板颜色、文本样式) | -| 1.13.0 | OpenIDEA 0.1.49 | 新增 `search-provider` 导出和 `searchCategories` 贡献点:可取消查询的全局搜索自定义分类 | -| 1.14.0 | OpenIDEA 0.1.50 | 可选 `hover-actions` 导出:行内侧 hover 显示的左侧操作,带锚定行和包含式触发行范围; `[[contributes.javaAgents]]` 的 `vmOptions` / `jdk`:在 `-javaagent:` 之前注入 JVM 参数(可选仅 JetBrains Runtime);`ui.set-status-item-menu` / `set-window-status-item-menu`:状态栏项菜单 | -| 1.15.0 | OpenIDEA 0.1.51 | `caret-moved` 事件;声明式 `[[contributes.skills]]`(`path = "skills//SKILL.md"`),在插件包中打包代理技能 | -| 1.16.0 | OpenIDEA 0.1.52 | 可选 `completion-list-provider` 导出:标记为不完整的补全在继续输入时再次询问,不会重新询问语言服务器和其他插件;`decorations.set-markdown`:悬停显示 Markdown 卡片的行尾装饰 | -| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`:自带 `#rrggbb` / `#rrggbbaa` 前景色和背景色的编辑器装饰,用于主题调色板之外的颜色 | -| 1.18.0 | OpenIDEA 0.1.54 | `[[contributes.overlays]]`:悬浮在工作台上方、从不抢占键盘焦点的插件网页,可通过 `openidea.overlay` 移动和调整大小;`[[contributes.dialogs]]`:插件网页显示在可调整大小的模态对话框中,用 `views.reveal` 打开,关闭时发 `closed` 视图事件,页面可调用 `openidea.dialog.close()`;`events.subscribe-paths-with-options`(`debounce-ms`)、`workspace.project.generation` 与 `FilesChanged` 的 `project`/`generation` 字段、过期运行目标/配置拒绝以及 `project-closed` 生命周期事件;`execution-configurations`、`run.start-with-options` 与 `runDetectors.outputMode`:插件运行配置的控制台输出方式(`pipes` 或 `pty`);`[[contributes.runAnything]]` 与 `run-anything-provider` 导出:以插件前缀开头的 Run Anything 行;`views.open-terminal-session-in`:在项目子目录中打开带 key 的终端;`workspace.invoking-project`:本次调用所服务窗口的项目,`gutter-actions` 和 `hover-actions` 中也可用;`events.watch-paths` 与 `watched-files-changed` 事件:监听项目之外、`fs.read` 授权范围内的文件和目录;`run-configuration-completion` 导出:补全插件自己运行配置的“实参”字段;`services.context` 和 `services.toolbar` 菜单:作用于 IDE 自带的 Services 节点,命令参数是选中的服务;`[[contributes.javaAgents]]` 的 `executor`:运行和调试旁边的“使用 \ 运行/调试 '\'”,只有经它启动时才加载该代理,插件自己的命令也可用配置 id 经它启动;需授权的 `agents.fork-session`:把录制的原生 agent 会话(`claude`、`codex` 或 `copilot`)派生为调用窗口项目中的新任务(`agents` 能力),宿主自行校验会话并构造 fork 调用 | -| 1.19.0 | OpenIDEA 0.1.56 | `[capabilities.reasons]`:插件用一句话说明为什么需要某个能力,显示在授权对话框和 设置 › 插件 中宿主说明的下方;`settings.open` / `settings.open-permissions`:打开设置并定位到插件自己的页面或它的权限;`net.fetch-stream`:边到达边读取响应体(服务器推送事件 SSE、模型的流式回复),SDK 提供 `host::fetch_stream` 和 `sse` 解析器;`editor.open-as-text`:即使文件被自定义编辑器认领,也用内置文本编辑器打开(SDK 的 `host::open_editor_as_text`);菜单点 `openIn`:编辑器、标签页和项目视图的 **打开方式** 子菜单 | -| 1.20.0 | OpenIDEA 0.1.57 | 数据库表的上下文菜单和只读表结构查看(`database.schema`)。可选的 `syntax-decorations-provider` 导出:用主题 token `rainbow-1` … `rainbow-5` 或自带的深色/浅色主题 `#rrggbb` 颜色,给打开的文本编辑器中的范围涂前景色,依据编辑器语法树的有界片段。 | -| 1.21.0 | `main` 上开发中 | 运行配置与运行生命周期扩展:`run-started` 事件与用户启动配置时的 `run-exited`、`run.stop`、`attach-child` 支持 `"java"`、`prepareCommand` 传入 `mode`(`"run"` / `"debug"`)并支持回环 `javaDebug` 附加 JDWP 调试器、`run.upsert-configuration`、`run.open-edit-configurations`、`ownsBeforeLaunch`、控制台日志文件实时标签页 `logFiles`(按 `project.read` / `fs.read` 授权)以及 `runConsole.toolbar` 菜单位置。设置控件:`presentation`(`radio`、`segmented`、`slider`、`color`、`checkbox-list`),为 `enum` 值提供标签、说明和图标的 `enumOptions`,`minimum` / `maximum` / `step`,以及隐藏设置的 `when` 条件。`build.read` 新增 `build.sdks` 与 `build.artifacts`:在受信任项目中读取已安装的 JDK / Maven / 工具链(带项目当前选中的 `active` 标记)以及构建模型 Maven/Gradle WAR 产物和 Project Structure › Artifacts 定义(含 `id`、`origin` 与 `tool`)。`editor.read` 下的 `TextEditor::visible_lines`:命令或事件触发时屏幕上显示的首行和末行。`[[contributes.dialogs]]` 的 `popup = true`:轻量弹出层,点击外部或窗口失去焦点时关闭。`cloneSources`:Clone Repository 对话框来源列表中的插件页面。受信任项目中的数据库发现与 SQL 执行:`database.schema` 新增 `database.connected-sources`、`database.list-schemas`、`database.list-tables`;新增独立高风险能力 `database.query` 与有界的 `database.execute-query`。 运行设备:`[[contributes.devices]]` 在标题栏的设备选择器中列出模拟器和手机,用于其适用的运行配置。 | +| API | 随哪个版本发布 | 主要内容 | +| ------ | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| 1.0.0 | OpenIDEA 0.1.36 | 基础 API:命令、事件、存储、任务、项目和编辑器访问、VCS、诊断、网络与密钥、进程、声明式视图和自定义编辑器、设置、编辑器 provider、syntax provider | +| 1.1.0 | OpenIDEA 0.1.37 | `vcs.remotes`、`ui.copy-to-clipboard`、`ui.open-url`,从视图中打开项目文件的指定行 | +| 1.2.0 | OpenIDEA 0.1.38 | 后台文档索引器;选择器、输入框和确认框;插件自定义的 `when` 上下文键;项目视图中选中的文件;清单 `icon`;`viewItem.context` 菜单 | +| 1.3.0 | OpenIDEA 0.1.39 | 提交信息和提交前检查、Services 详情面板、输入时诊断、悬停、内嵌提示、语义 token、改动文件的代码操作、HTTP 端点、项目外文件(`fs.read`/`fs.write`、`project.write`、插件私有目录)、批量 `files-changed` 事件和路径过滤、工作区符号、长时间运行的进程、带按钮的通知、翻译、多页设置、文件模板变量、Web 视图 PTY、日志标签页和内容标签页 | +| 1.4.0 | OpenIDEA 0.1.40 | `net.http:`、`ipc:`、`ide.commands` 和 `database.sources` 能力;编辑器与项目快照、装饰、文本搜索、问题视图、Git log/blame/diff;输出通道;OAuth 回环;运行、终端会话、运行配置、测试结果解析和运行目标;格式化等语言功能;嵌入语言;代码片段;更多菜单位置;数据库数据源;MCP 工具 | +| 1.5.0 | OpenIDEA 0.1.41 | `Project::notify`(只在某个项目的窗口中显示通知)、`net:ask` 能力、运行目标启动前校验、运行目标按命令设置工作目录参数 | +| 1.6.0 | OpenIDEA 0.1.43 | 面向事件流插件、受容量限制且绑定项目的后台 WebSocket | +| 1.7.0 | OpenIDEA 0.1.44 | `views.open-diff`:在差异查看器中对比两段文本,例如评审中某个文件的修改前后 | +| 1.8.0 | OpenIDEA 0.1.45 | `problems-changed` 工作台事件:宿主按文件保存每个生产者的诊断,注解跟着文件走,而不是跟着调用它的窗口 | +| 1.9.0 | OpenIDEA 0.1.46 | 带环境变量和调试器的运行配置、向正在运行的语言服务器发送请求(`lsp:`)、交给插件处理的服务器命令、编辑器面板 | +| 1.10.0 | OpenIDEA 0.1.47 | `build.dependencies`:IDE 已解析的 Maven / Gradle 依赖图(`build.read`) | +| 1.11.0 | OpenIDEA 0.1.48 | `ui.read-clipboard`:在用户运行的命令中读取剪贴板的文本和图片(`clipboard.read`) | +| 1.12.0 | OpenIDEA 0.1.49 | `ui.set-console-rules`:Run/Debug 控制台输出的高亮规则(正则、调色板颜色、文本样式) | +| 1.13.0 | OpenIDEA 0.1.49 | 新增 `search-provider` 导出和 `searchCategories` 贡献点:可取消查询的全局搜索自定义分类 | +| 1.14.0 | OpenIDEA 0.1.50 | 可选 `hover-actions` 导出:行内侧 hover 显示的左侧操作,带锚定行和包含式触发行范围; `[[contributes.javaAgents]]` 的 `vmOptions` / `jdk`:在 `-javaagent:` 之前注入 JVM 参数(可选仅 JetBrains Runtime);`ui.set-status-item-menu` / `set-window-status-item-menu`:状态栏项菜单 | +| 1.15.0 | OpenIDEA 0.1.51 | `caret-moved` 事件;声明式 `[[contributes.skills]]`(`path = "skills//SKILL.md"`),在插件包中打包代理技能 | +| 1.16.0 | OpenIDEA 0.1.52 | 可选 `completion-list-provider` 导出:标记为不完整的补全在继续输入时再次询问,不会重新询问语言服务器和其他插件;`decorations.set-markdown`:悬停显示 Markdown 卡片的行尾装饰 | +| 1.17.0 | OpenIDEA 0.1.53 | `decorations.set-styled`:自带 `#rrggbb` / `#rrggbbaa` 前景色和背景色的编辑器装饰,用于主题调色板之外的颜色 | +| 1.18.0 | OpenIDEA 0.1.54 | `[[contributes.overlays]]`:悬浮在工作台上方、从不抢占键盘焦点的插件网页,可通过 `openidea.overlay` 移动和调整大小;`[[contributes.dialogs]]`:插件网页显示在可调整大小的模态对话框中,用 `views.reveal` 打开,关闭时发 `closed` 视图事件,页面可调用 `openidea.dialog.close()`;`events.subscribe-paths-with-options`(`debounce-ms`)、`workspace.project.generation` 与 `FilesChanged` 的 `project`/`generation` 字段、过期运行目标/配置拒绝以及 `project-closed` 生命周期事件;`execution-configurations`、`run.start-with-options` 与 `runDetectors.outputMode`:插件运行配置的控制台输出方式(`pipes` 或 `pty`);`[[contributes.runAnything]]` 与 `run-anything-provider` 导出:以插件前缀开头的 Run Anything 行;`views.open-terminal-session-in`:在项目子目录中打开带 key 的终端;`workspace.invoking-project`:本次调用所服务窗口的项目,`gutter-actions` 和 `hover-actions` 中也可用;`events.watch-paths` 与 `watched-files-changed` 事件:监听项目之外、`fs.read` 授权范围内的文件和目录;`run-configuration-completion` 导出:补全插件自己运行配置的“实参”字段;`services.context` 和 `services.toolbar` 菜单:作用于 IDE 自带的 Services 节点,命令参数是选中的服务;`[[contributes.javaAgents]]` 的 `executor`:运行和调试旁边的“使用 \ 运行/调试 '\'”,只有经它启动时才加载该代理,插件自己的命令也可用配置 id 经它启动;需授权的 `agents.fork-session`:把录制的原生 agent 会话(`claude`、`codex` 或 `copilot`)派生为调用窗口项目中的新任务(`agents` 能力),宿主自行校验会话并构造 fork 调用 | +| 1.19.0 | OpenIDEA 0.1.56 | `[capabilities.reasons]`:插件用一句话说明为什么需要某个能力,显示在授权对话框和 设置 › 插件 中宿主说明的下方;`settings.open` / `settings.open-permissions`:打开设置并定位到插件自己的页面或它的权限;`net.fetch-stream`:边到达边读取响应体(服务器推送事件 SSE、模型的流式回复),SDK 提供 `host::fetch_stream` 和 `sse` 解析器;`editor.open-as-text`:即使文件被自定义编辑器认领,也用内置文本编辑器打开(SDK 的 `host::open_editor_as_text`);菜单点 `openIn`:编辑器、标签页和项目视图的 **打开方式** 子菜单 | +| 1.20.0 | OpenIDEA 0.1.57 | 数据库表的上下文菜单和只读表结构查看(`database.schema`)。可选的 `syntax-decorations-provider` 导出:用主题 token `rainbow-1` … `rainbow-5` 或自带的深色/浅色主题 `#rrggbb` 颜色,给打开的文本编辑器中的范围涂前景色,依据编辑器语法树的有界片段。 | +| 1.21.0 | `main` 上开发中 | 运行配置与运行生命周期扩展:`run-started` 事件与用户启动配置时的 `run-exited`、`run.stop`、`attach-child` 支持 `"java"`、`prepareCommand` 传入 `mode`(`"run"` / `"debug"`)并支持回环 `javaDebug` 附加 JDWP 调试器、`run.upsert-configuration`、`run.open-edit-configurations`、`ownsBeforeLaunch`、控制台日志文件实时标签页 `logFiles`(按 `project.read` / `fs.read` 授权)以及 `runConsole.toolbar` 菜单位置。设置控件:`presentation`(`radio`、`segmented`、`slider`、`color`、`checkbox-list`),为 `enum` 值提供标签、说明和图标的 `enumOptions`,`minimum` / `maximum` / `step`,以及隐藏设置的 `when` 条件。`build.read` 新增 `build.sdks` 与 `build.artifacts`:在受信任项目中读取已安装的 JDK / Maven / 工具链(带项目当前选中的 `active` 标记)以及构建模型 Maven/Gradle WAR 产物和 Project Structure › Artifacts 定义(含 `id`、`origin` 与 `tool`)。`editor.read` 下的 `TextEditor::visible_lines`:命令或事件触发时屏幕上显示的首行和末行。`[[contributes.dialogs]]` 的 `popup = true`:轻量弹出层,点击外部或窗口失去焦点时关闭。`cloneSources`:Clone Repository 对话框来源列表中的插件页面。受信任项目中的数据库发现与 SQL 执行:`database.schema` 新增 `database.connected-sources`、`database.list-schemas`、`database.list-tables`;新增独立高风险能力 `database.query` 与有界的 `database.execute-query`。 运行设备:`[[contributes.devices]]` 在标题栏的设备选择器中列出模拟器和手机,用于其适用的运行配置。Project 视图窗格(`[[contributes.projectViewPanes]]`、`project-view-provider` 导出、`project-view.refresh` / `select-in`、`projectViewContext` 菜单项),需要 `project.read`;`git.branches.popup` / `git.branch.context` 菜单、`invocation.git-action-context` 与 `views.open-revision-comparison`,需要 `vcs.read`。 | 每个版本新增内容的完整列表见 [`plugins/README.md`](https://github.com/l0ng-ai/openidea/blob/main/plugins/README.md)。 diff --git a/plugins/README.md b/plugins/README.md index af06378f4b..4d2261c8b0 100644 --- a/plugins/README.md +++ b/plugins/README.md @@ -136,37 +136,38 @@ work), but 0.1 code no longer runs: rebuild it against the 1.0 SDK. ### Contribution points -| Point | Declaration | Code needed | -| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- | -| `commands` | `id`, `title`, `category?`, `when?` | to run them | -| `themes` | `path` (theme JSON), `editor-scheme?` | no | -| `iconThemes` | `id`, `label`, `path` (icon theme JSON, see §5) | no | -| `languages` | `path` (`languages/.toml` format, see §6) | no | -| `runDetectors` | `id`, `name`, `files`, `command`, `args?`, `test?`, `framework?` (API 1.4; §6.2) | no | -| `runConfigurations` | `files`: marker files for the optional `run-configurations` export (API 1.4) | yes | -| `javaAgents` | `path` (a jar in the package), `args?`, `vmOptions?`, `jdk?`, `executor?` — a Java agent for Java run configurations, behind `java.agent` (API 1.10; `vmOptions`/`jdk` in 1.14; `executor` in 1.18; _Java agents_) | no | -| `devices` | `id`, `name`, `command`, `args?`, `appliesTo`, `runArgs?`, `env?`, `prepare?` — run devices (emulators, simulators, phones) offered in a title bar chooser for the run configurations `appliesTo` matches (API 1.21; _Run devices_) | no | -| `skills` | `path` (`skills//SKILL.md` in the package) — agent skill folder staged into coding-agent sessions (API 1.15) | no | -| `mcpTools` | `name`, `description`, `inputSchema` (package JSON Schema path), `readOnly`, `destructive` (API 1.4; see _Plugin MCP tools_) | yes | -| `snippets` | `language`, `path` (named JSON snippets; API 1.4) | no | -| `providers` | `kinds`, `languages` (editor providers, see _Providers_) | yes | -| `secrets` | `name`, `label`, `description?` (see _Network_) | to use them | -| `menus` | `menu` (`editor.context`, `projectView.context`, `editorTab.context`, `viewItem.context`, `tools`, `commit.message`; API 1.4: `editor.title`, `mainToolbar`, `problems.context`, `searchResults.context`; API 1.18: `services.context`, `services.toolbar`; API 1.19: `openIn`), `view?`, `command`, `when?` | no | -| `keymaps` | `command`, `key`, `mac?` (`Ctrl+Alt+C`; a chord: `Meta+K Meta+C`); `key = "Escape"` with a required `when` (API 1.10) runs after the editor's own Escape handling | no | -| `statusBar` | `id`, `text?`, `icon?`, `iconDark?` (API 1.21; at least `text` or `icon` is required), `tooltip?`, `command?`, `align?`, `priority?` | no | -| `settings` | `schema` (JSON file) or `pages` (API 1.3), `title?` — see _Settings_ | no | -| `views` | `id`, `title`, `icon?` (an icon name or a package SVG), `location` (`left`, `right`, `bottom`, `services`), `web?` (_Web views_), `frames?` (API 1.16), `group?`, `when?` (API 1.3) | without `web` | -| `customEditors` | `id`, `title`, `patterns` (file names), `priority` (`default`, `option`), `layout?`, `web?`, `frames?`, `binary?` (API 1.16) | without `web` | -| `editorPanels` | `id`, `web`, `width` (pixels, 40–400), `when?`, `frames?` (API 1.16) — needs `editor.read` (API 1.9; _Editor panels_) | no | -| `overlays` | `id`, `web`, `width`, `height` (pixels, 40–800), `anchor?`, `when?`, `interactive?` — floats over the workbench, never takes the focus (API 1.18; _Overlays_) | no | -| `runAnything` | `prefix`, `title?` — Run Anything lines starting with `prefix`, answered by the `run-anything-provider` export (API 1.18; _Run Anything entries_) | no | -| `dialogs` | `id`, `title`, `web`, `width` (320–1600), `height` (200–1200) — a modal, resizable dialog opened by `views::reveal(id)` (API 1.18; _Dialogs_) | no | -| `runConfigTypes` | `id`, `label`, `web`, `layout?` (`embedded` / `full`), `height?`, `icon?`, `iconDark?`, `group?`, `command?`, `args?`, `prepareCommand?`, `matchConfigPrefix?`, `defaults?` — a custom Run/Debug Configurations form (`openidea.runConfig`; API 1.20; _Custom run configuration forms_) | no | -| `cloneSources` | `id`, `label`, `icon?` (icon name or package SVG), `web` — an entry of the Clone Repository dialog whose page posts the chosen URL (API 1.21; _Clone sources_) | no | -| `fileIcons` | `id`, `patterns` (file names), `icon` (SVG), `iconDark?` — whatever icon theme is in use | no | -| `fileTemplates` | `id`, `name`, `extension`, `path`; API 1.3: `fileName`, `variables = [{ name, prompt }]` — New menu | no | -| `commitChecks` | `id`, `title` — a before-commit check in Commit Options (see _Commits_) | yes | -| `serverCommands` | `server`, `command`, `run` — a language server's client command run by this plugin's command (API 1.9; see _Commands a server hands to the client_) | +| Point | Declaration | Code needed | +| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- | +| `commands` | `id`, `title`, `category?`, `when?` | to run them | +| `themes` | `path` (theme JSON), `editor-scheme?` | no | +| `iconThemes` | `id`, `label`, `path` (icon theme JSON, see §5) | no | +| `languages` | `path` (`languages/.toml` format, see §6) | no | +| `runDetectors` | `id`, `name`, `files`, `command`, `args?`, `test?`, `framework?` (API 1.4; §6.2) | no | +| `runConfigurations` | `files`: marker files for the optional `run-configurations` export (API 1.4) | yes | +| `javaAgents` | `path` (a jar in the package), `args?`, `vmOptions?`, `jdk?`, `executor?` — a Java agent for Java run configurations, behind `java.agent` (API 1.10; `vmOptions`/`jdk` in 1.14; `executor` in 1.18; _Java agents_) | no | +| `devices` | `id`, `name`, `command`, `args?`, `appliesTo`, `runArgs?`, `env?`, `prepare?` — run devices (emulators, simulators, phones) offered in a title bar chooser for the run configurations `appliesTo` matches (API 1.21; _Run devices_) | no | +| `skills` | `path` (`skills//SKILL.md` in the package) — agent skill folder staged into coding-agent sessions (API 1.15) | no | +| `mcpTools` | `name`, `description`, `inputSchema` (package JSON Schema path), `readOnly`, `destructive` (API 1.4; see _Plugin MCP tools_) | yes | +| `snippets` | `language`, `path` (named JSON snippets; API 1.4) | no | +| `providers` | `kinds`, `languages` (editor providers, see _Providers_) | yes | +| `secrets` | `name`, `label`, `description?` (see _Network_) | to use them | +| `menus` | `menu` (`editor.context`, `projectView.context`, `editorTab.context`, `viewItem.context`, `tools`, `commit.message`; API 1.4: `editor.title`, `mainToolbar`, `problems.context`, `searchResults.context`; API 1.18: `services.context`, `services.toolbar`; API 1.19: `openIn`; API 1.21: `git.branches.popup`, `git.branch.context`), `view?`, `command`, `when?` | no | +| `keymaps` | `command`, `key`, `mac?` (`Ctrl+Alt+C`; a chord: `Meta+K Meta+C`); `key = "Escape"` with a required `when` (API 1.10) runs after the editor's own Escape handling | no | +| `statusBar` | `id`, `text?`, `icon?`, `iconDark?` (API 1.21; at least `text` or `icon` is required), `tooltip?`, `command?`, `align?`, `priority?` | no | +| `settings` | `schema` (JSON file) or `pages` (API 1.3), `title?` — see _Settings_ | no | +| `views` | `id`, `title`, `icon?` (an icon name or a package SVG), `location` (`left`, `right`, `bottom`, `services`), `web?` (_Web views_), `frames?` (API 1.16), `group?`, `when?` (API 1.3) | without `web` | +| `projectViewPanes` | `id`, `title`, `weight?` (API 1.21, see [Project view panes](#project-view-panes)) | yes | +| `customEditors` | `id`, `title`, `patterns` (file names), `priority` (`default`, `option`), `layout?`, `web?`, `frames?`, `binary?` (API 1.16) | without `web` | +| `editorPanels` | `id`, `web`, `width` (pixels, 40–400), `when?`, `frames?` (API 1.16) — needs `editor.read` (API 1.9; _Editor panels_) | no | +| `overlays` | `id`, `web`, `width`, `height` (pixels, 40–800), `anchor?`, `when?`, `interactive?` — floats over the workbench, never takes the focus (API 1.18; _Overlays_) | no | +| `runAnything` | `prefix`, `title?` — Run Anything lines starting with `prefix`, answered by the `run-anything-provider` export (API 1.18; _Run Anything entries_) | no | +| `dialogs` | `id`, `title`, `web`, `width` (320–1600), `height` (200–1200) — a modal, resizable dialog opened by `views::reveal(id)` (API 1.18; _Dialogs_) | no | +| `runConfigTypes` | `id`, `label`, `web`, `layout?` (`embedded` / `full`), `height?`, `icon?`, `iconDark?`, `group?`, `command?`, `args?`, `prepareCommand?`, `matchConfigPrefix?`, `defaults?` — a custom Run/Debug Configurations form (`openidea.runConfig`; API 1.20; _Custom run configuration forms_) | no | +| `cloneSources` | `id`, `label`, `icon?` (icon name or package SVG), `web` — an entry of the Clone Repository dialog whose page posts the chosen URL (API 1.21; _Clone sources_) | no | +| `fileIcons` | `id`, `patterns` (file names), `icon` (SVG), `iconDark?` — whatever icon theme is in use | no | +| `fileTemplates` | `id`, `name`, `extension`, `path`; API 1.3: `fileName`, `variables = [{ name, prompt }]` — New menu | no | +| `commitChecks` | `id`, `title` — a before-commit check in Commit Options (see _Commits_) | yes | +| `serverCommands` | `server`, `command`, `run` — a language server's client command run by this plugin's command (API 1.9; see _Commands a server hands to the client_) | A `viewItem.context` menu needs `view`, the id of one of the plugin's own views. It adds the commands to the right-click menu of the items in that @@ -2379,6 +2380,100 @@ the global choice for runs, process handles, terminals and log panes. Resetting a choice verifies its fallback, or revokes the grant if that is unavailable. The plugin continues to call its declared program name. +### Git branch menus and revision comparisons + +Plugins using API 1.21 can add commands to the top Git branch popup and to the +context menu of local and remote-tracking branch rows. The branch row menu is +shared by the popup and the Git Log Branches pane. + +```toml +[[contributes.menus]] +menu = "git.branches.popup" +command = "compare-release" + +[[contributes.menus]] +menu = "git.branch.context" +command = "compare-branch" +``` + +Declare `vcs.read` for the comparisons. In a Git menu command, +`Invocation::git_action_context()` gives the repository roots captured for +that command. A branch row also supplies its short name and full ref, such as +`refs/heads/release` or `refs/remotes/origin/release`. A merged branch row can +identify more than one repository. A command run from Find Action or a shortcut +has no Git menu context, so it can use its usual repository picker. + +With `vcs.read`, `host::open_revision_comparison(&RevisionComparison)` opens +the IDE's own comparison of two Git commits: a tab of the Compare tool window +with the changed-file tree, as **Compare Versions** in the Git Log does. It +takes a mapped repository root of the invoking window's trusted project and two +full commit hashes, optionally with display labels; the IDE checks that both +commits exist in that repository. The call returns once the tab is open; read +errors appear in the tab. For a three-dot comparison, resolve the merge base and +`HEAD` in the plugin and pass those two hashes. + +```rust +use openidea_plugin::{host, RevisionComparison}; + +host::open_revision_comparison(&RevisionComparison { + repository, + left: merge_base, + right: head, + left_label: Some("Merge base".into()), + right_label: Some("HEAD".into()), +})?; +``` + +### Project view panes + +Declare a pane to add an entry to the Project tool window's existing pane menu. +Plugins need API 1.21 and the `project.read` capability for the native node data. + +```toml +engines.openidea = "^1.21" +wasm = "dist/plugin.wasm" + +[capabilities] +required = ["project.read"] + +[[contributes.projectViewPanes]] +id = "go-folders" +title = "Go Folders" +weight = 10 +``` + +Plugin panes appear after the built-in panes, in ascending `weight` order +(default `0`). Implement `project_view::ProjectViewProvider` and use +`register_plugin!(MyPlugin, project_view)`. While the pane is active, the IDE +calls `modify_children` for loaded project directories with the local pane ID, +the native parent and its immediate children, and the active view options as a +JSON object. The default Project pane is available from the same menu. + +Return a flat list of `ProjectionNode`s. Use `ProjectionKind::ExistingNode` with +an input child's ID to preserve its original file icon, Git status, children +and file actions. To group `mod_A_1.go` and `mod_A_2.go`, return a +`ProjectionKind::VirtualFolder` with a stable ID such as `mod/A`, then list both +native IDs with `parent = Some("mod/A")`. A virtual folder can itself have a +virtual parent. With no `icon`, it uses the native folder icon. The IDE scopes +virtual IDs to the pane and native parent. Omitted native children remain at the +end in native order. Return `None` to keep the original child list. + +After rules change, call `host::refresh_project_view("go-folders", None)` or +pass the affected real directory. Stable virtual IDs let the pane retain its +expanded folders and selection across refreshes. Use +`host::select_in_project_view("go-folders", path, None)` to select a real path +through its virtual ancestors, or pass `"project"` to select it in the default +pane. Selection runs in the invoking window and focuses the tree by default. + +`projectView.context` menu items can set `projectViewContext = true` to receive +a JSON command argument with `viewId` and `nodes`. `viewId` is the active +built-in ID or `plugin::`. Each selected node includes `id` +and `kind` (`file`, `directory`, or `virtualFolder`), with `path` for real nodes. +Real paths also remain available through the command context's selected paths. +Menu `when` expressions can use `projectViewId` and `projectViewNodeKind`, with +the latter corresponding to the first selected node. Existing menu items keep +their path argument. + ### Clone sources (API 1.21) `[[contributes.cloneSources]]` adds an entry to the source list of **Get from diff --git a/plugins/official/ai-completion/dist/plugin.wasm b/plugins/official/ai-completion/dist/plugin.wasm index 0d348101ab..706981a0e6 100644 Binary files a/plugins/official/ai-completion/dist/plugin.wasm and b/plugins/official/ai-completion/dist/plugin.wasm differ diff --git a/plugins/official/ai-completion/dist/plugin.wasm.sources b/plugins/official/ai-completion/dist/plugin.wasm.sources index d612b7645b..24c3b3a6bc 100644 --- a/plugins/official/ai-completion/dist/plugin.wasm.sources +++ b/plugins/official/ai-completion/dist/plugin.wasm.sources @@ -1 +1 @@ -0d2ba7fc92b8da00b0a620c3e2aac5d633b65b4341bdd13a412b9bc3fbd5e8c2 +54b22990da11e71debe2abc8e8ed36919a90f70af8aab61a95959965b5df33d8 diff --git a/plugins/official/blame-annotations/dist/plugin.wasm b/plugins/official/blame-annotations/dist/plugin.wasm index 15e84af431..0627044b90 100644 Binary files a/plugins/official/blame-annotations/dist/plugin.wasm and b/plugins/official/blame-annotations/dist/plugin.wasm differ diff --git a/plugins/official/blame-annotations/dist/plugin.wasm.sources b/plugins/official/blame-annotations/dist/plugin.wasm.sources index f32349192b..6115909295 100644 --- a/plugins/official/blame-annotations/dist/plugin.wasm.sources +++ b/plugins/official/blame-annotations/dist/plugin.wasm.sources @@ -1 +1 @@ -095fdfeb792958f0506f214e945fecfa978591a3974d7980a9f7f7dae9310b38 +a9761bb3b4d8887ad94a3aac68812be2133c6277029ae8286ad7034fb05a5175 diff --git a/plugins/official/checkstyle/dist/plugin.wasm b/plugins/official/checkstyle/dist/plugin.wasm index 0b46f01c26..40d8b736c2 100644 Binary files a/plugins/official/checkstyle/dist/plugin.wasm and b/plugins/official/checkstyle/dist/plugin.wasm differ diff --git a/plugins/official/checkstyle/dist/plugin.wasm.sources b/plugins/official/checkstyle/dist/plugin.wasm.sources index c3c038e450..353f8e2eea 100644 --- a/plugins/official/checkstyle/dist/plugin.wasm.sources +++ b/plugins/official/checkstyle/dist/plugin.wasm.sources @@ -1 +1 @@ -0431ecfaba5556f307eecabfedb5b2f4662188fb270a873116a4ac03b45ba2c2 +5dbfc8e7c1c71a4a814838e1b455e17fb87c58c0aec928d23833c30ae5fa9f87 diff --git a/plugins/official/container-runner/dist/plugin.wasm b/plugins/official/container-runner/dist/plugin.wasm index e7d0c3dde2..82cf501d84 100644 Binary files a/plugins/official/container-runner/dist/plugin.wasm and b/plugins/official/container-runner/dist/plugin.wasm differ diff --git a/plugins/official/container-runner/dist/plugin.wasm.sources b/plugins/official/container-runner/dist/plugin.wasm.sources index 22b43ec293..f8d4f269e3 100644 --- a/plugins/official/container-runner/dist/plugin.wasm.sources +++ b/plugins/official/container-runner/dist/plugin.wasm.sources @@ -1 +1 @@ -eed66bc5ba59b24bbe0c68ae7848e870db78141642cf401e196d6c1d9c8f25fc +e8faa753caa35650e6c77fe62a1948a3b79b267a4f4f38739c3a32637880c6ce diff --git a/plugins/official/csv-editor/dist/plugin.wasm b/plugins/official/csv-editor/dist/plugin.wasm index efadfbb5d5..d6aae27d41 100644 Binary files a/plugins/official/csv-editor/dist/plugin.wasm and b/plugins/official/csv-editor/dist/plugin.wasm differ diff --git a/plugins/official/csv-editor/dist/plugin.wasm.sources b/plugins/official/csv-editor/dist/plugin.wasm.sources index 410cfa3448..fb85ed0741 100644 --- a/plugins/official/csv-editor/dist/plugin.wasm.sources +++ b/plugins/official/csv-editor/dist/plugin.wasm.sources @@ -1 +1 @@ -2446f750f0913c90602861476623eaefd9f4a6304981a09ecbe95f9949fb1446 +be7f2284a8290c565e441c7ff0574b58c4249ce1f67ea1af3e8521b43c551807 diff --git a/plugins/official/git-toolbox/dist/plugin.wasm b/plugins/official/git-toolbox/dist/plugin.wasm index e228c445a4..bcd5628d71 100644 Binary files a/plugins/official/git-toolbox/dist/plugin.wasm and b/plugins/official/git-toolbox/dist/plugin.wasm differ diff --git a/plugins/official/git-toolbox/dist/plugin.wasm.sources b/plugins/official/git-toolbox/dist/plugin.wasm.sources index 64375f0d00..c7caace174 100644 --- a/plugins/official/git-toolbox/dist/plugin.wasm.sources +++ b/plugins/official/git-toolbox/dist/plugin.wasm.sources @@ -1 +1 @@ -85eb06ed7afeccd3457a7c1f3652bf39c425d2fd88f87d7cfdfc4acd2cbc37c9 +d29178dedffd30452d6b9fb85c8528a468b2b247bb7a59640042a5cf85a223d3 diff --git a/plugins/official/graphviz/dist/plugin.wasm b/plugins/official/graphviz/dist/plugin.wasm index 22b52f021c..282ee663c2 100644 Binary files a/plugins/official/graphviz/dist/plugin.wasm and b/plugins/official/graphviz/dist/plugin.wasm differ diff --git a/plugins/official/graphviz/dist/plugin.wasm.sources b/plugins/official/graphviz/dist/plugin.wasm.sources index ee67e29cb5..35c0afe6c2 100644 --- a/plugins/official/graphviz/dist/plugin.wasm.sources +++ b/plugins/official/graphviz/dist/plugin.wasm.sources @@ -1 +1 @@ -4e9c376d7a0c7565371a5fa7710f7886d374e111c0e7c71caae19e788fbd09d3 +0547855b235f10359f1dc6dcb154be132211300825429d83fa46337c697ecf14 diff --git a/plugins/official/key-promoter/dist/plugin.wasm b/plugins/official/key-promoter/dist/plugin.wasm index 1a68a432df..fa9f232f40 100644 Binary files a/plugins/official/key-promoter/dist/plugin.wasm and b/plugins/official/key-promoter/dist/plugin.wasm differ diff --git a/plugins/official/key-promoter/dist/plugin.wasm.sources b/plugins/official/key-promoter/dist/plugin.wasm.sources index 5a78ae12b5..e6560fe179 100644 --- a/plugins/official/key-promoter/dist/plugin.wasm.sources +++ b/plugins/official/key-promoter/dist/plugin.wasm.sources @@ -1 +1 @@ -e151629f7152b552eb9604f042056465794fff30f7459dc62ce1fcb5e34d8a43 +b597327a81547352eb1d8fdd6633e3be9312292c9fd0574b0fc60f906284780d diff --git a/plugins/official/license-header/dist/plugin.wasm b/plugins/official/license-header/dist/plugin.wasm index 37b9d38382..cb32489bc5 100644 Binary files a/plugins/official/license-header/dist/plugin.wasm and b/plugins/official/license-header/dist/plugin.wasm differ diff --git a/plugins/official/license-header/dist/plugin.wasm.sources b/plugins/official/license-header/dist/plugin.wasm.sources index 10075de7c2..d93a6bdfd2 100644 --- a/plugins/official/license-header/dist/plugin.wasm.sources +++ b/plugins/official/license-header/dist/plugin.wasm.sources @@ -1 +1 @@ -a5d8ee8c8a20308844c6719e6e334873cc06177511f9f33da5f6662fc198bbb7 +1b19234becc4aa6e6f940c991f0fed1dcfc616904ee77976c9076a107a27f768 diff --git a/plugins/official/mybatis/dist/plugin.wasm b/plugins/official/mybatis/dist/plugin.wasm index 937e38c72a..7625d56897 100644 Binary files a/plugins/official/mybatis/dist/plugin.wasm and b/plugins/official/mybatis/dist/plugin.wasm differ diff --git a/plugins/official/mybatis/dist/plugin.wasm.sources b/plugins/official/mybatis/dist/plugin.wasm.sources index 8766d58b42..f530dbac5c 100644 --- a/plugins/official/mybatis/dist/plugin.wasm.sources +++ b/plugins/official/mybatis/dist/plugin.wasm.sources @@ -1 +1 @@ -bae0ab863bd7bf89a9eb4ca042c932eb78581a6197959798ad1a29caf2cf12c0 +b31423ef3ae954ee85bdab516cc802a3ef03cad2f87320ff0fb31cef6e16d1ad diff --git a/plugins/official/regex-tester/dist/plugin.wasm b/plugins/official/regex-tester/dist/plugin.wasm index dbd03cf0b8..fae02e9480 100644 Binary files a/plugins/official/regex-tester/dist/plugin.wasm and b/plugins/official/regex-tester/dist/plugin.wasm differ diff --git a/plugins/official/regex-tester/dist/plugin.wasm.sources b/plugins/official/regex-tester/dist/plugin.wasm.sources index 26bd190fe4..a78a1a1083 100644 --- a/plugins/official/regex-tester/dist/plugin.wasm.sources +++ b/plugins/official/regex-tester/dist/plugin.wasm.sources @@ -1 +1 @@ -c2352d877fd363c36bf0312063fe8f72cf51054c491d3d5b8c931c2a00fc598b +5802c77c7be6ef11b624fdd1ff096909ac1532dc5379a02e84ec5a49b5c7be43 diff --git a/plugins/official/solidity/dist/plugin.wasm b/plugins/official/solidity/dist/plugin.wasm index bb9772c48d..1bd5366fa4 100644 Binary files a/plugins/official/solidity/dist/plugin.wasm and b/plugins/official/solidity/dist/plugin.wasm differ diff --git a/plugins/official/solidity/dist/plugin.wasm.sources b/plugins/official/solidity/dist/plugin.wasm.sources index a69dfa79e1..7e75c4e1eb 100644 --- a/plugins/official/solidity/dist/plugin.wasm.sources +++ b/plugins/official/solidity/dist/plugin.wasm.sources @@ -1 +1 @@ -c86e0437ef6409aad40a913fc8fa516903dad560acf49061daa2641946f3bc0a +accaac7bfcedfa3cc55264f2eb3285f619ca93f9c42200dec9d8d782005b6fe9 diff --git a/plugins/official/string-tools/dist/plugin.wasm b/plugins/official/string-tools/dist/plugin.wasm index 06609c0e1a..5162132200 100644 Binary files a/plugins/official/string-tools/dist/plugin.wasm and b/plugins/official/string-tools/dist/plugin.wasm differ diff --git a/plugins/official/string-tools/dist/plugin.wasm.sources b/plugins/official/string-tools/dist/plugin.wasm.sources index 578fab2716..f497343ae2 100644 --- a/plugins/official/string-tools/dist/plugin.wasm.sources +++ b/plugins/official/string-tools/dist/plugin.wasm.sources @@ -1 +1 @@ -28f424805fe3a57b35be21ff7c576fef0c91d01b930eb2392d0eb277b27ff62e +a71bc33ba7c6313dfb82bddeb51073233777d30dfb5e4a51f9b75cae08fe2be3 diff --git a/plugins/official/test-runner/dist/plugin.wasm b/plugins/official/test-runner/dist/plugin.wasm index e416829c20..3fb9f5b115 100644 Binary files a/plugins/official/test-runner/dist/plugin.wasm and b/plugins/official/test-runner/dist/plugin.wasm differ diff --git a/plugins/official/test-runner/dist/plugin.wasm.sources b/plugins/official/test-runner/dist/plugin.wasm.sources index 2b96124494..70cef5b1c6 100644 --- a/plugins/official/test-runner/dist/plugin.wasm.sources +++ b/plugins/official/test-runner/dist/plugin.wasm.sources @@ -1 +1 @@ -438777ad76d9ea565e009819f022a357fbee36e1b93cd17d55a2f29b955c31af +0116f18bb296d858e3488d73cbdce74124d2a408b147e27368f77899498c4e00 diff --git a/plugins/official/todo-finder/dist/plugin.wasm b/plugins/official/todo-finder/dist/plugin.wasm index 7d0a980f84..283bea6e4f 100644 Binary files a/plugins/official/todo-finder/dist/plugin.wasm and b/plugins/official/todo-finder/dist/plugin.wasm differ diff --git a/plugins/official/todo-finder/dist/plugin.wasm.sources b/plugins/official/todo-finder/dist/plugin.wasm.sources index 55ba16717a..6633aab35c 100644 --- a/plugins/official/todo-finder/dist/plugin.wasm.sources +++ b/plugins/official/todo-finder/dist/plugin.wasm.sources @@ -1 +1 @@ -eef2a166065734b0b9e6a681e8dad650526f66a3d81ecc0b5a0e48166d5b8cc6 +eea5586216fe94ea8497e34e29a6dbb93b4e1315dcd68e28cab7abb5a28b568d diff --git a/sdk/rust/openidea-plugin/src/host.rs b/sdk/rust/openidea-plugin/src/host.rs index 06cffb4514..a370aa8a93 100644 --- a/sdk/rust/openidea-plugin/src/host.rs +++ b/sdk/rust/openidea-plugin/src/host.rs @@ -363,6 +363,17 @@ mod imp { i.selected_paths() } + pub fn invocation_git_action_context(i: InvocationRef<'_>) -> Option { + i.git_action_context().map(|context| GitActionContext { + repositories: context.repositories, + branch: context.branch.map(|branch| GitActionBranch { + name: branch.name, + full_ref: branch.full_ref, + remote: branch.remote, + }), + }) + } + pub fn editor_path(e: &EditorRes) -> String { e.path() } @@ -899,6 +910,14 @@ mod imp { wit::views::refresh(view) } + pub fn refresh_project_view(view_id: &str, directory: Option<&str>) -> Result<(), Error> { + wit::project_view::refresh(view_id, directory).map_err(error) + } + + pub fn select_in_project_view(view_id: &str, path: &str, focus: Option) -> Result<(), Error> { + wit::project_view::select_in(view_id, path, focus).map_err(error) + } + pub fn post_view_message(view: &str, message: &str) -> Result<(), Error> { wit::views::post_message(view, message).map_err(error) } @@ -1348,6 +1367,20 @@ mod imp { wit::views::open_file_diff(&file_diff_to(diff), file_name).map_err(error) } + fn revision_comparison_to(comparison: &RevisionComparison) -> wit::views::RevisionComparison { + wit::views::RevisionComparison { + repository: comparison.repository.clone(), + left: comparison.left.clone(), + right: comparison.right.clone(), + left_label: comparison.left_label.clone(), + right_label: comparison.right_label.clone(), + } + } + + pub fn open_revision_comparison(comparison: &RevisionComparison) -> Result<(), Error> { + wit::views::open_revision_comparison(&revision_comparison_to(comparison)).map_err(error) + } + pub fn open_terminal(title: &str, program: &str, args: &[String]) -> Result<(), Error> { wit::views::open_terminal(title, program, args).map_err(error) } @@ -1524,6 +1557,12 @@ impl<'a> Invocation<'a> { pub fn selected_paths(&self) -> Vec { imp::invocation_selected_paths(self.inner) } + + /// The click-time repository and branch selection of a Git menu command (API 1.21). + /// Requires `vcs.read`. Commands invoked from other surfaces have no Git action context. + pub fn git_action_context(&self) -> Option { + imp::invocation_git_action_context(self.inner) + } } /// A project open in the IDE. @@ -1931,6 +1970,17 @@ pub fn refresh_view(view: &str) { imp::refresh_view(view) } +/// Recomputes one of the plugin's native Project panes, optionally only below a given directory. +pub fn refresh_project_view(view_id: &str, directory: Option<&str>) -> Result<(), Error> { + imp::refresh_project_view(view_id, directory) +} + +/// Selects a native path in an owned pane or in the built-in `project` pane of the invoking window. +/// `None` for `focus` gives keyboard focus to the pane. +pub fn select_in_project_view(view_id: &str, path: &str, focus: Option) -> Result<(), Error> { + imp::select_in_project_view(view_id, path, focus) +} + /// Sends `message` to the script of view `view`'s HTML body. pub fn post_view_message(view: &str, message: &str) -> Result<(), Error> { imp::post_view_message(view, message) @@ -2741,6 +2791,13 @@ pub fn open_file_diff(diff: &crate::FileDiff, file_name: Option<&str>) -> Result imp::open_file_diff(diff, file_name) } +/// Opens the IDE's comparison of two full commit IDs (API 1.21): a tab of the Compare tool +/// window with the changed-file tree, as Compare Versions in the Git Log does. Requires +/// `vcs.read` and a trusted project window; the repository must be a mapped Git root. +pub fn open_revision_comparison(comparison: &RevisionComparison) -> Result<(), Error> { + imp::open_revision_comparison(comparison) +} + /// Registers/replaces a read-only project target. Requires the program's process grant. pub fn register_run_target(project: &Project, target: &crate::PluginRunTarget) -> Result<(), Error> { imp::register_run_target(&project.inner, target) diff --git a/sdk/rust/openidea-plugin/src/lib.rs b/sdk/rust/openidea-plugin/src/lib.rs index e7e52895ff..5e1333b8c0 100644 --- a/sdk/rust/openidea-plugin/src/lib.rs +++ b/sdk/rust/openidea-plugin/src/lib.rs @@ -50,6 +50,7 @@ pub mod indexing; pub mod inlay_hints; #[cfg(not(target_arch = "wasm32"))] pub mod mock; +pub mod project_view; pub mod providers; pub mod search; pub mod semantic_tokens; @@ -337,6 +338,23 @@ pub mod search_bindings { }); } +#[cfg(target_arch = "wasm32")] +#[doc(hidden)] +pub mod project_view_bindings { + wit_bindgen::generate!({ + world: "project-view-exports", path: "wit", pub_export_macro: true, + export_macro_name: "__export_project_view_world", + default_bindings_module: "openidea_plugin::project_view_bindings", + with: { + "openidea:plugin/project-view-types@1.21.0": crate::bindings::openidea::plugin::project_view_types, + "openidea:plugin/types@1.21.0": crate::bindings::openidea::plugin::types, + "openidea:plugin/workspace@1.21.0": crate::bindings::openidea::plugin::workspace, + "openidea:plugin/editor@1.21.0": crate::bindings::openidea::plugin::editor, + "openidea:plugin/invocation@1.21.0": crate::bindings::openidea::plugin::invocation, + }, + }); +} + /// The plugin API version this SDK targets. pub const API_VERSION: &str = "1.21"; @@ -422,6 +440,7 @@ macro_rules! __optional_exports { $crate::__rename_exports!($plugin, $component); }; (search, $plugin:ty, $component:ident) => { $crate::__search_exports!($plugin, $component); }; + (project_view, $plugin:ty, $component:ident) => { $crate::__project_view_exports!($plugin, $component); }; (endpoints, $plugin:ty, $component:ident) => { $crate::__endpoints_exports!($plugin, $component); }; @@ -762,6 +781,25 @@ macro_rules! __search_exports { }; } +#[doc(hidden)] +#[macro_export] +macro_rules! __project_view_exports { + ($plugin:ty, $component:ident) => { + impl $crate::project_view_bindings::exports::openidea::plugin::project_view_provider::Guest for $component { + fn modify_children( + view_id: String, + parent: $crate::bindings::openidea::plugin::project_view_types::NativeNode, + children: Vec<$crate::bindings::openidea::plugin::project_view_types::NativeNode>, + settings: String, + ctx: &$crate::bindings::openidea::plugin::invocation::Invocation, + ) -> Option> { + $crate::__rt::modify_project_view_children::<$plugin>(view_id, parent, children, settings, ctx) + } + } + $crate::project_view_bindings::__export_project_view_world!($component with_types_in $crate::project_view_bindings); + }; +} + #[doc(hidden)] #[macro_export] macro_rules! __endpoints_exports { @@ -1062,7 +1100,7 @@ pub mod __rt { pos: b::types::Position, trigger: Option, ) -> crate::completion_resolve_bindings::exports::openidea::plugin::completion_resolve_provider::ResolvableCompletionList - { +{ use crate::completion_resolve_bindings::exports::openidea::plugin::completion_resolve_provider as cr; let d = p::Document { path: d.path, language: d.language, version: d.version, text: d.text }; let list = with::(|x| x.completion(&d, at(pos), trigger.as_deref())); @@ -1722,6 +1760,45 @@ pub mod __rt { .collect() } + pub fn modify_project_view_children( + view_id: String, + parent: b::project_view_types::NativeNode, + children: Vec, + settings: String, + ctx: &b::invocation::Invocation, + ) -> Option> { + use crate::project_view::{NativeNode, NodeKind, ProjectionKind}; + use b::project_view_types as w; + + let native = |node: w::NativeNode| NativeNode { + id: node.id, + path: node.path, + label: node.label, + kind: match node.kind { + w::NodeKind::File => NodeKind::File, + w::NodeKind::Directory => NodeKind::Directory, + }, + }; + let children: Vec<_> = children.into_iter().map(native).collect(); + let ctx = Invocation::__new(ctx); + let result = with::(|p| p.modify_children(&view_id, &native(parent), &children, &settings, &ctx))?; + Some( + result + .into_iter() + .map(|node| w::ProjectionNode { + id: node.id, + parent: node.parent, + kind: match node.kind { + ProjectionKind::ExistingNode => w::ProjectionKind::ExistingNode, + ProjectionKind::VirtualFolder { label, icon } => { + w::ProjectionKind::VirtualFolder(w::FolderDetails { label, icon }) + } + }, + }) + .collect(), + ) + } + pub fn search( category: String, query: String, diff --git a/sdk/rust/openidea-plugin/src/mock.rs b/sdk/rust/openidea-plugin/src/mock.rs index 68b694dbb2..b70b9e01d0 100644 --- a/sdk/rust/openidea-plugin/src/mock.rs +++ b/sdk/rust/openidea-plugin/src/mock.rs @@ -118,6 +118,7 @@ struct State { dirs: BTreeSet, editor: Option, selected_paths: Vec, + git_action_context: Option, notifications: Vec, action_notifications: Vec, project_notifications: Vec<(String, ActionNotification)>, @@ -193,6 +194,8 @@ struct State { children: BTreeMap, next_child: u64, refreshed: Vec, + project_view_refreshes: Vec<(String, Option)>, + project_view_selections: Vec<(String, String, bool)>, view_messages: Vec<(String, String)>, terminals: Vec, terminal_sessions: BTreeMap, @@ -202,6 +205,7 @@ struct State { content_tabs: BTreeMap, content_replies: Vec<(String, crate::ContentTabReply)>, diffs: Vec<(crate::FileDiff, Option)>, + revision_comparisons: Vec, database_sources: BTreeMap<(String, String), PluginDataSource>, database_credentials: BTreeSet<(String, String)>, database_connections: Vec<(String, String)>, @@ -555,6 +559,17 @@ impl MockHost { Invocation::__new(MockInvocation(PhantomData)) } + /// Populates the branch-menu snapshot returned by the mock invocation. + pub fn with_git_action_context(self, context: GitActionContext) -> Self { + self.state.borrow_mut().git_action_context = Some(context); + self + } + + /// Revision comparisons requested through the mock host, in order. + pub fn revision_comparisons(&self) -> Vec { + self.state.borrow().revision_comparisons.clone() + } + pub fn notifications(&self) -> Vec { self.state.borrow().notifications.clone() } @@ -708,6 +723,14 @@ impl MockHost { self.state.borrow().revealed_views.clone() } + pub fn project_view_refreshes(&self) -> Vec<(String, Option)> { + self.state.borrow().project_view_refreshes.clone() + } + + pub fn project_view_selections(&self) -> Vec<(String, String, bool)> { + self.state.borrow().project_view_selections.clone() + } + /// Settings pages opened with [`crate::host::open_settings`], in order. pub fn opened_settings(&self) -> Vec> { self.state.borrow().opened_settings.clone() @@ -1863,6 +1886,10 @@ pub mod current { with(|s| s.selected_paths.clone()) } + pub fn invocation_git_action_context(_: InvocationRef<'_>) -> Option { + with(|s| require(s, "vcs.read").ok().and_then(|()| s.git_action_context.clone())) + } + pub fn editor_path(_: &EditorRes) -> String { editor(|_, e| e.path.clone()) } @@ -2846,6 +2873,22 @@ pub mod current { with(|s| s.refreshed.push(view.into())) } + pub fn refresh_project_view(view_id: &str, directory: Option<&str>) -> Result<(), Error> { + with(|s| { + require(s, "project.read")?; + s.project_view_refreshes.push((view_id.into(), directory.map(str::to_owned))); + Ok(()) + }) + } + + pub fn select_in_project_view(view_id: &str, path: &str, focus: Option) -> Result<(), Error> { + with(|s| { + require(s, "project.read")?; + s.project_view_selections.push((view_id.into(), path.into(), focus.unwrap_or(true))); + Ok(()) + }) + } + pub fn post_view_message(view: &str, message: &str) -> Result<(), Error> { with(|s| s.view_messages.push((view.into(), message.into()))); Ok(()) @@ -3433,6 +3476,23 @@ pub mod current { with(|s| s.diffs.push((diff.clone(), file_name.map(Into::into)))); Ok(()) } + fn validate_revision_comparison(s: &State, comparison: &RevisionComparison) -> Result<(), Error> { + require(s, "vcs.read")?; + if [&comparison.left, &comparison.right] + .into_iter() + .any(|id| !matches!(id.len(), 40 | 64) || !id.bytes().all(|b| b.is_ascii_hexdigit())) + { + return Err(Error::Invalid("expected full Git commit object IDs".into())); + } + Ok(()) + } + pub fn open_revision_comparison(comparison: &RevisionComparison) -> Result<(), Error> { + with(|s| { + validate_revision_comparison(s, comparison)?; + s.revision_comparisons.push(comparison.clone()); + Ok(()) + }) + } pub fn open_terminal(title: &str, program: &str, args: &[String]) -> Result<(), Error> { with(|s| { require(s, &format!("process:{program}"))?; diff --git a/sdk/rust/openidea-plugin/src/project_view.rs b/sdk/rust/openidea-plugin/src/project_view.rs new file mode 100644 index 0000000000..9c7985d5dd --- /dev/null +++ b/sdk/rust/openidea-plugin/src/project_view.rs @@ -0,0 +1,47 @@ +//! Native Project tool window panes (API 1.21). + +use crate::Invocation; + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum NodeKind { + File, + Directory, +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct NativeNode { + pub id: String, + pub path: String, + pub label: String, + pub kind: NodeKind, +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub enum ProjectionKind { + ExistingNode, + VirtualFolder { label: String, icon: Option }, +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct ProjectionNode { + /// A returned native child's id or a stable virtual id local to this native parent. + pub id: String, + /// A virtual parent id in the same response, or `None` for a direct child. + pub parent: Option, + pub kind: ProjectionKind, +} + +/// Implement for panes declared in `[[contributes.projectViewPanes]]` and +/// register with `register_plugin!(MyPlugin, project_view)`. +pub trait ProjectViewProvider { + /// Transform one native directory's direct children; `None` keeps the native order. + /// Omitted native children remain in the pane. The settings are view options as JSON. + fn modify_children( + &mut self, + view_id: &str, + parent: &NativeNode, + children: &[NativeNode], + settings: &str, + ctx: &Invocation<'_>, + ) -> Option>; +} diff --git a/sdk/rust/openidea-plugin/src/types.rs b/sdk/rust/openidea-plugin/src/types.rs index 722140a800..693f32cba7 100644 --- a/sdk/rust/openidea-plugin/src/types.rs +++ b/sdk/rust/openidea-plugin/src/types.rs @@ -1140,6 +1140,31 @@ pub struct DatabaseTableSchema { pub indexes: Vec, pub foreign_keys: Vec, } +/// A branch selected inside a Git menu. `full_ref` includes the Git namespace. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct GitActionBranch { + pub name: String, + pub full_ref: String, + pub remote: bool, +} + +/// The Git menu's repository and branch selection when a command was invoked. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct GitActionContext { + pub repositories: Vec, + pub branch: Option, +} + +/// A native comparison of two full commit object IDs in a Git repository. +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct RevisionComparison { + pub repository: String, + pub left: String, + pub right: String, + pub left_label: Option, + pub right_label: Option, +} + /// Non-secret identity of an already-connected project data source (API 1.21). #[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] #[serde(rename_all = "camelCase")] diff --git a/sdk/rust/openidea-plugin/tests/api21_git_actions.rs b/sdk/rust/openidea-plugin/tests/api21_git_actions.rs new file mode 100644 index 0000000000..a8eaf0d935 --- /dev/null +++ b/sdk/rust/openidea-plugin/tests/api21_git_actions.rs @@ -0,0 +1,41 @@ +use openidea_plugin::{Error, GitActionBranch, GitActionContext, RevisionComparison, host, mock::MockHost}; + +#[test] +fn opens_a_native_comparison_with_immutable_revisions() { + let mut comparison = RevisionComparison { + repository: "/repo".into(), + left: "a".repeat(40), + right: "b".repeat(40), + left_label: Some("Merge base".into()), + right_label: None, + }; + { + let _mock = MockHost::install().with_capabilities(&[]); + assert_eq!(host::open_revision_comparison(&comparison), Err(Error::Denied("vcs.read".into()))); + } + + let mock = MockHost::install().with_capabilities(&["vcs.read"]); + host::open_revision_comparison(&comparison).unwrap(); + assert_eq!(mock.revision_comparisons(), [comparison.clone()]); + comparison.left = "HEAD~1".into(); + assert!(matches!(host::open_revision_comparison(&comparison), Err(Error::Invalid(_)))); + assert_eq!(mock.revision_comparisons().len(), 1); +} + +#[test] +fn exposes_a_git_branch_snapshot_only_with_vcs_read() { + let context = GitActionContext { + repositories: vec!["/repo".into(), "/repo-two".into()], + branch: Some(GitActionBranch { + name: "origin/release".into(), + full_ref: "refs/remotes/origin/release".into(), + remote: true, + }), + }; + { + let mock = MockHost::install().with_capabilities(&[]).with_git_action_context(context.clone()); + assert_eq!(mock.invocation().git_action_context(), None); + } + let mock = MockHost::install().with_capabilities(&["vcs.read"]).with_git_action_context(context.clone()); + assert_eq!(mock.invocation().git_action_context(), Some(context)); +} diff --git a/sdk/rust/openidea-plugin/tests/api21_project_view.rs b/sdk/rust/openidea-plugin/tests/api21_project_view.rs new file mode 100644 index 0000000000..4ad82f22c6 --- /dev/null +++ b/sdk/rust/openidea-plugin/tests/api21_project_view.rs @@ -0,0 +1,19 @@ +use openidea_plugin::{Error, host, mock::MockHost}; + +#[test] +fn project_view_helpers_require_project_read_and_preserve_window_options() { + { + let _mock = MockHost::install().with_capabilities(&[]); + assert_eq!(host::refresh_project_view("grouped", None), Err(Error::Denied("project.read".into()))); + assert_eq!(host::select_in_project_view("project", "main.go", None), Err(Error::Denied("project.read".into()))); + } + let mock = MockHost::install().with_capabilities(&["project.read"]); + host::refresh_project_view("grouped", Some("src")).unwrap(); + host::select_in_project_view("grouped", "src/main.go", None).unwrap(); + host::select_in_project_view("project", "src/main.go", Some(false)).unwrap(); + assert_eq!(mock.project_view_refreshes(), [("grouped".into(), Some("src".into()))]); + assert_eq!( + mock.project_view_selections(), + [("grouped".into(), "src/main.go".into(), true), ("project".into(), "src/main.go".into(), false),] + ); +} diff --git a/sdk/rust/openidea-plugin/wit/plugin.wit b/sdk/rust/openidea-plugin/wit/plugin.wit index 42a119bcef..69ae30a676 100644 --- a/sdk/rust/openidea-plugin/wit/plugin.wit +++ b/sdk/rust/openidea-plugin/wit/plugin.wit @@ -34,6 +34,8 @@ world plugin { import command-runner; import language-servers; import views; + import project-view-types; + import project-view; import run; import run-targets; import database; @@ -235,5 +237,10 @@ world search { export search-provider; } /// A plugin that paints theme-token foreground marks from a syntax snapshot (API 1.20). world plugin-syntax-decorations { include plugin; export syntax-decorations-provider; } + +/// A native Project tool window pane (API 1.21). +world plugin-project-view { include plugin; export project-view-provider; } + +world project-view-exports { export project-view-provider; } /// Export-only syntax decorations, composed with the base plugin world. world syntax-decorations { export syntax-decorations-provider; } diff --git a/sdk/rust/openidea-plugin/wit/project-view.wit b/sdk/rust/openidea-plugin/wit/project-view.wit new file mode 100644 index 0000000000..8725958963 --- /dev/null +++ b/sdk/rust/openidea-plugin/wit/project-view.wit @@ -0,0 +1,55 @@ +package openidea:plugin@1.21.0; + +/// Nodes of the native Project tree (API 1.21). +interface project-view-types { + enum node-kind { file, directory } + record native-node { + id: string, + path: string, + label: string, + kind: node-kind, + } + record folder-details { + label: string, + /// An IDE icon name. The host uses its folder icon when absent or unknown. + icon: option, + } + variant projection-kind { + existing-node, + virtual-folder(folder-details), + } + record projection-node { + /// Existing nodes use an id from the input. A virtual folder uses a + /// stable plugin-chosen id scoped to this native parent. + id: string, + /// The virtual folder id to group under, or none for a direct child. + parent: option, + kind: projection-kind, + } +} + +interface project-view { + use types.{error}; + + /// Recompute the plugin's pane, or one project-relative or absolute + /// directory. Without an invoking window, invalidate the pane in every window. + refresh: func(view-id: string, directory: option) -> result<_, error>; + + /// Select a real file or directory in an owned pane or the built-in `project` + /// pane of the invoking window. `focus` defaults to true. + select-in: func(view-id: string, path: string, focus: option) -> result<_, error>; +} + +/// Optional export for `[[contributes.projectViewPanes]]`. It runs while the +/// plugin's pane is visible, on the project's native direct children. Return +/// none to leave those children unchanged. Order is preserved among siblings; +/// parent ids designate virtual folders in the same result. Omitted native +/// children stay in the pane in native order. Unknown ids, duplicate references +/// and invalid virtual trees discard the result. +interface project-view-provider { + use project-view-types.{native-node, projection-node}; + use invocation.{invocation}; + + /// `settings` is the current view options as a JSON object. + modify-children: func(view-id: string, parent: native-node, children: list, settings: string, ctx: borrow) -> option>; +} diff --git a/sdk/rust/openidea-plugin/wit/views.wit b/sdk/rust/openidea-plugin/wit/views.wit index 47a1d8e1ea..57e4126567 100644 --- a/sdk/rust/openidea-plugin/wit/views.wit +++ b/sdk/rust/openidea-plugin/wit/views.wit @@ -126,6 +126,15 @@ interface views { use detail-types.{process-log}; use process.{command}; + /// A repository-wide comparison of two full commit object IDs. + record revision-comparison { + repository: string, + left: string, + right: string, + left-label: option, + right-label: option, + } + /// An editor toolbar action; at most one action is the Save handler. record content-action { id: string, label: string, icon: option, primary: bool, save: bool } /// A plugin-owned content editor, scoped by key to the invoking window. @@ -171,6 +180,11 @@ interface views { /// and deleted files, instead of next to an empty text. Both sides none is /// `invalid`. open-file-diff: func(diff: file-diff, file-name: option) -> result<_, error>; + /// Opens the IDE's comparison of two commits (API 1.21): a tab of the Compare + /// tool window with the changed-file tree, as Compare Versions in the Git Log. + /// From a command or event of a trusted project window; requires `vcs.read`. + /// The repository must be a mapped Git root of the invoking project. + open-revision-comparison: func(comparison: revision-comparison) -> result<_, error>; /// The view (or every custom editor of that id) shows outdated content: /// the IDE renders it again. diff --git a/sdk/rust/openidea-plugin/wit/workspace.wit b/sdk/rust/openidea-plugin/wit/workspace.wit index 4018c87da8..04e9527de1 100644 --- a/sdk/rust/openidea-plugin/wit/workspace.wit +++ b/sdk/rust/openidea-plugin/wit/workspace.wit @@ -189,6 +189,9 @@ interface invocation { use workspace.{project}; use editor.{text-editor}; + record git-action-branch { name: string, full-ref: string, remote: bool } + record git-action-context { repositories: list, branch: option } + resource invocation { /// The window's project. project: func() -> option; @@ -199,6 +202,10 @@ interface invocation { /// Empty when it was not run on any, or when the menu was for a tab /// without a file (a virtual document). selected-paths: func() -> list; + /// Git branch-menu selection at invocation time (API 1.21). Requires + /// `vcs.read`. In the branches popup, `branch` is absent and `repositories` + /// contains the candidate Git roots. A branch row supplies its own roots. + git-action-context: func() -> option; } } diff --git a/src-tauri/tests/commands.snap b/src-tauri/tests/commands.snap index f321630fd0..206aa9419f 100644 --- a/src-tauri/tests/commands.snap +++ b/src-tauri/tests/commands.snap @@ -604,6 +604,7 @@ plugin_post_events trusted project_host bin plugin_prepare_debug_run trusted project_host bindings async plugin_preview_install always desktop bindings async plugin_program outside_restricted project_host bindings async +plugin_project_view_modify trusted project_host bindings async plugin_read_intellij_theme always desktop bindings async plugin_reload outside_restricted desktop bindings async plugin_revoke_net_host outside_restricted desktop bindings async @@ -612,6 +613,7 @@ plugin_run_anything_run trusted project_host bin plugin_run_anything_suggest trusted project_host bindings async plugin_run_command trusted project_host bindings async plugin_run_configuration_complete trusted project_host bindings async +plugin_run_git_command trusted project_host bindings async plugin_run_log_tail trusted project_host bindings async plugin_run_targets trusted project_host bindings async plugin_search trusted project_host bindings async diff --git a/src/bindings.ts b/src/bindings.ts index 8b704cc39c..0e37a9157e 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -1696,6 +1696,8 @@ export const commands = { pluginPreviewInstall: (path: string) => typedError(__TAURI_INVOKE("plugin_preview_install", { path })), /** The currently approved executable in the selected scope, after revalidating its pin. */ pluginProgram: (pluginId: string, program: string, scope: SettingsScope) => typedError(__TAURI_INVOKE("plugin_program", { pluginId, program, scope })), + /** Rearranges native children for one plugin-owned Project pane. */ + pluginProjectViewModify: (pluginId: string, viewId: string, parent: ProjectViewNativeNode, children: ProjectViewNativeNode[], settings: string, request: number | null) => typedError(__TAURI_INVOKE("plugin_project_view_modify", { pluginId, viewId, parent, children, settings, request })), /** Reads an IntelliJ theme plugin (`.jar`, Marketplace `.zip`, plugin folder) or `.theme.json` to import. */ pluginReadIntellijTheme: (path: string) => typedError(__TAURI_INVOKE("plugin_read_intellij_theme", { path })), /** Re-reads a plugin from disk (after rebuilding a dev plugin). */ @@ -1721,6 +1723,14 @@ export const commands = { } | null, paths: string[] | null, settingsScope: "global" | "project" | null, commandChain: string[] | null, request: number | null) => typedError(__TAURI_INVOKE("plugin_run_command", { pluginId, commandId, arg, editor, paths, settingsScope, commandChain, request })), /** Completions for a field of a plugin's own run configuration (API 1.18). */ pluginRunConfigurationComplete: (configId: string, field: string, text: string, caret: number) => typedError(__TAURI_INVOKE("plugin_run_configuration_complete", { configId, field, text, caret })), + /** Runs a declared Git menu command with the menu's repository and branch snapshot. */ + pluginRunGitCommand: (pluginId: string, commandId: string, context: GitActionContext, editor: { + path: string, + language: string, + selections: Range[], + /** First and last document line on screen (0-based, inclusive); absent from older clients. */ + visibleLines?: [number, number] | null, +} | null) => typedError(__TAURI_INVOKE("plugin_run_git_command", { pluginId, commandId, context, editor })), /** Reads an incremental chunk of an authorized log file for a plugin run session. */ pluginRunLogTail: (pluginId: string, path: string, offset: number, maxBytes: number | null) => typedError(__TAURI_INVOKE("plugin_run_log_tail", { pluginId, path, offset, maxBytes })), pluginRunTargets: () => typedError(__TAURI_INVOKE("plugin_run_targets")), @@ -10345,6 +10355,17 @@ export type GhRepo = { viewerPermission: string, }; +export type GitActionBranch = { + name: string, + fullRef: string, + remote: boolean, +}; + +export type GitActionContext = { + repositories: string[], + branch: GitActionBranch | null, +}; + export type GitAnnotateMovement = "none" | "withinFile" | "acrossFiles"; export type GitAnnotateSettings = { @@ -14296,244 +14317,244 @@ export type PluginEvent = PluginEvent_Serialize | PluginEvent_Deserialize; /** Backend → UI notifications (Tauri event `ide://plugin`). */ export type PluginEvent_Deserialize = /** Project target registrations or remembered prompt answers changed. */ -({ type: "runTargetsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "runTargetsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A window-owned operation; an empty request id queues an asynchronous run. */ -({ type: "windowRequest"; pluginId: string; requestId: string; request: WindowRequest_Deserialize }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "windowRequest"; pluginId: string; requestId: string; request: WindowRequest_Deserialize }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Reply to a content action in this window. */ -({ type: "contentTabReply"; pluginId: string; requestId: string; reply: ContentTabReply }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "contentTabReply"; pluginId: string; requestId: string; reply: ContentTabReply }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open two texts in this window's diff viewer. */ -({ type: "openDiff"; pluginId: string; diff: FileDiff; fileName: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; done?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openDiff"; pluginId: string; diff: FileDiff; fileName: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; directory?: never; done?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Plugins, their status or their contributions changed: re-fetch `plugin_list`. */ -({ type: "commandsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "commandsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Complete replacement of one plugin's project-scoped decorations. */ -({ type: "decorationsChanged"; pluginId: string; sets: DecorationSet[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "decorationsChanged"; pluginId: string; sets: DecorationSet[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Complete replacement of one plugin's console highlight rules (empty: none). */ -({ type: "consoleRulesChanged"; pluginId: string; rules: ConsoleRule[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "consoleRulesChanged"; pluginId: string; rules: ConsoleRule[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open or focus the IDE's native database Query Console in the invoking window (API 1.21). */ -({ type: "openDatabaseConsole"; pluginId: string; sourceId: string; sql: string | null; schema: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; selection?: never; sets?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openDatabaseConsole"; pluginId: string; sourceId: string; sql: string | null; schema: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; selection?: never; sets?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open the IDE's native table data grid in the invoking window (API 1.21). */ -({ type: "openDatabaseTable"; pluginId: string; sourceId: string; catalog: string | null; schema: string; table: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; selection?: never; sets?: never; sql?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openDatabaseTable"; pluginId: string; sourceId: string; catalog: string | null; schema: string; table: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; selection?: never; sets?: never; sql?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Complete replacement of one plugin's clickable console link rules (API 1.21). */ -({ type: "consoleLinksChanged"; pluginId: string; rules: ConsoleLinkRule[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "consoleLinksChanged"; pluginId: string; rules: ConsoleLinkRule[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open a file in the invoking window; `as_text` in the text editor even when a custom editor claims it. */ -({ type: "editorOpen"; path: IpcPath; selection: Range | null; asText: boolean }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "editorOpen"; path: IpcPath; selection: Range | null; asText: boolean }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Change selection or scrolling only in this window's already open editor. */ -({ type: "editorRanges"; path: IpcPath; ranges: Range[]; reveal: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; reply?: never; request?: never; requestId?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "editorRanges"; path: IpcPath; ranges: Range[]; reveal: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; reply?: never; request?: never; requestId?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A bounded output channel snapshot, or withdrawal when the plugin stops. */ -({ type: "outputChanged"; pluginId: string; channel: string; text: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "outputChanged"; pluginId: string; channel: string; text: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Reveal a read-only Output tab in the receiving window. */ -({ type: "revealOutput"; pluginId: string; channel: string; text: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "revealOutput"; pluginId: string; channel: string; text: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Execute an action through the receiving window and answer over IPC. */ -({ type: "executeCommand"; requestId: string; id: string; arg: string | null; chain: string[] }) & { actions?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "executeCommand"; requestId: string; id: string; arg: string | null; chain: string[] }) & { actions?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Cached document associations were disposed (reload, disable or failure). */ -({ type: "documentIndexesChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "documentIndexesChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * The routes `plugin_id` reports for the project `root` may have changed: * ask `plugin_endpoints` again. */ -({ type: "endpointsChanged"; pluginId: string; root: IpcPath }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "endpointsChanged"; pluginId: string; root: IpcPath }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * The marketplace offers newer versions of installed plugins (announced * once per set of versions). */ -({ type: "updatesAvailable"; updates: PluginUpdate[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; url?: never; value?: never; view?: never } | ({ type: "notification"; pluginId: string; level: NotificationLevel; title: string; body: string; +({ type: "updatesAvailable"; updates: PluginUpdate[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "notification"; pluginId: string; level: NotificationLevel; title: string; body: string; /** Buttons running the plugin's own commands (`ui.notify`). */ -actions: NotificationAction[] }) & { arg?: never; args?: never; asText?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +actions: NotificationAction[] }) & { arg?: never; args?: never; asText?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A plugin's status bar item was set (`item`) or removed. */ -({ type: "statusItemChanged"; pluginId: string; id: string; item: StatusItem_Deserialize | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "statusItemChanged"; pluginId: string; id: string; item: StatusItem_Deserialize | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** An override in the receiving window; removal exposes the global item. */ -({ type: "windowStatusItemChanged"; pluginId: string; id: string; item: StatusItem_Deserialize | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "windowStatusItemChanged"; pluginId: string; id: string; item: StatusItem_Deserialize | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A plugin's context key was set (`value`: JSON text) or removed, in the * emitted window (every window when the client is `None`). */ -({ type: "contextChanged"; pluginId: string; key: string; value: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; view?: never } | +({ type: "contextChanged"; pluginId: string; key: string; value: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; view?: never; viewId?: never } | /** A plugin began a task: show it with the background tasks. */ -({ type: "taskStarted"; pluginId: string; taskId: string; title: string; cancellable: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "taskProgress"; pluginId: string; taskId: string; done: number; total: number | null; message: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; title?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "taskEnded"; pluginId: string; taskId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "taskStarted"; pluginId: string; taskId: string; title: string; cancellable: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "taskProgress"; pluginId: string; taskId: string; done: number; total: number | null; message: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; title?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "taskEnded"; pluginId: string; taskId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * The kinds of workbench events plugins want changed: re-fetch * `plugin_event_kinds` (the UI reports only those). */ -({ type: "subscriptionsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "subscriptionsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A background WebSocket has messages ready for its owning plugin. */ -({ type: "websocketReady"; pluginId: string; connection: number }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "themeChanged"; theme: ActiveTheme | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "websocketReady"; pluginId: string; connection: number }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "themeChanged"; theme: ActiveTheme | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A plugin needs capabilities the user has not granted yet (first use * after migrating from 0.1): show its consent dialog. */ -({ type: "consentRequested"; pluginId: string; capabilities: CapabilityInfo[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "consentRequested"; pluginId: string; capabilities: CapabilityInfo[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A view (or the custom editors) of a plugin must be rendered again. */ -({ type: "viewChanged"; pluginId: string; view: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never } | +({ type: "viewChanged"; pluginId: string; view: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; viewId?: never } | ({ type: "projectViewRefresh"; pluginId: string; viewId: string; directory: IpcPath | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "projectViewSelect"; pluginId: string; viewId: string; path: IpcPath; focus: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | /** For the script of a view's `html` body. */ -({ type: "viewMessage"; pluginId: string; view: string; message: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never } | +({ type: "viewMessage"; pluginId: string; view: string; message: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; viewId?: never } | /** Open a terminal running `program` (already approved and verified). */ -({ type: "openTerminal"; pluginId: string; title: string; program: IpcPath; args: string[]; cwd: IpcPath }) & { actions?: never; arg?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "openLocation"; pluginId: string; path: IpcPath; line: number; column: number }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openTerminal"; pluginId: string; title: string; program: IpcPath; args: string[]; cwd: IpcPath }) & { actions?: never; arg?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "openLocation"; pluginId: string; path: IpcPath; line: number; column: number }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * Open (or focus) the log tab `key` following `log` (`views.open-log-tab`); * it starts the program with `plugin_log_tab_spawn`. */ -({ type: "openLogTab"; pluginId: string; key: string; title: string; log: ServiceLog }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; level?: never; line?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openLogTab"; pluginId: string; key: string; title: string; log: ServiceLog }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; level?: never; line?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * Plugin languages, or the servers they may start, changed: re-fetch * `languages` (the host re-detects open documents: [`crate::Host::plugin_languages_changed`]). */ -({ type: "languagesChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "languagesChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Copy `text` to the system clipboard. */ -({ type: "copyToClipboard"; pluginId: string; text: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "copyToClipboard"; pluginId: string; text: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open `url` (`http(s)://`) in the system browser. */ -({ type: "openUrl"; pluginId: string; url: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; value?: never; view?: never } | +({ type: "openUrl"; pluginId: string; url: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; value?: never; view?: never; viewId?: never } | /** A window command/event requests the normal File > Open flow. */ -({ type: "openProject"; pluginId: string; path: string; newWindow: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openProject"; pluginId: string; path: string; newWindow: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A command waits for the user's answer: show `prompt`, then report it with * `plugin_answer_prompt(prompt_id, …)`. */ -({ type: "promptRequested"; pluginId: string; promptId: string; prompt: Prompt }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "promptRequested"; pluginId: string; promptId: string; prompt: Prompt }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** The call that asked gave up (cancelled, or its plugin stopped): close the prompt. */ -({ type: "promptClosed"; promptId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "promptClosed"; promptId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A command of this window's prompting plugin was run from another window and refused * while the plugin waits for the answer here: bring this window to the front. */ -({ type: "promptWaiting"; pluginId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "promptWaiting"; pluginId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Bring the tool window of the plugin's view `view` to the front. */ -({ type: "revealView"; pluginId: string; view: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never } | +({ type: "revealView"; pluginId: string; view: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; viewId?: never } | /** * Open Settings at the plugin's own page: its settings node (`page` none), the declared * sub-page `page`, or (`permissions`) Settings › Plugins with its permissions in view. */ -({ type: "openSettings"; pluginId: string; page: string | null; permissions: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openSettings"; pluginId: string; page: string | null; permissions: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A command needs the window's Commit view: answer with * `plugin_answer_commit(request_id, …)`. Closed like a prompt (`PromptClosed`). */ -({ type: "commitRequested"; pluginId: string; requestId: string; request: CommitRequest }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "commitRequested"; pluginId: string; requestId: string; request: CommitRequest }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A command the user ran reads the clipboard (`ui.read-clipboard`): answer with * `plugin_answer_clipboard(request_id, …)`. Closed like a prompt (`PromptClosed`). */ -({ type: "clipboardRequested"; pluginId: string; requestId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never }; +({ type: "clipboardRequested"; pluginId: string; requestId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never }; /** Backend → UI notifications (Tauri event `ide://plugin`). */ export type PluginEvent_Serialize = /** Project target registrations or remembered prompt answers changed. */ -({ type: "runTargetsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "runTargetsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A window-owned operation; an empty request id queues an asynchronous run. */ -({ type: "windowRequest"; pluginId: string; requestId: string; request: WindowRequest_Serialize }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "windowRequest"; pluginId: string; requestId: string; request: WindowRequest_Serialize }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Reply to a content action in this window. */ -({ type: "contentTabReply"; pluginId: string; requestId: string; reply: ContentTabReply }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "contentTabReply"; pluginId: string; requestId: string; reply: ContentTabReply }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open two texts in this window's diff viewer. */ -({ type: "openDiff"; pluginId: string; diff: FileDiff; fileName: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; done?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openDiff"; pluginId: string; diff: FileDiff; fileName: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; directory?: never; done?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Plugins, their status or their contributions changed: re-fetch `plugin_list`. */ -({ type: "commandsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "commandsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Complete replacement of one plugin's project-scoped decorations. */ -({ type: "decorationsChanged"; pluginId: string; sets: DecorationSet[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "decorationsChanged"; pluginId: string; sets: DecorationSet[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Complete replacement of one plugin's console highlight rules (empty: none). */ -({ type: "consoleRulesChanged"; pluginId: string; rules: ConsoleRule[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "consoleRulesChanged"; pluginId: string; rules: ConsoleRule[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open or focus the IDE's native database Query Console in the invoking window (API 1.21). */ -({ type: "openDatabaseConsole"; pluginId: string; sourceId: string; sql: string | null; schema: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; selection?: never; sets?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openDatabaseConsole"; pluginId: string; sourceId: string; sql: string | null; schema: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; selection?: never; sets?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open the IDE's native table data grid in the invoking window (API 1.21). */ -({ type: "openDatabaseTable"; pluginId: string; sourceId: string; catalog: string | null; schema: string; table: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; selection?: never; sets?: never; sql?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openDatabaseTable"; pluginId: string; sourceId: string; catalog: string | null; schema: string; table: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; selection?: never; sets?: never; sql?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Complete replacement of one plugin's clickable console link rules (API 1.21). */ -({ type: "consoleLinksChanged"; pluginId: string; rules: ConsoleLinkRule[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "consoleLinksChanged"; pluginId: string; rules: ConsoleLinkRule[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open a file in the invoking window; `as_text` in the text editor even when a custom editor claims it. */ -({ type: "editorOpen"; path: IpcPath; selection: Range | null; asText: boolean }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "editorOpen"; path: IpcPath; selection: Range | null; asText: boolean }) & { actions?: never; arg?: never; args?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Change selection or scrolling only in this window's already open editor. */ -({ type: "editorRanges"; path: IpcPath; ranges: Range[]; reveal: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; reply?: never; request?: never; requestId?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "editorRanges"; path: IpcPath; ranges: Range[]; reveal: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; reply?: never; request?: never; requestId?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A bounded output channel snapshot, or withdrawal when the plugin stops. */ -({ type: "outputChanged"; pluginId: string; channel: string; text: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "outputChanged"; pluginId: string; channel: string; text: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Reveal a read-only Output tab in the receiving window. */ -({ type: "revealOutput"; pluginId: string; channel: string; text: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "revealOutput"; pluginId: string; channel: string; text: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Execute an action through the receiving window and answer over IPC. */ -({ type: "executeCommand"; requestId: string; id: string; arg: string | null; chain: string[] }) & { actions?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "executeCommand"; requestId: string; id: string; arg: string | null; chain: string[] }) & { actions?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Cached document associations were disposed (reload, disable or failure). */ -({ type: "documentIndexesChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "documentIndexesChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * The routes `plugin_id` reports for the project `root` may have changed: * ask `plugin_endpoints` again. */ -({ type: "endpointsChanged"; pluginId: string; root: IpcPath }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "endpointsChanged"; pluginId: string; root: IpcPath }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * The marketplace offers newer versions of installed plugins (announced * once per set of versions). */ -({ type: "updatesAvailable"; updates: PluginUpdate[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; url?: never; value?: never; view?: never } | ({ type: "notification"; pluginId: string; level: NotificationLevel; title: string; body: string; +({ type: "updatesAvailable"; updates: PluginUpdate[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "notification"; pluginId: string; level: NotificationLevel; title: string; body: string; /** Buttons running the plugin's own commands (`ui.notify`). */ -actions: NotificationAction[] }) & { arg?: never; args?: never; asText?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +actions: NotificationAction[] }) & { arg?: never; args?: never; asText?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A plugin's status bar item was set (`item`) or removed. */ -({ type: "statusItemChanged"; pluginId: string; id: string; item: StatusItem_Serialize | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "statusItemChanged"; pluginId: string; id: string; item: StatusItem_Serialize | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** An override in the receiving window; removal exposes the global item. */ -({ type: "windowStatusItemChanged"; pluginId: string; id: string; item: StatusItem_Serialize | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "windowStatusItemChanged"; pluginId: string; id: string; item: StatusItem_Serialize | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A plugin's context key was set (`value`: JSON text) or removed, in the * emitted window (every window when the client is `None`). */ -({ type: "contextChanged"; pluginId: string; key: string; value: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; view?: never } | +({ type: "contextChanged"; pluginId: string; key: string; value: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; view?: never; viewId?: never } | /** A plugin began a task: show it with the background tasks. */ -({ type: "taskStarted"; pluginId: string; taskId: string; title: string; cancellable: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "taskProgress"; pluginId: string; taskId: string; done: number; total: number | null; message: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; title?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "taskEnded"; pluginId: string; taskId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "taskStarted"; pluginId: string; taskId: string; title: string; cancellable: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "taskProgress"; pluginId: string; taskId: string; done: number; total: number | null; message: string | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; title?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "taskEnded"; pluginId: string; taskId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * The kinds of workbench events plugins want changed: re-fetch * `plugin_event_kinds` (the UI reports only those). */ -({ type: "subscriptionsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "subscriptionsChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A background WebSocket has messages ready for its owning plugin. */ -({ type: "websocketReady"; pluginId: string; connection: number }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "themeChanged"; theme: ActiveTheme | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "websocketReady"; pluginId: string; connection: number }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "themeChanged"; theme: ActiveTheme | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A plugin needs capabilities the user has not granted yet (first use * after migrating from 0.1): show its consent dialog. */ -({ type: "consentRequested"; pluginId: string; capabilities: CapabilityInfo[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "consentRequested"; pluginId: string; capabilities: CapabilityInfo[] }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** A view (or the custom editors) of a plugin must be rendered again. */ -({ type: "viewChanged"; pluginId: string; view: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never } | +({ type: "viewChanged"; pluginId: string; view: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; viewId?: never } | ({ type: "projectViewRefresh"; pluginId: string; viewId: string; directory: IpcPath | null }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "projectViewSelect"; pluginId: string; viewId: string; path: IpcPath; focus: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | /** For the script of a view's `html` body. */ -({ type: "viewMessage"; pluginId: string; view: string; message: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never } | +({ type: "viewMessage"; pluginId: string; view: string; message: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; viewId?: never } | /** Open a terminal running `program` (already approved and verified). */ -({ type: "openTerminal"; pluginId: string; title: string; program: IpcPath; args: string[]; cwd: IpcPath }) & { actions?: never; arg?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | ({ type: "openLocation"; pluginId: string; path: IpcPath; line: number; column: number }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openTerminal"; pluginId: string; title: string; program: IpcPath; args: string[]; cwd: IpcPath }) & { actions?: never; arg?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | ({ type: "openLocation"; pluginId: string; path: IpcPath; line: number; column: number }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; log?: never; message?: never; newWindow?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * Open (or focus) the log tab `key` following `log` (`views.open-log-tab`); * it starts the program with `plugin_log_tab_spawn`. */ -({ type: "openLogTab"; pluginId: string; key: string; title: string; log: ServiceLog }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; level?: never; line?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openLogTab"; pluginId: string; key: string; title: string; log: ServiceLog }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; level?: never; line?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * Plugin languages, or the servers they may start, changed: re-fetch * `languages` (the host re-detects open documents: [`crate::Host::plugin_languages_changed`]). */ -({ type: "languagesChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "languagesChanged" }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Copy `text` to the system clipboard. */ -({ type: "copyToClipboard"; pluginId: string; text: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "copyToClipboard"; pluginId: string; text: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Open `url` (`http(s)://`) in the system browser. */ -({ type: "openUrl"; pluginId: string; url: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; value?: never; view?: never } | +({ type: "openUrl"; pluginId: string; url: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; value?: never; view?: never; viewId?: never } | /** A window command/event requests the normal File > Open flow. */ -({ type: "openProject"; pluginId: string; path: string; newWindow: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openProject"; pluginId: string; path: string; newWindow: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; page?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A command waits for the user's answer: show `prompt`, then report it with * `plugin_answer_prompt(prompt_id, …)`. */ -({ type: "promptRequested"; pluginId: string; promptId: string; prompt: Prompt }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "promptRequested"; pluginId: string; promptId: string; prompt: Prompt }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** The call that asked gave up (cancelled, or its plugin stopped): close the prompt. */ -({ type: "promptClosed"; promptId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "promptClosed"; promptId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; pluginId?: never; program?: never; prompt?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A command of this window's prompting plugin was run from another window and refused * while the plugin waits for the answer here: bring this window to the front. */ -({ type: "promptWaiting"; pluginId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "promptWaiting"; pluginId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** Bring the tool window of the plugin's view `view` to the front. */ -({ type: "revealView"; pluginId: string; view: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never } | +({ type: "revealView"; pluginId: string; view: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; viewId?: never } | /** * Open Settings at the plugin's own page: its settings node (`page` none), the declared * sub-page `page`, or (`permissions`) Settings › Plugins with its permissions in view. */ -({ type: "openSettings"; pluginId: string; page: string | null; permissions: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "openSettings"; pluginId: string; page: string | null; permissions: boolean }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; path?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; requestId?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A command needs the window's Commit view: answer with * `plugin_answer_commit(request_id, …)`. Closed like a prompt (`PromptClosed`). */ -({ type: "commitRequested"; pluginId: string; requestId: string; request: CommitRequest }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never } | +({ type: "commitRequested"; pluginId: string; requestId: string; request: CommitRequest }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never } | /** * A command the user ran reads the clipboard (`ui.read-clipboard`): answer with * `plugin_answer_clipboard(request_id, …)`. Closed like a prompt (`PromptClosed`). */ -({ type: "clipboardRequested"; pluginId: string; requestId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; done?: never; fileName?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never }; +({ type: "clipboardRequested"; pluginId: string; requestId: string }) & { actions?: never; arg?: never; args?: never; asText?: never; body?: never; cancellable?: never; capabilities?: never; catalog?: never; chain?: never; channel?: never; column?: never; connection?: never; cwd?: never; diff?: never; directory?: never; done?: never; fileName?: never; focus?: never; id?: never; item?: never; key?: never; level?: never; line?: never; log?: never; message?: never; newWindow?: never; page?: never; path?: never; permissions?: never; program?: never; prompt?: never; promptId?: never; ranges?: never; reply?: never; request?: never; reveal?: never; root?: never; rules?: never; schema?: never; selection?: never; sets?: never; sourceId?: never; sql?: never; table?: never; taskId?: never; text?: never; theme?: never; title?: never; total?: never; updates?: never; url?: never; value?: never; view?: never; viewId?: never }; /** A group of file extensions in a plugin's native chooser. */ export type PluginFileFilter = { @@ -15229,6 +15250,17 @@ export type ProjectUpdateTarget = { detachedSubmodule: boolean, }; +export type ProjectViewNativeNode = { + id: string, + path: string, + label: string, + kind: ProjectViewNodeKind, +}; + +export type ProjectViewNodeKind = "file" | "directory"; + +export type ProjectViewProjectionNode = { kind: "existingNode"; id: string; parent: string | null } | { kind: "virtualFolder"; id: string; parent: string | null; label: string; icon: string | null }; + /** Payload for promoting an auto-memory note into `AGENTS.md`. */ export type PromoteAgentMemoryInput = { sourceId: string, @@ -16170,6 +16202,14 @@ export type RevisionChange = { link?: LinkTarget | null, }; +export type RevisionComparison = { + repository: string, + left: string, + right: string, + leftLabel: string | null, + rightLabel: string | null, +}; + export type RewrittenCommit = { head: HeadChange, commit: string, @@ -19071,28 +19111,32 @@ export type WindowRequest = WindowRequest_Serialize | WindowRequest_Deserialize; /** A request that the invoking window acknowledges through plugin_answer_command. */ export type WindowRequest_Deserialize = /** Connect and introspect using the normal Database action in this window. */ -({ kind: "databaseConnect"; id: string }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never } | +({ kind: "databaseConnect"; id: string }) & { args?: never; comparison?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; key?: never; operation?: never; program?: never; project?: never; tab?: never; title?: never } | /** Open and acknowledge validation by the shared content editor. */ -({ kind: "contentTab"; tab: ContentTab }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; title?: never } | ({ kind: "run"; operation: string; config: RunConfig_Deserialize; debug: boolean }) & { args?: never; configId?: never; cwd?: never; draft?: never; env?: never; id?: never; key?: never; program?: never; tab?: never; title?: never } | ({ kind: "terminal"; operation: string; key: string; title: string; program: IpcPath; args: string[]; env: { [key in string]: string }; cwd: IpcPath }) & { config?: never; configId?: never; debug?: never; draft?: never; id?: never; tab?: never } | +({ kind: "contentTab"; tab: ContentTab }) & { args?: never; comparison?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; project?: never; title?: never } | +/** Open the native comparison of two commits in this window's Compare tool window. */ +({ kind: "revisionComparison"; comparison: RevisionComparison; project: string }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never } | ({ kind: "run"; operation: string; config: RunConfig_Deserialize; debug: boolean }) & { args?: never; comparison?: never; configId?: never; cwd?: never; draft?: never; env?: never; id?: never; key?: never; program?: never; project?: never; tab?: never; title?: never } | ({ kind: "terminal"; operation: string; key: string; title: string; program: IpcPath; args: string[]; env: { [key in string]: string }; cwd: IpcPath }) & { comparison?: never; config?: never; configId?: never; debug?: never; draft?: never; id?: never; project?: never; tab?: never } | /** Stop an active run/debug session belonging to this plugin (API 1.21). */ -({ kind: "stopRun"; id: string }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never } | +({ kind: "stopRun"; id: string }) & { args?: never; comparison?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; key?: never; operation?: never; program?: never; project?: never; tab?: never; title?: never } | /** Create or update a saved run configuration for one of this plugin's own types (API 1.21). */ -({ kind: "upsertRunConfiguration"; draft: RunConfigDraft }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never } | +({ kind: "upsertRunConfiguration"; draft: RunConfigDraft }) & { args?: never; comparison?: never; config?: never; configId?: never; cwd?: never; debug?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; project?: never; tab?: never; title?: never } | /** Open Run/Debug Configurations dialog, optionally selecting `config_id` (API 1.21). */ -({ kind: "openEditConfigurations"; configId: string | null }) & { args?: never; config?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never }; +({ kind: "openEditConfigurations"; configId: string | null }) & { args?: never; comparison?: never; config?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; project?: never; tab?: never; title?: never }; /** A request that the invoking window acknowledges through plugin_answer_command. */ export type WindowRequest_Serialize = /** Connect and introspect using the normal Database action in this window. */ -({ kind: "databaseConnect"; id: string }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never } | +({ kind: "databaseConnect"; id: string }) & { args?: never; comparison?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; key?: never; operation?: never; program?: never; project?: never; tab?: never; title?: never } | /** Open and acknowledge validation by the shared content editor. */ -({ kind: "contentTab"; tab: ContentTab }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; title?: never } | ({ kind: "run"; operation: string; config: RunConfig_Serialize; debug: boolean }) & { args?: never; configId?: never; cwd?: never; draft?: never; env?: never; id?: never; key?: never; program?: never; tab?: never; title?: never } | ({ kind: "terminal"; operation: string; key: string; title: string; program: IpcPath; args: string[]; env: { [key in string]: string }; cwd: IpcPath }) & { config?: never; configId?: never; debug?: never; draft?: never; id?: never; tab?: never } | +({ kind: "contentTab"; tab: ContentTab }) & { args?: never; comparison?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; project?: never; title?: never } | +/** Open the native comparison of two commits in this window's Compare tool window. */ +({ kind: "revisionComparison"; comparison: RevisionComparison; project: string }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never } | ({ kind: "run"; operation: string; config: RunConfig_Serialize; debug: boolean }) & { args?: never; comparison?: never; configId?: never; cwd?: never; draft?: never; env?: never; id?: never; key?: never; program?: never; project?: never; tab?: never; title?: never } | ({ kind: "terminal"; operation: string; key: string; title: string; program: IpcPath; args: string[]; env: { [key in string]: string }; cwd: IpcPath }) & { comparison?: never; config?: never; configId?: never; debug?: never; draft?: never; id?: never; project?: never; tab?: never } | /** Stop an active run/debug session belonging to this plugin (API 1.21). */ -({ kind: "stopRun"; id: string }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never } | +({ kind: "stopRun"; id: string }) & { args?: never; comparison?: never; config?: never; configId?: never; cwd?: never; debug?: never; draft?: never; env?: never; key?: never; operation?: never; program?: never; project?: never; tab?: never; title?: never } | /** Create or update a saved run configuration for one of this plugin's own types (API 1.21). */ -({ kind: "upsertRunConfiguration"; draft: RunConfigDraft }) & { args?: never; config?: never; configId?: never; cwd?: never; debug?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never } | +({ kind: "upsertRunConfiguration"; draft: RunConfigDraft }) & { args?: never; comparison?: never; config?: never; configId?: never; cwd?: never; debug?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; project?: never; tab?: never; title?: never } | /** Open Run/Debug Configurations dialog, optionally selecting `config_id` (API 1.21). */ -({ kind: "openEditConfigurations"; configId: string | null }) & { args?: never; config?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; tab?: never; title?: never }; +({ kind: "openEditConfigurations"; configId: string | null }) & { args?: never; comparison?: never; config?: never; cwd?: never; debug?: never; draft?: never; env?: never; id?: never; key?: never; operation?: never; program?: never; project?: never; tab?: never; title?: never }; export type WindowTab = WindowTab_Serialize | WindowTab_Deserialize; diff --git a/src/features/plugins/__tests__/commandBackend.test.ts b/src/features/plugins/__tests__/commandBackend.test.ts index 12b9c0b200..3328ec6be8 100644 --- a/src/features/plugins/__tests__/commandBackend.test.ts +++ b/src/features/plugins/__tests__/commandBackend.test.ts @@ -9,6 +9,21 @@ vi.mock("@tauri-apps/api/core", async (original) => ({ afterEach(() => vi.clearAllMocks()); +it("uses the Git command IPC with the captured repositories and full ref", async () => { + vi.mocked(invoke).mockResolvedValue("finished"); + const context = { + repositories: ["/project/a", "/project/b"], + branch: { name: "origin/release", fullRef: "refs/remotes/origin/release", remote: true }, + }; + await expect(tauriPluginsBackend.runGitCommand("example", "compare-branch", context, null)).resolves.toBe("finished"); + expect(invoke).toHaveBeenCalledExactlyOnceWith("plugin_run_git_command", { + pluginId: "example", + commandId: "compare-branch", + context, + editor: null, + }); +}); + it("cancels the same IPC request and settles the caller as soon as it aborts", async () => { let complete!: (value: string) => void; vi.mocked(invoke).mockImplementation((command) => diff --git a/src/features/plugins/__tests__/projectUi.test.tsx b/src/features/plugins/__tests__/projectUi.test.tsx index 093da482d3..275b800023 100644 --- a/src/features/plugins/__tests__/projectUi.test.tsx +++ b/src/features/plugins/__tests__/projectUi.test.tsx @@ -1,7 +1,9 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { waitFor } from "@testing-library/react"; import { registerAction } from "@/platform/actions"; +import { useProject } from "@/platform/project"; import { provideNotificationService, type NotificationService } from "@/workbench/contributions"; +import { provideRevisionComparisonService } from "@/workbench/gitActions"; import { createMemoryPluginsBackend, setPluginsBackend } from "../backend"; import { handleRuntimeEvent } from "../runtimeUi"; @@ -11,6 +13,7 @@ vi.mock("@/platform/ipc", async (original) => ({ ...(await original()), const answerPrompt = vi.fn().mockResolvedValue(undefined); let notes: Parameters[0][]; let dispose: (() => void) | undefined; +const originalProject = useProject.getState().project; beforeEach(() => { vi.clearAllMocks(); dispose = undefined; @@ -18,7 +21,10 @@ beforeEach(() => { provideNotificationService({ notify: (note) => void notes.push(note) }); setPluginsBackend({ ...createMemoryPluginsBackend(), answerPrompt }); }); -afterEach(() => dispose?.()); +afterEach(() => { + dispose?.(); + useProject.setState({ project: originalProject }); +}); const ask = (id: string) => handleRuntimeEvent({ type: "promptRequested", @@ -122,3 +128,74 @@ it("acknowledges database connection only after the normal project action succee expect(answerCommand).toHaveBeenCalledWith("failed", { kind: "failed", value: "Error: offline" }), ); }); + +const comparison = { + repository: "/work/repo", + left: "1".repeat(40), + right: "2".repeat(40), + leftLabel: "Merge base", + rightLabel: null, +}; + +it("answers once the comparison is open in the requesting project", async () => { + useProject.setState({ project: { root: "/work" } as never }); + const open = vi.fn(); + dispose = provideRevisionComparisonService(open); + const answerCommand = vi.fn().mockResolvedValue(true); + setPluginsBackend({ ...createMemoryPluginsBackend(), answerCommand }); + const request = { kind: "revisionComparison", comparison, project: "/work" } as const; + handleRuntimeEvent({ type: "windowRequest", pluginId: "p", requestId: "compare", request }); + await waitFor(() => expect(answerCommand).toHaveBeenCalledWith("compare", { kind: "value", value: null })); + expect(open).toHaveBeenCalledExactlyOnceWith(comparison); + + open.mockImplementationOnce(() => { + throw new Error("repository closed"); + }); + handleRuntimeEvent({ type: "windowRequest", pluginId: "p", requestId: "failed-compare", request }); + await waitFor(() => + expect(answerCommand).toHaveBeenCalledWith("failed-compare", { kind: "failed", value: "Error: repository closed" }), + ); +}); + +it("rejects a comparison for a project the window no longer shows", async () => { + useProject.setState({ project: { root: "/work/second" } as never }); + const open = vi.fn(); + dispose = provideRevisionComparisonService(open); + const answerCommand = vi.fn().mockResolvedValue(undefined); + setPluginsBackend({ ...createMemoryPluginsBackend(), answerCommand }); + handleRuntimeEvent({ + type: "windowRequest", + pluginId: "p", + requestId: "late-comparison", + request: { kind: "revisionComparison", project: "/work/first", comparison }, + }); + await waitFor(() => + expect(answerCommand).toHaveBeenCalledWith("late-comparison", { kind: "failed", value: expect.any(String) }), + ); + expect(open).not.toHaveBeenCalled(); +}); + +it("handles a closed window when trying to send a failed revision comparison answer", async () => { + useProject.setState({ project: { root: "/work" } as never }); + dispose = provideRevisionComparisonService(() => { + throw new Error("project closed"); + }); + const answerCommand = vi.fn().mockRejectedValue(new Error("project no longer trusted")); + setPluginsBackend({ ...createMemoryPluginsBackend(), answerCommand }); + const warned = vi.spyOn(console, "warn").mockImplementation(() => {}); + try { + handleRuntimeEvent({ + type: "windowRequest", + pluginId: "p", + requestId: "close-during-comparison", + request: { kind: "revisionComparison", project: "/work", comparison }, + }); + await waitFor(() => expect(warned).toHaveBeenCalled()); + expect(answerCommand).toHaveBeenCalledExactlyOnceWith("close-during-comparison", { + kind: "failed", + value: "Error: project closed", + }); + } finally { + warned.mockRestore(); + } +}); diff --git a/src/features/plugins/__tests__/projectViewPanes.test.ts b/src/features/plugins/__tests__/projectViewPanes.test.ts new file mode 100644 index 0000000000..d478e36977 --- /dev/null +++ b/src/features/plugins/__tests__/projectViewPanes.test.ts @@ -0,0 +1,69 @@ +import { afterEach, beforeEach, expect, it, vi } from "vitest"; +import type { PluginInfo } from "@/bindings"; +import { + projectViewPaneId, + provideProjectViewPaneService, + useProjectViewPanes, + type ProjectViewNativeNode, +} from "@/workbench/projectViewPanes"; +import { createMemoryPluginsBackend, setPluginsBackend } from "../backend"; +import { handlePluginEvent } from "../bridge"; +import { clearUiContributions, syncUiContributions } from "../projection"; +import { defineBuiltinUiPoints } from "../points"; + +let disposePoints: () => void; + +beforeEach(() => { + disposePoints = defineBuiltinUiPoints(); +}); + +afterEach(() => { + clearUiContributions(); + disposePoints(); + setPluginsBackend(null); +}); + +it("projects a plugin manifest pane to the workbench using its own provider and local id", async () => { + const projectViewModify = vi.fn().mockResolvedValue(null); + setPluginsBackend({ ...createMemoryPluginsBackend([]), projectViewModify }); + syncUiContributions( + [{ pluginId: "p", point: "projectViewPanes", key: "go", decl: { id: "go", title: "Go Folders", weight: 2 } }], + [{ id: "p", name: "Plugin", enabled: true, status: "active" } as PluginInfo], + ); + const id = projectViewPaneId("p", "go"); + const pane = useProjectViewPanes.getState().panes.get(id)!; + expect(pane).toMatchObject({ id: "plugin:p:go", title: "Go Folders", weight: 2 }); + + const parent: ProjectViewNativeNode = { id: "/p", path: "/p", label: "p", kind: "directory" }; + const child: ProjectViewNativeNode = { id: "/p/a.go", path: "/p/a.go", label: "a.go", kind: "file" }; + const { signal } = new AbortController(); + await pane.modifyChildren(parent, [child], { compact: true }, signal); + expect(projectViewModify).toHaveBeenCalledWith("p", "go", parent, [child], '{"compact":true}', signal); + + clearUiContributions(); + expect(useProjectViewPanes.getState().panes.has(id)).toBe(false); +}); + +it("routes host refresh and select requests to the owned or default pane", () => { + const refresh = vi.fn(() => true); + const select = vi.fn(() => true); + const off = provideProjectViewPaneService({ refresh, select }); + try { + handlePluginEvent({ type: "projectViewRefresh", pluginId: "p", viewId: "go", directory: "/p/src" }); + handlePluginEvent({ type: "projectViewSelect", pluginId: "p", viewId: "go", path: "/p/src/a.go", focus: false }); + handlePluginEvent({ + type: "projectViewSelect", + pluginId: "p", + viewId: "project", + path: "/p/src/a.go", + focus: true, + }); + expect(refresh).toHaveBeenCalledWith("plugin:p:go", "/p/src"); + expect(select.mock.calls).toEqual([ + ["plugin:p:go", "/p/src/a.go", false], + ["project", "/p/src/a.go", true], + ]); + } finally { + off(); + } +}); diff --git a/src/features/plugins/__tests__/views.test.tsx b/src/features/plugins/__tests__/views.test.tsx index 418c5c282b..b22c03947f 100644 --- a/src/features/plugins/__tests__/views.test.tsx +++ b/src/features/plugins/__tests__/views.test.tsx @@ -5,6 +5,7 @@ import { ContextMenuHost, hideContextMenu } from "@/ui"; import type { View, ViewEvent } from "@/bindings"; import { executeAction, registerAction } from "@/platform/actions"; import { bindingsFor, effectiveBindings, registerExtensionBindings, useKeymap } from "@/platform/keymap"; +import { gitBranchActions } from "@/workbench/gitActions"; import { createMemoryPluginsBackend, setPluginsBackend, type PluginsBackend } from "../backend"; import { commandArgs, defineBuiltinUiPoints } from "../points"; import { clearUiContributions, syncUiContributions } from "../projection"; @@ -162,6 +163,39 @@ describe("plugin keymaps", () => { }); describe("plugin menus", () => { + it("projects Git menu declarations and dispatches the captured branch to the plugin command", async () => { + const runGitCommand = vi.fn().mockResolvedValue(null); + const runCommand = vi.fn().mockResolvedValue(null); + setPluginsBackend({ ...createMemoryPluginsBackend([]), runGitCommand, runCommand }); + const plugin = { id: "p", name: "P", enabled: true, status: "active" } as Parameters< + typeof syncUiContributions + >[1][number]; + syncUiContributions( + [ + { pluginId: "p", point: "commands", key: "compare", decl: { id: "compare", title: "Compare Revisions" } }, + { + pluginId: "p", + point: "menus", + key: "git.branch.context/compare", + decl: { menu: "git.branch.context", command: "compare", when: "workspaceOpen" }, + }, + ], + [plugin], + ); + expect(gitBranchActions("git.branch.context")).toMatchObject([ + { id: "plugin.p.compare", title: "Compare Revisions", when: "workspaceOpen" }, + ]); + const gitAction = { + repositories: ["/repo/a", "/repo/b"], + branch: { name: "origin/release", fullRef: "refs/remotes/origin/release", remote: true }, + }; + await executeAction("plugin.p.compare", { gitAction }); + expect(runGitCommand).toHaveBeenCalledWith("p", "compare", gitAction, null); + expect(runCommand).not.toHaveBeenCalled(); + await executeAction("plugin.p.compare"); + expect(runCommand).toHaveBeenCalledWith("p", "compare", null, null, []); + }); + it("unpacks command arguments", () => { expect(commandArgs("x")).toEqual(["x", []]); expect(commandArgs({ path: "/a", paths: ["/a", "/b"] })).toEqual(["/a", ["/a", "/b"]]); @@ -169,6 +203,59 @@ describe("plugin menus", () => { expect(commandArgs({ path: 3 })).toEqual([null, []]); }); + it("passes project view metadata to commands that opt in and keeps their selected paths", () => { + const offRich = registerAction({ id: "plugin.p.rich", title: "Rich", run: () => {} }); + const offLegacy = registerAction({ id: "plugin.p.legacy", title: "Legacy", run: () => {} }); + const plugin = { id: "p", name: "P", status: "active", enabled: true } as unknown as Parameters< + typeof syncUiContributions + >[1][number]; + syncUiContributions( + [ + { + pluginId: "p", + point: "menus", + key: "projectView.context/rich", + decl: { + menu: "projectView.context", + command: "rich", + projectViewContext: true, + when: "projectViewId == 'plugin:p:groups'", + }, + }, + { + pluginId: "p", + point: "menus", + key: "projectView.context/legacy", + decl: { menu: "projectView.context", command: "legacy" }, + }, + ], + [plugin], + ); + try { + const context = { + viewId: "plugin:p:groups", + nodes: [{ id: "/p/mod_A_1.go", kind: "file" as const, path: "/p/mod_A_1.go" }], + }; + const physical = pluginMenuItems("projectView", ["/p/mod_A_1.go"], undefined, [false], context); + expect(physical).toMatchObject([ + { action: "plugin.p.rich", arg: { projectView: context } }, + { action: "plugin.p.legacy", arg: { path: "/p/mod_A_1.go" } }, + ]); + expect(commandArgs(physical[0] && "arg" in physical[0] ? physical[0].arg : undefined)).toEqual([ + JSON.stringify(context), + ["/p/mod_A_1.go"], + ]); + + const virtual = { viewId: context.viewId, nodes: [{ id: "mod/A", kind: "virtualFolder" as const }] }; + expect(pluginMenuItems("projectView", [], undefined, [], virtual)).toMatchObject([ + { action: "plugin.p.rich", arg: { projectView: virtual, paths: [] } }, + ]); + } finally { + offLegacy(); + offRich(); + } + }); + it("projects context menu entries for their command's action", () => { const off = registerAction({ id: "plugin.p.check", title: "Check", run: () => {} }); const plugin = { diff --git a/src/features/plugins/backend.ts b/src/features/plugins/backend.ts index 46980c7810..02832763d5 100644 --- a/src/features/plugins/backend.ts +++ b/src/features/plugins/backend.ts @@ -45,6 +45,8 @@ import { choosePath } from "@/platform/choosePath"; import { tx } from "@/platform/i18n"; import { useRemote } from "@/platform/remote"; import { call, commands, IpcError, isCancelled, isTauri, nextRequestId } from "@/platform/ipc"; +import type { GitActionContext } from "@/workbench/gitActions"; +import type { ProjectViewNativeNode, ProjectViewProjectionNode } from "@/workbench/projectViewPanes"; import { editorContext } from "./editorContext"; export interface PluginsBackend { @@ -91,10 +93,24 @@ export interface PluginsBackend { /** Aborting rejects the call and cancels that backend request. */ signal?: AbortSignal, ): Promise; + runGitCommand( + pluginId: string, + commandId: string, + context: GitActionContext, + editor: PluginEditor | null, + ): Promise; /** Run Anything entries of the plugin declaring `prefix`, for the field's text (API 1.18). */ runAnythingSuggest(pluginId: string, prefix: string, text: string): Promise; /** Runs a Run Anything line starting with the plugin's `prefix` (API 1.18): whether it claimed it. */ runAnythingRun(pluginId: string, prefix: string, line: string): Promise; + projectViewModify( + pluginId: string, + viewId: string, + parent: ProjectViewNativeNode, + children: ProjectViewNativeNode[], + settings: string, + signal: AbortSignal, + ): Promise; /** Workbench events plugins subscribed to (see `eventKinds`). */ postEvents(events: WorkbenchEvent[]): Promise; /** Kinds of workbench events plugins want; re-fetch on `subscriptionsChanged`. */ @@ -260,7 +276,20 @@ export const tauriPluginsBackend: PluginsBackend = { }, reload: (id) => call(commands.pluginReload(id)), runAnythingSuggest: (pluginId, prefix, text) => call(commands.pluginRunAnythingSuggest(pluginId, prefix, text)), + runGitCommand: (pluginId, commandId, context, editor) => + call(commands.pluginRunGitCommand(pluginId, commandId, context, editor)), runAnythingRun: (pluginId, prefix, line) => call(commands.pluginRunAnythingRun(pluginId, prefix, line)), + projectViewModify: async (pluginId, viewId, parent, children, settings, signal) => { + signal.throwIfAborted(); + const request = nextRequestId(); + const cancel = () => void commands.cancelRequest(request).catch(() => {}); + signal.addEventListener("abort", cancel, { once: true }); + try { + return await call(commands.pluginProjectViewModify(pluginId, viewId, parent, children, settings, request)); + } finally { + signal.removeEventListener("abort", cancel); + } + }, runCommand: async (pluginId, commandId, arg, editor, paths, settingsScope, commandChain, signal) => { signal?.throwIfAborted(); const request = signal ? nextRequestId() : null; @@ -726,7 +755,9 @@ export function createMemoryPluginsBackend( }, reload: async (id) => find(id), runAnythingSuggest: async () => [], + runGitCommand: async () => null, runAnythingRun: async () => false, + projectViewModify: async () => null, runCommand: async (pluginId, commandId) => { const p = find(pluginId); if (p.status !== "active" && p.status !== "inactive") diff --git a/src/features/plugins/bridge.ts b/src/features/plugins/bridge.ts index cc812a52ef..ecedefc26d 100644 --- a/src/features/plugins/bridge.ts +++ b/src/features/plugins/bridge.ts @@ -11,6 +11,7 @@ import { useEditorRegistry } from "@/editor/api"; import { refreshLanguageInfos } from "@/editor/core/cm/languages"; import { clearBackoffs } from "@/editor/lsp/availability"; import { endpointsChanged, notifications } from "@/workbench/contributions"; +import { projectViewPaneId, refreshProjectView, selectInProjectView } from "@/workbench/projectViewPanes"; import { languageListChanged } from "@/platform/languageList"; import { executeAction } from "@/platform/actions"; import { useProject } from "@/platform/project"; @@ -104,6 +105,16 @@ export function handlePluginEvent(e: PluginEvent) { case "endpointsChanged": if (e.root === useProject.getState().project?.root) endpointsChanged(); break; + case "projectViewRefresh": + refreshProjectView(projectViewPaneId(e.pluginId, e.viewId), e.directory); + break; + case "projectViewSelect": + selectInProjectView( + e.viewId === "project" ? "project" : projectViewPaneId(e.pluginId, e.viewId), + e.path, + e.focus, + ); + break; case "updatesAvailable": announceUpdates(e.updates); break; diff --git a/src/features/plugins/corePoints.tsx b/src/features/plugins/corePoints.tsx index e1d9cfceaf..f0d24390b4 100644 --- a/src/features/plugins/corePoints.tsx +++ b/src/features/plugins/corePoints.tsx @@ -15,6 +15,7 @@ import { executeAction, registerAction } from "@/platform/actions"; import { tx } from "@/platform/i18n"; import { addContributedTheme, pluginThemeRef } from "@/platform/themes"; import { currentThemeChoice, setTheme, useThemeOverride } from "@/workbench/theme"; +import { isGitActionArgument } from "@/workbench/gitActions"; import { useProject } from "@/platform/project"; import { Button, Kbd, T } from "@/ui"; import { addIconTheme, iconThemeKey, selectIconTheme, useSelectedIconTheme } from "./iconThemes"; @@ -29,16 +30,19 @@ import styles from "./PluginsPage.module.css"; /** Unpacks an action argument: a bare path, or a menu's `{ path, paths }`. */ export function commandArgs(arg: unknown): [string | null, string[]] { if (typeof arg === "string") return [arg, []]; - const { path, paths, line, column } = (arg ?? {}) as { + const { path, paths, line, column, projectView } = (arg ?? {}) as { path?: unknown; paths?: unknown; line?: unknown; column?: unknown; + projectView?: unknown; }; - if (typeof path !== "string" || !Array.isArray(paths)) return [null, []]; - if (typeof line === "number" && typeof column === "number") - return [JSON.stringify({ path, line, column }), paths.filter((p): p is string => typeof p === "string")]; - return [path, paths.filter((p): p is string => typeof p === "string")]; + if (!Array.isArray(paths)) return [null, []]; + const selected = paths.filter((p): p is string => typeof p === "string"); + if (projectView && typeof projectView === "object") return [JSON.stringify(projectView), selected]; + if (typeof path !== "string") return [null, []]; + if (typeof line === "number" && typeof column === "number") return [JSON.stringify({ path, line, column }), selected]; + return [path, selected]; } export const pluginActionId = (pluginId: string, commandId: string) => `plugin.${pluginId}.${commandId}`; @@ -269,6 +273,10 @@ export function defineCoreUiPoints(): () => void { keywords: ["plugin", plugin.name, pluginId], description: tx`From plugin ${plugin.name}`, run: async ({ arg }: { arg?: unknown }) => { + if (isGitActionArgument(arg)) { + await runPluginCommand(pluginId, decl.id, null, [], arg.gitAction); + return; + } // A shortcut passes nothing: the plugin's focused view supplies its selected item. const [path, paths] = commandArgs(arg ?? focusedViewItem(pluginId, action.id)); await runPluginCommand(pluginId, decl.id, path, paths); diff --git a/src/features/plugins/pluginText.ts b/src/features/plugins/pluginText.ts index 81920dd71e..bb3ed5fdf1 100644 --- a/src/features/plugins/pluginText.ts +++ b/src/features/plugins/pluginText.ts @@ -78,6 +78,7 @@ const TEXT_KEYS: Record = { searchCategories: ["title"], menus: ["submenu"], views: ["title"], + projectViewPanes: ["title"], markerIcons: ["tooltip"], customEditors: ["title"], dialogs: ["title"], diff --git a/src/features/plugins/runtimeUi.tsx b/src/features/plugins/runtimeUi.tsx index 2bd7b3e8e3..4413be658d 100644 --- a/src/features/plugins/runtimeUi.tsx +++ b/src/features/plugins/runtimeUi.tsx @@ -57,6 +57,7 @@ import { registerStatusItem, } from "@/workbench/contributions"; import { pickItems, promptInput } from "@/workbench/inputDialogs"; +import { openRevisionComparison } from "@/workbench/gitActions"; import { confirm } from "@/workbench/messages"; import { removeTask, upsertTask, useTasks } from "@/workbench/tasks"; import { editorContext } from "./editorContext"; @@ -948,6 +949,21 @@ export function startRuntimeUi(): () => void { async function handleWindowRequest(e: Extract) { const r = e.request; + if (r.kind === "revisionComparison") { + let answer: CommandAnswer; + try { + const { project, opening } = useProject.getState(); + if (opening || r.project !== project?.root) throw new Error(tx("Could not open comparison")); + openRevisionComparison(r.comparison); + answer = { kind: "value", value: null }; + } catch (error) { + answer = { kind: "failed", value: String(error) }; + } + await pluginsBackend() + .answerCommand(e.requestId, answer) + .catch((error) => console.warn("cannot answer revision comparison request", error)); + return; + } try { if (r.kind === "databaseConnect") { if (!getAction("db.pluginConnect")) throw new Error(tx("Database service unavailable")); diff --git a/src/features/plugins/store.ts b/src/features/plugins/store.ts index 510e384598..8d249cbefe 100644 --- a/src/features/plugins/store.ts +++ b/src/features/plugins/store.ts @@ -15,6 +15,7 @@ import type { import { notifications } from "@/workbench/contributions"; import { pluginsBackend, type PluginsBackend } from "./backend"; import { editorContext } from "./editorContext"; +import type { GitActionContext } from "@/workbench/gitActions"; import { iconThemeKey, selectedIconTheme, selectIconTheme } from "./iconThemes"; import { translatorOf, usePluginCatalogs } from "./pluginText"; @@ -488,9 +489,11 @@ export async function runPluginCommand( commandId: string, arg: string | null = null, paths: string[] = [], + gitAction?: GitActionContext, ) { const title = commandTitle(pluginId, commandId); try { + if (gitAction) return await pluginsBackend().runGitCommand(pluginId, commandId, gitAction, editorContext()); return await pluginsBackend().runCommand(pluginId, commandId, arg, editorContext(), paths); } catch (e) { await refreshPlugins(); diff --git a/src/features/plugins/uiPoints.tsx b/src/features/plugins/uiPoints.tsx index c3df79e23c..f65a5ce6f4 100644 --- a/src/features/plugins/uiPoints.tsx +++ b/src/features/plugins/uiPoints.tsx @@ -49,10 +49,13 @@ import { registerTextEditorWrapper, type ContextMenuId, type ContributedCommitProblem, + type ProjectViewMenuContext, type ServiceContext, type ServiceItemAction, type ToolWindowAnchor, } from "@/workbench/contributions"; +import { projectViewPaneId, registerProjectViewPane } from "@/workbench/projectViewPanes"; +import { registerGitBranchAction } from "@/workbench/gitActions"; import { pluginsBackend } from "./backend"; import { pluginIconName } from "./pluginIcon"; import { projectMarkerIcon, type MarkerIconDecl } from "./markerIcons"; @@ -110,6 +113,8 @@ interface MenuDecl { | "services.context" | "services.toolbar" | "database.table.context" + | "git.branches.popup" + | "git.branch.context" | "database.source.context" | "database.schema.context" | "database.column.context" @@ -117,6 +122,7 @@ interface MenuDecl { | "runConsole.toolbar"; view?: string | null; command: string; + projectViewContext?: boolean; when?: string | null; /** Groups the plugin's entries of one context menu under this label. */ submenu?: string | null; @@ -196,21 +202,37 @@ export function pluginMenuItems( paths: readonly string[], position?: { line: number; column: number }, dirs?: readonly boolean[], + projectView?: ProjectViewMenuContext, ): MenuItem[] { const out: MenuItem[] = []; const groups = new Map(); const resource = menu === "projectView" || menu === "editorTab" || menu === "openIn" ? resourceWhenContext(paths, dirs) : undefined; - const evalCtx = resource ? { ...getContext(), ...resource } : undefined; + const evalCtx = + resource || projectView + ? { + ...getContext(), + ...resource, + ...(projectView && { + projectViewId: projectView.viewId, + projectViewNodeKind: projectView.nodes[0]?.kind, + }), + } + : undefined; for (const { pluginId, decl } of contextItems.values()) { if (CONTEXT_MENUS[decl.menu] !== menu || !evaluateWhen(decl.when ?? undefined, evalCtx)) continue; + if (projectView && !paths.length && !decl.projectViewContext) continue; const action = pluginActionId(pluginId, decl.command); if (!getAction(action)) continue; // The editor menu runs with the focused editor; the others name their file. + const arg = + decl.projectViewContext && projectView + ? { projectView, paths: [...paths] } + : { path: paths[0], paths: [...paths], ...(position ?? {}) }; addGrouped(out, groups, pluginId, decl.submenu, { kind: "action", action, - arg: menu === "editor" ? undefined : { path: paths[0], paths: [...paths], ...(position ?? {}) }, + arg: menu === "editor" ? undefined : arg, }); } return flattenSingleGroups(out); @@ -444,6 +466,14 @@ export function pluginServiceActions(services: readonly ServiceContext[]): Servi } function projectMenu(pluginId: string, decl: MenuDecl, plugin: PluginInfo): () => void { + if (decl.menu === "git.branches.popup" || decl.menu === "git.branch.context") { + const id = pluginActionId(pluginId, decl.command); + return registerGitBranchAction(decl.menu, { + id, + title: decl.commandTitle ?? getAction(id)?.title, + when: decl.when ?? undefined, + }); + } if (decl.menu === "tools") { const action = pluginActionId(pluginId, decl.command); const title = decl.commandTitle ?? getAction(action)?.title ?? `${plugin.name}: ${decl.command}`; @@ -830,6 +860,17 @@ export function defineViewUiPoints(): () => void { title: "Run Anything", project: ({ pluginId, decl }) => projectRunAnything(pluginId, decl), }), + defineUiPoint<{ id: string; title: string; weight?: number }>("projectViewPanes", { + title: "Project Views", + project: ({ pluginId, decl }) => + registerProjectViewPane({ + id: projectViewPaneId(pluginId, decl.id), + title: decl.title, + weight: decl.weight ?? 0, + modifyChildren: (parent, children, settings, signal) => + pluginsBackend().projectViewModify(pluginId, decl.id, parent, children, JSON.stringify(settings), signal), + }), + }), defineUiPoint("markerIcons", { title: "Marker Icons", project: ({ pluginId, decl }) => projectMarkerIcon(pluginId, decl), @@ -916,12 +957,14 @@ export function startViewUi(openInput: (input: ReturnType { const items = pluginMenuItems( menu, ctx.paths, ctx.line === undefined ? undefined : { line: ctx.line, column: ctx.column ?? 0 }, ctx.dirs, + menu === "projectView" ? ctx.projectView : undefined, ); const path = ctx.paths[0]; if ((menu === "projectView" || menu === "editorTab") && path && !ctx.dirs?.[0]) { diff --git a/src/features/project-tree/HeaderActions.tsx b/src/features/project-tree/HeaderActions.tsx index 87888f3f90..bb18730902 100644 --- a/src/features/project-tree/HeaderActions.tsx +++ b/src/features/project-tree/HeaderActions.tsx @@ -3,6 +3,7 @@ import { IconButton, type MenuItem } from "@/ui"; import { useProject } from "@/platform/project"; import { userScopes } from "@/platform/scopes"; import { useEditorPrefs } from "@/platform/editorSettings"; +import { isPluginProjectViewPane, projectViewPanes, useProjectViewPanes } from "@/workbench/projectViewPanes"; import { VIEW_MODES, hasVisibleSelection, @@ -17,11 +18,13 @@ import { import type { SortKey } from "./model"; /** The title's "Project ▾" pane switcher (IDEA: Project / Project Files / Open Files / …). */ -export function useProjectTitleMenu(): { label: string; items: MenuItem[] } { +export function useProjectTitleMenu(): { label: string; items: MenuItem[]; verbatim?: boolean } { const mode = useProjectTree((s) => s.mode); const scope = useProjectTree((s) => s.scope); const unity = useProjectTree((s) => s.unity); const unreal = useProjectTree((s) => s.unreal); + const pluginPanes = useProjectViewPanes((s) => s.panes); + const pluginPane = isPluginProjectViewPane(mode) ? pluginPanes.get(mode) : undefined; // The engine panes only exist in a project of that engine. const available = (id: string) => (id !== "unity" || Boolean(unity)) && (id !== "unreal" || Boolean(unreal)); // User scopes (Settings › Scopes) follow the built-in panes, as in IDEA. @@ -32,6 +35,14 @@ export function useProjectTitleMenu(): { label: string; items: MenuItem[] } { checked: id === mode, run: () => setViewMode(id), })); + for (const pane of projectViewPanes(pluginPanes)) + items.push({ + id: pane.id, + label: pane.title, + verbatim: true, + checked: pane.id === mode, + run: () => setViewMode(pane.id), + }); if (scopes.length) { items.push({ kind: "separator" }); for (const s of scopes) @@ -44,7 +55,11 @@ export function useProjectTitleMenu(): { label: string; items: MenuItem[] } { }); } return { - label: mode === "scope" ? (scope ?? "Project") : (VIEW_MODES.find(([id]) => id === mode)?.[1] ?? "Project"), + label: + mode === "scope" + ? (scope ?? "Project") + : (pluginPane?.title ?? VIEW_MODES.find(([id]) => id === mode)?.[1] ?? "Project"), + ...(pluginPane ? { verbatim: true } : {}), items, }; } diff --git a/src/features/project-tree/ProjectView.test.tsx b/src/features/project-tree/ProjectView.test.tsx index 34ea268e84..f425d71218 100644 --- a/src/features/project-tree/ProjectView.test.tsx +++ b/src/features/project-tree/ProjectView.test.tsx @@ -12,6 +12,7 @@ import { setFileDecorations, type EditorService, } from "@/workbench/contributions"; +import { projectViewPaneId, registerProjectViewPane, selectInProjectView } from "@/workbench/projectViewPanes"; import { activate } from "./index"; import { setOsClipboardForTests } from "./clipboard"; import { MemoryFs, setProjectFsForTests } from "./fs"; @@ -27,7 +28,7 @@ import { _emitEditorEvent, useEditorRegistry } from "@/editor/api"; import { LspPopups } from "@/editor/lsp/Popups"; import { closePopup, useLspPopup } from "@/editor/lsp/popupStore"; import { clearLineTokens } from "@/editor/lineTokens"; -import { ProjectHeaderActions, useProjectHeaderMenu } from "./HeaderActions"; +import { ProjectHeaderActions, useProjectHeaderMenu, useProjectTitleMenu } from "./HeaderActions"; import { executeAction, getAction } from "@/platform/actions"; import { useProject } from "@/platform/project"; import { useBuildPresentation } from "@/platform/projectPresentation"; @@ -149,6 +150,57 @@ function setup() { } describe("ProjectView", () => { + it("uses the native pane menu, icons and file opening for a plugin's Go groups", async () => { + const path = `${ROOT}/src/mod_A_1.go`; + fs = new MemoryFs({ [path]: "package demo", [`${ROOT}/src/mod_A_2.go`]: "package demo" }, ROOT); + setProjectFsForTests(fs, ROOT); + initProjectTree(ROOT, "acme"); + const id = projectViewPaneId("test.better-go-folder", "groups"); + const unregister = registerProjectViewPane({ + id, + title: "Better Go Folder", + weight: 10, + modifyChildren: async (parent, children) => + parent.path === `${ROOT}/src` + ? [ + { kind: "virtualFolder", id: "mod", label: "mod" }, + { kind: "virtualFolder", id: "A", label: "A", parent: "mod", icon: "unregistered-project-folder-icon" }, + ...children.map((child) => ({ kind: "existingNode" as const, id: child.id, parent: "A" })), + ] + : null, + }); + try { + const { row, rows } = setup(); + const title = renderHook(useProjectTitleMenu); + const pane = title.result.current.items.find((item) => "id" in item && item.id === id); + expect(pane).toMatchObject({ label: "Better Go Folder", checked: false }); + act(() => { + if (pane && "run" in pane) pane.run?.(); + }); + expect(title.result.current.label).toBe("Better Go Folder"); + expect(title.result.current.verbatim).toBe(true); + await waitFor(() => expect(row("src")).toBeDefined()); + fireEvent.doubleClick(row("src")); + await waitFor(() => expect(rows()).toContain("mod")); + expect(row("mod").querySelector("[data-project-icon]")).toHaveAttribute("data-project-icon", "folder"); + expect(row("mod").querySelector("[data-project-path]")).toBeNull(); + fireEvent.doubleClick(row("mod")); + expect(row("A").querySelector("[data-project-icon]")).toHaveAttribute("data-project-icon", "folder"); + fireEvent.doubleClick(row("A")); + expect(row("mod_A_1.go").querySelector("[data-project-icon]")).toHaveAttribute("data-project-icon", "file-go"); + fireEvent.doubleClick(row("mod_A_1.go")); + expect(openFile).toHaveBeenLastCalledWith(path, { focus: true, preview: undefined }); + + act(() => { + expect(selectInProjectView("project", path, false)).toBe(true); + }); + await waitFor(() => expect(row("mod_A_1.go")).toHaveAttribute("aria-selected", "true")); + expect(rows()).not.toContain("mod"); + } finally { + act(unregister); + } + }); + describe("Java class names", () => { const source = `${ROOT}/src/main/java`; const testSource = `${ROOT}/src/test/java`; diff --git a/src/features/project-tree/ProjectView.tsx b/src/features/project-tree/ProjectView.tsx index 5c698c2b94..594098d4a7 100644 --- a/src/features/project-tree/ProjectView.tsx +++ b/src/features/project-tree/ProjectView.tsx @@ -55,6 +55,7 @@ import { Tree, acquirePopup, fileIconName, + hasIcon, useFileIconRevision, folderIconName, themedFolderIconName, @@ -69,7 +70,7 @@ import { import { badgeKind } from "@/ui/symbolKind"; import { projectScopeForPath } from "@/ui/folderPresentation"; import { isConfiguredLibraryDirectory, prepareLibraryTargets } from "./addLibrary"; -import { contextMenuItems, menuGroupContext, newMenuItems } from "./contextMenu"; +import { contextMenuItems, newMenuItems, projectViewMenuGroupContext } from "./contextMenu"; import { openNewPopup } from "./newPopupModel"; import { presentationBadge, presentationIcon, useJvmPresentation } from "@/ui/filePresentation"; import { @@ -169,7 +170,7 @@ export function showQuickPreview(path?: string): boolean { const getKey = (n: ProjectNode) => n.key; const decoratedLabel = (n: ProjectNode, fallback = n.label) => - n.placeholder || n.member ? n.label : (getFileDecoration(n.path)?.label ?? fallback); + n.placeholder || n.member || n.virtualFolder ? n.label : (getFileDecoration(n.path)?.label ?? fallback); function iconFor( node: ProjectNode, @@ -182,6 +183,10 @@ function iconFor( libraryDir: boolean, ): string { if (node.placeholder) return node.placeholder === "dir" ? "folder" : "file"; + if (node.virtualFolder) + return node.icon && hasIcon(node.icon) + ? node.icon + : (themedFolderIconName(node.label, expanded, false) ?? "folder"); if (node.icon) return node.icon; if (node.dir) { // A folder with a role keeps the role icon unless the icon theme names it for that role. @@ -361,7 +366,8 @@ const Row = memo(function Row({ }: RowProps) { // Memoised: redraw this row itself when the file icon theme changes. useFileIconRevision(); - const deco = useFileDecoration(node.path); + const decoration = useFileDecoration(node.virtualFolder ? "" : node.path); + const deco = node.virtualFolder ? {} : decoration; const root = useProjectTree((s) => s.root); const detected = useDetectedRoots(); const build = useProjectPresentation(); @@ -406,7 +412,7 @@ const Row = memo(function Row({ return ( { - if (!revealRequest) return; + if (!revealRequest || revealRequest.projectionPending) return; const { path, focus, seq, explain } = revealRequest; const exact = model.keyOfPath.get(path); const loadingAncestors = info.pending.some((p) => p === path || isInside(path, p)); @@ -733,7 +739,8 @@ export function ProjectView() { ); const loadChildren = useCallback( - (n: ProjectNode) => (n.member ? Promise.resolve() : n.dir ? loadDir(n.path) : loadOutline(n.path)), + (n: ProjectNode) => + n.member || n.virtualFolder ? Promise.resolve() : n.dir ? loadDir(n.path) : loadOutline(n.path), [], ); const showLoadingRow = useCallback((node: ProjectNode) => !node.dir || slowListings.has(node.path), [slowListings]); @@ -745,6 +752,7 @@ export function ProjectView() { if (!n.dir && !children) return n.group ? undefined : outlineRows.get(n.path); if ( !children || + model.projectedDirectories?.has(n.key) || !decorationProviders.size || options.sortBy !== "name" || !children.some((child) => decoratedLabel(child) !== child.label) @@ -793,7 +801,8 @@ export function ProjectView() { }, []); const onContextMenu = useCallback((node: ProjectNode | null, sel: Set, e: ReactMouseEvent) => { - const m = selectModel(useProjectTree.getState()); + const state = useProjectTree.getState(); + const m = selectModel(state); if (!node) { const rootNode = m.roots[0]; if (!rootNode) return; @@ -810,12 +819,17 @@ export function ProjectView() { if (items.length) showContextMenu(e, items); return; } - if (target.every((n) => n.group) || target.some((n) => n.member)) return; + if (target.every((n) => n.group && !n.virtualFolder) || target.some((n) => n.member)) return; // Contributed groups and collapsed library folders may read the filesystem first (bounded wait). const at = { x: e.clientX, y: e.clientY }; - void Promise.all([prepareMenuGroups("projectView", menuGroupContext(target)), prepareLibraryTargets(target)]).then( - () => showContextMenu(at, contextMenuItems(target, at)), - ); + void Promise.all([ + prepareMenuGroups("projectView", projectViewMenuGroupContext(target)), + prepareLibraryTargets(target.filter((n) => !n.virtualFolder)), + ]).then(() => { + if (useProjectTree.getState().mode !== state.mode) return; + const items = contextMenuItems(target, at); + if (items.length) showContextMenu(at, items); + }); }, []); const focusTree = useCallback(() => requestAnimationFrame(() => handle.current?.focus()), []); @@ -825,7 +839,7 @@ export function ProjectView() { const onRowClick = useCallback((node: ProjectNode, e: ReactMouseEvent) => { if (e.button !== 0 || e.shiftKey || e.metaKey || e.ctrlKey || e.altKey) return; - if (node.placeholder || node.group || dragged.current) return; + if (node.placeholder || (node.group && !node.virtualFolder) || dragged.current) return; const { options: o, editing: ed } = useProjectTree.getState(); if (ed) return; if (e.detail > 1 && !(node.dir && o.singleClickExpand && e.detail % 2 === 1)) return; @@ -935,7 +949,9 @@ export function ProjectView() { const m = selectModel(useProjectTree.getState()); const keys = before.has(node.key) ? [...before] : [node.key]; if (before.has(node.key)) setSelection(before, lead); - nodes = keys.map((k) => m.byKey.get(k)).filter((n): n is ProjectNode => !!n && !n.placeholder); + nodes = keys + .map((k) => m.byKey.get(k)) + .filter((n): n is ProjectNode => !!n && !n.placeholder && !n.virtualFolder); // A project root is a folder to a target outside the tree (the terminal, an editor, an // agent composer), and PyCharm drags it the same way; moving one inside the tree is not a // move we make, so it stays out of what an in-tree drop moves and out of an OS drag. diff --git a/src/features/project-tree/actions.ts b/src/features/project-tree/actions.ts index 34c2ab539d..6ae2c83022 100644 --- a/src/features/project-tree/actions.ts +++ b/src/features/project-tree/actions.ts @@ -8,6 +8,11 @@ import { dirname, useProject } from "@/platform/project"; import { isUntitledUri } from "@/platform/virtualDocs"; import { showContextMenu, type MenuItem } from "@/ui"; import { maybeEditorService, menuGroupItems, toolWindowService } from "@/workbench/contributions"; +import { + projectViewPanes, + selectInProjectView as selectInNamedProjectView, + useProjectViewPanes, +} from "@/workbench/projectViewPanes"; import { OPTION_LABELS, SORT_LABELS, flipToggle, isToggled } from "./HeaderActions"; import { canAddAsLibrary, openAddAsLibraryDialog } from "./addLibrary"; import { compareTarget, isModuleNode, newMenuItems, revealLabel } from "./contextMenu"; @@ -131,7 +136,7 @@ export function selectInProjectView(path?: string | null, focus = true, expand = */ export function selectInTargets(path: string): MenuItem[] { const { unity } = useProjectTree.getState(); - const views = VIEW_MODES.filter(([mode]) => mode !== "unity" || unity).map(([mode, label]) => ({ + const views: MenuItem[] = VIEW_MODES.filter(([mode]) => mode !== "unity" || unity).map(([mode, label]) => ({ label, disabled: !modeShows(path, mode), run: () => { @@ -139,6 +144,13 @@ export function selectInTargets(path: string): MenuItem[] { selectInProjectView(path); }, })); + for (const pane of projectViewPanes()) + views.push({ + label: pane.title, + verbatim: true, + disabled: !modeShows(path, pane.id), + run: () => void selectInNamedProjectView(pane.id, path), + }); return [ { kind: "header", label: "Select In", asTitle: true }, { @@ -185,6 +197,32 @@ function showSelectIn(path: string) { showContextMenu(at, selectInTargets(path), { numbers: true }); } +export function registerPluginPaneActions(): () => void { + let removeActions = () => {}; + const update = () => { + removeActions(); + removeActions = registerActions( + projectViewPanes().map((pane) => ({ + id: `project.viewMode.${pane.id}`, + title: tx`Project View: Show ${pane.title}`, + category: "View", + when: OPEN, + keywords: ["project", "pane", "scope", "view as"], + run: () => { + setViewMode(pane.id); + showProjectView(false); + }, + })), + ); + }; + update(); + const unsubscribe = useProjectViewPanes.subscribe(update); + return () => { + unsubscribe(); + removeActions(); + }; +} + export function registerProjectActions(): () => void { const copyPath = (kind: PathKind, id: string, title: string): Action => ({ id, @@ -243,7 +281,8 @@ export function registerProjectActions(): () => void { if (opts?.revealOutside && !canRevealInProjectTree(path)) return revealInFinder(nodesFrom(path)); return void selectInProjectView(path, true, !!opts?.expand); } - const target = maybeEditorService()?.activePath() ?? leadNode()?.path; + const lead = leadNode(); + const target = maybeEditorService()?.activePath() ?? (lead?.virtualFolder ? null : lead?.path); if (target) showSelectIn(target); }, }, diff --git a/src/features/project-tree/contextMenu.test.ts b/src/features/project-tree/contextMenu.test.ts index 8fc55940b0..d0b6ffc1b3 100644 --- a/src/features/project-tree/contextMenu.test.ts +++ b/src/features/project-tree/contextMenu.test.ts @@ -96,6 +96,29 @@ afterEach(() => { }); describe("project view context menu", () => { + it("offers virtual folders only to context contributors that accept them", () => { + const ordinary = vi.fn(() => [{ label: "Filesystem command", run: () => undefined }]); + const virtual = vi.fn(() => [{ label: "Group command", run: () => undefined }]); + disposers.push( + registerMenuGroup({ id: "test.paths", menus: ["projectView"], items: ordinary }), + registerMenuGroup({ id: "test.groups", menus: ["projectView"], virtualProjectFolders: true, items: virtual }), + ); + const previousMode = useProjectTree.getState().mode; + useProjectTree.setState({ mode: "plugin:p:groups" }); + try { + const group = { ...node("project-group:mod/A", true), virtualFolder: true, virtualFolderId: "mod/A" } as const; + expect(labels(contextMenuItems([group])).filter((label) => label !== "-")).toEqual(["Group command"]); + expect(ordinary).not.toHaveBeenCalled(); + expect(virtual).toHaveBeenCalledWith("projectView", { + paths: [], + dirs: [], + projectView: { viewId: "plugin:p:groups", nodes: [{ id: "mod/A", kind: "virtualFolder" }] }, + }); + } finally { + useProjectTree.setState({ mode: previousMode }); + } + }); + it("offers directory comparison only for two folders and Compare With for a single folder", () => { expect(labels(contextMenuItems([node("/p/left", true), node("/p/right", true)]))).toContain("Compare Directories"); expect(labels(contextMenuItems([node("/p/left", true)]))).toContain("Compare With…"); diff --git a/src/features/project-tree/contextMenu.ts b/src/features/project-tree/contextMenu.ts index 529d39ae64..1e9cbdab88 100644 --- a/src/features/project-tree/contextMenu.ts +++ b/src/features/project-tree/contextMenu.ts @@ -212,6 +212,11 @@ function workspaceMemberItems(node: ProjectNode | null): MenuItem[] { /** `at`: where the menu opens, for the popups its items open (Copy Path/Reference…). */ export function contextMenuItems(nodes: ProjectNode[], at: MenuPoint = "center"): MenuItem[] { + const contributionContext = projectViewMenuGroupContext(nodes); + if (nodes.some((n) => n.virtualFolder)) { + nodes = nodes.filter((n) => !n.virtualFolder); + if (!nodes.length) return menuGroupItems("projectView", contributionContext); + } if (nodes.some((n) => n.readOnly)) return libraryMenuItems( nodes.filter((n) => !n.group), @@ -370,7 +375,7 @@ export function contextMenuItems(nodes: ProjectNode[], at: MenuPoint = "center") ); // Contributed groups (Run / Debug '…', More Run/Debug ›), each followed by a separator. - push(...menuGroupItems("projectView", menuGroupContext(nodes))); + push(...menuGroupItems("projectView", contributionContext)); // Open in Right Split / Open In › push( @@ -617,11 +622,27 @@ function copyPathItem(nodes: ProjectNode[], at: MenuPoint, library: boolean): En }; } -/** What contributed menu groups see: the selected (non-placeholder) paths. */ +/** The filesystem targets shared by project menu groups. */ export function menuGroupContext(nodes: ProjectNode[]): MenuGroupContext { - const real = nodes.filter((n) => !n.placeholder); + const real = nodes.filter((n) => !n.placeholder && !n.virtualFolder); return { paths: real.map((n) => n.menuPath ?? n.path), dirs: real.map((n) => (n.menuPath ? false : n.dir)), }; } + +export function projectViewMenuGroupContext(nodes: ProjectNode[]): MenuGroupContext { + return { + ...menuGroupContext(nodes), + projectView: { + viewId: useProjectTree.getState().mode, + nodes: nodes + .filter((n) => !n.placeholder && (!n.group || n.virtualFolder)) + .map((n) => + n.virtualFolder + ? { id: n.virtualFolderId ?? n.key, kind: "virtualFolder" } + : { id: n.key, kind: n.dir ? "directory" : "file", path: n.path }, + ), + }, + }; +} diff --git a/src/features/project-tree/index.ts b/src/features/project-tree/index.ts index 7f20bbbbe3..0fa4b90c03 100644 --- a/src/features/project-tree/index.ts +++ b/src/features/project-tree/index.ts @@ -25,7 +25,7 @@ import { useLocalChanges, useProjectViewRoots, } from "@/workbench/contributions"; -import { registerProjectActions } from "./actions"; +import { registerPluginPaneActions, registerProjectActions } from "./actions"; import { clearLibraryProbeCache } from "./addLibrary"; import { AddLibraryDialogHost } from "./AddLibraryDialog"; import { mavenExternalRoots } from "./mavenRoots"; @@ -51,6 +51,7 @@ import { setOpenFiles, setScopeFiles, setViewMode, + startProjectViewPanes, useProjectTree, } from "./store"; @@ -328,6 +329,8 @@ export function activate(): () => void { registerOverlay({ id: "project.refactoringPreview", component: RefactoringPreviewHost }), registerOverlay({ id: "project.newPopup", component: NewPopupHost }), registerProjectActions(), + registerPluginPaneActions(), + startProjectViewPanes(), // Edit › Undo while the Project view has focus. registerUndoHandler( (command, focused) => diff --git a/src/features/project-tree/model.ts b/src/features/project-tree/model.ts index 98601a3bfd..e2e96457c5 100644 --- a/src/features/project-tree/model.ts +++ b/src/features/project-tree/model.ts @@ -67,6 +67,9 @@ export interface ProjectNode { note?: string; /** A node grouping other nodes, without a folder of its own ("External Libraries"). */ group?: boolean; + /** A plugin-created grouping folder and its ID within its native parent. */ + virtualFolder?: true; + virtualFolderId?: string; /** A group node: the file whose context-menu groups its menu shows (a solution's `.sln`). */ menuPath?: string; /** Library sources: no new / rename / move / delete. */ @@ -82,6 +85,8 @@ export interface TreeModel { byKey: Map; /** Any folder / file path present in the model → key of the node showing it. */ keyOfPath: Map; + /** Parent keys whose order is supplied by a project pane provider. */ + projectedDirectories?: ReadonlySet; } export type Listings = ReadonlyMap; diff --git a/src/features/project-tree/operations.ts b/src/features/project-tree/operations.ts index c32fc9e309..a38a7867a3 100644 --- a/src/features/project-tree/operations.ts +++ b/src/features/project-tree/operations.ts @@ -77,14 +77,14 @@ function fail(title: string, e: unknown) { // --------------------------------------------------------------------------- // Selection helpers -/** Selected nodes in tree order (placeholders excluded). */ +/** Selected nodes in tree order for the native selection actions. */ export function selectedNodes(): ProjectNode[] { const { selected } = get(); const model = currentModel(); const out: ProjectNode[] = []; for (const key of selected) { const n = model.byKey.get(key); - if (n && !n.placeholder) out.push(n); + if (n && !n.placeholder && !n.virtualFolder) out.push(n); } return out; } @@ -118,6 +118,7 @@ function isUnityAssetFolder(path: string): boolean { /** Folder that receives new / pasted items: the selected folder or the selected file's parent. */ export function targetFolder(node: ProjectNode | null = leadNode()): string | null { + if (node?.virtualFolder) return null; if (!node && get().lead?.startsWith(MEMBER_PREFIX)) return null; const { root } = get(); if (!root) return null; diff --git a/src/features/project-tree/projectViewPanes.test.ts b/src/features/project-tree/projectViewPanes.test.ts new file mode 100644 index 0000000000..1fa763554f --- /dev/null +++ b/src/features/project-tree/projectViewPanes.test.ts @@ -0,0 +1,173 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import * as panes from "@/workbench/projectViewPanes"; +import { MemoryFs, setProjectFsForTests } from "./fs"; +import * as store from "./store"; + +const root = "/p"; +const folder = "/p/src"; +const file = "/p/src/mod_A_1.go"; +const second = "/p/src/mod_A_2.go"; + +describe("plugin project view panes", () => { + const dispose: Array<() => void> = []; + + beforeEach(async () => { + localStorage.clear(); + setProjectFsForTests(new MemoryFs({ [file]: "first", [second]: "second" }, root), root); + store.initProjectTree(root, "Project"); + await store.loadDir(root); + await store.loadDir(folder); + }); + + afterEach(() => { + dispose + .splice(0) + .reverse() + .forEach((f) => f()); + store.setViewMode("project"); + store.initProjectTree(null); + setProjectFsForTests(null); + }); + + function show(modifyChildren: panes.ProjectViewPane["modifyChildren"]) { + const id = panes.projectViewPaneId("test.better-go-folder", "groups"); + dispose.push(store.startProjectViewPanes()); + dispose.push(panes.registerProjectViewPane({ id, title: "Better Go Folder", weight: 10, modifyChildren })); + store.setViewMode(id); + store.setExpanded(new Set([root, folder])); + return id; + } + + const group = (label = "A"): panes.ProjectViewProjectionNode[] => [ + { kind: "virtualFolder", id: "mod", label: "mod" }, + { kind: "virtualFolder", id: "A", label, parent: "mod" }, + { kind: "existingNode", id: file, parent: "A" }, + { kind: "existingNode", id: second, parent: "A" }, + ]; + + it("reparents native files under nested virtual folders and keeps the original view intact", async () => { + const id = show(async (parent) => (parent.path === folder ? group() : null)); + const native = store.currentModel().byKey.get(file)!; + await vi.waitFor(() => expect(store.currentModel().children.get(folder)?.[0]?.label).toBe("mod")); + const model = store.currentModel(); + const mod = model.children.get(folder)![0]!; + const a = model.children.get(mod.key)![0]!; + expect(a.virtualFolder).toBe(true); + expect(a.key).not.toContain("/p/src/A/"); + expect(model.children.get(a.key)?.[0]).toBe(native); + expect(model.keyOfPath.get(file)).toBe(native.key); + expect(store.useProjectTree.getState().mode).toBe(id); + + store.setViewMode("project"); + expect( + store + .currentModel() + .children.get(folder) + ?.map((entry) => entry.path), + ).toEqual([file, second]); + }); + + it("refreshes one directory and retains the virtual folder's expansion and selected original file", async () => { + let label = "A"; + const modify = vi.fn(async (parent) => + parent.path === folder ? group(label) : null, + ); + const id = show(modify); + await vi.waitFor(() => expect(store.currentModel().children.get(folder)?.[0]?.label).toBe("mod")); + const mod = store.currentModel().children.get(folder)![0]!; + const a = store.currentModel().children.get(mod.key)![0]!; + store.setExpanded(new Set([root, folder, mod.key, a.key])); + store.setSelection(new Set([file]), file); + modify.mockClear(); + label = "Package A"; + + expect(panes.refreshProjectView(id, folder)).toBe(true); + await vi.waitFor(() => expect(store.currentModel().byKey.get(a.key)?.label).toBe(label)); + expect(modify.mock.calls.map(([parent]) => parent.path)).toEqual([folder]); + expect(store.useProjectTree.getState().expanded.has(a.key)).toBe(true); + expect(store.useProjectTree.getState().selected).toEqual(new Set([file])); + }); + + it("opens virtual ancestors to reveal an original path in an explicitly selected custom pane", async () => { + const id = show(async (parent) => (parent.path === folder ? group() : null)); + store.setViewMode("project"); + expect(panes.selectInProjectView(id, file, false)).toBe(true); + await vi.waitFor(() => { + const mod = store.currentModel().children.get(folder)?.[0]; + const a = mod && store.currentModel().children.get(mod.key)?.[0]; + expect(a?.virtualFolder).toBe(true); + expect(store.useProjectTree.getState().expanded.has(a!.key)).toBe(true); + expect(store.useProjectTree.getState().expanded.has(mod!.key)).toBe(true); + }); + expect(panes.selectInProjectView("project", file, false)).toBe(true); + expect(store.useProjectTree.getState().mode).toBe("project"); + }); + + it("leaves the native list intact when the plugin returns a cycle or an unknown reference", async () => { + let answer: panes.ProjectViewProjectionNode[] = [ + { kind: "virtualFolder", id: "cycle", parent: "cycle", label: "cycle" }, + { kind: "existingNode", id: file, parent: "cycle" }, + ]; + const modify = vi.fn(async (parent) => + parent.path === folder ? answer : null, + ); + const id = show(modify); + await vi.waitFor(() => expect(modify.mock.calls.some(([p]) => p.path === folder)).toBe(true)); + expect( + store + .currentModel() + .children.get(folder) + ?.map((entry) => entry.path), + ).toEqual([file, second]); + answer = [{ kind: "existingNode", id: "/p/foreign.go" }]; + panes.refreshProjectView(id, folder); + await vi.waitFor(() => expect(modify.mock.calls.filter(([p]) => p.path === folder)).toHaveLength(2)); + expect( + store + .currentModel() + .children.get(folder) + ?.map((entry) => entry.path), + ).toEqual([file, second]); + }); + + it("discards a superseded answer when refreshing a directory during a provider request", async () => { + let finishOld!: (answer: panes.ProjectViewProjectionNode[]) => void; + const old = new Promise((resolve) => { + finishOld = resolve; + }); + let originalSignal: AbortSignal | undefined; + const id = show(async (parent, _children, _settings, signal) => { + if (parent.path !== folder) return null; + if (originalSignal) return group("Updated"); + originalSignal = signal; + return old; + }); + await vi.waitFor(() => expect(originalSignal).toBeDefined()); + expect(panes.refreshProjectView(id, folder)).toBe(true); + expect(originalSignal?.aborted).toBe(true); + const folderLabel = () => + [...store.currentModel().byKey.values()].find((node) => node.virtualFolderId === "A")?.label; + await vi.waitFor(() => expect(folderLabel()).toBe("Updated")); + finishOld(group("Outdated")); + await old; + await Promise.resolve(); + expect(folderLabel()).toBe("Updated"); + }); + + it("expands projected virtual descendants of a native directory within the action's limit", async () => { + show(async (parent) => (parent.path === folder ? group() : null)); + store.setExpanded(new Set([root])); + await store.expandAll(folder, 2); + const model = store.currentModel(); + const mod = model.children.get(folder)![0]!; + const a = model.children.get(mod.key)?.[0]; + expect(mod.virtualFolder).toBe(true); + expect(a?.virtualFolder).toBe(true); + expect(store.useProjectTree.getState().expanded.has(mod.key)).toBe(true); + expect(store.useProjectTree.getState().expanded.has(a!.key)).toBe(false); + + store.setSelection(new Set([folder]), folder); + await store.expandSelected(); + expect(store.useProjectTree.getState().expanded.has(a!.key)).toBe(true); + }); +}); diff --git a/src/features/project-tree/projectViewProjection.ts b/src/features/project-tree/projectViewProjection.ts new file mode 100644 index 0000000000..1d6ef284fa --- /dev/null +++ b/src/features/project-tree/projectViewProjection.ts @@ -0,0 +1,122 @@ +import type { ProjectViewNativeNode, ProjectViewPaneId, ProjectViewProjectionNode } from "@/workbench/projectViewPanes"; +import { GROUP_PREFIX, type ProjectNode, type TreeModel } from "./model"; + +export interface DirectoryProjection { + signature: string; + nodes: ProjectViewProjectionNode[] | null; +} + +const MAX_NODES = 4096; +const MAX_DEPTH = 32; + +const acceptsNativeNode = (node: ProjectNode) => !node.placeholder && !node.group && !node.readOnly && !node.member; + +const describe = (node: ProjectNode): ProjectViewNativeNode => ({ + id: node.key, + path: node.path, + label: node.label, + kind: node.dir ? "directory" : "file", +}); + +export function projectionInput(model: TreeModel, key: string) { + const folder = model.byKey.get(key); + if (!folder?.dir || !acceptsNativeNode(folder)) return null; + const children = model.children.get(key)?.filter(acceptsNativeNode).map(describe); + if (!children || children.length > MAX_NODES) return null; + const parent = describe(folder); + return { parent, children, signature: JSON.stringify([parent, children]) }; +} + +function projectDirectory( + mode: ProjectViewPaneId, + key: string, + native: ProjectNode[], + rows: ProjectViewProjectionNode[], +) { + if (!rows.length || rows.length > MAX_NODES) return null; + const originals = new Map(native.filter(acceptsNativeNode).map((n) => [n.key, n])); + const folders = new Map(); + const usedOriginals = new Set(); + for (const row of rows) { + if (row.kind === "existingNode") { + if (!originals.has(row.id) || usedOriginals.has(row.id)) return null; + usedOriginals.add(row.id); + } else if (row.kind === "virtualFolder") { + if (!row.id || !row.label || folders.has(row.id)) return null; + folders.set(row.id, row); + } else return null; + } + for (const row of rows) { + for (let parent = row.parent, depth = 0; parent != null; depth++) { + const folder = folders.get(parent); + if (!folder || depth >= MAX_DEPTH) return null; + parent = folder.parent; + } + } + + // Tuple encoding keeps virtual IDs disjoint even for several parents and plugin panes. + const virtualKey = (id: string) => GROUP_PREFIX + "plugin:" + JSON.stringify([mode, key, id]); + const children = new Map([[key, []]]); + const byKey = new Map(); + for (const entry of folders.values()) { + const id = virtualKey(entry.id); + children.set(id, []); + byKey.set(id, { + key: id, + path: id, + chain: [], + label: entry.label, + dir: true, + root: false, + entry: null, + ignored: false, + excluded: false, + symlink: false, + icon: entry.icon ?? undefined, + group: true, + readOnly: true, + virtualFolder: true, + virtualFolderId: entry.id, + }); + } + for (const row of rows) { + const node = row.kind === "existingNode" ? originals.get(row.id)! : byKey.get(virtualKey(row.id))!; + const parent = row.parent == null ? key : virtualKey(row.parent); + children.get(parent)!.push(node); + } + const top = children.get(key)!; + for (const node of native) if (!node.placeholder && !usedOriginals.has(node.key)) top.push(node); + top.unshift(...native.filter((n) => n.placeholder)); + return { children, byKey }; +} + +export function projectNativeTree( + model: TreeModel, + mode: ProjectViewPaneId, + projections: ReadonlyMap, +): TreeModel { + let result: TreeModel | undefined; + const projectedDirectories = new Set(); + for (const [key, projection] of projections) { + if (!projection.nodes || projectionInput(model, key)?.signature !== projection.signature) continue; + const projected = projectDirectory(mode, key, model.children.get(key)!, projection.nodes); + if (!projected) continue; + result ??= { ...model, children: new Map(model.children), byKey: new Map(model.byKey), projectedDirectories }; + for (const [parent, rows] of projected.children) { + result.children.set(parent, rows); + projectedDirectories.add(parent); + } + for (const [id, node] of projected.byKey) result.byKey.set(id, node); + } + return result ?? model; +} + +export function ancestorsInTree(model: TreeModel): (key: string) => string[] { + const parents = new Map(); + for (const [parent, children] of model.children) for (const child of children) parents.set(child.key, parent); + return (key) => { + const ancestors: string[] = []; + for (let parent = parents.get(key); parent !== undefined; parent = parents.get(parent)) ancestors.push(parent); + return ancestors; + }; +} diff --git a/src/features/project-tree/store.ts b/src/features/project-tree/store.ts index 83855c301f..a8495309ba 100644 --- a/src/features/project-tree/store.ts +++ b/src/features/project-tree/store.ts @@ -12,7 +12,14 @@ import { IpcError } from "@/platform/ipc"; import { isVirtualUri, libraryEntryPaths, sourceOriginEntryPaths } from "@/platform/virtualDocs"; import { isIgnoredName } from "@/platform/ignoredNames"; import { tx, txPart } from "@/platform/i18n"; -import { notifications } from "@/workbench/contributions"; +import { notifications, toolWindowService } from "@/workbench/contributions"; +import { + isPluginProjectViewPane, + provideProjectViewPaneService, + useProjectViewPanes, + type ProjectViewPane, + type ProjectViewPaneId, +} from "@/workbench/projectViewPanes"; import { editorPrefs } from "@/platform/editorSettings"; import { validateProjectStructure } from "@/platform/languageSettings"; import { useProject } from "@/platform/project"; @@ -35,6 +42,7 @@ import { dropListings, isDirEntry, mergeListing, + nodeKeyFor, planRefresh, visibleEntries, visibleInfo, @@ -46,6 +54,7 @@ import { type TreeOptions, } from "./model"; import { projectFs } from "./fs"; +import { ancestorsInTree, projectNativeTree, projectionInput, type DirectoryProjection } from "./projectViewProjection"; import { PROJECT_TYPES, type ProjectType } from "@/ui/projectType"; import { projectViewRoots, @@ -98,7 +107,7 @@ function storedOptions(): ViewOptions { } /** IDEA's Project view panes ("Project ▾" in the tool window header). */ -export type ViewMode = +type BuiltinViewMode = | "unity" | "unreal" | "project" @@ -108,7 +117,10 @@ export type ViewMode = | "scratches" | "scope"; -export const VIEW_MODES: ReadonlyArray<[ViewMode, string]> = [ +export type ViewMode = BuiltinViewMode | ProjectViewPaneId; +type CachedDirectoryProjection = DirectoryProjection & { options: ViewOptions }; + +export const VIEW_MODES: ReadonlyArray<[BuiltinViewMode, string]> = [ ["unity", "Unity"], ["unreal", "Unreal"], ["project", "Project"], @@ -152,10 +164,17 @@ interface ProjectTreeState { clipboard: Clipboard | null; /** A path to select (and scroll to) once its row is visible. */ /** `explain`: say which view option hides the path when only an ancestor can be selected. */ - revealRequest: { path: string; focus: boolean; seq: number; explain?: boolean } | null; + revealRequest: { + path: string; + focus: boolean; + seq: number; + explain?: boolean; + projectionPending?: "listings" | "providers"; + } | null; /** Folder key highlighted as drop target. */ dropTarget: string | null; mode: ViewMode; + projectViewProjections: ReadonlyMap; /** Files open in editor tabs (Open Files mode). */ openFiles: readonly string[]; /** Files with VCS changes (All Changed Files mode). */ @@ -171,6 +190,7 @@ interface ProjectTreeState { } const EMPTY_UNAVAILABLE: ReadonlySet = new Set(); +const EMPTY_PROJECTIONS: ProjectTreeState["projectViewProjections"] = new Map(); const OPTIONS_KEY = "openidea.projectTree.options"; const MODE_KEY = "openidea.projectTree.mode"; @@ -214,6 +234,7 @@ export const useProjectTree = create(() => ({ revealRequest: null, dropTarget: null, mode: readMode(), + projectViewProjections: EMPTY_PROJECTIONS, openFiles: [], changedFiles: [], scope: readJson(SCOPE_KEY), @@ -268,7 +289,7 @@ function treeOptions(s: ProjectTreeState): TreeOptions { return s.individualFolders.size ? { ...s.options, individualFolders: s.individualFolders } : s.options; } -export function selectModel(s: ProjectTreeState): TreeModel { +function selectNativeModel(s: ProjectTreeState): TreeModel { const files = filesOf(s); if ( memo && @@ -377,6 +398,26 @@ export function selectModel(s: ProjectTreeState): TreeModel { return model; } +let projectionMemo: + | { + native: TreeModel; + mode: ProjectViewPaneId; + projections: ProjectTreeState["projectViewProjections"]; + model: TreeModel; + } + | undefined; + +export function selectModel(s: ProjectTreeState): TreeModel { + const native = selectNativeModel(s); + const { mode, projectViewProjections: projections } = s; + if (!isPluginProjectViewPane(mode) || !projections.size) return native; + if (projectionMemo?.native === native && projectionMemo.mode === mode && projectionMemo.projections === projections) + return projectionMemo.model; + const model = projectNativeTree(native, mode, projections); + projectionMemo = { native, mode, projections, model }; + return model; +} + export const currentModel = () => selectModel(get()); // --------------------------------------------------------------------------- @@ -479,6 +520,7 @@ export function initProjectTree( unity, unreal, mode, + projectViewProjections: EMPTY_PROJECTIONS, root, name, members, @@ -539,18 +581,221 @@ export function setViewMode(mode: ViewMode) { const s = get(); if (mode === "unity" && !s.unity) return; if (mode === "unreal" && !s.unreal) return; + if (isPluginProjectViewPane(mode) && !useProjectViewPanes.getState().panes.has(mode)) return; if (s.mode === mode) return; cancelExpansion(); - modeExpanded.set(s.mode, s.expanded); + if (!isPluginProjectViewPane(s.mode) || useProjectViewPanes.getState().panes.has(s.mode)) + modeExpanded.set(s.mode, s.expanded); autoExpanded.clear(); - writeJson(MODE_KEY, mode); + if (!isPluginProjectViewPane(mode)) writeJson(MODE_KEY, mode); set({ mode, + projectViewProjections: EMPTY_PROJECTIONS, expanded: modeExpanded.get(mode) ?? initialExpanded(s.root, mode), selected: new Set(), lead: null, editing: null, dropTarget: null, + revealRequest: null, + }); +} + +/** Providers are queried only for loaded, expanded directories in the active plugin pane. */ +export function startProjectViewPanes(): () => void { + type Pending = { abort: AbortController; signature: string; options: ViewOptions }; + const pending = new Map(); + const invalidated = new Set(); + let pane: ProjectViewPane | undefined; + let projectGeneration = generation; + let scheduled = false; + let stopped = false; + + const abort = (key: string, request: Pending) => { + pending.delete(key); + request.abort.abort(); + }; + + const schedule = () => { + if (stopped || scheduled) return; + scheduled = true; + queueMicrotask(() => { + scheduled = false; + if (!stopped) sync(); + }); + }; + + function sync() { + const s = get(); + const { mode, root, options, expanded, projectViewProjections, revealRequest } = s; + const active = isPluginProjectViewPane(mode) ? useProjectViewPanes.getState().panes.get(mode) : undefined; + if (active !== pane || generation !== projectGeneration) { + for (const [key, request] of pending) abort(key, request); + invalidated.clear(); + pane = active; + projectGeneration = generation; + if (projectViewProjections.size) { + set({ projectViewProjections: EMPTY_PROJECTIONS }); + return; + } + } + if (!active && isPluginProjectViewPane(mode)) setViewMode("project"); + if (!active || !root) return; + const native = selectNativeModel(s); + const inputFor = (key: string) => projectPaneInput(native, s, key); + const upToDate = (key: string, signature: string) => { + const cached = projectViewProjections.get(key); + return cached?.signature === signature && cached.options === options && !invalidated.has(key); + }; + for (const [key, request] of pending) { + if (request.options !== options || inputFor(key)?.signature !== request.signature) abort(key, request); + } + + let revealAncestors: string[] = []; + if (revealRequest?.projectionPending === "providers") { + const nativeKey = nodeKeyFor(native, revealRequest.path); + if (nativeKey) revealAncestors = ancestorsInTree(native)(nativeKey); + const ready = revealAncestors.every((key) => { + const input = inputFor(key); + return !input || upToDate(key, input.signature); + }); + if (ready) { + const projected = selectModel(s); + const key = nodeKeyFor(projected, revealRequest.path); + const next = new Set(expanded); + if (key) for (const ancestor of ancestorsInTree(projected)(key)) next.add(ancestor); + set({ expanded: next, revealRequest: { ...revealRequest, projectionPending: undefined } }); + return; + } + } + + for (const key of new Set([...revealAncestors, ...invalidated, ...expanded])) { + if (pending.size >= 4) break; + const input = inputFor(key); + if (!input) { + invalidated.delete(key); + continue; + } + if (pending.has(key) || upToDate(key, input.signature)) continue; + const request = { abort: new AbortController(), signature: input.signature, options }; + const requestGeneration = projectGeneration; + pending.set(key, request); + // Providers may be reloaded or the project may close while their host call is queued. + const finish = (nodes: DirectoryProjection["nodes"]) => { + if (pending.get(key) !== request) return; + pending.delete(key); + const current = get(); + if ( + requestGeneration !== generation || + current.mode !== mode || + useProjectViewPanes.getState().panes.get(active.id) !== active || + current.options !== options || + projectPaneInput(selectNativeModel(current), current, key)?.signature !== input.signature + ) { + schedule(); + return; + } + invalidated.delete(key); + applyDirectoryProjection(current, key, { nodes, options, signature: input.signature }); + }; + void Promise.resolve() + .then(() => { + request.abort.signal.throwIfAborted(); + return active.modifyChildren(input.parent, input.children, { ...options }, request.abort.signal); + }) + .then(finish, () => finish(null)); + } + } + + const unprovide = provideProjectViewPaneService({ + refresh(viewId, directory) { + if (!isPluginProjectViewPane(viewId) || !useProjectViewPanes.getState().panes.has(viewId)) return false; + const s = get(); + if (s.mode !== viewId) return true; + const native = selectNativeModel(s); + const target = directory == null ? null : native.keyOfPath.get(ipcPath(directory)); + if (directory != null && (target == null || !native.byKey.get(target)?.dir)) return false; + for (const key of target == null ? new Set([...s.expanded, ...s.projectViewProjections.keys()]) : [target]) { + invalidated.add(key); + const request = pending.get(key); + if (request) abort(key, request); + } + schedule(); + return true; + }, + select(viewId, path, focus) { + if ( + viewId !== "project" && + (!isPluginProjectViewPane(viewId) || !useProjectViewPanes.getState().panes.has(viewId)) + ) + return false; + const target = ipcPath(path); + if (!canRevealInProjectTree(target) || !modeShows(target, viewId)) return false; + setViewMode(viewId); + try { + toolWindowService().show("project", focus); + } catch { + /* The tool window service is not installed in model tests. */ + } + return revealPath(target, focus, true); + }, + }); + const unsubscribeTree = useProjectTree.subscribe((s, previous) => { + if (isPluginProjectViewPane(s.mode) || isPluginProjectViewPane(previous.mode)) schedule(); + }); + const unsubscribePanes = useProjectViewPanes.subscribe(({ panes }, previous) => { + for (const id of previous.panes.keys()) if (!panes.has(id)) modeExpanded.delete(id); + schedule(); + }); + const unsubscribeRoots = useProjectViewRoots.subscribe(schedule); + schedule(); + return () => { + stopped = true; + unsubscribeTree(); + unsubscribePanes(); + unsubscribeRoots(); + unprovide(); + for (const [key, request] of pending) abort(key, request); + }; +} + +function projectPaneInput(model: TreeModel, s: ProjectTreeState, key: string) { + const folder = model.byKey.get(key); + return folder && s.root && [s.root, ...(s.members ?? [])].some((root) => isSameOrInside(folder.path, root)) + ? projectionInput(model, key) + : null; +} + +function applyDirectoryProjection(s: ProjectTreeState, key: string, answer: CachedDirectoryProjection) { + const projectViewProjections = new Map(s.projectViewProjections).set(key, answer); + if (!s.selected.size && ![...s.expanded].some(isGroupKey)) { + set({ projectViewProjections }); + return; + } + const previous = selectModel(s); + const model = selectModel({ ...s, projectViewProjections }); + if (model === previous) { + set({ projectViewProjections }); + return; + } + const visibleBefore = s.selected.size ? visibleInfo(previous, s.expanded).visible : null; + let ancestors: ReturnType | undefined; + let expanded: Set | undefined; + let selected: Set | undefined; + for (const id of s.expanded) + if (!model.byKey.has(id) && previous.byKey.get(id)?.virtualFolder) (expanded ??= new Set(s.expanded)).delete(id); + for (const id of s.selected) { + if (!model.byKey.has(id) && previous.byKey.get(id)?.virtualFolder) (selected ??= new Set(s.selected)).delete(id); + else if (model.byKey.has(id) && visibleBefore?.has(id)) { + ancestors ??= ancestorsInTree(model); + for (const ancestor of ancestors(id)) + if (!s.expanded.has(ancestor)) (expanded ??= new Set(s.expanded)).add(ancestor); + } + } + set({ + projectViewProjections, + expanded: expanded ?? s.expanded, + selected: selected ?? s.selected, + lead: selected && s.lead && !selected.has(s.lead) ? null : s.lead, }); } @@ -1192,8 +1437,21 @@ function revealTarget( changed = true; } if (changed) setExpanded(next); - set({ revealRequest: { path, focus, seq: ++revealSeq, ...(explain ? { explain } : {}) } }); - for (const a of folders) void loadDir(a); + const pluginPane = isPluginProjectViewPane(get().mode); + const request = { + path, + focus, + seq: ++revealSeq, + ...(explain ? { explain } : {}), + ...(pluginPane ? { projectionPending: "listings" as const } : {}), + }; + set({ revealRequest: request }); + if (pluginPane) { + void Promise.all(folders.map((a) => loadDir(a))).then(() => { + if (get().revealRequest?.seq === request.seq) + set({ revealRequest: { ...request, projectionPending: "providers" } }); + }); + } else for (const a of folders) void loadDir(a); return true; } @@ -1227,6 +1485,7 @@ const hiddenScratch = (path: string, { options, root }: ProjectTreeState) => export function modeShows(path: string, mode = get().mode): boolean { const state = get(); if (!state.root) return false; + if (isPluginProjectViewPane(mode)) return !hiddenScratch(path, state); switch (mode) { case "unity": return !!state.unity && unityPathVisible(path, treeOptions({ ...state, mode })) && !hiddenScratch(path, state); @@ -1330,6 +1589,7 @@ export async function expandAll(from?: string, limit = 400) { if (isFilteredMode(mode)) return setExpanded(new Set([...model.byKey.values()].filter((n) => n.dir).map((n) => n.key))); const queue = [from ?? model.roots[0]?.key ?? root]; + if (isPluginProjectViewPane(mode)) return expandProjectedFolders(queue, limit); const toExpand = new Set(get().expanded); let count = 0; const gen = generation; @@ -1366,6 +1626,7 @@ export function expandSelected(): Promise { const { visible } = visibleInfo(model, expanded); const roots = [...selected].filter((key) => visible.has(key) && isExpandableFolder(model.byKey.get(key))); if (!roots.length) return Promise.resolve(); + if (isPluginProjectViewPane(mode)) return expandProjectedFolders(roots); cancelExpansion(); if (isFilteredMode(mode)) { @@ -1428,7 +1689,75 @@ export function expandSelected(): Promise { }); } -function isExpandableFolder(node: ProjectNode | undefined): boolean { +/** Opens each directory before requesting its projected children, then follows the actual pane's tree. */ +async function expandProjectedFolders(roots: string[], limit = Number.MAX_SAFE_INTEGER) { + cancelExpansion(); + const controller = new AbortController(); + const { signal } = controller; + const expansion: Expansion = { paths: new Set(), opened: new Map(), cancel: () => controller.abort() }; + activeExpansion = expansion; + const queue = [...roots]; + const seen = new Set(queue); + try { + for (let cursor = 0; cursor < queue.length && cursor < limit && !signal.aborted; cursor++) { + const key = queue[cursor]!; + const node = currentModel().byKey.get(key); + if (!isExpandableFolder(node)) continue; + const expanded = new Set(get().expanded).add(key); + for (const path of node.chain) expanded.add(keyLike(key, path)); + if (!node.group) expansion.paths.add(node.path); + set({ expanded }); + if (!node.group) { + // oxlint-disable-next-line no-await-in-loop -- a compacted chain can lengthen as its listing loads + await loadProjectedFolder(key, node.path, expansion.paths, signal); + // oxlint-disable-next-line no-await-in-loop -- expanded children must come from the settled projection + await waitForDirectoryProjection(key, signal); + } + if (signal.aborted) break; + for (const child of currentModel().children.get(key) ?? []) { + if (isExpandableFolder(child) && !seen.has(child.key)) { + seen.add(child.key); + queue.push(child.key); + } + } + } + } finally { + if (activeExpansion === expansion) activeExpansion = undefined; + } +} + +async function loadProjectedFolder(key: string, path: string, paths: Set, signal: AbortSignal) { + while (!signal.aborted) { + paths.add(path); + // oxlint-disable-next-line no-await-in-loop -- the next effective path depends on this folder's listing + await loadDir(path); + const next = currentModel().byKey.get(key)?.path; + if (!next || next === path) return; + path = next; + } +} + +function waitForDirectoryProjection(key: string, signal: AbortSignal): Promise { + const ready = (s: ProjectTreeState) => { + const input = projectPaneInput(selectNativeModel(s), s, key); + const answer = s.projectViewProjections.get(key); + return !input || (answer?.signature === input.signature && answer.options === s.options); + }; + if (signal.aborted || ready(get())) return Promise.resolve(); + return new Promise((resolve) => { + const finish = () => { + unsubscribe(); + signal.removeEventListener("abort", finish); + resolve(); + }; + const unsubscribe = useProjectTree.subscribe((s) => { + if (ready(s)) finish(); + }); + signal.addEventListener("abort", finish, { once: true }); + }); +} + +function isExpandableFolder(node: ProjectNode | undefined): node is ProjectNode { return !!node?.dir && !node.placeholder && !node.ignored && !node.excluded && !node.symlink; } diff --git a/src/features/vcs/BranchWidget.module.css b/src/features/vcs/BranchWidget.module.css index 2046ed476d..851db72908 100644 --- a/src/features/vcs/BranchWidget.module.css +++ b/src/features/vcs/BranchWidget.module.css @@ -99,6 +99,10 @@ align-items: center; gap: var(--space-2); } +.disabledAction { + color: var(--fg-faint); + cursor: default; +} .rowIcon { flex: none; color: var(--fg-icon); diff --git a/src/features/vcs/BranchWidget.tsx b/src/features/vcs/BranchWidget.tsx index af49ae7388..e8ef90e8e2 100644 --- a/src/features/vcs/BranchWidget.tsx +++ b/src/features/vcs/BranchWidget.tsx @@ -4,7 +4,8 @@ import { useEffect, useLayoutEffect, useMemo, useRef, useState, type KeyboardEve import clsx from "clsx"; import { create } from "zustand"; import type { Branch } from "@/bindings"; -import { executeAction } from "@/platform/actions"; +import { executeAction, useActions } from "@/platform/actions"; +import { useContextKeys } from "@/platform/context"; import { call, commands } from "@/platform/ipc"; import { useProject } from "@/platform/project"; import { bindingsFor, normalizeBinding, registerKeyClaim, shortcutLabel, strokeOf } from "@/platform/keymap"; @@ -24,11 +25,13 @@ import { T, } from "@/ui"; import { useRowHeight } from "@/ui/density"; +import { isGitActionArgument, useGitBranchActions } from "@/workbench/gitActions"; import type { PopupAnchor } from "@/ui/Popup"; import { isSubmenuAim, type MenuPointer } from "@/ui/menuAim"; import { useActiveRepository, useWidgetBranch } from "./activeRepository"; import { buildBranchRows, + popupActionLabel, preferredBranchRow, scopedExpansion, withExpanded, @@ -38,6 +41,7 @@ import { import { branchPresentation, extensionPopupActions, useBranchWidgetExtensions } from "./branchWidgetExtensions"; import { branchMenu, commonBranchMenu, inRepo, tagMenu } from "./branchMenu"; import { recentBranches, configuredRemoteNames, toggleFavoriteBranch, useFavoriteBranchesOf } from "./branchOps"; +import { gitBranchPopupActions } from "./gitPluginActions"; import { inProgress, operationTitle, type InProgress } from "./operations"; import { branchRepositoryRoots, @@ -429,7 +433,23 @@ function BranchesPopup({ anchor, onClose }: { anchor: PopupAnchor; onClose: () = const multi = roots.length > 1; const worktreeFor = useBranchWorktrees(); const extensions = useBranchWidgetExtensions((s) => s.extensions); - const actions = useMemo(() => [...POPUP_ACTIONS, ...extensionPopupActions(extensions)], [extensions]); + const kinds = useVcs((s) => s.kinds); + const menu = useGitBranchActions((s) => s["git.branches.popup"]); + const registered = useActions((s) => s.actions); + const context = useContextKeys(); + const actions = useMemo( + () => [ + ...POPUP_ACTIONS, + ...extensionPopupActions(extensions), + ...gitBranchPopupActions( + roots.filter((root) => (kinds[root] ?? "git") === "git"), + menu, + registered, + context, + ), + ], + [extensions, roots, kinds, menu, registered, context], + ); // ⌥⌘N is also Inline (enabled while a popup is open over an editor): the search field handles it here. useEffect(() => registerKeyClaim((_e, stroke) => isNewBranchStroke(stroke)), []); const [initialSize] = useState(loadPopupSize); @@ -585,12 +605,13 @@ function BranchesPanel({ onClose, actions: baseActions, worktreeFor, root, fallb void executeAction(id, { repo: root }); return; } - void (root ? focusRepo(root) : Promise.resolve()).then(() => executeAction(id, arg)); + void (root && !isGitActionArgument(arg) ? focusRepo(root) : Promise.resolve()).then(() => executeAction(id, arg)); }; const activate = (i: number) => { const row = rows[i]; if (!row) return; if (row.type === "action") { + if (row.action.disabled) return; run(row.action.id, row.action.arg); } else if (row.type === "group") { if (!query.trim()) setOpen(row.key, !row.expanded); @@ -885,6 +906,7 @@ function MultiRepoPanel({ const row = rows[i]; if (!row) return; if (row.type === "action") { + if (row.action.disabled) return; onClose(); void executeAction(row.action.id, row.action.id === "vcs.newWorktree" ? { repo: current } : row.action.arg); } else if (row.type === "group") { @@ -1176,7 +1198,11 @@ function BranchRowView({ if (row.type === "action") { const keys = shortcutLabel(row.action.id); return ( - + {row.action.checked === false ? ( ) : ( @@ -1186,7 +1212,12 @@ function BranchRowView({ className={styles.rowIcon} /> )} - + {keys && {keys}} ); diff --git a/src/features/vcs/__tests__/branchWidget.test.tsx b/src/features/vcs/__tests__/branchWidget.test.tsx index 0d981082b9..ed933004d1 100644 --- a/src/features/vcs/__tests__/branchWidget.test.tsx +++ b/src/features/vcs/__tests__/branchWidget.test.tsx @@ -1,8 +1,10 @@ import { act, fireEvent, render, screen } from "@testing-library/react"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import type { BranchInfo } from "@/bindings"; +import { registerAction } from "@/platform/actions"; import { emitLocalIdeEvent } from "@/platform/ipc"; import { deferred } from "@/test/deferred"; +import { registerGitBranchAction } from "@/workbench/gitActions"; const ipc = vi.hoisted(() => ({ branchInfo: vi.fn() })); vi.mock("@/platform/ipc", async (original) => { @@ -26,7 +28,7 @@ vi.mock("@/workbench/contributions", async (original) => ({ })); import { iconMarkup } from "@/ui"; -import { BranchWidget } from "../BranchWidget"; +import { BranchesPopupHost, BranchWidget, useBranchesPopup } from "../BranchWidget"; import { showSyncCommitsForCurrent, useSyncCommits } from "../SyncCommitsPopup"; import { useVcs } from "../store"; @@ -77,10 +79,71 @@ beforeEach(() => { afterEach(() => { useVcs.setState(initial); + useBranchesPopup.setState({ open: false }); useSyncCommits.setState({ source: null }); editor.path = null; }); +it("opens a contributed popup command with the current Git repositories", async () => { + const svn = "/app/wc"; + useVcs.setState({ roots: [primary, service, svn], kinds: { [svn]: "subversion" } }); + const id = "plugin.fixtures.compare-release"; + const title = "Compare with Release Fixture"; + const run = vi.fn(); + const disposeContribution = registerGitBranchAction("git.branches.popup", { id, title }); + let disposeAction = () => {}; + try { + const { container } = render( + <> + + + , + ); + fireEvent.click(container.querySelector("[data-branches-widget]")!); + expect(screen.queryByText(title)).not.toBeInTheDocument(); + act(() => { + disposeAction = registerAction({ id, title, run }); + }); + fireEvent.click(await screen.findByText(title)); + await vi.waitFor(() => + expect(run).toHaveBeenCalledWith( + expect.objectContaining({ + arg: { gitAction: { repositories: [primary, service], branch: null } }, + }), + ), + ); + expect(useBranchesPopup.getState().open).toBe(false); + } finally { + disposeContribution(); + disposeAction(); + } +}); + +it("leaves an unavailable Git plugin command disabled without dismissing the popup", async () => { + const id = "plugin.fixtures.disabled"; + const title = "Unavailable Git Fixture"; + const run = vi.fn(); + const disposeAction = registerAction({ id, title, when: "false", run }); + const disposeContribution = registerGitBranchAction("git.branches.popup", { id, title }); + try { + const { container } = render( + <> + + + , + ); + fireEvent.click(container.querySelector("[data-branches-widget]")!); + const label = await screen.findByText(title); + expect(label.closest('[aria-disabled="true"]')).toBeInTheDocument(); + fireEvent.click(label); + expect(run).not.toHaveBeenCalled(); + expect(useBranchesPopup.getState().open).toBe(true); + } finally { + disposeContribution(); + disposeAction(); + } +}); + describe("Git toolbar repository", () => { it("uses the active file's counts and ranges even if both repositories share HEAD", async () => { editor.path = `${service}/diagram.png`; diff --git a/src/features/vcs/__tests__/branches.test.ts b/src/features/vcs/__tests__/branches.test.ts index 0f45047fa1..8c8ab15e71 100644 --- a/src/features/vcs/__tests__/branches.test.ts +++ b/src/features/vcs/__tests__/branches.test.ts @@ -6,6 +6,7 @@ import { buildBranchRows, buildBranchTree, buildMergedBranchTree, + buildRepositoryBranchTree, mergedRefTooltip, filterBranchTree, isFavoriteBranch, @@ -253,6 +254,41 @@ describe("buildBranchTree", () => { ...outline(n.children ?? [], depth + 1), ]); + const leaves = (nodes: readonly BranchTreeNode[]): BranchTreeNode[] => + nodes.flatMap((node) => (node.branch ? [node] : leaves(node.children ?? []))); + + const sharedName = "origin/release"; + const local = b(sharedName, { remote: false }); + const remote = b(sharedName); + + it("keeps distinct local and remote rows when their short names collide", () => { + const branches = [local, remote, b("origin/feature"), b("main")]; + expect(leaves(buildBranchTree(branches, null)).map((node) => [node.key, node.ref, node.branch?.remote])).toEqual([ + ["b:main", "main", false], + ["b:origin/release", sharedName, false], + ["b:origin/feature", "origin/feature", true], + ["b-remote:origin/release", sharedName, true], + ]); + + const grouped = buildRepositoryBranchTree([{ root: "/repo", name: "repo", branches, tags: [] }], () => null); + expect(leaves(grouped).map((node) => node.key)).toContain("/repo:b-remote:origin/release"); + }); + + it("distinguishes short-name collisions in the merged tree while keeping the repos of each ref", () => { + const tree = buildMergedBranchTree( + [ + { root: "/a", name: "a", branches: [local], tags: [] }, + { root: "/b", name: "b", branches: [remote], tags: [] }, + ], + null, + "/a", + ); + expect(leaves(tree).map((node) => [node.key, node.ref, node.repos])).toEqual([ + ["b:origin/release", sharedName, ["/a"]], + ["b-remote:origin/release", sharedName, ["/b"]], + ]); + }); + it("groups names into folders with favorites first", () => { const tree = buildBranchTree( [ diff --git a/src/features/vcs/__tests__/gitPluginActions.test.ts b/src/features/vcs/__tests__/gitPluginActions.test.ts new file mode 100644 index 0000000000..a68f20e307 --- /dev/null +++ b/src/features/vcs/__tests__/gitPluginActions.test.ts @@ -0,0 +1,146 @@ +import { afterEach, describe, expect, it, vi } from "vitest"; +import { clearMocks, mockWindows } from "@tauri-apps/api/mocks"; +import type { Branch } from "@/bindings"; +import { registerAction } from "@/platform/actions"; +import { clearContext, getContext, setContext } from "@/platform/context"; +import { resolveMenuItems } from "@/ui/Menu"; +import { + openRevisionComparison, + provideRevisionComparisonService, + registerGitBranchAction, +} from "@/workbench/gitActions"; +import { branchMenu, inRepo, mergedBranchMenu } from "../branchMenu"; +import { openGitRevisionComparison } from "../operations"; +import { useCompareTool } from "../compareTool"; +import { useVcs } from "../store"; +import { installVcsArgContext } from "../vcsArgContext"; + +const initial = useVcs.getState(); +const first = "/work/repo"; +const second = "/work/another"; +const svn = "/work/working-copy"; +const remote: Branch = { + name: "origin/topic/release", + remote: true, + current: false, + upstream: null, + ahead: 0, + behind: 0, + lastCommitMs: null, +}; +const title = "Compare Clicked Branch"; +const id = "plugin.example.compare"; + +afterEach(() => { + clearMocks(); + useVcs.setState(initial); +}); + +describe("Git plugin branch menus", () => { + it("captures the clicked remote ref and repository independently of the selected repository", async () => { + useVcs.setState({ roots: [first, second], repo: first }); + const run = vi.fn(); + const done = vi.fn(); + const offAction = registerAction({ id, title, run }); + const offMenu = registerGitBranchAction("git.branch.context", { id, title }); + try { + const items = inRepo(second, branchMenu(remote, "main", done, { repo: second })); + const item = items.find((i) => "label" in i && i.label === title); + expect(item).toMatchObject({ verbatim: true }); + resolveMenuItems(item ? [item] : [])[0]?.run?.(); + await vi.waitFor(() => expect(done).toHaveBeenCalledOnce()); + await vi.waitFor(() => + expect(run).toHaveBeenCalledWith( + expect.objectContaining({ + arg: { + gitAction: { + repositories: [second], + branch: { name: remote.name, fullRef: "refs/remotes/origin/topic/release", remote: true }, + }, + }, + }), + ), + ); + expect(useVcs.getState().repo).toBe(first); + } finally { + offMenu(); + offAction(); + } + }); + + it("passes a common local branch and only its Git roots, respecting the menu when expression", async () => { + useVcs.setState({ roots: [first, second, svn], repo: svn, kinds: { [svn]: "subversion" } }); + const previous = getContext().vcsKind; + setContext("vcsKind", "subversion"); + const offContext = installVcsArgContext(); + const run = vi.fn(); + const offAction = registerAction({ id, title, when: "vcsKind == git", run }); + const offHiddenAction = registerAction({ id: "plugin.example.hidden", title: "Hidden", run: vi.fn() }); + const offMenu = registerGitBranchAction("git.branch.context", { id, title: "Delete", when: "vcsKind == git" }); + const hidden = registerGitBranchAction("git.branch.context", { + id: "plugin.example.hidden", + title: "Hidden", + when: "false", + }); + try { + const branch = { name: "topic/release", remote: false, current: true, favorite: false, upstream: false }; + const local = { ...remote, name: branch.name, remote: false, current: true }; + const menu = mergedBranchMenu(local, branch, [first, second, svn], branch.name, [ + { repo: first, branch: local }, + { repo: second, branch: { ...local, name: "another-branch" } }, + ]); + const item = menu.find((i) => i.kind === "action" && i.action === id); + resolveMenuItems(item ? [item] : [])[0]?.run?.(); + await vi.waitFor(() => + expect(run).toHaveBeenCalledWith( + expect.objectContaining({ + ctx: expect.objectContaining({ vcsKind: "git" }), + arg: { + gitAction: { + repositories: [first, second], + branch: { name: branch.name, fullRef: "refs/heads/topic/release", remote: false }, + }, + }, + }), + ), + ); + expect(menu.some((i) => "label" in i && i.label === "Hidden")).toBe(false); + expect( + branchMenu(remote, "main", undefined, { repo: svn }).some((i) => i.kind === "action" && i.action === id), + ).toBe(false); + } finally { + hidden(); + offHiddenAction(); + offMenu(); + offAction(); + offContext(); + if (previous === undefined) clearContext("vcsKind"); + else setContext("vcsKind", previous); + } + }); +}); + +it("opens a Compare tool window tab for the named Git repository", () => { + useVcs.setState({ roots: [first, second, svn], repo: first, kinds: { [svn]: "subversion" } }); + mockWindows("main"); + const off = provideRevisionComparisonService(openGitRevisionComparison); + try { + const left = "a".repeat(40); + const right = "b".repeat(40); + openRevisionComparison({ repository: second, left, right, leftLabel: "Merge base" }); + const { tabs, activeId } = useCompareTool.getState(); + expect(tabs).toHaveLength(1); + expect(tabs[0]).toMatchObject({ + id: activeId, + repo: second, + from: { rev: left, label: "Merge base" }, + to: { rev: right, label: "bbbbbbbb" }, + }); + expect(() => openRevisionComparison({ repository: svn, left, right })).toThrow(); + expect(() => openRevisionComparison({ repository: "/unmapped", left, right })).toThrow(); + expect(useCompareTool.getState().tabs).toHaveLength(1); + } finally { + off(); + useCompareTool.getState().close(); + } +}); diff --git a/src/features/vcs/branchMenu.ts b/src/features/vcs/branchMenu.ts index cff911cfcb..362d658c8a 100644 --- a/src/features/vcs/branchMenu.ts +++ b/src/features/vcs/branchMenu.ts @@ -2,6 +2,7 @@ import type { Branch } from "@/bindings"; import { executeAction } from "@/platform/actions"; import { showContextMenu, useContextMenuStore, type MenuItem } from "@/ui"; +import { isGitActionArgument } from "@/workbench/gitActions"; import { isFavoriteBranch } from "./branches"; import { branchRef, @@ -25,6 +26,7 @@ import { type BranchUpdateTarget, } from "./branchOps"; import { branchRebaseProblem } from "./branchRebase"; +import { gitBranchContextActions } from "./gitPluginActions"; import type { CommonBranch } from "./repoBranches"; import { currentRepo, currentRepoRoot, focusRepo, useVcs, vcsKindOf } from "./store"; import { openWorktree } from "./openWorktree"; @@ -131,6 +133,7 @@ export function branchMenu( if (vcsKindOf(repo) !== "git") { return b.current ? [favoriteItem] : [{ label: "Switch", run: run(() => checkoutBranch(b)) }, favoriteItem]; } + const extensionItems = gitBranchContextActions(b, repo ? [repo] : [], done); const newWorktree = worktreeMenuItem(b, run); // Update Selected acts on every selected local branch, each in its own repository. const updating = !!useVcs.getState().remoteBusy; @@ -173,6 +176,7 @@ export function branchMenu( { label: "Rename…", run: run(() => renameBranch(b)) }, favoriteItem, history, + ...extensionItems, ]; } const items: MenuItem[] = [ @@ -235,7 +239,7 @@ export function branchMenu( ), }, ); - return items; + return [...items, ...extensionItems]; } /** Tag entries of the Branches popup. */ @@ -317,6 +321,7 @@ export function commonBranchMenu( ): MenuItem[] { // A Git branch: a working copy among the roots takes no part. const roots = all.filter((root) => vcsKindOf(root) === "git"); + const extensionItems = gitBranchContextActions(b, roots, done); const run = (fn: () => unknown) => () => { done(); void fn(); @@ -347,6 +352,7 @@ export function commonBranchMenu( pushBranchItem(b.name, run, roots), { kind: "separator" }, rename, + ...extensionItems, ]; const { heads } = useVcs.getState(); const selectedHeads = roots.map((root) => heads[root]); @@ -424,7 +430,7 @@ export function commonBranchMenu( run: run(() => deleteBranches(roots.map((repo) => ({ repo, branch: b })))), }, ); - return items; + return [...items, ...extensionItems]; } /** `items` acting on repository `root`: it is selected (with its branches loaded) before each entry runs. */ @@ -435,13 +441,15 @@ export function inRepo(root: string, items: MenuItem[]): MenuItem[] { }); return items.map((item): MenuItem => { if (item.kind === "separator" || item.kind === "header") return item; - if (item.kind === "action") + if (item.kind === "action") { + if (isGitActionArgument(item.arg)) return item; return { label: item.label ?? item.action, icon: item.icon ?? undefined, disabled: item.disabled, run: runInRepo(() => executeAction(item.action, item.arg)), }; + } const run = item.run; return { ...item, @@ -472,7 +480,8 @@ export function mergedBranchMenu( }; const several = new Set(selected.map((t) => t.branch?.name)).size > 1; const own = commonBranchMenu(common, roots, current, done, checkedOutInWorktree).filter( - (item) => !several || !("label" in item) || (item.label !== "Update" && item.label !== "Delete"), + (item) => + !several || item.kind === "action" || !("label" in item) || (item.label !== "Update" && item.label !== "Delete"), ); const selection: MenuItem[] = several ? [ diff --git a/src/features/vcs/branches.ts b/src/features/vcs/branches.ts index a33ff008ad..ece04e2a82 100644 --- a/src/features/vcs/branches.ts +++ b/src/features/vcs/branches.ts @@ -27,6 +27,8 @@ export interface PopupAction { id: string; label: string; icon?: string; + verbatim?: boolean; + disabled?: boolean; /** Action argument passed to `executeAction`. */ arg?: unknown; /** A separator goes between actions of different groups (Update / Commit / Push | New Branch / Checkout…). */ @@ -35,6 +37,8 @@ export interface PopupAction { checked?: boolean; } +export const popupActionLabel = (action: PopupAction): string => (action.verbatim ? action.label : tx(action.label)); + export type BranchGroup = "recent" | "local" | "remote"; export type BranchRow = @@ -178,8 +182,8 @@ export function actionRows( for (const a of actions) { // An action the root's version control system does not have (Push for Subversion). const registered = getAction(a.id); - if (registered && !isActionVisible(registered)) continue; - const m = match(tx(a.label)); + if (registered && !isActionVisible(registered, undefined, a.arg)) continue; + const m = match(popupActionLabel(a)); if (m === false) continue; if (separators && rows.length && a.group !== last) rows.push({ type: "section", key: `separator:action:${a.id}`, label: "" }); @@ -289,7 +293,7 @@ const GROUP_RANK: Record = { recent: 1, local: 2, remote: 3 export function preferredBranchRow(rows: readonly BranchRow[], query: string): number { return preferredMatch(rows, query, (r) => r.type === "action" - ? { rank: 0, name: tx(r.action.label) } + ? { rank: 0, name: popupActionLabel(r.action) } : r.type === "branch" ? { rank: GROUP_RANK[r.group], name: r.branch.name } : r.type === "tag" @@ -464,6 +468,8 @@ export function buildBranchTree( favorites: readonly string[] | null, tags: readonly string[] = [], ): BranchTreeNode[] { + const local = branches.filter((b) => !b.remote); + const localNames = new Set(local.map((b) => b.name)); const level = (list: { b: Branch; rest: string }[], keyPrefix: string): BranchTreeNode[] => { const folders = new Map(); const leaves: BranchTreeNode[] = []; @@ -473,8 +479,10 @@ export function buildBranchTree( const seg = item.rest.slice(0, i); folders.set(seg, [...(folders.get(seg) ?? []), { b: item.b, rest: item.rest.slice(i + 1) }]); } else { + // Short-name filters keep addressing the local row when the two refs share a name. + const prefix = item.b.remote && localNames.has(item.b.name) ? "b-remote" : "b"; leaves.push({ - key: `b:${item.b.name}`, + key: `${prefix}:${item.b.name}`, label: item.rest, kind: "branch", ref: item.b.name, @@ -495,7 +503,6 @@ export function buildBranchTree( const top = leaves.filter((n) => rank(n) < 2).sort((a, b) => rank(a) - rank(b) || byName(a, b)); return [...top, ...folderNodes, ...leaves.filter((n) => rank(n) === 2).sort(byName)]; }; - const local = branches.filter((b) => !b.remote); const byRemote = new Map(); for (const b of branches) { if (!b.remote || b.name.endsWith("/HEAD")) continue; diff --git a/src/features/vcs/gitPluginActions.ts b/src/features/vcs/gitPluginActions.ts new file mode 100644 index 0000000000..ed742adab3 --- /dev/null +++ b/src/features/vcs/gitPluginActions.ts @@ -0,0 +1,77 @@ +import type { Branch } from "@/bindings"; +import { isActionEnabled, isActionVisible, useActions, type Action } from "@/platform/actions"; +import { evaluateWhen, getContext, type ContextKeys } from "@/platform/context"; +import type { MenuItem } from "@/ui"; +import { + gitBranchActions, + type GitActionArgument, + type GitActionContext, + type GitBranchAction, +} from "@/workbench/gitActions"; +import { branchRef } from "./branchOps"; +import type { PopupAction } from "./branches"; + +const gitContext = { vcsKind: "git", vcsAnyGit: true } as const; + +function availableGitActions( + repositories: readonly string[], + branch: GitActionContext["branch"], + contributions: readonly GitBranchAction[], + actions: ReadonlyMap, + context: ContextKeys, +) { + if (!repositories.length) return []; + const arg: GitActionArgument = { gitAction: { repositories: [...repositories], branch } }; + const scoped = { ...context, ...gitContext }; + return contributions.flatMap(({ id, title, icon, when }) => { + const action = actions.get(id); + if (!action || !evaluateWhen(when ?? undefined, scoped) || !isActionVisible(action, scoped, arg)) return []; + return [ + { + id, + label: title ?? action.title, + icon: icon ?? action.icon, + arg, + verbatim: true, + disabled: !isActionEnabled(action, scoped, arg), + }, + ]; + }); +} + +export function gitBranchPopupActions( + repositories: readonly string[], + contributions: readonly GitBranchAction[], + actions: ReadonlyMap, + context: ContextKeys, +): PopupAction[] { + return availableGitActions(repositories, null, contributions, actions, context).map((action) => ({ + ...action, + group: "plugin-git", + })); +} + +export function gitBranchContextActions( + { name, remote }: Pick, + repositories: readonly string[], + done: () => void, +): MenuItem[] { + const actions = availableGitActions( + repositories, + { name, remote, fullRef: branchRef(name, remote) }, + gitBranchActions("git.branch.context"), + useActions.getState().actions, + getContext(), + ); + if (!actions.length) return []; + return [ + { kind: "separator" }, + ...actions.map(({ id, ...item }): MenuItem => ({ + kind: "action", + action: id, + ...item, + context: gitContext, + before: done, + })), + ]; +} diff --git a/src/features/vcs/index.ts b/src/features/vcs/index.ts index 296c50e040..a60c091934 100644 --- a/src/features/vcs/index.ts +++ b/src/features/vcs/index.ts @@ -21,6 +21,7 @@ import { registerTitleItem, registerToolWindow, } from "@/workbench/contributions"; +import { provideRevisionComparisonService } from "@/workbench/gitActions"; import { executeAction, getAction, isActionEnabled, registerActions } from "@/platform/actions"; import { lazyComponent } from "@/ui"; import { commitWindowFocused, registerVcsActions } from "./actions"; @@ -33,7 +34,13 @@ import { comparisonPaneIds, type BranchComparisonData, } from "./CompareBranches"; -import { controlLabel, controlOperation, inProgress, installOperationNoticeExpiry } from "./operations"; +import { + controlLabel, + controlOperation, + inProgress, + installOperationNoticeExpiry, + openGitRevisionComparison, +} from "./operations"; import { annotationsShown, blameSlot } from "./blame"; import { activateRevisionAnnotations } from "./annotateRevisionProvider"; import { inlineBlame } from "./inlineBlame"; @@ -221,6 +228,7 @@ function registerGitContributions(): () => void { trackCommitWindow(), registerVcsToolWindow(), installVcsArgContext(), + provideRevisionComparisonService(openGitRevisionComparison), registerEditorContribution({ id: "vcs.changeMarkers", order: 60, diff --git a/src/features/vcs/operations.tsx b/src/features/vcs/operations.tsx index f50300db53..0b50e1cebf 100644 --- a/src/features/vcs/operations.tsx +++ b/src/features/vcs/operations.tsx @@ -21,6 +21,7 @@ import { workflowSettings } from "@/platform/workflowSettings"; import { Button, Checkbox, Dialog, Icon, Input, Radio, Select, Spinner, T, Toolbar } from "@/ui"; import { useFilePresentation } from "@/ui/filePresentation"; import { notifications } from "@/workbench/contributions"; +import type { RevisionComparison } from "@/workbench/gitActions"; import { ask } from "@/workbench/messages"; import { diffInput, openVcsDiff, vcsDiffInFront, type DiffData, type DiffSide } from "./diffInput"; import { confirmDialog, openDialog, promptText } from "./dialogs"; @@ -53,6 +54,7 @@ import { repoOf, selectRepo, useVcs, + vcsKindOf, } from "./store"; import styles from "./common.module.css"; import resetStyles from "./ResetDialog.module.css"; @@ -1062,6 +1064,14 @@ export function showCompareRevisions(from: string, to: string, fromLabel = from, showComparison({ rev: from, label: fromLabel }, { rev: to, label: toLabel }, undefined, repo); } +/** A plugin's comparison of two commits (`views.open-revision-comparison`), opened like Compare Versions. */ +export function openGitRevisionComparison({ repository, left, right, leftLabel, rightLabel }: RevisionComparison) { + const repo = ipcPath(repository); + if (!useVcs.getState().roots.includes(repo) || vcsKindOf(repo) !== "git") + throw new Error(tx("Could not open comparison")); + showCompareRevisions(left, right, leftLabel ?? short(left), rightLabel ?? short(right), repo); +} + export function showPathComparison(paths: string[], rev: string, repositories: string[] | null) { showComparison({ rev, label: rev }, null, { paths, repositories }); } diff --git a/src/features/vcs/repoBranches.ts b/src/features/vcs/repoBranches.ts index 949e826a4a..fb00c6eb01 100644 --- a/src/features/vcs/repoBranches.ts +++ b/src/features/vcs/repoBranches.ts @@ -8,6 +8,7 @@ import { defaultFolderOpen, favoritesInAny, isFavoriteBranch, + popupActionLabel, preferredMatch, prefixTreeRows, recentLocal, @@ -402,7 +403,7 @@ export function preferredRepoRow(rows: readonly RepoRow[], query: string): numbe return preferredMatch(rows, query, (r) => { switch (r.type) { case "action": - return { rank: 0, name: tx(r.action.label) }; + return { rank: 0, name: popupActionLabel(r.action) }; case "repo": return { rank: 1, name: r.repo.name }; case "common": diff --git a/src/features/vcs/vcsArgContext.ts b/src/features/vcs/vcsArgContext.ts index 8ccb1594cc..d4dbfaee4b 100644 --- a/src/features/vcs/vcsArgContext.ts +++ b/src/features/vcs/vcsArgContext.ts @@ -5,6 +5,7 @@ */ import type { ContextKeys } from "@/platform/context"; import { registerArgContext } from "@/platform/actions"; +import { isGitActionArgument } from "@/workbench/gitActions"; import { rootOf } from "./model"; import { commitRepo } from "./multiRoot"; import { provideVcsScope } from "@/workbench/contributions"; @@ -15,6 +16,7 @@ function rootsOf(arg: unknown, roots: readonly string[]): (string | null)[] { if (Array.isArray(arg)) return arg.flatMap((item) => rootsOf(item, roots)); if (typeof arg === "string") return arg.startsWith("/") || /^[A-Za-z]:[\\/]/.test(arg) ? [rootOf(arg, roots)] : []; if (!arg || typeof arg !== "object") return []; + if (isGitActionArgument(arg)) return arg.gitAction.repositories.filter((repo) => roots.includes(repo)); const o = arg as Record; if ("summary" in o && "id" in o) { const repo = commitRepo(o as never); diff --git a/src/platform/locales/text/en.json b/src/platform/locales/text/en.json index a94c7f9b5a..b92ba18bb7 100644 --- a/src/platform/locales/text/en.json +++ b/src/platform/locales/text/en.json @@ -1235,6 +1235,8 @@ "PTY input limit exceeded": "PTY input limit exceeded", "Cannot start PTY: process:{program} capability not granted.": "Cannot start PTY: process:{program} capability not granted.", "Marker Icons": "Marker Icons", + "Project Views": "Project Views", + "Could not open comparison": "Could not open comparison", "Editor Panels": "Editor Panels", "Overlays": "Overlays", "Dialogs": "Dialogs", diff --git a/src/platform/locales/text/zh.json b/src/platform/locales/text/zh.json index c7cd65e9b4..e03516b494 100644 --- a/src/platform/locales/text/zh.json +++ b/src/platform/locales/text/zh.json @@ -1026,6 +1026,8 @@ "PTY input limit exceeded": "PTY 输入超出限制", "Cannot start PTY: process:{program} capability not granted.": "无法启动 PTY:未授予 process:{program} 权限。", "Marker Icons": "行标记图标", + "Project Views": "项目视图", + "Could not open comparison": "无法打开比较", "Editor Panels": "编辑器面板", "Overlays": "浮层", "Dialogs": "对话框", diff --git a/src/workbench/contributions.ts b/src/workbench/contributions.ts index f4918a1656..f5b4ddd3d6 100644 --- a/src/workbench/contributions.ts +++ b/src/workbench/contributions.ts @@ -81,7 +81,7 @@ export interface ToolWindowContribution { * returning the current view's label and the items the title opens instead * of `headerMenu`'s. */ - titleMenu?: (id: string) => { label: string; items: MenuItem[] }; + titleMenu?: (id: string) => { label: string; items: MenuItem[]; verbatim?: boolean }; /** Badge (e.g. problem count) shown on the stripe button. */ useBadge?: () => number | string | null; /** Only shown when a project is open (default true). */ @@ -1740,11 +1740,17 @@ export function registerMenuSlotItem(slot: string, item: MenuSlotItem): () => vo })); } +export interface ProjectViewMenuContext { + viewId: string; + nodes: { id: string; kind: "file" | "directory" | "virtualFolder"; path?: string }[]; +} + export interface MenuGroupContext { /** Files / directories the menu is for (absolute paths; a virtual URI for virtual documents). */ paths: string[]; /** Per path: whether it is a directory (project view). */ dirs?: boolean[]; + projectView?: ProjectViewMenuContext; /** New menu: the detected type of the project owning the target directory. */ projectType?: ProjectType; /** The document text, when the menu is for an open document. */ @@ -1764,6 +1770,8 @@ export interface MenuGroupContribution { menus: ContextMenuId[]; /** Lower first. */ order?: number; + /** Accepts project-view selections containing virtual folders without a filesystem target. */ + virtualProjectFolders?: boolean; /** Items for this menu (empty for none); called synchronously while the menu is built. */ items(menu: ContextMenuId, ctx: MenuGroupContext): MenuItem[]; /** Optional async preparation before the menu opens (e.g. reading the file), bounded by the caller. */ @@ -1779,16 +1787,17 @@ export function registerMenuGroup(group: MenuGroupContribution): () => void { }; } -function groupsFor(menu: ContextMenuId): MenuGroupContribution[] { +function groupsFor(menu: ContextMenuId, ctx: MenuGroupContext): MenuGroupContribution[] { + const virtualOnly = menu === "projectView" && !ctx.paths.length && !!ctx.projectView?.nodes.length; return [...menuGroups.values()] - .filter((g) => g.menus.includes(menu)) + .filter((g) => g.menus.includes(menu) && (!virtualOnly || g.virtualProjectFolders)) .sort((a, b) => (a.order ?? 0) - (b.order ?? 0) || a.id.localeCompare(b.id)); } /** Contributed items for `menu`, each non-empty group followed by a separator. */ export function menuGroupItems(menu: ContextMenuId, ctx: MenuGroupContext): MenuItem[] { const out: MenuItem[] = []; - for (const g of groupsFor(menu)) { + for (const g of groupsFor(menu, ctx)) { let items: MenuItem[] = []; try { items = g.items(menu, ctx); @@ -1999,7 +2008,7 @@ export function clearProjectViewLead() { /** Runs the groups' `prepare` hooks, giving up after `timeoutMs` so the menu never waits long. */ export async function prepareMenuGroups(menu: ContextMenuId, ctx: MenuGroupContext, timeoutMs = 200): Promise { - const pending = groupsFor(menu) + const pending = groupsFor(menu, ctx) .map((g) => g.prepare?.(menu, ctx).catch(() => undefined)) .filter((p): p is Promise => !!p); if (!pending.length) return; diff --git a/src/workbench/gitActions.ts b/src/workbench/gitActions.ts new file mode 100644 index 0000000000..2a6bc059ce --- /dev/null +++ b/src/workbench/gitActions.ts @@ -0,0 +1,71 @@ +import { create } from "zustand"; +import { tx } from "@/platform/i18n"; + +export type GitBranchActionPlace = "git.branches.popup" | "git.branch.context"; + +export interface GitActionContext { + repositories: string[]; + branch: { name: string; fullRef: string; remote: boolean } | null; +} + +export interface GitActionArgument { + gitAction: GitActionContext; +} + +export function isGitActionArgument(arg: unknown): arg is GitActionArgument { + const context = (arg as Partial | undefined | null)?.gitAction; + return ( + !!context && + Array.isArray(context.repositories) && + context.repositories.every((repo) => typeof repo === "string") && + (context.branch === null || + (typeof context.branch?.name === "string" && + typeof context.branch.fullRef === "string" && + typeof context.branch.remote === "boolean")) + ); +} + +export interface GitBranchAction { + id: string; + title?: string; + icon?: string; + when?: string | null; +} + +export const useGitBranchActions = create>(() => ({ + "git.branches.popup": [], + "git.branch.context": [], +})); + +export function gitBranchActions(place: GitBranchActionPlace): readonly GitBranchAction[] { + return useGitBranchActions.getState()[place]; +} + +export function registerGitBranchAction(place: GitBranchActionPlace, action: GitBranchAction): () => void { + useGitBranchActions.setState((s) => ({ [place]: [...s[place].filter((item) => item.id !== action.id), action] })); + return () => useGitBranchActions.setState((s) => ({ [place]: s[place].filter((item) => item !== action) })); +} + +export interface RevisionComparison { + repository: string; + left: string; + right: string; + leftLabel?: string | null; + rightLabel?: string | null; +} + +type RevisionComparisonService = (comparison: RevisionComparison) => void; +let comparisonService: RevisionComparisonService | undefined; + +export function provideRevisionComparisonService(open: RevisionComparisonService): () => void { + comparisonService = open; + return () => { + if (comparisonService === open) comparisonService = undefined; + }; +} + +/** Opens the IDE's comparison of two commits, as Compare Versions does. */ +export function openRevisionComparison(comparison: RevisionComparison): void { + if (!comparisonService) throw new Error(tx("Could not open comparison")); + comparisonService(comparison); +} diff --git a/src/workbench/projectViewPanes.ts b/src/workbench/projectViewPanes.ts new file mode 100644 index 0000000000..6e1baa2b8f --- /dev/null +++ b/src/workbench/projectViewPanes.ts @@ -0,0 +1,72 @@ +import { create } from "zustand"; + +export type ProjectViewPaneId = `plugin:${string}:${string}`; + +export const projectViewPaneId = (pluginId: string, viewId: string): ProjectViewPaneId => + `plugin:${pluginId}:${viewId}`; + +export interface ProjectViewNativeNode { + id: string; + path: string; + label: string; + kind: "file" | "directory"; +} + +export type ProjectViewProjectionNode = + | { kind: "existingNode"; id: string; parent?: string | null } + | { kind: "virtualFolder"; id: string; label: string; icon?: string | null; parent?: string | null }; + +export interface ProjectViewPane { + id: ProjectViewPaneId; + title: string; + weight: number; + modifyChildren( + parent: ProjectViewNativeNode, + children: ProjectViewNativeNode[], + settings: Readonly>, + signal: AbortSignal, + ): Promise; +} + +export const useProjectViewPanes = create<{ panes: ReadonlyMap }>(() => ({ + panes: new Map(), +})); + +export function registerProjectViewPane(pane: ProjectViewPane): () => void { + useProjectViewPanes.setState(({ panes }) => ({ panes: new Map(panes).set(pane.id, pane) })); + return () => + useProjectViewPanes.setState((state) => { + if (state.panes.get(pane.id) !== pane) return state; + const panes = new Map(state.panes); + panes.delete(pane.id); + return { panes }; + }); +} + +export const isPluginProjectViewPane = (id: string): id is ProjectViewPaneId => id.startsWith("plugin:"); + +export function projectViewPanes(panes = useProjectViewPanes.getState().panes): ProjectViewPane[] { + return [...panes.values()].sort((a, b) => a.weight - b.weight || a.id.localeCompare(b.id)); +} + +interface ProjectViewPaneService { + refresh(viewId: string, directory?: string | null): boolean; + select(viewId: string, path: string, focus: boolean): boolean; +} + +let paneService: ProjectViewPaneService | undefined; + +export function provideProjectViewPaneService(service: ProjectViewPaneService): () => void { + paneService = service; + return () => { + if (paneService === service) paneService = undefined; + }; +} + +export function refreshProjectView(viewId: string, directory?: string | null): boolean { + return paneService?.refresh(viewId, directory) ?? false; +} + +export function selectInProjectView(viewId: string, path: string, focus = true): boolean { + return paneService?.select(viewId, path, focus) ?? false; +} diff --git a/src/workbench/toolwindows/ToolWindows.tsx b/src/workbench/toolwindows/ToolWindows.tsx index 5616e8678d..357bc5a16e 100644 --- a/src/workbench/toolwindows/ToolWindows.tsx +++ b/src/workbench/toolwindows/ToolWindows.tsx @@ -603,7 +603,7 @@ function staticHeaderMenu(items: MenuItem[] | undefined): (id: string) => MenuIt return f; } -const noTitleMenu = (): { label: string; items: MenuItem[] } | null => null; +const noTitleMenu = () => null; /** The tool window around its content, for `ToolWindowHeader` and `useOwnToolWindowHeader`. */ const ToolWindowFrame = createContext<{ tw: ToolWindowContribution; setOwnHeader: (own: boolean) => void } | null>( @@ -754,7 +754,7 @@ function HeaderRow({ const titleMenu = useTitleMenu(tw.id); const titleItems = titleMenu?.items ?? (tw.plainTitle ? [] : own); const windowTitle = toolWindowTitle(tw); - const titleLabel = titleMenu ? tx(titleMenu.label) : windowTitle; + const titleLabel = titleMenu ? (titleMenu.verbatim ? titleMenu.label : tx(titleMenu.label)) : windowTitle; return (
, + } + variant projection-kind { + existing-node, + virtual-folder(folder-details), + } + record projection-node { + /// Existing nodes use an id from the input. A virtual folder uses a + /// stable plugin-chosen id scoped to this native parent. + id: string, + /// The virtual folder id to group under, or none for a direct child. + parent: option, + kind: projection-kind, + } +} + +interface project-view { + use types.{error}; + + /// Recompute the plugin's pane, or one project-relative or absolute + /// directory. Without an invoking window, invalidate the pane in every window. + refresh: func(view-id: string, directory: option) -> result<_, error>; + + /// Select a real file or directory in an owned pane or the built-in `project` + /// pane of the invoking window. `focus` defaults to true. + select-in: func(view-id: string, path: string, focus: option) -> result<_, error>; +} + +/// Optional export for `[[contributes.projectViewPanes]]`. It runs while the +/// plugin's pane is visible, on the project's native direct children. Return +/// none to leave those children unchanged. Order is preserved among siblings; +/// parent ids designate virtual folders in the same result. Omitted native +/// children stay in the pane in native order. Unknown ids, duplicate references +/// and invalid virtual trees discard the result. +interface project-view-provider { + use project-view-types.{native-node, projection-node}; + use invocation.{invocation}; + + /// `settings` is the current view options as a JSON object. + modify-children: func(view-id: string, parent: native-node, children: list, settings: string, ctx: borrow) -> option>; +} diff --git a/wit/views.wit b/wit/views.wit index 47a1d8e1ea..57e4126567 100644 --- a/wit/views.wit +++ b/wit/views.wit @@ -126,6 +126,15 @@ interface views { use detail-types.{process-log}; use process.{command}; + /// A repository-wide comparison of two full commit object IDs. + record revision-comparison { + repository: string, + left: string, + right: string, + left-label: option, + right-label: option, + } + /// An editor toolbar action; at most one action is the Save handler. record content-action { id: string, label: string, icon: option, primary: bool, save: bool } /// A plugin-owned content editor, scoped by key to the invoking window. @@ -171,6 +180,11 @@ interface views { /// and deleted files, instead of next to an empty text. Both sides none is /// `invalid`. open-file-diff: func(diff: file-diff, file-name: option) -> result<_, error>; + /// Opens the IDE's comparison of two commits (API 1.21): a tab of the Compare + /// tool window with the changed-file tree, as Compare Versions in the Git Log. + /// From a command or event of a trusted project window; requires `vcs.read`. + /// The repository must be a mapped Git root of the invoking project. + open-revision-comparison: func(comparison: revision-comparison) -> result<_, error>; /// The view (or every custom editor of that id) shows outdated content: /// the IDE renders it again. diff --git a/wit/workspace.wit b/wit/workspace.wit index 4018c87da8..04e9527de1 100644 --- a/wit/workspace.wit +++ b/wit/workspace.wit @@ -189,6 +189,9 @@ interface invocation { use workspace.{project}; use editor.{text-editor}; + record git-action-branch { name: string, full-ref: string, remote: bool } + record git-action-context { repositories: list, branch: option } + resource invocation { /// The window's project. project: func() -> option; @@ -199,6 +202,10 @@ interface invocation { /// Empty when it was not run on any, or when the menu was for a tab /// without a file (a virtual document). selected-paths: func() -> list; + /// Git branch-menu selection at invocation time (API 1.21). Requires + /// `vcs.read`. In the branches popup, `branch` is absent and `repositories` + /// contains the candidate Git roots. A branch row supplies its own roots. + git-action-context: func() -> option; } }