Skip to content
Open
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
1 change: 1 addition & 0 deletions src-tauri/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub mod open_in;
#[cfg(feature = "tauri-runtime")]
pub mod notification;
pub mod pet;
pub mod preset_gallery;
pub mod project_boot;
pub mod question;
pub mod quick_messages;
Expand Down
56 changes: 56 additions & 0 deletions src-tauri/src/commands/preset_gallery.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
//! Tauri + Axum command surface for the appearance preset gallery.
//!
//! Thin double-mode wrappers over `crate::preset_gallery`, which owns the URL
//! policy, the byte caps and the digest check. Stateless (no DB / `AppState`),
//! like the `background_market_*` trio in `commands::background`.

use crate::app_error::AppCommandError;
use crate::preset_gallery::{self, GalleryDocument};

// ─── core ops ───────────────────────────────────────────────────────────

pub async fn preset_gallery_fetch_index_core(
url: String,
) -> Result<GalleryDocument, AppCommandError> {
preset_gallery::fetch_index(&url).await
}

pub async fn preset_gallery_fetch_preset_core(
url: String,
sha256: String,
) -> Result<GalleryDocument, AppCommandError> {
preset_gallery::fetch_preset(&url, &sha256).await
}

// ─── web-handler param structs ──────────────────────────────────────────

/// Web-mode JSON bodies for the `preset_gallery_*` commands. The Tauri commands
/// take flat scalars (auto snake_case-translated on the way in); the Axum
/// handlers need named structs to deserialize the same camelCase payload.
#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PresetGalleryIndexParams {
pub url: String,
}

#[derive(serde::Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PresetGalleryPresetParams {
pub url: String,
pub sha256: String,
}

// ─── tauri command wrappers ─────────────────────────────────────────────

#[cfg_attr(feature = "tauri-runtime", tauri::command)]
pub async fn preset_gallery_fetch_index(url: String) -> Result<GalleryDocument, AppCommandError> {
preset_gallery_fetch_index_core(url).await
}

#[cfg_attr(feature = "tauri-runtime", tauri::command)]
pub async fn preset_gallery_fetch_preset(
url: String,
sha256: String,
) -> Result<GalleryDocument, AppCommandError> {
preset_gallery_fetch_preset_core(url, sha256).await
}
6 changes: 5 additions & 1 deletion src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ pub mod pet_state_mapper;
pub mod pets;
#[cfg(feature = "tauri-runtime")]
pub mod preferences;
pub mod preset_gallery;
pub mod process;
pub mod supervise;
mod terminal;
Expand Down Expand Up @@ -71,7 +72,8 @@ mod tauri_app {
experts as experts_commands, feedback as feedback_commands, file_io, folder_commands,
folder_links, office_tools as office_tools_commands, open_in,
folders, logging as logging_commands, mcp as mcp_commands,
model_provider as model_provider_commands, notification, pet as pet_commands, project_boot,
model_provider as model_provider_commands, notification, pet as pet_commands,
preset_gallery as preset_gallery_commands, project_boot,
question as question_commands, quick_messages as quick_messages_commands,
remote_proxy as remote_proxy_commands,
remote_workspace as remote_workspace_commands, science as science_commands,
Expand Down Expand Up @@ -1366,6 +1368,8 @@ mod tauri_app {
background_commands::background_market_search,
background_commands::background_market_asset,
background_commands::background_market_download,
preset_gallery_commands::preset_gallery_fetch_index,
preset_gallery_commands::preset_gallery_fetch_preset,
app_update_commands::app_update_state,
app_update_commands::perform_app_update,
app_update_commands::restart_app,
Expand Down
Loading
Loading