Completes the commands/ module split: GitHub commands now live in github.rs (88 lines) instead of bloating git.rs (318→233). Vault and frontmatter tests moved from mod.rs to vault.rs where they belong (mod.rs 254→93 lines, CodeScene 9.24→9.84). Deduplicated batch_archive/trash test setup with a shared temp_note helper. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
105 lines
3.2 KiB
Rust
105 lines
3.2 KiB
Rust
#[cfg(desktop)]
|
|
use crate::menu;
|
|
use crate::settings::Settings;
|
|
use crate::vault_list;
|
|
use crate::vault_list::VaultList;
|
|
|
|
use super::parse_build_label;
|
|
|
|
// ── MCP commands (desktop) ──────────────────────────────────────────────────
|
|
|
|
#[cfg(desktop)]
|
|
#[tauri::command]
|
|
pub async fn register_mcp_tools(vault_path: String) -> Result<String, String> {
|
|
let vault_path = super::expand_tilde(&vault_path).into_owned();
|
|
tokio::task::spawn_blocking(move || crate::mcp::register_mcp(&vault_path))
|
|
.await
|
|
.map_err(|e| format!("Registration task failed: {e}"))?
|
|
}
|
|
|
|
#[cfg(desktop)]
|
|
#[tauri::command]
|
|
pub async fn check_mcp_status() -> Result<crate::mcp::McpStatus, String> {
|
|
tokio::task::spawn_blocking(crate::mcp::check_mcp_status)
|
|
.await
|
|
.map_err(|e| format!("MCP status check failed: {e}"))
|
|
}
|
|
|
|
// ── MCP commands (mobile stubs) ─────────────────────────────────────────────
|
|
|
|
#[cfg(mobile)]
|
|
#[tauri::command]
|
|
pub async fn register_mcp_tools(_vault_path: String) -> Result<String, String> {
|
|
Err("MCP is not available on mobile".into())
|
|
}
|
|
|
|
#[cfg(mobile)]
|
|
#[tauri::command]
|
|
pub async fn check_mcp_status() -> Result<crate::mcp::McpStatus, String> {
|
|
Ok(crate::mcp::McpStatus::NotInstalled)
|
|
}
|
|
|
|
// ── Menu commands ───────────────────────────────────────────────────────────
|
|
|
|
#[cfg(desktop)]
|
|
#[tauri::command]
|
|
pub fn update_menu_state(
|
|
app_handle: tauri::AppHandle,
|
|
has_active_note: bool,
|
|
has_modified_files: Option<bool>,
|
|
has_conflicts: Option<bool>,
|
|
) -> Result<(), String> {
|
|
menu::set_note_items_enabled(&app_handle, has_active_note);
|
|
if let Some(v) = has_modified_files {
|
|
menu::set_git_commit_items_enabled(&app_handle, v);
|
|
}
|
|
if let Some(v) = has_conflicts {
|
|
menu::set_git_conflict_items_enabled(&app_handle, v);
|
|
}
|
|
Ok(())
|
|
}
|
|
|
|
#[cfg(mobile)]
|
|
#[tauri::command]
|
|
pub fn update_menu_state(
|
|
_app_handle: tauri::AppHandle,
|
|
_has_active_note: bool,
|
|
_has_modified_files: Option<bool>,
|
|
_has_conflicts: Option<bool>,
|
|
) -> Result<(), String> {
|
|
Ok(())
|
|
}
|
|
|
|
// ── Settings & config commands ──────────────────────────────────────────────
|
|
|
|
#[tauri::command]
|
|
pub fn get_build_number(app_handle: tauri::AppHandle) -> String {
|
|
let version = app_handle.package_info().version.to_string();
|
|
parse_build_label(&version)
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub fn get_settings() -> Result<Settings, String> {
|
|
crate::settings::get_settings()
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub fn save_settings(settings: Settings) -> Result<(), String> {
|
|
crate::settings::save_settings(settings)
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub fn reinit_telemetry() {
|
|
crate::telemetry::reinit_sentry();
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub fn load_vault_list() -> Result<VaultList, String> {
|
|
vault_list::load_vault_list()
|
|
}
|
|
|
|
#[tauri::command]
|
|
pub fn save_vault_list(list: VaultList) -> Result<(), String> {
|
|
vault_list::save_vault_list(&list)
|
|
}
|