Skip to content

refactor(client): drop the Settings.watch method#40495

Open
ggazzo wants to merge 1 commit into
refactor/settings-watch-to-peekfrom
refactor/drop-settings-watch-method
Open

refactor(client): drop the Settings.watch method#40495
ggazzo wants to merge 1 commit into
refactor/settings-watch-to-peekfrom
refactor/drop-settings-watch-method

Conversation

@ggazzo
Copy link
Copy Markdown
Member

@ggazzo ggazzo commented May 12, 2026

Stacked on top of #40494 (`refactor/settings-watch-to-peek`).

Summary

#40494 took the four obviously-non-reactive client callers of `settings.watch` (room types + account sidebar items) over to `settings.peek`. The remaining six callers in `apps/meteor/app/utils/client/` and `apps/meteor/app/ui-message/client/` are in the exact same shape: they run inside synchronous helper functions called from React render paths, not from `Tracker.autorun`, so the watch-flavoured "Tracker reactivity" never made it back into the UI tree. Switch them to `settings.peek` too:

  • `app/utils/client/getRoomAvatarURL.ts` (`Accounts_RoomAvatarExternalProviderUrl`)
  • `app/utils/client/getURL.ts` (`CDN_PREFIX`, `Site_Url`)
  • `app/utils/client/lib/getUserPreference.ts` (`Accounts_Default_User_Preferences_${key}` fallback)
  • `app/utils/client/restrictions.ts` (`FileUpload_MediaTypeBlackList`, `FileUpload_MediaTypeWhiteList`)
  • `app/ui-message/client/messageBox/messageBoxFormatting.ts` (`Katex_Enabled`)

With every `Settings.watch` caller migrated, drop the method itself from `client/lib/settings/settings.ts` and stop importing `meteor/watch` from there. The bridge file lives on for now — `meteor/user.ts` (`watchUserId` / `watchUser`) is still consumed by `meteor/overrides/userAndUsers.ts`, which exits later with the rest of the overrides folder.

Test plan

  • `yarn eslint` on the 6 changed files: 0 errors.
  • `tsc --noEmit` on `apps/meteor` is clean.
  • `grep "settings\.watch\b"` in `apps/meteor` (excluding server / test fixtures / settings middleware) shows zero matches.
  • Manual: room avatars via `Accounts_RoomAvatarExternalProviderUrl` still load.
  • Manual: KaTeX formatting button toggles via `Katex_Enabled` (one render cycle after the toggle — already the existing behaviour).
  • Manual: file upload validation honours the configured whitelist/blacklist.

Task: ARCH-2144

Summary by CodeRabbit

  • Refactor
    • Updated internal settings access patterns throughout the application to use non-reactive read methods instead of reactive subscriptions across configuration management.

Review Change Stack

#40494 took the four obviously-non-reactive client callers of
settings.watch (room types + account sidebar items) over to settings.peek.
The remaining six callers in apps/meteor/app/utils/client/ and
apps/meteor/app/ui-message/client/ are in the exact same shape: they run
inside synchronous helper functions called from React render paths, not
from Tracker.autorun, so the watch-flavoured "Tracker reactivity" never
made it back into the UI tree. Switch them to settings.peek too:

- app/utils/client/getRoomAvatarURL.ts (Accounts_RoomAvatarExternalProviderUrl)
- app/utils/client/getURL.ts (CDN_PREFIX, Site_Url)
- app/utils/client/lib/getUserPreference.ts (Accounts_Default_User_Preferences_${key} fallback)
- app/utils/client/restrictions.ts (FileUpload_MediaTypeBlackList, FileUpload_MediaTypeWhiteList)
- app/ui-message/client/messageBox/messageBoxFormatting.ts (Katex_Enabled)

With every Settings.watch caller migrated, drop the method itself from
client/lib/settings/settings.ts and stop importing meteor/watch from
there. The bridge file lives on for now — meteor/user.ts (watchUserId /
watchUser) is still consumed by meteor/overrides/userAndUsers.ts, which
exits later with the rest of the overrides folder.
@ggazzo ggazzo requested a review from a team as a code owner May 12, 2026 14:38
@ggazzo
Copy link
Copy Markdown
Member Author

ggazzo commented May 12, 2026

/jira ARCH-2116

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot Bot commented May 12, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 12, 2026

⚠️ No Changeset found

Latest commit: d7de02e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 12, 2026

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: 22fbfd48-84bc-45fa-99c7-f9126c592b90

📥 Commits

Reviewing files that changed from the base of the PR and between 0a5a0e2 and d7de02e.

📒 Files selected for processing (6)
  • apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts
  • apps/meteor/app/utils/client/getRoomAvatarURL.ts
  • apps/meteor/app/utils/client/getURL.ts
  • apps/meteor/app/utils/client/lib/getUserPreference.ts
  • apps/meteor/app/utils/client/restrictions.ts
  • apps/meteor/client/lib/settings/settings.ts
💤 Files with no reviewable changes (1)
  • apps/meteor/client/lib/settings/settings.ts
📜 Recent review details
⏰ 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
🧰 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/app/utils/client/restrictions.ts
  • apps/meteor/app/utils/client/getURL.ts
  • apps/meteor/app/utils/client/lib/getUserPreference.ts
  • apps/meteor/app/utils/client/getRoomAvatarURL.ts
  • apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts
🧠 Learnings (3)
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In the Rocket.Chat repository, do not reference Biome lint rules in code review feedback. Biome is not used even if biome.json exists; only reference Biome rules if there is explicit, project-wide usage documented. For TypeScript files, review lint implications without Biome guidance unless the project enables Biome rules.

Applied to files:

  • apps/meteor/app/utils/client/restrictions.ts
  • apps/meteor/app/utils/client/getURL.ts
  • apps/meteor/app/utils/client/lib/getUserPreference.ts
  • apps/meteor/app/utils/client/getRoomAvatarURL.ts
  • apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts
📚 Learning: 2026-02-26T19:25:44.063Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38778
File: packages/ui-voip/src/providers/useMediaSession.ts:192-192
Timestamp: 2026-02-26T19:25:44.063Z
Learning: In this repository (RocketChat/Rocket.Chat), Biome lint rules are not used even if a biome.json exists. When reviewing TypeScript files (e.g., packages/ui-voip/src/providers/useMediaSession.ts), ensure lint suggestions do not reference Biome-specific rules. Rely on general ESLint/TypeScript lint rules and project conventions instead.

Applied to files:

  • apps/meteor/app/utils/client/restrictions.ts
  • apps/meteor/app/utils/client/getURL.ts
  • apps/meteor/app/utils/client/lib/getUserPreference.ts
  • apps/meteor/app/utils/client/getRoomAvatarURL.ts
  • apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts
📚 Learning: 2026-05-06T12:21:44.083Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 40256
File: apps/meteor/client/components/CreateDiscussion/CreateDiscussion.tsx:121-149
Timestamp: 2026-05-06T12:21:44.083Z
Learning: Field wrappers in rocket.chat/fuselage-forms (Field, FieldLabel, FieldRow, FieldError, FieldHint) auto-create htmlFor/id associations, aria-describedby, and role="alert" for errors. Do not manually set htmlFor, id, aria-describedby, or role attributes when using these wrappers. This automatic wiring does not apply to plain rocket.chat/fuselage components, which require explicit ID wiring per the accessibility docs. In code reviews, prefer using fuselage-forms wrappers for form fields and verify there is no unnecessary manual ID/aria wiring in files that use these wrappers. If a component uses plain fuselage components, ensure proper id wiring as per docs.

Applied to files:

  • apps/meteor/app/utils/client/restrictions.ts
  • apps/meteor/app/utils/client/getURL.ts
  • apps/meteor/app/utils/client/lib/getUserPreference.ts
  • apps/meteor/app/utils/client/getRoomAvatarURL.ts
  • apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts
🔇 Additional comments (5)
apps/meteor/app/utils/client/getRoomAvatarURL.ts (1)

7-7: LGTM!

apps/meteor/app/utils/client/getURL.ts (1)

17-18: LGTM!

apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts (1)

104-104: LGTM!

apps/meteor/app/utils/client/restrictions.ts (1)

5-6: LGTM!

apps/meteor/app/utils/client/lib/getUserPreference.ts (1)

46-46: LGTM!


Walkthrough

Settings class removes the reactive watch() method and all dependent code migrates to non-reactive peek() lookups across KaTeX formatting, room avatar, URL computation, user preferences, and file upload validation.

Changes

Settings API Migration

Layer / File(s) Summary
Settings class API removal
apps/meteor/client/lib/settings/settings.ts
The watch() reactive getter method is removed; imports simplify to only PublicSettings, and peek() becomes the first available settings read API. The class preserves subscription-based init(), callback dispatch, and observe() registration logic.
Consumer migration from watch to peek
apps/meteor/app/ui-message/client/messageBox/messageBoxFormatting.ts, apps/meteor/app/utils/client/getRoomAvatarURL.ts, apps/meteor/app/utils/client/getURL.ts, apps/meteor/app/utils/client/lib/getUserPreference.ts, apps/meteor/app/utils/client/restrictions.ts
Five modules switch settings reads from settings.watch(...) to settings.peek(...): KaTeX button eligibility, room avatar URL provider config, CDN and Site URL configuration, user preference defaults, and file upload media type filtering.

🎯 2 (Simple) | ⏱️ ~10 minutes

type: chore

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: removing the Settings.watch method from the client settings module.
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.

✏️ 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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.63%. Comparing base (0a5a0e2) to head (d7de02e).

Additional details and impacted files

Impacted file tree graph

@@                       Coverage Diff                        @@
##           refactor/settings-watch-to-peek   #40495   +/-   ##
================================================================
  Coverage                            69.63%   69.63%           
================================================================
  Files                                 3318     3318           
  Lines                               121972   121948   -24     
  Branches                             21805    21786   -19     
================================================================
- Hits                                 84931    84916   -15     
+ Misses                               33712    33710    -2     
+ Partials                              3329     3322    -7     
Flag Coverage Δ
unit 70.44% <100.00%> (+0.01%) ⬆️

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.

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.

1 participant