Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
15 changes: 15 additions & 0 deletions desktop/src-tauri/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 desktop/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ buzz_sdk_pkg = { package = "buzz-sdk", path = "../../crates/buzz-sdk" }
buzz_agent_pkg = { package = "buzz-agent", path = "../../crates/buzz-agent" }
buzz_voice_pkg = { package = "buzz-voice", path = "../../crates/buzz-voice" }
buzz_terminal = { package = "buzz-terminal", path = "crates/buzz-terminal" }
buzz_ws_client_pkg = { package = "buzz-ws-client", path = "../../crates/buzz-ws-client" }
portable-pty = "0.9"
iroh = { version = "1.0.2", optional = true }
mesh-llm-sdk = { git = "https://github.com/Mesh-LLM/mesh-llm.git", tag = "v0.75.1", package = "mesh-llm-sdk", default-features = false, features = ["client", "serving"], optional = true }
Expand Down
44 changes: 35 additions & 9 deletions desktop/src-tauri/src/archive/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ mod metric_store;
mod pipeline;
pub mod store;
mod store_migrations;
pub mod sync;

use pipeline::{commit_archive, plan_archive, query_buckets};

Expand Down Expand Up @@ -150,8 +151,20 @@ pub async fn archive_events(
state: State<'_, AppState>,
candidates: Vec<ArchiveCandidate>,
) -> Result<ArchiveBatchResult, String> {
let identity_pk = identity_pubkey(&state)?;
let relay_url = relay_ws_url_with_override(&state);
archive_candidates(&state, candidates).await
}

/// The body of [`archive_events`], callable without a command invocation.
///
/// The native sync task archives through this directly: routing its batches
/// back out to the renderer just to have the renderer invoke the command would
/// reintroduce the IPC round trip the move exists to delete.
pub(crate) async fn archive_candidates(
state: &AppState,
candidates: Vec<ArchiveCandidate>,
) -> Result<ArchiveBatchResult, String> {
let identity_pk = identity_pubkey(state)?;
let relay_url = relay_ws_url_with_override(state);
let now = now_secs();

// ── Phase 1: plan (blocking SQLite) ─────────────────────────────────────
Expand All @@ -163,8 +176,7 @@ pub async fn archive_events(
.await?;

// ── Phase 2: relay queries (async) ───────────────────────────────────────
let state_ref: &AppState = &state;
let bucket_results = query_buckets(plan.buckets, state_ref).await;
let bucket_results = query_buckets(plan.buckets, state).await;

// ── Phase 3: persist (blocking SQLite) ──────────────────────────────────
let owner_keys = {
Expand Down Expand Up @@ -286,6 +298,7 @@ fn validate_ephemeral_frame(
#[tauri::command]
pub async fn create_save_subscription(
state: State<'_, AppState>,
sync_state: State<'_, sync::ArchiveSyncState>,
scope_type: ScopeType,
scope_value: String,
kinds: Vec<u32>,
Expand Down Expand Up @@ -333,7 +346,9 @@ pub async fn create_save_subscription(
&scope_value,
&kinds_json,
now,
)
)?;
sync_state.notify_subscriptions_changed().await;
Ok(())
}

/// Probe: the current user has access to `channel_id` (kind 39002 lists them).
Expand Down Expand Up @@ -426,6 +441,7 @@ async fn probe_event_readable(state: &AppState, event_id: &str) -> Result<(), St
#[tauri::command]
pub async fn merge_save_subscription_kinds(
state: State<'_, AppState>,
sync_state: State<'_, sync::ArchiveSyncState>,
kind: u32,
) -> Result<(), String> {
if kind > u32::from(u16::MAX) {
Expand All @@ -439,7 +455,9 @@ pub async fn merge_save_subscription_kinds(
run_archive_db_task(move |conn| {
store::merge_owner_p_kinds(conn, &identity_pk, &relay_url, &owner_pk, kind, now)
})
.await
.await?;
sync_state.notify_subscriptions_changed().await;
Ok(())
}

// ── remove_save_subscription_kind ────────────────────────────────────────────
Expand All @@ -459,6 +477,7 @@ pub async fn merge_save_subscription_kinds(
#[tauri::command]
pub async fn remove_save_subscription_kind(
state: State<'_, AppState>,
sync_state: State<'_, sync::ArchiveSyncState>,
kind: u32,
) -> Result<(), String> {
if kind > u32::from(u16::MAX) {
Expand All @@ -471,7 +490,9 @@ pub async fn remove_save_subscription_kind(
run_archive_db_task(move |conn| {
store::remove_owner_p_kind(conn, &identity_pk, &relay_url, &owner_pk, kind)
})
.await
.await?;
sync_state.notify_subscriptions_changed().await;
Ok(())
}

// ── list_save_subscriptions ──────────────────────────────────────────────────
Expand All @@ -496,12 +517,13 @@ pub async fn list_save_subscriptions(
#[tauri::command]
pub async fn delete_save_subscription(
state: State<'_, AppState>,
sync_state: State<'_, sync::ArchiveSyncState>,
scope_type: ScopeType,
scope_value: String,
) -> Result<bool, String> {
let identity_pk = identity_pubkey(&state)?;
let relay_url = relay_ws_url_with_override(&state);
run_archive_db_task(move |conn| {
let removed = run_archive_db_task(move |conn| {
store::delete_save_subscription(
conn,
&identity_pk,
Expand All @@ -510,7 +532,11 @@ pub async fn delete_save_subscription(
&scope_value,
)
})
.await
.await?;
if removed {
sync_state.notify_subscriptions_changed().await;
}
Ok(removed)
}

// ── read_archived_events ─────────────────────────────────────────────────────
Expand Down
Loading