feat: enable notification action buttons on Windows (not just macOS)
Electron's 'action' event fires on both macOS and Windows per docs. Removed isMac guard — now Allow/Deny buttons appear on Windows too. Linux excluded (libnotify doesn't fire the 'action' event).
This commit is contained in:
parent
95b282577f
commit
020aaab1c6
1 changed files with 9 additions and 3 deletions
|
|
@ -5380,16 +5380,21 @@ export class TeamProvisioningService {
|
||||||
if (!ElectronNotification.isSupported()) return;
|
if (!ElectronNotification.isSupported()) return;
|
||||||
|
|
||||||
const isMac = process.platform === 'darwin';
|
const isMac = process.platform === 'darwin';
|
||||||
|
const isLinux = process.platform === 'linux';
|
||||||
const iconPath = isMac ? undefined : getAppIconPath();
|
const iconPath = isMac ? undefined : getAppIconPath();
|
||||||
const teamLabel = run.request.displayName ?? run.teamName;
|
const teamLabel = run.request.displayName ?? run.teamName;
|
||||||
const body = this.formatToolApprovalBody(approval.toolName, approval.toolInput);
|
const body = this.formatToolApprovalBody(approval.toolName, approval.toolInput);
|
||||||
|
|
||||||
|
// Actions (Allow/Deny buttons) supported on macOS and Windows.
|
||||||
|
// Linux libnotify doesn't fire the 'action' event — users get click-to-focus.
|
||||||
|
const supportsActions = !isLinux;
|
||||||
|
|
||||||
const notification = new ElectronNotification({
|
const notification = new ElectronNotification({
|
||||||
title: `Tool Approval — ${teamLabel}`,
|
title: `Tool Approval — ${teamLabel}`,
|
||||||
body,
|
body,
|
||||||
sound: config.notifications.soundEnabled ? 'default' : undefined,
|
sound: config.notifications.soundEnabled ? 'default' : undefined,
|
||||||
...(iconPath ? { icon: iconPath } : {}),
|
...(iconPath ? { icon: iconPath } : {}),
|
||||||
...(isMac
|
...(supportsActions
|
||||||
? {
|
? {
|
||||||
actions: [
|
actions: [
|
||||||
{ type: 'button' as const, text: 'Allow' },
|
{ type: 'button' as const, text: 'Allow' },
|
||||||
|
|
@ -5417,8 +5422,9 @@ export class TeamProvisioningService {
|
||||||
|
|
||||||
notification.on('close', cleanup);
|
notification.on('close', cleanup);
|
||||||
|
|
||||||
// macOS action buttons: Allow (index 0) / Deny (index 1)
|
// Action buttons: Allow (index 0) / Deny (index 1)
|
||||||
if (isMac) {
|
// 'action' event fires on macOS and Windows (not Linux)
|
||||||
|
if (supportsActions) {
|
||||||
notification.on('action', (_event, index) => {
|
notification.on('action', (_event, index) => {
|
||||||
cleanup();
|
cleanup();
|
||||||
const allow = index === 0;
|
const allow = index === 0;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue