Skip to content
Merged
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
25 changes: 22 additions & 3 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use tauri::Manager;
use tauri::{Manager, RunEvent, WindowEvent};

mod backend;
mod codex;
Expand Down Expand Up @@ -42,6 +42,16 @@ pub fn run() {
.manage(menu::MenuItemRegistry::<tauri::Wry>::default())
.menu(menu::build_menu)
.on_menu_event(menu::handle_menu_event)
.on_window_event(|window, event| {
if window.label() != "main" {
return;
}
#[cfg(target_os = "macos")]
if let WindowEvent::CloseRequested { api, .. } = event {
api.prevent_close();
let _ = window.hide();
Comment thread
Dimillian marked this conversation as resolved.
}
})
.setup(|app| {
let state = state::AppState::load(&app.handle());
app.manage(state);
Expand All @@ -56,7 +66,7 @@ pub fn run() {
#[cfg(desktop)]
let builder = builder.plugin(tauri_plugin_window_state::Builder::default().build());

builder
let app = builder
.plugin(tauri_plugin_liquid_glass::init())
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
Expand Down Expand Up @@ -143,6 +153,15 @@ pub fn run() {
dictation::dictation_cancel,
local_usage::local_usage_snapshot
])
.run(tauri::generate_context!())
.build(tauri::generate_context!())
.expect("error while running tauri application");

app.run(|app_handle, event| {
if let RunEvent::Reopen { .. } = event {
if let Some(window) = app_handle.get_webview_window("main") {
let _ = window.show();
let _ = window.set_focus();
Comment on lines +159 to +163
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Guard mac-only RunEvent::Reopen usage

On Linux/Windows builds, RunEvent::Reopen is not available because Tauri gates that enum variant behind #[cfg(target_os = "macos")]. As written, this if let RunEvent::Reopen { .. } = event match will fail to compile on non-mac targets, breaking cross-platform builds. Consider wrapping the reopen handler in a #[cfg(target_os = "macos")] block or using a cfg-guarded helper.

Useful? React with 👍 / 👎.

}
}
});
}
2 changes: 2 additions & 0 deletions src-tauri/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,8 @@ pub(crate) fn handle_menu_event<R: tauri::Runtime>(

fn emit_menu_event<R: tauri::Runtime>(app: &tauri::AppHandle<R>, event: &str) {
if let Some(window) = app.get_webview_window("main") {
let _ = window.show();
let _ = window.set_focus();
let _ = window.emit(event, ());
} else {
let _ = app.emit(event, ());
Expand Down
1 change: 0 additions & 1 deletion src-tauri/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::collections::HashMap;
use std::path::PathBuf;
use std::sync::Arc;

use tauri::{AppHandle, Manager};
use tokio::sync::Mutex;

Expand Down
1 change: 0 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1379,7 +1379,6 @@ function MainApp() {
});

useMenuAcceleratorController({ appSettings, onDebug: addDebugEntry });

const isDefaultScale = Math.abs(uiScale - 1) < 0.001;
const dropOverlayActive = isWorkspaceDropActive;
const dropOverlayText = "Drop Project Here";
Expand Down
8 changes: 7 additions & 1 deletion src/features/settings/components/SettingsView.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,13 @@ describe("SettingsView Display", () => {
if (!row) {
throw new Error("Expected reduce transparency row");
}
fireEvent.click(within(row).getByRole("button"));
const toggle = row.querySelector(
"button.settings-toggle",
) as HTMLButtonElement | null;
if (!toggle) {
throw new Error("Expected reduce transparency toggle");
}
fireEvent.click(toggle);

expect(onToggleTransparency).toHaveBeenCalledWith(true);
});
Expand Down