fix: deduplicate desktop notifications and tighten notification text extraction
Desktop notifications no longer duplicate when native delivery succeeds Reasoning chain-of-thought is excluded from notification body text Untyped message parts are ignored in notification text extraction
This commit is contained in:
@@ -84,11 +84,17 @@ export const createNotificationTemplateRuntime = (deps) => {
|
||||
: text;
|
||||
};
|
||||
|
||||
const isNotificationTextPart = (part) => {
|
||||
if (!part || typeof part !== 'object') return false;
|
||||
if (part.type !== 'text') return false;
|
||||
return typeof part.text === 'string' || typeof part.content === 'string';
|
||||
};
|
||||
|
||||
const extractTextFromParts = (parts, maxLength = NOTIFICATION_BODY_MAX_CHARS) => {
|
||||
if (!Array.isArray(parts) || parts.length === 0) return '';
|
||||
|
||||
const textParts = parts
|
||||
.filter((part) => part && (part.type === 'text' || typeof part.text === 'string' || typeof part.content === 'string'))
|
||||
.filter(isNotificationTextPart)
|
||||
.map((part) => part.text || part.content || '')
|
||||
.filter(Boolean);
|
||||
|
||||
@@ -112,7 +118,7 @@ export const createNotificationTemplateRuntime = (deps) => {
|
||||
const content = info.content;
|
||||
if (Array.isArray(content)) {
|
||||
const textContent = content
|
||||
.filter((entry) => entry && (entry.type === 'text' || typeof entry.text === 'string'))
|
||||
.filter(isNotificationTextPart)
|
||||
.map((entry) => entry.text || '')
|
||||
.filter(Boolean);
|
||||
if (textContent.length > 0) {
|
||||
|
||||
Reference in New Issue
Block a user