FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: dedupe duplicated notification reply events on Windows by jeanfbrito · Pull Request #3420 · RocketChat/Rocket.Chat.Electron · GitHub

fix: dedupe duplicated notification reply events on Windows - #3420

Merged
jeanfbrito merged 1 commit into
hotfix/4.15.6from
fix/windows-notification-reply-duplicated
Jul 16, 2026
Merged

fix: dedupe duplicated notification reply events on Windows#3420
jeanfbrito merged 1 commit into
hotfix/4.15.6from
fix/windows-notification-reply-duplicated

Conversation

jeanfbrito commented Jul 16, 2026
edited by coderabbitai Bot
Loading

Copy link
Copy Markdown
Member

What

Replying to a desktop notification on Windows sent the message twice.

Why

The 4.15.x line ships Electron 42.5.0. Before Electron 42, inline-reply events from Windows toasts were not dispatched at all on non-MSIX installs; electron/electron#51286 (landed in 42) enabled them, but a single user reply can now be delivered more than once to the app:

  • both the WinRT in-process activation path and the COM toast-activator path can dispatch the same reply, with no upstream dedupe, and
  • re-showing the same Notification instance (our same-tag update path in src/notifications/main.ts) registers additional toast event handlers, and per Electron docs the reply event "can be fired multiple times".

Each duplicated 'reply' event flowed main → preload → webapp (that chain is strictly 1:1) and the webapp sent the message once per event.

How

Idempotency guard at the source boundary in the main process: a repliedNotifications set keyed by notification id.

  • 'reply' listener dispatches NOTIFICATIONS_NOTIFICATION_REPLIED only for ids not in the set.
  • The set entry is cleared on 'show' (each display cycle re-arms the reply), so replying again to a re-displayed notification still works.
  • Deliberately not cleared on 'close': the duplicate event can arrive after the toast dismisses, so clearing there would let it through.

Cross-platform by design — a second reply within one show-cycle is never a legitimate user action (submitting a reply dismisses the toast on every OS).

Testing

  • New main-process spec src/notifications/main/main.spec.ts driving the real setupNotifications() → create-requested → listener path: duplicate 'reply' dispatches exactly once; a subsequent 'show' re-arms the guard.
  • tsc --noEmit, targeted Jest, and ESLint pass on the 4.15.5 base.
  • Runtime toast behavior on Windows still needs validation with a signed installer — hence build-artifacts.

Release

Targets hotfix/4.15.6 (branched from the 4.15.5 tag) for a 4.15.6 patch release. Should also be cherry-picked to master (applies clean; src/notifications/main.ts is identical there).

Summary by CodeRabbit

  • Bug Fixes

    • Prevented duplicate notification reply events from triggering repeated actions.
    • Reply handling is correctly reset when a notification is shown again.
  • Tests

    • Added regression coverage for duplicate replies and notification re-display behavior.

Electron 42 can dispatch a single Windows toast inline reply more than
once (WinRT and COM activation paths both fire after electron/electron#51286,
and re-showing a notification instance registers additional toast handlers).
Each duplicated 'reply' event reached the webapp and sent the message twice.

Guard NOTIFICATIONS_NOTIFICATION_REPLIED dispatch with a per-notification
replied set, re-armed on each 'show' so replies from a re-displayed
notification still work. Deliberately not cleared on 'close': the duplicate
event can arrive after the toast dismisses, so clearing there would reopen
the race.

coderabbitai Bot commented Jul 16, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info ⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: baaef9b1-b9df-4b54-9d90-c12b2483c318

📥 Commits

Reviewing files that changed from the base of the PR and between 1061ba1 and 7d304b9.

📒 Files selected for processing (2)
  • src/notifications/main.ts
  • src/notifications/main/main.spec.ts
📜 Recent review details ⏰ Context from checks skipped due to timeout. (6)
  • GitHub Check: check (ubuntu-latest)
  • GitHub Check: check (windows-latest)
  • GitHub Check: check (macos-latest)
  • GitHub Check: build (macos-latest, mac)
  • GitHub Check: build (windows-latest, windows)
  • GitHub Check: build (ubuntu-latest, linux)
🧰 Additional context used 📓 Path-based instructions (5) **/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Use TypeScript for new code unless explicitly told otherwise.
Use Fuselage components from @rocket.chat/fuselage for UI work unless the design requires something Fuselage does not provide.
Check Theme.d.ts for valid color tokens before using Fuselage colors.
Verify library props, APIs, and tokens against official docs or local .d.ts files instead of assuming.
Use React functional components with hooks.
Redux actions follow FSA shape.
Use camelCase for file names and PascalCase for components.
Prefer clear names over unnecessary comments.
Prefer editing existing files over creating new abstractions unless the new abstraction removes real complexity or matches an existing pattern.

**/*.{ts,tsx}: Use TypeScript for all new code unless explicitly told otherwise.
Use Fuselage components for all UI work; create custom components only when Fuselage lacks the required functionality.
Import Fuselage components from @rocket.chat/fuselage.
Use only valid color tokens documented by Theme.d.ts.
Use optional chaining with fallbacks for platform-specific APIs, especially Linux-only process APIs such as process.getuid(), getgid(), geteuid(), and getegid().
Use TypeScript strict mode.
Redux actions must follow the Flux Standard Action pattern.
Use camelCase for file names and PascalCase for component names.
Avoid unnecessary comments; prefer self-documenting code through clear naming.
Do not commit or push without explicit user permission.
Verify library APIs, props, tokens, and types against official documentation and .d.ts files instead of assuming they are valid.

Files:

  • src/notifications/main/main.spec.ts
  • src/notifications/main.ts
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Renderer specs use *.spec.ts / *.spec.tsx.

Files:

  • src/notifications/main/main.spec.ts
src/*/*/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Renderer specs must live in a Jest-matched nested path, such as src/<module>/<subdir>/*.spec.ts(x); flat src/<module>/*.spec.ts files are not discovered by the current testMatch.

Files:

  • src/notifications/main/main.spec.ts
**/*.spec.ts

📄 CodeRabbit inference engine (CLAUDE.md)

Use *.spec.ts for renderer process tests.

Files:

  • src/notifications/main/main.spec.ts
src/**/*.{spec.ts,spec.tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Renderer test files should be placed in nested module paths such as src/<module>/<subdir>/*.spec.ts(x) so Jest discovers them.

Files:

  • src/notifications/main/main.spec.ts
🔇 Additional comments (2)
src/notifications/main.ts (1)

51-51: LGTM!

Also applies to: 83-84, 132-137

src/notifications/main/main.spec.ts (1)

1-140: LGTM!


Walkthrough

Notification reply handling now suppresses duplicate reply events per notification id, resets that tracking when the notification is shown, and adds mocked main-process regression tests for both behaviors.

Changes

Notification reply deduplication

Layer / File(s) Summary
Reply guard lifecycle
src/notifications/main.ts
Tracks handled notification ids, clears each id on show, and dispatches only the first reply event for an id.
Reply guard regression coverage
src/notifications/main/main.spec.ts
Mocks the notification flow and verifies duplicate replies dispatch once while a later show permits another reply dispatch.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: type: bug

🚥 Pre-merge checks | ✅ 5 ✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: deduplicating duplicate notification reply events on Windows.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copy link
Copy Markdown

Copy link
Copy Markdown

macOS installer download

jeanfbrito merged commit b62b165 into hotfix/4.15.6 Jul 16, 2026
8 checks passed
jeanfbrito deleted the fix/windows-notification-reply-duplicated branch July 16, 2026 22:11
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL