Skip to content
Closed
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
10 changes: 10 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@tanstack/react-virtual": "^3.13.18",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-dialog": "^2.6.0",
"@tauri-apps/plugin-notification": "^2.3.3",
"@tauri-apps/plugin-opener": "^2",
"@tauri-apps/plugin-process": "^2.3.1",
"@tauri-apps/plugin-updater": "^2.9.0",
Expand Down
69 changes: 68 additions & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = ["protocol-asset", "macos-private-api"] }
tauri-plugin-liquid-glass = "0.1"
tauri-plugin-notification = "2"
tauri-plugin-opener = "2"
tauri-plugin-process = "2"
serde = { version = "1", features = ["derive"] }
Expand Down
1 change: 1 addition & 0 deletions src-tauri/capabilities/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"updater:default",
"window-state:default",
"liquid-glass:default",
"notification:default",
"core:window:allow-set-effects",
"core:window:allow-start-dragging"
]
Expand Down
1 change: 1 addition & 0 deletions src-tauri/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub fn run() {
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_dialog::init())
.plugin(tauri_plugin_process::init())
.plugin(tauri_plugin_notification::init())
.invoke_handler(tauri::generate_handler![
settings::get_app_settings,
settings::update_app_settings,
Expand Down
11 changes: 11 additions & 0 deletions src-tauri/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ pub(crate) struct AppSettings {
pub(crate) notification_sounds_enabled: bool,
#[serde(default = "default_preload_git_diffs", rename = "preloadGitDiffs")]
pub(crate) preload_git_diffs: bool,
#[serde(
default = "default_system_notifications_enabled",
rename = "systemNotificationsEnabled"
)]
pub(crate) system_notifications_enabled: bool,
#[serde(
default = "default_experimental_collab_enabled",
rename = "experimentalCollabEnabled"
Expand Down Expand Up @@ -605,6 +610,10 @@ fn default_notification_sounds_enabled() -> bool {
true
}

fn default_system_notifications_enabled() -> bool {
true
}

fn default_preload_git_diffs() -> bool {
true
}
Expand Down Expand Up @@ -769,6 +778,7 @@ impl Default for AppSettings {
code_font_family: default_code_font_family(),
code_font_size: default_code_font_size(),
notification_sounds_enabled: true,
system_notifications_enabled: true,
preload_git_diffs: default_preload_git_diffs(),
experimental_collab_enabled: false,
experimental_collaboration_modes_enabled: false,
Expand Down Expand Up @@ -867,6 +877,7 @@ mod tests {
assert!(settings.code_font_family.contains("SF Mono"));
assert_eq!(settings.code_font_size, 11);
assert!(settings.notification_sounds_enabled);
assert!(settings.system_notifications_enabled);
assert!(settings.preload_git_diffs);
assert!(!settings.experimental_steer_enabled);
assert!(!settings.dictation_enabled);
Expand Down
9 changes: 9 additions & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,21 @@ function MainApp() {
} = useSettingsModalState();
const composerInputRef = useRef<HTMLTextAreaElement | null>(null);

const getWorkspaceName = useCallback(
(workspaceId: string) => workspacesById.get(workspaceId)?.name,
[workspacesById],
);

const {
updaterState,
startUpdate,
dismissUpdate,
handleTestNotificationSound,
handleTestSystemNotification,
} = useUpdaterController({
notificationSoundsEnabled: appSettings.notificationSoundsEnabled,
systemNotificationsEnabled: appSettings.systemNotificationsEnabled,
getWorkspaceName,
onDebug: addDebugEntry,
successSoundUrl,
errorSoundUrl,
Expand Down Expand Up @@ -2160,6 +2168,7 @@ function MainApp() {
scaleShortcutTitle,
scaleShortcutText,
onTestNotificationSound: handleTestNotificationSound,
onTestSystemNotification: handleTestSystemNotification,
dictationModelStatus: dictationModel.status,
onDownloadDictationModel: dictationModel.download,
onCancelDictationDownload: dictationModel.cancel,
Expand Down
18 changes: 18 additions & 0 deletions src/features/app/hooks/useUpdaterController.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
import { useCallback, useRef } from "react";
import { useUpdater } from "../../update/hooks/useUpdater";
import { useAgentSoundNotifications } from "../../notifications/hooks/useAgentSoundNotifications";
import { useAgentSystemNotifications } from "../../notifications/hooks/useAgentSystemNotifications";
import { useWindowFocusState } from "../../layout/hooks/useWindowFocusState";
import { useTauriEvent } from "./useTauriEvent";
import { playNotificationSound } from "../../../utils/notificationSounds";
import { subscribeUpdaterCheck } from "../../../services/events";
import { sendNotification } from "../../../services/tauri";
import type { DebugEntry } from "../../../types";

type Params = {
notificationSoundsEnabled: boolean;
systemNotificationsEnabled: boolean;
getWorkspaceName?: (workspaceId: string) => string | undefined;
onDebug: (entry: DebugEntry) => void;
successSoundUrl: string;
errorSoundUrl: string;
};

export function useUpdaterController({
notificationSoundsEnabled,
systemNotificationsEnabled,
getWorkspaceName,
onDebug,
successSoundUrl,
errorSoundUrl,
Expand Down Expand Up @@ -52,6 +58,13 @@ export function useUpdaterController({
onDebug,
});

useAgentSystemNotifications({
enabled: systemNotificationsEnabled,
isWindowFocused,
getWorkspaceName,
onDebug,
});

const handleTestNotificationSound = useCallback(() => {
const useError = nextTestSoundIsError.current;
nextTestSoundIsError.current = !useError;
Expand All @@ -60,11 +73,16 @@ export function useUpdaterController({
playNotificationSound(url, type, onDebug);
}, [errorSoundUrl, onDebug, successSoundUrl]);

const handleTestSystemNotification = useCallback(() => {
void sendNotification("Test Notification", "This is a test notification from CodexMonitor.");
}, []);

return {
updaterState,
startUpdate,
checkForUpdates,
dismissUpdate: dismiss,
handleTestNotificationSound,
handleTestSystemNotification,
};
}
Loading