Improve custom notification logging to reflect actual trigger state

- Update ToastContext to compute willTriggerCustomNotification before logging
- audioNotification.enabled now only true when notification WILL be sent
- Add reason field to explain why notification was skipped (disabled, no-command, opted-out, no-content)
- Bump notification skip log from debug to info level in IPC handler
- Update test to match new audioNotification format with reason field
This commit is contained in:
Pedram Amini
2026-02-05 02:56:55 -06:00
parent 9af6a603c0
commit 7574757849
3 changed files with 33 additions and 15 deletions

View File

@@ -271,7 +271,7 @@ describe('ToastContext', () => {
taskDuration: 5000, taskDuration: 5000,
agentSessionId: 'test-session-id', agentSessionId: 'test-session-id',
tabName: 'TestTab', tabName: 'TestTab',
audioNotification: { enabled: false }, audioNotification: { enabled: false, reason: 'disabled' },
}); });
}); });

View File

@@ -364,7 +364,10 @@ export function registerNotificationsHandlers(): void {
async (_event, text: string, command?: string): Promise<NotificationCommandResponse> => { async (_event, text: string, command?: string): Promise<NotificationCommandResponse> => {
// Skip if there's no content to send // Skip if there's no content to send
if (!text || text.trim().length === 0) { if (!text || text.trim().length === 0) {
logger.debug('Notification skipped - no content to send', 'Notification'); logger.info('Notification skipped - empty or whitespace-only content', 'Notification', {
textLength: text?.length ?? 0,
hasText: !!text,
});
return { success: true }; // Return success since there's nothing to do return { success: true }; // Return success since there's nothing to do
} }

View File

@@ -98,7 +98,16 @@ export function ToastProvider({
// Capture audio feedback state for logging // Capture audio feedback state for logging
const { enabled: audioEnabled, command: audioCommand } = audioFeedbackRef.current; const { enabled: audioEnabled, command: audioCommand } = audioFeedbackRef.current;
// Determine if we have content to send for custom notification
// Also skip if there's no content to send
const hasContent = toast.message && toast.message.trim().length > 0;
// Determine if custom notification will actually be triggered
const willTriggerCustomNotification =
audioEnabled && audioCommand && !toast.skipCustomNotification && hasContent;
// Log toast to system logs (include audio notification info) // Log toast to system logs (include audio notification info)
// Only log enabled: true when we will actually trigger the notification
window.maestro.logger.toast(toast.title, { window.maestro.logger.toast(toast.title, {
type: toast.type, type: toast.type,
message: toast.message, message: toast.message,
@@ -107,23 +116,29 @@ export function ToastProvider({
taskDuration: toast.taskDuration, taskDuration: toast.taskDuration,
agentSessionId: toast.agentSessionId, agentSessionId: toast.agentSessionId,
tabName: toast.tabName, tabName: toast.tabName,
// Audio/TTS notification info // Audio/TTS notification info - reflects whether notification WILL be triggered
audioNotification: audioNotification: willTriggerCustomNotification
audioEnabled && audioCommand
? { ? {
enabled: true, enabled: true,
command: audioCommand, command: audioCommand,
} }
: { : {
enabled: false, enabled: false,
reason: !audioEnabled
? 'disabled'
: !audioCommand
? 'no-command'
: toast.skipCustomNotification
? 'opted-out'
: !hasContent
? 'no-content'
: 'unknown',
}, },
}); });
// Run custom notification command if enabled and configured // Run custom notification command if enabled and configured
// Skip for toasts that explicitly opt out (e.g., synopsis messages) // Skip for toasts that explicitly opt out (e.g., synopsis messages)
// Also skip if there's no content to send if (willTriggerCustomNotification) {
const hasContent = toast.message && toast.message.trim().length > 0;
if (audioEnabled && audioCommand && !toast.skipCustomNotification && hasContent) {
console.log( console.log(
'[ToastContext] Running custom notification with message:', '[ToastContext] Running custom notification with message:',
toast.message, toast.message,