feat(kon): wire Tauri shell — thin commands, ProviderRegistry, tray
- lib.rs rewritten from scaffold to full app setup (~70 lines) - AppState holds Arc<LocalEngine> for Whisper and Parakeet - commands/models.rs: download, check, list, load for both engines Maps legacy size strings (Tiny/Base/Small/Medium) to ModelId - commands/transcription.rs: transcribe_pcm, transcribe_file, transcribe_pcm_parakeet Delegates to LocalEngine.transcribe_sync() + post_process_segments() - commands/audio.rs: save_audio via kon_audio::write_wav - commands/windows.rs: open_task_window, open_viewer_window - commands/llm.rs: 8 stub commands preserved for frontend compatibility - tray.rs: extracted system tray setup (show, status, quit, click-to-show) - Close-to-tray behaviour preserved - All 25 v0.2 command names preserved for Svelte frontend compatibility - clippy clean Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,9 +1,83 @@
|
||||
mod commands;
|
||||
mod tray;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use tauri::Manager;
|
||||
|
||||
use kon_core::types::EngineName;
|
||||
use kon_transcription::LocalEngine;
|
||||
|
||||
/// Shared app state holding the transcription engines.
|
||||
pub struct AppState {
|
||||
pub whisper_engine: Arc<LocalEngine>,
|
||||
pub parakeet_engine: Arc<LocalEngine>,
|
||||
}
|
||||
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_opener::init())
|
||||
.plugin(tauri_plugin_dialog::init())
|
||||
.plugin(tauri_plugin_global_shortcut::Builder::new().build())
|
||||
.manage(AppState {
|
||||
whisper_engine: Arc::new(LocalEngine::new(
|
||||
EngineName::new("whisper"),
|
||||
)),
|
||||
parakeet_engine: Arc::new(LocalEngine::new(
|
||||
EngineName::new("parakeet"),
|
||||
)),
|
||||
})
|
||||
.setup(|app| {
|
||||
if let Err(e) = tray::setup(app) {
|
||||
eprintln!("Failed to setup tray: {e}");
|
||||
}
|
||||
|
||||
// Close-to-tray: hide window instead of exiting
|
||||
let main_window = app.get_webview_window("main").unwrap();
|
||||
let win = main_window.clone();
|
||||
main_window.on_window_event(move |event| {
|
||||
if let tauri::WindowEvent::CloseRequested { api, .. } = event
|
||||
{
|
||||
api.prevent_close();
|
||||
let _ = win.hide();
|
||||
}
|
||||
});
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
// Whisper model management
|
||||
commands::models::download_model,
|
||||
commands::models::check_model,
|
||||
commands::models::list_models,
|
||||
commands::models::load_model,
|
||||
commands::models::check_engine,
|
||||
// Parakeet model management
|
||||
commands::models::download_parakeet_model,
|
||||
commands::models::check_parakeet_model,
|
||||
commands::models::list_parakeet_models,
|
||||
commands::models::load_parakeet_model,
|
||||
commands::models::check_parakeet_engine,
|
||||
// Transcription
|
||||
commands::transcription::transcribe_pcm,
|
||||
commands::transcription::transcribe_file,
|
||||
commands::transcription::transcribe_pcm_parakeet,
|
||||
// Audio
|
||||
commands::audio::save_audio,
|
||||
// Windows
|
||||
commands::windows::open_task_window,
|
||||
commands::windows::open_viewer_window,
|
||||
// LLM stubs
|
||||
commands::llm::download_llm_model,
|
||||
commands::llm::check_llm_model,
|
||||
commands::llm::list_llm_models,
|
||||
commands::llm::load_llm_model,
|
||||
commands::llm::check_llm_engine,
|
||||
commands::llm::llm_generate,
|
||||
commands::llm::llm_extract_tasks,
|
||||
commands::llm::llm_format_transcript,
|
||||
])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running Kon");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user