refactor(desktop): consolidate notification helpers and add channel names to toasts#1286
Merged
Merged
Conversation
…ames to toasts Thread reply toasts fell back to "Reply in Thread" when the channels query hadn't resolved yet — the inline channels.find() returned undefined on an empty array. Reminder toasts had no channel context at all. Extract three shared helpers into notificationFormat.ts: resolveNotificationChannelLabel, truncateNotificationBody, and formatNotificationTitle. Wire all affected paths through them so channel name resolution and body truncation are consistent across every toast type. Thread replies now show "Reply in #channelName" (null-safe: falls back to "Reply" when the channel isn't loaded yet). Reminder toasts now show "Reminder due in #channelName" for single-reminder toasts with a target channel. Feed path behavior is unchanged — it already had correct formatting and now delegates body truncation to the shared helper. DM path title is unchanged (participants are the title). Co-authored-by: Will Pfleger <pfleger.will@gmail.com> Signed-off-by: Will Pfleger <pfleger.will@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extracts three shared helpers into a new
notificationFormat.tsmodule and wires all desktop notification paths through them, fixing missing channel names in thread reply and reminder toasts.New file:
desktop/src/features/notifications/lib/notificationFormat.tsresolveNotificationChannelLabel(channelId, channels)— returns"#channelName"ornull(null-safe: returns null when the channels query hasn't resolved yet, so the toast still fires with just the prefix)truncateNotificationBody(content, fallback)— consistent 140-char truncation with...suffixformatNotificationTitle({ prefix, channelLabel })— produces"prefix in #channel"or just"prefix"Why
Thread reply toasts fell back to
"Reply in Thread"when thechannelsarray was empty at WebSocket event time (race condition: the channels query hadn't resolved yet). Reminder toasts had no channel context at all. Each of the four toast paths had its own inline body truncation logic with slightly different behavior.Changes per path
notificationTitle()+ inline truncationformatNotificationTitle()+truncateNotificationBody(); behavior unchangedchannels.find()→"Reply in Thread"on misschannels.find()→"Reply in #channelName"or"Reply"on misstruncateNotificationBody(); title unchanged (participants are the title)"Reminder due""Reminder due in #channelName"for single-reminder toasts with a target channelNotes
nullfromresolveNotificationChannelLabelwhen the channel isn't in the list means the toast fires with just the prefix rather than being blocked. This is better UX than a silent miss."N reminders are due"is the signal.useChannelsQuery()inAppShell.tsxis moved 13 lines earlier sochannelsis available beforeuseReminderNotificationsis called. Hook call order is preserved.