First-run chooser, node shutdown on switch, file picker, export path fix

- First-run: show Start Fresh / Import chooser only when single auto-created
  identity with no profile (not on every boot without a display name).
- Identity switch: shut down old node's endpoint before starting new one.
  Fixes lockup after multiple switches (zombie background tasks).
- File picker: native Browse buttons on export (folder) and import (ZIP file)
  via tauri-plugin-dialog.
- Export path: resolve relative paths against home dir (was using process cwd).
- Lightbox close: only close on overlay/image click, not inner form content.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Scott Reimers 2026-04-06 01:58:02 -04:00
parent a349d33422
commit ec731fdb4b
6 changed files with 171 additions and 15 deletions

View file

@ -257,11 +257,10 @@ impl IdentityManager {
anyhow::bail!("Identity {} not found", &target_hex[..12]);
}
// Shutdown current node if running
// Shutdown current node before switching
if let Some(ref node) = self.active_node {
info!(old = hex::encode(node.node_id), new = target_hex, "Switching identity");
// Node::shutdown would go here once implemented
// For now, dropping the Arc triggers cleanup when last reference is released
info!(old = hex::encode(node.node_id), new = target_hex, "Switching identity — shutting down old node");
node.network.shutdown_ref().await;
}
self.active_node = None;
self.active_id = None;

View file

@ -2335,6 +2335,14 @@ impl Network {
Ok(())
}
/// Shutdown via Arc reference — closes the endpoint, causing all background tasks to exit.
pub async fn shutdown_ref(&self) {
if let Some(ref mapping) = self.upnp_mapping {
crate::upnp::remove_upnp_mapping(mapping.external_addr.port()).await;
}
self.endpoint.close().await;
}
/// Propagate an engagement diff to all downstream holders of a post (CDN tree).
/// Excludes the sender to avoid loops.
pub async fn propagate_engagement_diff(