Task 23: Native notifications (#23) #56
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "task/23-notifications"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on: task/10-core-messages-readstate, task/12-platform-persistence, task/14-app-runtime (base of this branch's own commits:
d0f3c10).What this builds
fluxer-core(src/notifications.rs): after every reducer,App::applyasksnotification_for(app, event)and appendsEffect::Notify(Notification { title, body, channel_id, message_id })for aMESSAGE_CREATEthatLocalSettings::notifications_enabled),can_view), or is in a DM / group DM,Title
<author> in #channel/<author>(named asdisplay_namedoes). Body: content with<@id>,<@&id>,<#id>and custom emoji written as names, Markdown kept (as the Electron client'spreserveMarkdown), cut to 200 characters;Attachment: <filename>for a message without text.fluxer-platform(src/notify/{mod,linux,windows}.rs):trait Notifier { fn notify(&self, &Notification) -> Result<()> }andsystem_notifier(on_click). Both backends usenotify-rust4 (new dependency, named by the task): the freedesktop service over zbus on Linux, a WinRT toast on Windows. On Linux the body is escaped when the server reads markup, and thedefaultaction reports a click. Clicks are waited for on one thread per open notification, at most 32.Finding on the fork crate:
fluxer_linux_notificationsis napi-only (public API is a#[napi]class taking JS callbacks/objects, D-Bus code private,napi_build::setup()inbuild.rs), so the plan's fallbacknotify-rustis used. Recorded incrates/fluxer-platform/README.mdanddeny.toml.apps/fluxer(outside the task's file list, the wiring Task 14 left for this task):Effect::Notifygoes to a blocking worker owning the notifier; a click comes back as an internal event and becomesCloseSettings/SelectGuild/SelectChannelas needed.Runtime::with_notifierreplaces the system notifier (tests).How it was tested
crates/fluxer-core/tests/notifications.rs: the plan's four tests (mention_in_unselected_channel_notifies,message_in_selected_focused_channel_does_not_notify,dm_notifies_even_without_mention,notifications_disabled_suppresses) plus @everyone, own message, unknown channel, system message, logged out, mention names in the body, truncation, attachment fallback. Written first and seen failing (commit099de95).fluxer-platformunit tests: click watching (click, close, the 32 limit), capability parsing, markup escaping.apps/fluxerunit tests: the notify worker (order, clicks, a failing notifier), what a click selects, stale clicks.cargo run -p fluxer-platform --example notifywas accepted and shown by the server. The click was not exercised by a person, and nothing was run on Windows.FLUXER_SCREENSHOT_TESTS=1 cargo xtask cigreen locally.Deviations from the plan
icon: AvatarSourceonNotification. The type comes with Task 21, which is not in this stack and does not merge into it mechanically. Follow-up: #54.mention_everyoneand channel allows" is implemented as "the user can view the channel"; the per-guild suppress-@everyone setting, mutes and role mentions are not modelled in Foundation.crates/fluxer-core/tests/messages.rs(Task 10): one assertion that a DM message produces no effects now expects exactly theNotify.apps/fluxer/src/{runtime,lib}.rs(wiring),crates/fluxer-core/src/{app,effect,lib}.rs, the three READMEs,Cargo.toml/Cargo.lock/deny.toml(dependency), andcrates/fluxer-platform/examples/notify.rs(the manual check).notify-rustbrings zbus 6 next to keyring's zbus 5 (cargo-deny: duplicate warning only).For the reviewer
crates/fluxer-platform/src/notify/windows.rswas written against the notify-rust 4.19 sources and has only ever been compiled by the Windows runner.fluxer --devservershows real notifications if a scenario contains a mention or DM (basicdoes not).WindowFocus, desktop entry, Windows app id): #55.Closes #23
🤖 Generated with Claude Code
Independent review: Task 23 (notifications)
Reviewed
d0f3c10..c0c5a4e(branchtask/23-notifications) in a fresh worktree.Checks
mention_in_unselected_channel_notifies,message_in_selected_focused_channel_does_not_notify,dm_notifies_even_without_mention,notifications_disabled_suppressesall exist incrates/fluxer-core/tests/notifications.rs, assert the fullNotification(title"ada in #general"/"Ada L.", body, ids), and pass. The 200-character truncation and the "not selected OR unfocused" rule are tested too.trait Notifier { fn notify(&self, n: &Notification) -> Result<()> }present;Effect::Notify(Notification { title, body, channel_id, message_id })emitted; click ->UserAction::SelectChannel(preceded byCloseSettings/SelectGuildwhen needed);LocalSettings.notifications_enabledandUiState.window_focusedrespected. One deviation, see finding 1.fluxer-coregains no dependency (core-isolation step green); nothing influxer-ui; the<...>reference parser innotifications.rsslices only at ASCII</>boundaries and has no panicking path on server text; no tokens or secrets in code or fixtures.notify-rustis the dependency the plan names; cargo-deny green (newzbus5/6 duplicate is a warning only).message_for_unknown_channel_does_not_notifycovers it.cargo xtask ciin the review worktree: green (fmt, clippy, deny, core-isolation, tests; screenshot step skipped becauseFLUXER_SCREENSHOT_TESTSwas not set in my run).Findings
crates/fluxer-core/src/effect.rs:Notificationhas noicon: AvatarSource, which the plan's Interfaces block lists.AvatarSourceis produced by Task 21, which is not in this stack, and nothing merged consumes the field, so no other task breaks. Tracked in #54; adding the field later is a breaking struct-literal change for the tests here, so do it with Task 21's merge.crates/fluxer-platform/src/notify/windows.rs: never compiled (no Windows target here either). I read it against the notify-rust 4.19.0 sources:show()returnswindows::NotificationHandle,wait_for_response(impl ResponseHandler) -> Result<()>andNotificationResponse::is_default_actionexist and the handle isSend, so it should compile, but the Windows runner is the first real compile. The integrator must see that runner green before merge.apps/fluxer/src/runtime.rs:Runtime::newdefaults to the system notifier, soapps/fluxer/tests/runtime.rsand--devserverwould pop real desktop notifications as soon as a scenario contains a DM or a mention (basichas neither today: its one liveMESSAGE_CREATEis an unmentioned guild message). Tests should pass a no-op notifier viawith_notifierbefore such a scenario is added.SelectChannelpath was not exercised by hand (the KDE check only showed the notification); it is covered by unit tests ofClicks,notify_workerandclick_actionsonly. Window raise on click is deferred to #55.crates/fluxer-core/tests/messages.rs: one Task 10 assertion changed from "no effects" to "exactly oneEffect::Notify" for a DM message. Correct consequence of this task, noted because it is outside the Files list.Verdict: approve (0 blocking, 5 minor; local ci green, Windows runner still to be confirmed by the integrator).