Skip to content

fix: don't reload external pages Closes #3299#3300

Open
gaincoder wants to merge 1 commit intoRocketChat:masterfrom
gaincoder:master
Open

fix: don't reload external pages Closes #3299#3300
gaincoder wants to merge 1 commit intoRocketChat:masterfrom
gaincoder:master

Conversation

@gaincoder
Copy link
Copy Markdown

@gaincoder gaincoder commented Apr 14, 2026

On external pages (e.g. SAML/SSO), where window.require is not available, injected.ts fired a force-reload, this fix will avoid that

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced external page detection: The system now identifies non-Meteor pages during recovery operations and handles them gracefully without forcing unnecessary reloads, improving stability.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 14, 2026

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Walkthrough

The injected script now includes a defensive check before force-reloading when window.require remains unavailable after retry timeout. It first verifies if window.__meteor_runtime_config__ exists; if undefined (indicating an external non-Meteor page), it logs and returns without triggering the reload.

Changes

Cohort / File(s) Summary
Injected Script Retry Handler
src/injected.ts
Added conditional check to detect external (non-Meteor) pages before force-reloading. When __meteor_runtime_config__ is undefined, the reload is skipped and a log message is generated; otherwise, original force-reload behavior is preserved.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

Suggested labels

type: bug, area: authentication

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: don't reload external pages' directly and clearly summarizes the main change in the changeset - preventing force-reloads on external pages where window.require is unavailable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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.

Copy link
Copy Markdown
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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/injected.ts`:
- Line 57: Remove the trailing whitespace on the empty line inside the
injected.ts module: delete the spaces so the line is truly blank (or enable
trim-trailing-whitespace/save actions) to satisfy Prettier and linting; then
save/commit the change so CI passes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 940bf340-450b-4a01-99ff-a2a304cd90d7

📥 Commits

Reviewing files that changed from the base of the PR and between d865454 and 6f5a879.

📒 Files selected for processing (1)
  • src/injected.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{ts,tsx}: Use TypeScript for all new code in this codebase unless explicitly told otherwise
Use Fuselage components from @rocket.chat/fuselage for all UI work — only create custom components when Fuselage doesn't provide the needed functionality
Check Theme.d.ts for valid color tokens when working with Fuselage components
Use optional chaining with fallbacks for platform-specific APIs instead of mocks (e.g., process.getuid?.() ?? 1000) to ensure code works across all platforms without requiring mocks
TypeScript code must use strict mode
Use React functional components with hooks instead of class components
Redux actions must follow the FSA (Flux Standard Action) pattern
Use camelCase for file naming
Use PascalCase for component file names (React components)
Write self-documenting code through clear naming — avoid unnecessary comments

Files:

  • src/injected.ts
🧠 Learnings (2)
📓 Common learnings
Learnt from: Ram-sah19
Repo: RocketChat/Rocket.Chat.Electron PR: 3254
File: .github/workflows/build-release.yml:80-94
Timestamp: 2026-03-11T06:38:40.426Z
Learning: In the RocketChat/Rocket.Chat.Electron repository, the issues flagged in `.github/workflows/build-release.yml` (e.g., `node12` runtime in the release action and missing `snapcraft_token` input), i18n files, and `electron-builder.json` are pre-existing in the `develop` branch and are pulled in during merge conflict resolution. Do not flag these as new issues introduced by PRs that only modify `src/injected.ts` and `src/ui/main/rootWindow.ts`.
📚 Learning: 2026-03-11T06:38:40.426Z
Learnt from: Ram-sah19
Repo: RocketChat/Rocket.Chat.Electron PR: 3254
File: .github/workflows/build-release.yml:80-94
Timestamp: 2026-03-11T06:38:40.426Z
Learning: In the RocketChat/Rocket.Chat.Electron repository, the issues flagged in `.github/workflows/build-release.yml` (e.g., `node12` runtime in the release action and missing `snapcraft_token` input), i18n files, and `electron-builder.json` are pre-existing in the `develop` branch and are pulled in during merge conflict resolution. Do not flag these as new issues introduced by PRs that only modify `src/injected.ts` and `src/ui/main/rootWindow.ts`.

Applied to files:

  • src/injected.ts
🪛 ESLint
src/injected.ts

[error] 57-57: Delete ··········

(prettier/prettier)

🔇 Additional comments (1)
src/injected.ts (1)

51-56: Correctly skips force reload on external non-Meteor pages.

This guard is a good fix for SAML/SSO external flows and prevents unwanted reload interruptions.

);
return;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Remove trailing whitespace to unblock Prettier.

Line 57 contains only spaces and is currently flagged by lint.

🧹 Minimal fix
-      
+
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
🧰 Tools
🪛 ESLint

[error] 57-57: Delete ··········

(prettier/prettier)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/injected.ts` at line 57, Remove the trailing whitespace on the empty line
inside the injected.ts module: delete the spaces so the line is truly blank (or
enable trim-trailing-whitespace/save actions) to satisfy Prettier and linting;
then save/commit the change so CI passes.

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