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
7 changes: 7 additions & 0 deletions apps/twig/src/main/services/notification/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export class NotificationService {
log.info("Dock badge shown");
}

bounceDock(): void {
if (process.platform === "darwin") {
app.dock?.bounce("informational");
log.info("Dock bounce triggered");
}
}

private clearDockBadge(): void {
if (!this.hasBadge) return;

Expand Down
1 change: 1 addition & 0 deletions apps/twig/src/main/trpc/routers/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ export const notificationRouter = router({
getService().send(input.title, input.body, input.silent),
),
showDockBadge: publicProcedure.mutation(() => getService().showDockBadge()),
bounceDock: publicProcedure.mutation(() => getService().bounceDock()),
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ export function ChatSettings() {
const {
desktopNotifications,
dockBadgeNotifications,
dockBounceNotifications,
completionSound,
completionVolume,
autoConvertLongText,
sendMessagesWith,
setDesktopNotifications,
setDockBadgeNotifications,
setDockBounceNotifications,
setCompletionSound,
setCompletionVolume,
setAutoConvertLongText,
Expand Down Expand Up @@ -90,6 +92,17 @@ export function ChatSettings() {
/>
</SettingRow>

<SettingRow
label="Bounce dock icon"
description="Bounce the dock icon when the agent finishes a task or needs your input"
>
<Switch
checked={dockBounceNotifications}
onCheckedChange={setDockBounceNotifications}
size="1"
/>
</SettingRow>

<SettingRow
label="Sound effect"
description="Play a sound when the agent finishes a task or needs your input"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface SettingsStore {
lastUsedModel: string | null;
desktopNotifications: boolean;
dockBadgeNotifications: boolean;
dockBounceNotifications: boolean;
cursorGlow: boolean;
autoConvertLongText: boolean;
completionSound: CompletionSound;
Expand All @@ -36,6 +37,7 @@ interface SettingsStore {
setLastUsedModel: (model: string) => void;
setDesktopNotifications: (enabled: boolean) => void;
setDockBadgeNotifications: (enabled: boolean) => void;
setDockBounceNotifications: (enabled: boolean) => void;
setCursorGlow: (enabled: boolean) => void;
setAutoConvertLongText: (enabled: boolean) => void;
setSendMessagesWith: (mode: SendMessagesWith) => void;
Expand All @@ -54,6 +56,7 @@ export const useSettingsStore = create<SettingsStore>()(
lastUsedModel: null,
desktopNotifications: true,
dockBadgeNotifications: true,
dockBounceNotifications: false,
completionSound: "none",
completionVolume: 80,
cursorGlow: false,
Expand All @@ -75,6 +78,8 @@ export const useSettingsStore = create<SettingsStore>()(
set({ desktopNotifications: enabled }),
setDockBadgeNotifications: (enabled) =>
set({ dockBadgeNotifications: enabled }),
setDockBounceNotifications: (enabled) =>
set({ dockBounceNotifications: enabled }),
setCursorGlow: (enabled) => set({ cursorGlow: enabled }),
setAutoConvertLongText: (enabled) =>
set({ autoConvertLongText: enabled }),
Expand All @@ -96,6 +101,7 @@ export const useSettingsStore = create<SettingsStore>()(
lastUsedModel: state.lastUsedModel,
desktopNotifications: state.desktopNotifications,
dockBadgeNotifications: state.dockBadgeNotifications,
dockBounceNotifications: state.dockBounceNotifications,
cursorGlow: state.cursorGlow,
autoConvertLongText: state.autoConvertLongText,
completionSound: state.completionSound,
Expand Down
14 changes: 14 additions & 0 deletions apps/twig/src/renderer/lib/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ function showDockBadge(): void {
});
}

function bounceDock(): void {
trpcVanilla.notification.bounceDock.mutate().catch((err) => {
log.error("Failed to bounce dock", err);
});
}

export function notifyPromptComplete(
taskTitle: string,
stopReason: string,
Expand All @@ -39,6 +45,7 @@ export function notifyPromptComplete(
completionVolume,
desktopNotifications,
dockBadgeNotifications,
dockBounceNotifications,
} = useSettingsStore.getState();

const isWindowFocused = document.hasFocus();
Expand All @@ -57,6 +64,9 @@ export function notifyPromptComplete(
if (dockBadgeNotifications) {
showDockBadge();
}
if (dockBounceNotifications) {
bounceDock();
}
}

export function notifyPermissionRequest(taskTitle: string): void {
Expand All @@ -65,6 +75,7 @@ export function notifyPermissionRequest(taskTitle: string): void {
completionVolume,
desktopNotifications,
dockBadgeNotifications,
dockBounceNotifications,
} = useSettingsStore.getState();
const isWindowFocused = document.hasFocus();

Expand All @@ -82,5 +93,8 @@ export function notifyPermissionRequest(taskTitle: string): void {
if (dockBadgeNotifications) {
showDockBadge();
}
if (dockBounceNotifications) {
bounceDock();
}
}
}
Loading