Skip to content

Conversation

@yash-rajpal
Copy link
Member

@yash-rajpal yash-rajpal commented Dec 8, 2025

Proposed changes (including videos or screenshots)

When Rocket.Chat is embedded in web clients, Rocket.Chat is supposed to emit a startup event upon loading to inform the parent window when Rocket.Chat is ready. Currently we were not emitting this event as expected.
This PR fixes this issue and moves the implementation to react.

Issue(s)

Steps to test or reproduce

  • Embed Rocket.Chat into a web page
  • Listen the events emitted by the Rocket.Chat iframe
  • startup event is not emitted.

Further comments

CORE-1536

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where the global startup event was not dispatched on client initialization; startup-dependent behaviors now reliably receive the startup notification.
    • Ensured the startup event is triggered at the correct point in the app lifecycle to improve reliability of components that run on initial load.

✏️ Tip: You can customize this high-level summary in your review settings.

@dionisio-bot
Copy link
Contributor

dionisio-bot bot commented Dec 8, 2025

Looks like this PR is ready to merge! 🎉
If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link

changeset-bot bot commented Dec 8, 2025

🦋 Changeset detected

Latest commit: de9d15d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 41 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings Patch
@rocket.chat/uikit-playground Patch
@rocket.chat/api-client Patch
@rocket.chat/apps Patch
@rocket.chat/core-services Patch
@rocket.chat/cron Patch
@rocket.chat/ddp-client Patch
@rocket.chat/freeswitch Patch
@rocket.chat/fuselage-ui-kit Patch
@rocket.chat/gazzodown Patch
@rocket.chat/http-router Patch
@rocket.chat/livechat Patch
@rocket.chat/model-typings Patch
@rocket.chat/ui-avatar Patch
@rocket.chat/ui-client Patch
@rocket.chat/ui-contexts Patch
@rocket.chat/web-ui-registration Patch
@rocket.chat/account-service Patch
@rocket.chat/authorization-service Patch
@rocket.chat/ddp-streamer Patch
@rocket.chat/omnichannel-transcript Patch
@rocket.chat/presence-service Patch
@rocket.chat/queue-worker Patch
@rocket.chat/stream-hub-service Patch
@rocket.chat/federation-matrix Patch
@rocket.chat/license Patch
@rocket.chat/media-calls Patch
@rocket.chat/omnichannel-services Patch
@rocket.chat/pdf-worker Patch
@rocket.chat/presence Patch
rocketchat-services Patch
@rocket.chat/models Patch
@rocket.chat/network-broker Patch
@rocket.chat/omni-core-ee Patch
@rocket.chat/mock-providers Patch
@rocket.chat/ui-video-conf Patch
@rocket.chat/ui-voip Patch
@rocket.chat/instance-status Patch
@rocket.chat/omni-core Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 8, 2025

Walkthrough

The PR moves the global startup event dispatch from the initial Meteor.startup invocation into a React lifecycle hook mounted in AppLayout, restoring the iframe startup message by firing the event when the root component mounts.

Changes

Cohort / File(s) Summary
Changeset
/.changeset/tender-wolves-promise.md
Adds a patch-level changeset documenting the fix for the missing startup iframe event.
Startup wiring
apps/meteor/client/startup/startup.ts
Removed the direct fireGlobalEvent('startup', true) call from Meteor.startup.
AppLayout integration
apps/meteor/client/views/root/AppLayout.tsx
Imported and invoked the new useStartupEvent hook so the startup event is dispatched when the root component mounts.
New hook
apps/meteor/client/views/root/hooks/useStartupEvent.ts
Added useStartupEvent — a React hook that uses useEffect + useFireGlobalEvent to dispatch the global startup event on mount.

Sequence Diagram(s)

sequenceDiagram
  participant App as AppLayout (React)
  participant StartupHook as useStartupEvent
  participant Global as fireGlobalEvent / postMessage
  participant Parent as Parent window (iframe listener)

  App ->> StartupHook: mount (useEffect)
  StartupHook ->> Global: fireGlobalEvent('startup', true)
  Global ->> Parent: window.postMessage({ eventName: 'startup', ... })
  Parent -->> Parent: parent receives startup event
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check timing/race conditions between AppLayout mount and iframe parent expecting startup.
  • Verify useStartupEvent fires exactly once and integrates with existing useFireGlobalEvent behavior.
  • Confirm removal from startup.ts doesn't affect other startup side effects or tests.

Possibly related PRs

  • #37354: Modifies apps/meteor/client/views/root/AppLayout.tsx to add/relocate lifecycle hooks; likely code-level overlap with this AppLayout change.

Suggested labels

stat: ready to merge, stat: QA assured

Suggested reviewers

  • tassoevan
  • ggazzo
  • MartinSchoeler

Poem

🐰 I hopped from startup to React's warm light,
A tiny event sent into the night,
The iframe now wakes with a cheerful chime,
Startup returned — right on mounting time! 🎉

Pre-merge checks and finishing touches

✅ 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 'fix: startup iframe event' clearly and concisely describes the main objective of the PR—restoring the missing startup iframe event.
Linked Issues check ✅ Passed The PR successfully addresses all coding requirements from issues #36881 and CORE-1536: restores the startup iframe event emission and unblocks login-with-token integrations.
Out of Scope Changes check ✅ Passed All changes are directly related to restoring the startup iframe event; no unrelated modifications detected beyond the stated objectives.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch chore/startup-event

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 84d0ce2 and 157d407.

📒 Files selected for processing (1)
  • apps/meteor/client/views/root/hooks/useStartupEvent.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/meteor/client/views/root/hooks/useStartupEvent.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build

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 and usage tips.

@yash-rajpal yash-rajpal marked this pull request as ready for review December 8, 2025 12:13
@yash-rajpal yash-rajpal requested a review from a team as a code owner December 8, 2025 12:13
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Jira integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between f99a203 and 84d0ce2.

📒 Files selected for processing (4)
  • .changeset/tender-wolves-promise.md (1 hunks)
  • apps/meteor/client/startup/startup.ts (0 hunks)
  • apps/meteor/client/views/root/AppLayout.tsx (2 hunks)
  • apps/meteor/client/views/root/hooks/useStartupEvent.ts (1 hunks)
💤 Files with no reviewable changes (1)
  • apps/meteor/client/startup/startup.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)

**/*.{ts,tsx,js}: Write concise, technical TypeScript/JavaScript with accurate typing in Playwright tests
Avoid code comments in the implementation

Files:

  • apps/meteor/client/views/root/hooks/useStartupEvent.ts
  • apps/meteor/client/views/root/AppLayout.tsx
🧬 Code graph analysis (1)
apps/meteor/client/views/root/AppLayout.tsx (1)
apps/meteor/client/views/root/hooks/useStartupEvent.ts (1)
  • useStartupEvent (5-11)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: 🔨 Test Unit / Unit Tests
  • GitHub Check: 🔎 Code Check / TypeScript
  • GitHub Check: 🔎 Code Check / Code Lint
  • GitHub Check: 🔨 Test Storybook / Test Storybook
  • GitHub Check: 📦 Meteor Build (coverage)
  • GitHub Check: CodeQL-Build
  • GitHub Check: CodeQL-Build
🔇 Additional comments (2)
.changeset/tender-wolves-promise.md (1)

1-5: LGTM!

The changeset properly documents this as a patch-level fix for the missing startup iframe event dispatch.

apps/meteor/client/views/root/AppLayout.tsx (1)

33-33: LGTM! Hook integration is correct.

The useStartupEvent hook is properly imported and invoked in the AppLayout component. While it's called late in the hook sequence (line 73), all hooks execute during the render phase before the component mounts, so the startup event will still fire when the component mounts.

Also applies to: 73-73

@github-actions
Copy link
Contributor

github-actions bot commented Dec 8, 2025

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.2GiB 1.2GiB +12MiB
rocketchat 359MiB 347MiB +12MiB
omnichannel-transcript-service 132MiB 132MiB -2.6KiB
queue-worker-service 132MiB 132MiB -272B
ddp-streamer-service 126MiB 126MiB +1.4KiB
account-service 113MiB 113MiB -270B
stream-hub-service 111MiB 111MiB -1.2KiB
authorization-service 111MiB 111MiB +1B
presence-service 111MiB 111MiB -479B

📊 Historical Trend

---
config:
  theme: "dark"
  xyChart:
    width: 900
    height: 400
---
xychart
  title "Image Size Evolution by Service (Last 30 Days + This PR)"
  x-axis ["11/15 22:28", "11/16 01:28", "11/17 23:50", "11/18 22:53", "11/19 23:02", "11/21 16:49", "11/24 17:34", "11/27 22:32", "11/28 19:05", "12/01 23:01", "12/02 21:57", "12/03 21:00", "12/04 18:17", "12/05 21:56", "12/08 16:42", "12/08 17:36 (PR)"]
  y-axis "Size (GB)" 0 --> 0.5
  line "account-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "authorization-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "ddp-streamer-service" [0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12, 0.12]
  line "omnichannel-transcript-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "presence-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
  line "queue-worker-service" [0.14, 0.14, 0.14, 0.14, 0.14, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13]
  line "rocketchat" [0.36, 0.36, 0.35, 0.35, 0.35, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.35]
  line "stream-hub-service" [0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11, 0.11]
Loading

Statistics (last 15 days):

  • 📊 Average: 1.5GiB
  • ⬇️ Minimum: 1.2GiB
  • ⬆️ Maximum: 1.6GiB
  • 🎯 Current PR: 1.2GiB
ℹ️ About this report

This report compares Docker image sizes from this build against the develop baseline.

  • Tag: pr-37718
  • Baseline: develop
  • Timestamp: 2025-12-08 17:36:37 UTC
  • Historical data points: 15

Updated: Mon, 08 Dec 2025 17:36:37 GMT

@gabriellsh gabriellsh changed the title fix: 'startup` iframe event fix: startup iframe event Dec 8, 2025
@codecov
Copy link

codecov bot commented Dec 8, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.80%. Comparing base (d0be8ad) to head (de9d15d).
⚠️ Report is 7 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #37718      +/-   ##
===========================================
+ Coverage    67.78%   67.80%   +0.02%     
===========================================
  Files         3449     3450       +1     
  Lines       113987   113976      -11     
  Branches     20956    20955       -1     
===========================================
+ Hits         77262    77279      +17     
+ Misses       34610    34577      -33     
- Partials      2115     2120       +5     
Flag Coverage Δ
e2e 57.32% <100.00%> (+0.09%) ⬆️
e2e-api 42.13% <ø> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com>
@alfredodelfabro alfredodelfabro added this to the 7.14.0 milestone Dec 8, 2025
@juliajforesti juliajforesti added the stat: QA assured Means it has been tested and approved by a company insider label Dec 8, 2025
@dionisio-bot dionisio-bot bot added the stat: ready to merge PR tested and approved waiting for merge label Dec 8, 2025
@kodiakhq kodiakhq bot merged commit 27e4252 into develop Dec 8, 2025
48 checks passed
@kodiakhq kodiakhq bot deleted the chore/startup-event branch December 8, 2025 18:03
@dougfabris dougfabris modified the milestones: 7.14.0, 8.0.0 Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stat: QA assured Means it has been tested and approved by a company insider stat: ready to merge PR tested and approved waiting for merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing startup iframe event since 7.9.0

6 participants