Skip to content

A cross-platform desktop All-in-One assistant for Claude Code, Codex, OpenCode,DeepSeek Harness and more. Only official website: ccswitch.io

1.6 KB
Raw Blame
use crate::app_config::AppType;
use crate::error::AppError;
use tauri::State;

use crate::services::omo::{OmoLocalFileData, SLIM, STANDARD};
use crate::services::OmoService;
use crate::store::AppState;

#[tauri::command]
pub async fn read_omo_local_file() -> Result<OmoLocalFileData, AppError> {
    OmoService::read_local_file(&STANDARD)
}

#[tauri::command]
pub async fn get_current_omo_provider_id(state: State<'_, AppState>) -> Result<String, String> {
    let provider = state
        .db
        .get_current_omo_provider(&AppType::OpenCode, "omo")?;
    Ok(provider.map(|p| p.id).unwrap_or_default())
}

#[tauri::command]
pub async fn disable_current_omo(
    app: tauri::AppHandle,
    state: State<'_, AppState>,
) -> Result<(), String> {
    OmoService::disable_current(&state, &STANDARD)?;
    crate::tray::refresh_tray_menu(&app);
    Ok(())
}

// ── OMO Slim commands ───────────────────────────────────────

#[tauri::command]
pub async fn read_omo_slim_local_file() -> Result<OmoLocalFileData, AppError> {
    OmoService::read_local_file(&SLIM)
}

#[tauri::command]
pub async fn get_current_omo_slim_provider_id(
    state: State<'_, AppState>,
) -> Result<String, String> {
    let provider = state
        .db
        .get_current_omo_provider(&AppType::OpenCode, "omo-slim")?;
    Ok(provider.map(|p| p.id).unwrap_or_default())
}

#[tauri::command]
pub async fn disable_current_omo_slim(
    app: tauri::AppHandle,
    state: State<'_, AppState>,
) -> Result<(), String> {
    OmoService::disable_current(&state, &SLIM)?;
    crate::tray::refresh_tray_menu(&app);
    Ok(())
}