Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
38a11eb
fix(plugins): share retained update discovery across plugin management
johnmatthewtennant Nov 16, 2026
1d1b43b
refactor(plugins): separate saved-folder reader repair from shared ch…
johnmatthewtennant Nov 16, 2026
94e30b9
refactor(plugins): reconcile automatic checks through the shared result
johnmatthewtennant Nov 16, 2026
9e927cc
test(plugins): wait for the sibling update action to become visible
johnmatthewtennant Nov 16, 2026
e15f63d
fix(plugins): order background results when source acquisition starts
johnmatthewtennant Nov 16, 2026
4f38e92
fix(plugins): read saved folder updates without scanning sibling pack…
johnmatthewtennant Nov 16, 2026
53794aa
fix(plugins): bound concurrent saved-folder update reads
johnmatthewtennant Nov 16, 2026
3486e40
test(plugins): change signed artifacts around update review
johnmatthewtennant Nov 16, 2026
7ba7b21
fix(plugins): validate retained results against discovery sources
johnmatthewtennant Nov 16, 2026
ca15e8f
fix(plugins): keep saved-folder update probes independent
johnmatthewtennant Nov 16, 2026
a6c2a46
fix(plugins): keep update check keyboard focus
johnmatthewtennant Nov 19, 2026
04322ed
docs(plugins): distinguish Git and saved-folder checks
johnmatthewtennant Nov 19, 2026
4a56091
fix(plugins): open saved folders without following symlinks
johnmatthewtennant Nov 19, 2026
85b959e
Cover saved-folder checks after a directory moves
johnmatthewtennant Nov 19, 2026
a37f718
Format saved plugin folder errors once
johnmatthewtennant Nov 19, 2026
f47aeca
test(plugins): dismiss update notices using the current toast stack
johnmatthewtennant Nov 23, 2026
08814a0
Keep disposed plugin checks out of the shared cache
johnmatthewtennant Nov 23, 2026
7f2aa3f
Wait for connectivity before retrying automatic Git checks
johnmatthewtennant Nov 23, 2026
2a01102
Keep manually chosen replacement previews in the dialog
johnmatthewtennant Nov 23, 2026
1c5701e
Use a typed exact-name query for the plugin update button
johnmatthewtennant Nov 23, 2026
e6f7cc5
fix(plugins): validate installations before observing Git updates
johnmatthewtennant Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/plugin-manager/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dirs = "6"
tempfile = "3"
url = "2"
cap-std = "4"
cap-fs-ext = "4"
reqwest = { version = "0.13", default-features = false, features = ["rustls", "blocking"] }
nostr = { version = "=0.45.5", default-features = false, features = ["std", "os-rng"] }
# Unused in code: its build metadata (`DEP_TAURI_DEV`) tells build.rs whether
Expand Down
302 changes: 250 additions & 52 deletions crates/plugin-manager/src/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::{
access::{AccessRules, Transport},
artifact_from_parts, err, hash, icon_revision,
managed::{canonical_path, valid_commit, valid_reference},
Catalog, GitSource, InstallSource, Manager, Manifest, Release, ReloadSource, Result, UrlSource,
BASE64, LIMIT, MAX_ICON_BYTES, MAX_README_BYTES,
prepare_reload_artifact, Catalog, GitSource, InstallSource, Manager, Manifest, Release,
ReloadSource, Result, UrlSource, BASE64, LIMIT, MAX_ICON_BYTES, MAX_README_BYTES,
};
use base64::Engine as _;
use nostr::event::Event;
Expand Down Expand Up @@ -279,63 +279,51 @@ pub fn prepare_upload(upload: FolderUpload) -> Result<PreparedImport> {

/// Resolve the installed source natively; callers cannot supply an arbitrary path.
pub fn prepare_saved_folder(manager: &Manager, id: &str) -> Result<PreparedImport> {
let plugin = manager
.catalog()?
.plugins
.into_iter()
.find(|plugin| plugin.manifest.id == id)
.ok_or("Plugin is not installed")?;
let Some(InstallSource::Folder(source)) = plugin.update_source else {
return Err("Plugin has no saved folder source".into());
};
let mut prepared = prepare_folder(&source.root)?;
if !prepared
.preview
.candidates
.iter()
.any(|candidate| candidate.path == source.path && candidate.manifest.id == id)
{
let prefix = if source.path == "." {
"Selected folder"
} else {
&source.path
};
return Err(prepared
.preview
.warnings
.iter()
.find(|warning| warning.starts_with(&format!("{prefix}:")))
.cloned()
.unwrap_or_else(|| {
"The saved folder no longer contains this plugin at its installed path.".into()
}));
}
prepared
.preview
.candidates
.retain(|candidate| candidate.path == source.path && candidate.manifest.id == id);
prepared.artifacts.retain(|path, _| path == &source.path);
let (source, release) = read_saved_folder(manager, id)?;
let mut prepared =
PreparedImport::new(source.root.display().to_string(), None, Some(source.root))?;
prepared.add(source.path, Ok(release))?;
Ok(prepared)
}

/// No preview is retained, installed, or published to the native import slot.
#[derive(Debug, Serialize)]
pub struct UpdateCheck {
pub revision: String,
pub publisher: Option<String>,
}

/// No preview is retained, installed, or published to the native import slot.
pub fn check_saved_folder(manager: &Manager, id: &str) -> Result<UpdateCheck> {
let prepared = prepare_saved_folder(manager, id)?;
prepared
.preview
.candidates
.first()
.map(|candidate| UpdateCheck {
revision: candidate.revision.clone(),
publisher: candidate.publisher.clone(),
})
.ok_or_else(|| "Saved source has no candidate".into())
let (_, release) = read_saved_folder(manager, id)?;
Ok(UpdateCheck {
revision: hash(&release.bytes),
publisher: release.publisher(),
})
}

fn read_saved_folder(manager: &Manager, id: &str) -> Result<(ReloadSource, Release)> {
let plugin = manager
.catalog()?
.plugins
.into_iter()
.find(|plugin| plugin.manifest.id == id)
.ok_or("Plugin is not installed")?;
let source = plugin
.update_source
.ok_or("Plugin has no saved folder source")?;
let InstallSource::Folder(folder) = &source else {
return Err("Plugin has no saved folder source".into());
};
let release = prepare_reload_artifact(&source)?;
let manifest = release
.validate()
.map_err(|reason| folder.read_error(reason))?;
if manifest.id != id {
return Err(folder.read_error(
"The saved folder no longer contains this plugin at its installed path.".into(),
));
}
Ok((folder.clone(), release))
}

pub fn prepare_folder(directory: &Path) -> Result<PreparedImport> {
Expand Down Expand Up @@ -2574,15 +2562,225 @@ mod tests {
assert!(bound
.install(&manager, &bound.preview.token, "other")
.is_err());
fs::remove_file(source.join("plugin.signature.json")).unwrap();
let expected = "dist: Incomplete signed plugin release pair";
assert_eq!(
check_saved_folder(&manager, "example.checked").unwrap_err(),
expected
);
assert_eq!(
prepare_saved_folder(&manager, "example.checked")
.err()
.unwrap(),
expected
);
assert_eq!(
manager.reload_live("example.checked").err().unwrap(),
expected
);

fs::remove_file(source.join("plugin.js")).unwrap();
for name in ["plugin.artifact.json", "plugin.signature.json"] {
fs::remove_file(source.join(name)).unwrap();
}
fs::remove_file(source.join("plugin.artifact.json")).unwrap();
let error = check_saved_folder(&manager, "example.checked").unwrap_err();
assert!(error.contains("dist:"), "{error}");
assert!(error.contains("plugin.js"), "{error}");
}

#[test]
fn saved_folder_checks_ignore_sibling_discovery_limits() {
let root = tempfile::tempdir().unwrap();
plugin(root.path(), "dist", "example.checked");
let home = tempfile::tempdir().unwrap();
let manager = Manager::open(Some(home.path().into()), "test", false).unwrap();
let pending = prepare_folder(root.path()).unwrap();
let installed = pending
.install(&manager, &pending.preview.token, "dist")
.unwrap();
let original = installed
.plugins
.iter()
.find(|p| p.manifest.id == "example.checked")
.unwrap()
.revision
.clone();
for index in 0..MAX_PLUGINS {
plugin(
root.path(),
&format!("sibling-{index}"),
&format!("example.sibling{index}"),
);
}
assert!(prepare_folder(root.path()).is_err());
assert_eq!(
check_saved_folder(&manager, "example.checked")
.unwrap()
.revision,
original
);
}

#[cfg(unix)]
#[test]
fn saved_folder_updates_require_the_original_directory() {
let root = tempfile::tempdir().unwrap();
let source = plugin(root.path(), "dist", "example.checked");
let home = tempfile::tempdir().unwrap();
let manager = Manager::open(Some(home.path().into()), "test", false).unwrap();
let pending = prepare_folder(root.path()).unwrap();
pending
.install(&manager, &pending.preview.token, "dist")
.unwrap();
assert!(check_saved_folder(&manager, "example.checked").is_ok());

let moved = root.path().join("moved");
fs::rename(&source, &moved).unwrap();
std::os::unix::fs::symlink(&moved, &source).unwrap();

assert!(check_saved_folder(&manager, "example.checked").is_err());
assert!(prepare_saved_folder(&manager, "example.checked").is_err());
}

#[test]
fn saved_folder_update_preview_ignores_siblings_and_installs_captured_bytes() {
let root = tempfile::tempdir().unwrap();
let source = plugin(root.path(), "dist", "example.checked");
let home = tempfile::tempdir().unwrap();
let manager = Manager::open(Some(home.path().into()), "test", false).unwrap();
let initial = prepare_folder(root.path()).unwrap();
initial
.install(&manager, &initial.preview.token, "dist")
.unwrap();
for index in 0..MAX_PLUGINS {
plugin(
root.path(),
&format!("sibling-{index}"),
&format!("example.sibling{index}"),
);
}
fs::write(
source.join("plugin.js"),
"export function activate() { /* changed */ }",
)
.unwrap();
sign(&source);
let revision = check_saved_folder(&manager, "example.checked")
.unwrap()
.revision;
let preview = prepare_saved_folder(&manager, "example.checked").unwrap();
assert_eq!(preview.preview.candidates.len(), 1);
assert_eq!(preview.preview.candidates[0].path, "dist");
assert_eq!(preview.preview.candidates[0].revision, revision);
fs::write(
source.join("plugin.js"),
"export function activate() { /* later */ }",
)
.unwrap();
sign(&source);
assert_ne!(
check_saved_folder(&manager, "example.checked")
.unwrap()
.revision,
revision
);
let installed = preview
.install(&manager, &preview.preview.token, "dist")
.unwrap();
let plugin = installed
.plugins
.iter()
.find(|p| p.manifest.id == "example.checked")
.unwrap();
assert_eq!(plugin.revision, revision);
let Some(InstallSource::Folder(saved)) = &plugin.update_source else {
panic!("saved folder missing")
};
assert_eq!(saved.path, "dist");
assert_eq!(saved.root, root.path().canonicalize().unwrap());
}

#[test]
fn saved_folder_check_reports_signature_only_repair_without_scanning_siblings() {
let root = tempfile::tempdir().unwrap();
let source = plugin(root.path(), "dist", "example.checked");
let home = tempfile::tempdir().unwrap();
let manager = Manager::open(Some(home.path().into()), "test", false).unwrap();
let pending = prepare_folder(root.path()).unwrap();
pending
.install(&manager, &pending.preview.token, "dist")
.unwrap();
// A legacy install may lack metadata even when its source is now signed.
let mut registry = manager.read().unwrap();
registry
.installed
.get_mut("example.checked")
.unwrap()
.current_signature = None;
manager.save(&registry).unwrap();
let installed = manager.catalog().unwrap();
let unsigned = installed
.plugins
.iter()
.find(|p| p.manifest.id == "example.checked")
.unwrap();
assert!(unsigned.publisher.is_none());
let publisher = crate::sign_release(&source, TEST_SIGNING_KEY).unwrap();
for index in 0..MAX_PLUGINS {
plugin(
root.path(),
&format!("sibling-{index}"),
&format!("example.sibling{index}"),
);
}
let checked = check_saved_folder(&manager, "example.checked").unwrap();
assert_eq!(checked.revision, unsigned.revision);
assert_eq!(checked.publisher.as_deref(), Some(publisher.as_str()));
let captured = prepare_saved_folder(&manager, "example.checked").unwrap();
assert_eq!(captured.preview.candidates[0].publisher, checked.publisher);
assert!(manager
.catalog()
.unwrap()
.plugins
.iter()
.find(|p| p.manifest.id == "example.checked")
.unwrap()
.publisher
.is_none());
fs::write(source.join("plugin.signature.json"), "{}").unwrap();
assert!(check_saved_folder(&manager, "example.checked").is_err());
}

#[test]
fn saved_folder_checks_confine_replaced_paths_and_validate_package_identity() {
let root = tempfile::tempdir().unwrap();
let source = plugin(root.path(), "dist", "example.checked");
let home = tempfile::tempdir().unwrap();
let manager = Manager::open(Some(home.path().into()), "test", false).unwrap();
let pending = prepare_folder(root.path()).unwrap();
pending
.install(&manager, &pending.preview.token, "dist")
.unwrap();
#[cfg(unix)]
{
let outside = tempfile::tempdir().unwrap();
let escaped = plugin(outside.path(), "dist", "example.checked");
fs::remove_dir_all(&source).unwrap();
std::os::unix::fs::symlink(&escaped, &source).unwrap();
assert!(check_saved_folder(&manager, "example.checked").is_err());
assert!(prepare_saved_folder(&manager, "example.checked").is_err());
fs::remove_file(&source).unwrap();
}
plugin(root.path(), "dist", "example.changed");
assert!(check_saved_folder(&manager, "example.checked").is_err());
assert!(prepare_saved_folder(&manager, "example.checked").is_err());
// A signature is verified even during discovery, before owner review.
plugin(root.path(), "dist", "example.checked");
let key = nostr::key::SecretKey::generate().to_secret_hex();
crate::sign_release(&source, &key).unwrap();
fs::write(source.join("plugin.signature.json"), "{}").unwrap();
assert!(check_saved_folder(&manager, "example.checked").is_err());
assert!(prepare_saved_folder(&manager, "example.checked").is_err());
}

#[test]
fn signed_folder_import_load_reload_and_publisher_continuity() {
let root = tempfile::tempdir().unwrap();
Expand Down
Loading
Loading