Skip to content
Draft
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
392 changes: 333 additions & 59 deletions Cargo.lock

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,8 @@ downcast-rs = "2.0.2"
dyn-clone = "1.0.20"
regex = "1.12.2"
shellexpand = "3.1.0"

[patch.crates-io]
tauri = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-runtime = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
tauri-utils = { git = "https://github.com/tauri-apps/tauri", branch = "feat/cef" }
15 changes: 13 additions & 2 deletions backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "atuin-desktop"
description = "Atuin Desktop"
publish = false
workspace = ".."
version = "0.2.11" # duplicated here as CN CLI can't handle workspace version
version = "0.2.11" # duplicated here as CN CLI can't handle workspace version
edition.workspace = true

[lints.clippy]
Expand Down Expand Up @@ -36,7 +36,12 @@ url = { workspace = true }
sha2 = "0.10"
bigdecimal = { workspace = true }

tauri = { version = "2.9.4", features = ["tray-icon", "devtools"] }
tauri = { version = "2.9.4", default-features = false, features = [
"tray-icon",
"devtools",
"compression",
"common-controls-v6",
] }
tauri-plugin-http = { version = "2.5.4", features = ["native-tls"] }
tauri-plugin-deep-link = "2.4.5"
tauri-plugin-single-instance = { version = "2.3.6", features = ["deep-link"] }
Expand Down Expand Up @@ -83,6 +88,9 @@ dirs = { workspace = true }
tempfile = { workspace = true }
config = "0.15.19"

[dev-dependencies]
tauri = { version = "2.9.4", features = ["test"] }

[dependencies.tauri-plugin-sql]
features = ["sqlite"] # or "postgres", or "mysql"
version = "2.3.1"
Expand All @@ -94,6 +102,9 @@ cocoa = "0.26"
tauri-plugin-updater = "2.9.0"

[features]
default = ["wry"]
# this feature is used for production builds or when `devPath` points to the filesystem
# DO NOT REMOVE!!
custom-protocol = ["tauri/custom-protocol"]
wry = ["tauri/wry"]
cef = ["tauri/cef"]
6 changes: 3 additions & 3 deletions backend/src/commands/audio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use rodio::{Decoder, OutputStream, Sink};
use serde::Serialize;
use std::fs::File;
use std::io::BufReader;
use tauri::{path::BaseDirectory, AppHandle, Manager};
use tauri::{path::BaseDirectory, AppHandle, Manager, Runtime};

#[derive(Debug, Serialize)]
pub struct SoundInfo {
Expand All @@ -27,7 +27,7 @@ fn to_display_name(stem: &str) -> String {
}

#[tauri::command]
pub async fn list_sounds(app: AppHandle) -> Result<Vec<SoundInfo>, String> {
pub async fn list_sounds<R: Runtime>(app: AppHandle<R>) -> Result<Vec<SoundInfo>, String> {
let sounds_path = app
.path()
.resolve("resources/sounds", BaseDirectory::Resource)
Expand Down Expand Up @@ -62,7 +62,7 @@ pub async fn list_sounds(app: AppHandle) -> Result<Vec<SoundInfo>, String> {
}

#[tauri::command]
pub async fn play_sound(app: AppHandle, sound_id: String, volume: f32) -> Result<(), String> {
pub async fn play_sound<R: Runtime>(app: AppHandle<R>, sound_id: String, volume: f32) -> Result<(), String> {
log::info!(
"play_sound called with sound_id={}, volume={}",
sound_id,
Expand Down
20 changes: 10 additions & 10 deletions backend/src/commands/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use atuin_desktop_runtime::pty::PtyStoreHandle;
use atuin_desktop_runtime::ssh::SshPoolHandle;
use serde_json::Value;
use tauri::Manager;
use tauri::{ipc::Channel, AppHandle, State};
use tauri::{ipc::Channel, AppHandle, Runtime, State};
use tokio::sync::oneshot;
use uuid::Uuid;

Expand Down Expand Up @@ -51,18 +51,18 @@ impl MessageChannel<DocumentBridgeMessage> for DocumentBridgeChannel {
}

#[derive(Clone)]
struct KvBlockLocalValueProvider {
app_handle: AppHandle,
struct KvBlockLocalValueProvider<R: Runtime> {
app_handle: AppHandle<R>,
}

impl KvBlockLocalValueProvider {
pub fn new(app_handle: AppHandle) -> Self {
impl<R: Runtime> KvBlockLocalValueProvider<R> {
pub fn new(app_handle: AppHandle<R>) -> Self {
Self { app_handle }
}
}

#[async_trait]
impl LocalValueProvider for KvBlockLocalValueProvider {
impl<R: Runtime> LocalValueProvider for KvBlockLocalValueProvider<R> {
async fn get_block_local_value(
&self,
block_id: Uuid,
Expand Down Expand Up @@ -283,8 +283,8 @@ pub async fn cancel_block_execution(
}

#[tauri::command]
pub async fn open_document(
app: AppHandle,
pub async fn open_document<R: Runtime>(
app: AppHandle<R>,
state: State<'_, AtuinState>,
document_id: String,
document: Vec<serde_json::Value>,
Expand Down Expand Up @@ -493,8 +493,8 @@ pub async fn remove_stored_context_for_document(
}

#[tauri::command]
pub async fn start_serial_execution(
app: AppHandle,
pub async fn start_serial_execution<R: Runtime>(
app: AppHandle<R>,
state: State<'_, AtuinState>,
document_id: String,
from_block: Option<String>,
Expand Down
6 changes: 3 additions & 3 deletions backend/src/commands/events.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use async_trait::async_trait;
use tauri::{ipc::Channel, AppHandle, Manager};
use tauri::{ipc::Channel, AppHandle, Manager, Runtime};
use tokio::sync::mpsc;

use crate::state::AtuinState;
Expand Down Expand Up @@ -28,8 +28,8 @@ impl EventBus for ChannelEventBus {

/// Subscribe to the Grand Central event stream
#[tauri::command]
pub async fn subscribe_to_events(
app_handle: AppHandle,
pub async fn subscribe_to_events<R: Runtime>(
app_handle: AppHandle<R>,
event_channel: Channel<GCEvent>,
) -> Result<(), String> {
let state = app_handle
Expand Down
4 changes: 2 additions & 2 deletions backend/src/commands/exec_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ struct ExecLogCompletedEvent {
}

#[tauri::command]
pub async fn log_execution(
app: tauri::AppHandle,
pub async fn log_execution<R: tauri::Runtime>(
app: tauri::AppHandle<R>,
state: tauri::State<'_, crate::state::AtuinState>,
block: Block,
start_time: u64,
Expand Down
4 changes: 2 additions & 2 deletions backend/src/commands/pty_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use uuid::Uuid;
use crate::{run::pty::remove_pty, state::AtuinState};

#[tauri::command]
pub async fn runbook_kill_all_ptys(
app: tauri::AppHandle,
pub async fn runbook_kill_all_ptys<R: tauri::Runtime>(
app: tauri::AppHandle<R>,
state: tauri::State<'_, AtuinState>,
runbook: Uuid,
) -> Result<(), String> {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/commands/workspaces.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::path::{Path, PathBuf};

use serde_yaml::Value;
use tauri::{ipc::Channel, path::BaseDirectory, AppHandle, Manager, State};
use tauri::{ipc::Channel, path::BaseDirectory, AppHandle, Manager, Runtime, State};

use crate::{
state::AtuinState,
Expand All @@ -14,7 +14,7 @@ use crate::{
};

#[tauri::command]
pub async fn copy_welcome_workspace(app: AppHandle, id: String) -> Result<String, String> {
pub async fn copy_welcome_workspace<R: Runtime>(app: AppHandle<R>, id: String) -> Result<String, String> {
let welcome_path = app
.path()
.resolve("resources/welcome", BaseDirectory::Resource)
Expand Down
4 changes: 2 additions & 2 deletions backend/src/kv.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use serde::{de::DeserializeOwned, Serialize};
use sqlx::{Row, SqlitePool};
use tauri::{AppHandle, Manager};
use tauri::{AppHandle, Manager, Runtime};

pub(crate) async fn get<T: DeserializeOwned>(
db: &SqlitePool,
Expand Down Expand Up @@ -34,7 +34,7 @@ pub(crate) async fn set<T: Serialize>(db: &SqlitePool, key: &str, value: &T) ->
.map_err(|e| e.to_string())
}

pub(crate) async fn open_db(app: &AppHandle) -> eyre::Result<SqlitePool> {
pub(crate) async fn open_db<R: Runtime>(app: &AppHandle<R>) -> eyre::Result<SqlitePool> {
let state = app.state::<crate::state::AtuinState>();
state.db_instances.get_pool("kv").await
}
21 changes: 14 additions & 7 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::path::PathBuf;
use std::{env, fs};

use tauri::path::BaseDirectory;
use tauri::{http, App, AppHandle, Manager, RunEvent};
use tauri::{http, App, AppHandle, Manager, RunEvent, Runtime};
use tauri_plugin_log::fern::colors::{Color, ColoredLevelConfig};
use time::format_description::well_known::Rfc3339;

Expand Down Expand Up @@ -46,6 +46,13 @@ use dotfiles::aliases::aliases;
use crate::advanced_settings::AdvancedSettings;
use crate::menu::TabItem;

#[cfg(all(not(test), feature = "cef"))]
use tauri::Cef as BrowserEngine;
#[cfg(all(not(test), not(feature = "cef"), feature = "wry"))]
use tauri::Wry as BrowserEngine;
#[cfg(test)]
use tauri::test::MockRuntime as BrowserEngine;

#[derive(Debug, serde::Serialize)]
struct HomeInfo {
pub record_count: u64,
Expand Down Expand Up @@ -308,7 +315,7 @@ async fn cli_settings() -> Result<Settings, String> {
}

#[tauri::command]
async fn get_app_version(app: AppHandle) -> Result<String, String> {
async fn get_app_version<R: Runtime>(app: AppHandle<R>) -> Result<String, String> {
let version = app.package_info().version.to_string();
Ok(version)
}
Expand Down Expand Up @@ -344,14 +351,14 @@ async fn get_platform_info() -> Result<String, String> {
}

#[tauri::command]
async fn update_window_menu_tabs(app: AppHandle, tabs: Vec<TabItem>) -> Result<(), String> {
async fn update_window_menu_tabs<R: Runtime>(app: AppHandle<R>, tabs: Vec<TabItem>) -> Result<(), String> {
let new_menu = menu::menu(&app, &tabs).map_err(|e| e.to_string())?;
let _ = app.set_menu(new_menu);

Ok(())
}

fn backup_databases(app: &App) -> tauri::Result<()> {
fn backup_databases<R: Runtime>(app: &App<R>) -> tauri::Result<()> {
let version = app.package_info().version.to_string();
// This seems like the wrong directory to use, but it's what the SQL plugin uses so ¯\_(ツ)_/¯
let base_dir = app.path().app_config_dir()?;
Expand Down Expand Up @@ -383,7 +390,7 @@ fn backup_databases(app: &App) -> tauri::Result<()> {
Ok(())
}

fn show_window(app: &AppHandle) {
fn show_window<R: Runtime>(app: &AppHandle<R>) {
let windows = app.webview_windows();

windows
Expand All @@ -394,7 +401,7 @@ fn show_window(app: &AppHandle) {
.expect("Can't Bring Window to Focus");
}

async fn apply_runbooks_migrations(app: &AppHandle) -> eyre::Result<()> {
async fn apply_runbooks_migrations<R: Runtime>(app: &AppHandle<R>) -> eyre::Result<()> {
let state = app.state::<crate::state::AtuinState>();
let pool = state.db_instances.get_pool("runbooks").await?;
sqlx::migrate!("./migrations/runbooks").run(&pool).await?;
Expand All @@ -416,7 +423,7 @@ fn main() {
.debug(Color::Blue)
.trace(Color::BrightBlack);

let builder = tauri::Builder::default().plugin(
let builder = tauri::Builder::<BrowserEngine>::new().plugin(
tauri_plugin_log::Builder::new()
.targets([
tauri_plugin_log::Target::new(tauri_plugin_log::TargetKind::Stderr),
Expand Down
16 changes: 8 additions & 8 deletions backend/src/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{kv, state};
use tauri::utils::config::BackgroundThrottlingPolicy;
use tauri::webview::WebviewWindowBuilder;
use tauri::{
AppHandle, LogicalSize, Manager, PhysicalPosition, PhysicalSize, WebviewUrl, WebviewWindow,
AppHandle, LogicalSize, Manager, PhysicalPosition, PhysicalSize, Runtime, WebviewUrl, WebviewWindow,
};

#[derive(Clone, serde::Serialize, serde::Deserialize, Debug)]
Expand Down Expand Up @@ -45,7 +45,7 @@ fn get_os() -> String {
}
}

pub(crate) async fn create_main_window(app: &AppHandle) -> Result<(), String> {
pub(crate) async fn create_main_window<R: Runtime>(app: &AppHandle<R>) -> Result<(), String> {
let dev_prefix = app.state::<state::AtuinState>().dev_prefix.clone();
let channel = env!("APP_CHANNEL");

Expand Down Expand Up @@ -114,7 +114,7 @@ pub(crate) async fn create_main_window(app: &AppHandle) -> Result<(), String> {
.disable_drag_drop_handler()
.min_inner_size(500.0, 500.0)
.background_throttling(BackgroundThrottlingPolicy::Suspend)
.visible(false);
.visible(true);

builder = {
#[cfg(target_os = "macos")]
Expand Down Expand Up @@ -171,7 +171,7 @@ pub(crate) async fn create_main_window(app: &AppHandle) -> Result<(), String> {
Ok(())
}

fn is_correctly_sized_and_positioned(window: &WebviewWindow, window_state: &WindowState) -> bool {
fn is_correctly_sized_and_positioned<R: Runtime>(window: &WebviewWindow<R>, window_state: &WindowState) -> bool {
let position = window.outer_position().unwrap();
let size = window.outer_size().unwrap();
position.x == window_state.x
Expand All @@ -181,7 +181,7 @@ fn is_correctly_sized_and_positioned(window: &WebviewWindow, window_state: &Wind
}

#[tauri::command]
pub(crate) async fn save_window_info(app: AppHandle) -> Result<(), String> {
pub(crate) async fn save_window_info<R: Runtime>(app: AppHandle<R>) -> Result<(), String> {
let window = app.get_webview_window("main").unwrap();
let position = window.outer_position().unwrap();
let size = window.outer_size().unwrap();
Expand All @@ -193,19 +193,19 @@ pub(crate) async fn save_window_info(app: AppHandle) -> Result<(), String> {
}

#[tauri::command]
pub(crate) async fn show_window(app: AppHandle) -> Result<(), String> {
pub(crate) async fn show_window<R: Runtime>(app: AppHandle<R>) -> Result<(), String> {
let window = app.get_webview_window("main").unwrap();
window.show().unwrap();
window.set_focus().unwrap();
Ok(())
}

async fn save_window_state(app: &AppHandle, state: WindowState) -> Result<(), String> {
async fn save_window_state<R: Runtime>(app: &AppHandle<R>, state: WindowState) -> Result<(), String> {
let db = kv::open_db(app).await.map_err(|e| e.to_string())?;
kv::set(&db, "window_state_u32", &state).await
}

async fn load_window_state(app: &AppHandle) -> Result<Option<WindowState>, String> {
async fn load_window_state<R: Runtime>(app: &AppHandle<R>) -> Result<Option<WindowState>, String> {
let db = kv::open_db(app).await.map_err(|e| e.to_string())?;
kv::get(&db, "window_state_u32").await
}
6 changes: 3 additions & 3 deletions backend/src/run/pty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use atuin_desktop_runtime::pty::PtyStoreHandle;
use eyre::Result;
use tauri::Manager;

async fn update_badge_count(app: &tauri::AppHandle, store: PtyStoreHandle) -> Result<()> {
async fn update_badge_count<R: tauri::Runtime>(app: &tauri::AppHandle<R>, store: PtyStoreHandle) -> Result<()> {
let len = store.len().await?;
let len = if len == 0 { None } else { Some(len as i64) };

Expand Down Expand Up @@ -48,8 +48,8 @@ pub(crate) async fn pty_resize(
Ok(())
}

pub(crate) async fn remove_pty(
app: tauri::AppHandle,
pub(crate) async fn remove_pty<R: tauri::Runtime>(
app: tauri::AppHandle<R>,
pid: uuid::Uuid,
store: PtyStoreHandle,
) -> Result<(), String> {
Expand Down
4 changes: 2 additions & 2 deletions backend/src/runbooks/runbook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ pub fn export_atrb(json: String, file_path: String) -> Result<(), String> {
}

#[tauri::command]
pub async fn delete_runbook_cleanup(
app: tauri::AppHandle,
pub async fn delete_runbook_cleanup<R: tauri::Runtime>(
app: tauri::AppHandle<R>,
state: State<'_, AtuinState>,
runbook: Uuid,
) -> Result<(), String> {
Expand Down
Loading
Loading