//! The Tauri command surface. //! //! Every command is a thin translation between the IPC boundary and the //! workspace actor. No logic lives here. use std::path::PathBuf; use gigit_git::{RefEntry, RepositorySummary}; use tauri::ipc::Channel; use tauri::State; use crate::error::Result; use crate::graph_stream::GraphEvent; use crate::recents::{RecentRepository, RecentsHandle}; use crate::workspace::{OpenedRepository, RepositoryId, WorkspaceHandle}; #[tauri::command] pub async fn open_repository( path: PathBuf, workspace: State<'_, WorkspaceHandle>, ) -> Result { workspace.open(path).await } #[tauri::command] pub async fn close_repository( id: RepositoryId, workspace: State<'_, WorkspaceHandle>, ) -> Result { workspace.close(id).await } #[tauri::command] pub async fn repository_summary( id: RepositoryId, workspace: State<'_, WorkspaceHandle>, ) -> Result { workspace.summary(id).await } #[tauri::command] pub async fn list_references( id: RepositoryId, workspace: State<'_, WorkspaceHandle>, ) -> Result> { workspace.references(id).await } /// Start streaming the commit graph. /// /// `budget` is how many rows may be sent before the frontend asks for more — /// enough to fill the first screen, typically. #[tauri::command] pub async fn stream_graph( id: RepositoryId, channel: Channel, budget: usize, workspace: State<'_, WorkspaceHandle>, ) -> Result<()> { workspace.stream_graph(id, channel, budget).await } /// Allow the running stream to send `rows` more rows. #[tauri::command] pub async fn request_more_rows( id: RepositoryId, rows: usize, workspace: State<'_, WorkspaceHandle>, ) -> Result<()> { workspace.request_more_rows(id, rows).await } /// Repositories opened before, most recent first. #[tauri::command] pub async fn list_recent_repositories( recents: State<'_, RecentsHandle>, ) -> Result> { recents.list().await } /// Drop a repository from the recents list. Returns whether it was there. #[tauri::command] pub async fn forget_recent_repository( id: RepositoryId, recents: State<'_, RecentsHandle>, ) -> Result { recents.forget(id).await }