Add completion, browser integration, and workspace improvements

This commit is contained in:
Knotty Wyvern
2026-10-07 11:25:17 -07:00
parent dd9fc64676
commit a8b1defb9d
86 changed files with 3524 additions and 203 deletions
+16 -2
View File
@@ -861,6 +861,13 @@ impl Service {
}
}
impl PluginState {
pub fn require_lease(&self, app: &AppHandle, owner: &str, id: &str) -> Result<()> {
self.with(app, |service| {
let enabled = service.catalog.plugins.get(id).is_some_and(|record| record.enabled && record.removal.is_none());
let leased = service.leases.get(id).is_some_and(|windows| windows.contains(owner));
if enabled && leased { Ok(()) } else { Err("The browser plugin is not enabled in this window.".into()) }
})
}
fn with<T>(
&self,
app: &AppHandle,
@@ -1019,6 +1026,7 @@ pub async fn plugins_set_enabled(
enabled: bool,
hash: Option<String>,
) -> Result<()> {
let stop_browser = id == "runestone.browser" && !enabled;
state.with(&app, |service| {
if service.removing.contains_key(&id) {
return Err("Wait for plugin removal to finish.".into());
@@ -1047,6 +1055,7 @@ pub async fn plugins_set_enabled(
}
Ok(())
})?;
if stop_browser { app.state::<crate::browser::BrowserState>().close_all(); }
changed(&app);
Ok(())
}
@@ -1183,7 +1192,8 @@ pub async fn plugins_data(
id: String,
value: Option<String>,
) -> Result<String> {
state.with(&app, |service| {
let changed = value.is_some();
let result = state.with(&app, |service| {
if !service.row(&id)?.enabled {
return Err("The plugin is disabled.".into());
}
@@ -1211,7 +1221,11 @@ pub async fn plugins_data(
} else {
Ok("null".into())
}
})
})?;
if changed {
let _ = app.emit("plugin-settings-changed", &id);
}
Ok(result)
}
#[tauri::command]
pub async fn plugins_asset(