plugins: keep dev workspace plugins in watch mode

This commit is contained in:
Gregory Schier
2026-02-26 09:53:34 -08:00
parent 072b486857
commit e64404d7a5
3 changed files with 16 additions and 10 deletions

View File

@@ -39,13 +39,13 @@ impl CliContext {
let plugin_manager = if with_plugins {
let embedded_vendored_plugin_dir = data_dir.join("vendored-plugins");
let vendored_plugin_dir =
let bundled_plugin_dir =
resolve_bundled_plugin_dir_for_cli(&embedded_vendored_plugin_dir);
let installed_plugin_dir = data_dir.join("installed-plugins");
let node_bin_path = PathBuf::from("node");
if vendored_plugin_dir == embedded_vendored_plugin_dir {
prepare_embedded_vendored_plugins(&vendored_plugin_dir)
if bundled_plugin_dir == embedded_vendored_plugin_dir {
prepare_embedded_vendored_plugins(&embedded_vendored_plugin_dir)
.expect("Failed to prepare bundled plugins");
}
@@ -56,7 +56,8 @@ impl CliContext {
});
match PluginManager::new(
vendored_plugin_dir,
bundled_plugin_dir,
embedded_vendored_plugin_dir,
installed_plugin_dir,
node_bin_path,
plugin_runtime_main,

View File

@@ -240,14 +240,14 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
Builder::new("yaak-plugins")
.setup(|app_handle, _| {
// Resolve paths for plugin manager
let bundled_plugin_dir = app_handle
let vendored_plugin_dir = app_handle
.path()
.resolve("vendored/plugins", BaseDirectory::Resource)
.expect("failed to resolve plugin directory resource");
let vendored_plugin_dir = if is_dev() {
resolve_workspace_plugins_dir().unwrap_or(bundled_plugin_dir)
let bundled_plugin_dir = if is_dev() {
resolve_workspace_plugins_dir().unwrap_or_else(|| vendored_plugin_dir.clone())
} else {
bundled_plugin_dir
vendored_plugin_dir.clone()
};
let installed_plugin_dir = app_handle
@@ -279,6 +279,7 @@ pub fn init<R: Runtime>() -> TauriPlugin<R> {
let app_handle_clone = app_handle.clone();
tauri::async_runtime::block_on(async move {
let manager = PluginManager::new(
bundled_plugin_dir,
vendored_plugin_dir,
installed_plugin_dir,
node_bin_path,

View File

@@ -45,6 +45,7 @@ pub struct PluginManager {
kill_tx: tokio::sync::watch::Sender<bool>,
killed_rx: Arc<Mutex<Option<oneshot::Receiver<()>>>>,
ws_service: Arc<PluginRuntimeServerWebsocket>,
bundled_plugin_dir: PathBuf,
vendored_plugin_dir: PathBuf,
pub(crate) installed_plugin_dir: PathBuf,
}
@@ -56,6 +57,7 @@ impl PluginManager {
/// Create a new PluginManager with the given paths.
///
/// # Arguments
/// * `bundled_plugin_dir` - Directory to scan for bundled plugins
/// * `vendored_plugin_dir` - Path to vendored plugins directory
/// * `installed_plugin_dir` - Path to installed plugins directory
/// * `node_bin_path` - Path to the yaaknode binary
@@ -63,6 +65,7 @@ impl PluginManager {
/// * `query_manager` - Query manager for bundled plugin registration and loading
/// * `plugin_context` - Context to use while initializing plugins
pub async fn new(
bundled_plugin_dir: PathBuf,
vendored_plugin_dir: PathBuf,
installed_plugin_dir: PathBuf,
node_bin_path: PathBuf,
@@ -85,6 +88,7 @@ impl PluginManager {
ws_service: Arc::new(ws_service.clone()),
kill_tx: kill_server_tx,
killed_rx: Arc::new(Mutex::new(Some(killed_rx))),
bundled_plugin_dir,
vendored_plugin_dir,
installed_plugin_dir,
};
@@ -190,8 +194,8 @@ impl PluginManager {
/// Read plugin directories from disk and return their paths.
/// This is useful for discovering bundled plugins.
pub async fn list_bundled_plugin_dirs(&self) -> Result<Vec<String>> {
info!("Loading bundled plugins from {:?}", self.vendored_plugin_dir);
read_plugins_dir(&self.vendored_plugin_dir).await
info!("Loading bundled plugins from {:?}", self.bundled_plugin_dir);
read_plugins_dir(&self.bundled_plugin_dir).await
}
pub async fn uninstall(&self, plugin_context: &PluginContext, dir: &str) -> Result<()> {