Skip to content

Revert "fix: ContextualBar state and refresh behavior on custom sounds (#38442)"#38818

Merged
ggazzo merged 2 commits intodevelopfrom
revert-38442-fix/custom-sounds-bug
Feb 19, 2026
Merged

Revert "fix: ContextualBar state and refresh behavior on custom sounds (#38442)"#38818
ggazzo merged 2 commits intodevelopfrom
revert-38442-fix/custom-sounds-bug

Conversation

@nazabucciarelli
Copy link
Copy Markdown
Contributor

@nazabucciarelli nazabucciarelli commented Feb 19, 2026

Issue

I need to rollback this PR (#38442) in order to merge the cleaner version of these fixes:
CORE-1819 Address technical debt following CORE-1789 (custom-sounds single resource fetch)

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Modified custom sounds query parameter handling to accept name-based searches only; direct _id parameter queries are no longer supported.
    • Updated custom sounds upload modal behavior to remain open after file upload completion.
  • Changes

    • Updated custom sound edit component to make the close callback optional.

@nazabucciarelli nazabucciarelli added this to the 8.2.0 milestone Feb 19, 2026
@nazabucciarelli nazabucciarelli requested review from a team as code owners February 19, 2026 19:15
@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Feb 19, 2026

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

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Feb 19, 2026

⚠️ No Changeset found

Latest commit: 5dbc06f

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 Feb 19, 2026

Walkthrough

Changes remove _id query parameter support from the custom-sounds list endpoint and related test coverage. UI components no longer explicitly close after save actions and now refetch data instead. The close prop is made optional across sound editing components.

Changes

Cohort / File(s) Summary
API Endpoint & Tests
apps/meteor/app/api/server/v1/custom-sounds.ts, apps/meteor/tests/end-to-end/api/custom-sounds.ts
Removed _id parameter handling from custom-sounds.list endpoint query type and filter logic. Deleted test case that verified fetching by _id. Querying by name with case-insensitive regex remains supported.
UI Components – Sound Management
apps/meteor/client/views/admin/customSounds/AddCustomSound.tsx, apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx, apps/meteor/client/views/admin/customSounds/EditSound.tsx
Removed close() invocations from save paths in AddCustomSound and EditSound. Made close prop optional across all components. Added refetch logic to EditCustomSound to refresh data on changes.
Changelog
.changeset/hip-melons-bow.md
Removed changelog entry for custom sounds contextbar state and refresh behavior fixes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Technical debt we shed with care,
_id parameters? Removed from there!
Refetch flows now keep things fresh,
No more closes—just a mesh.
Cleaner code hops through the air! 🌟

🚥 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.
Linked Issues check ✅ Passed The PR successfully reverts the previous fix to address CORE-1819's requirement of removing single-resource fetching logic from custom-sounds.list and creating a dedicated endpoint instead.
Out of Scope Changes check ✅ Passed All changes are in-scope: they revert the previous fix by removing _id filtering from the API, removing close() calls from client components, making close optional, and removing related tests.
Title check ✅ Passed The pull request title clearly and accurately describes the main change: reverting a specific previous commit related to custom sounds contextual bar behavior.

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

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 6 files

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx (1)

19-29: ⚠️ Potential issue | 🟠 Major

Query fires with no guard when _id is undefined, populating the form with an arbitrary sound.

_id is typed string | undefined. When it is undefined, JSON.stringify({ _id: undefined }) produces '{}' (JSON.stringify silently drops undefined values), so the list query runs unrestricted and sounds[0] returns whichever sound sorts first — silently mis-populating the edit form.

Add an enabled guard so the query is suppressed until a valid _id is available:

🐛 Proposed fix
 const { data, isPending, refetch } = useQuery({
     queryKey: ['custom-sounds', _id],
+    enabled: !!_id,
     queryFn: async () => {
         const { sounds } = await getSounds({ query: JSON.stringify({ _id }) });
 
         if (sounds.length === 0) {
             throw new Error(t('No_results_found'));
         }
         return sounds[0];
     },
     meta: { apiErrorToastMessage: true },
 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx` around lines
19 - 29, The useQuery call in EditCustomSound.tsx fires when _id is undefined,
causing getSounds to receive '{}' and returning the wrong sound; update the
useQuery invocation (the hook that destructures { data, isPending, refetch }) to
include an enabled guard that only runs when a valid _id exists (e.g., enabled:
Boolean(_id) or typeof _id === 'string'), so the queryFn (which calls getSounds
and returns sounds[0]) is suppressed until _id is defined.
apps/meteor/client/views/admin/customSounds/EditSound.tsx (1)

152-152: ⚠️ Potential issue | 🟡 Minor

Cancel button is silently non-functional when close is not provided.

close is now optional, so when the component renders without a close prop, this button becomes a no-op click target with no visual indication to the user. Consider guarding or rendering the button conditionally:

💡 Proposed fix
-<Button onClick={close}>{t('Cancel')}</Button>
+{close && <Button onClick={close}>{t('Cancel')}</Button>}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/meteor/client/views/admin/customSounds/EditSound.tsx` at line 152, The
Cancel Button inside the EditSound component currently calls an optional prop
close and becomes a silent no-op when close is undefined; update the JSX around
the Button (the Button that calls close) to either render the Button only when
the close prop exists or render a disabled/aria-disabled Button with an
explanatory title/tooltip when close is absent, so users get a visible
affordance—locate the EditSound component and the Button that references close
and implement the conditional render or disable logic accordingly.
🧹 Nitpick comments (1)
apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx (1)

41-44: handleChange recreated on every render; wrap in useCallback.

Without memoisation, every render of EditCustomSound produces a new handleChange reference. Because EditSound has onChange in the useCallback dependency arrays for both handleSave and handleDeleteButtonClick, those callbacks also recreate on every parent render — creating an avoidable re-render cascade.

♻️ Proposed fix
-const handleChange: () => void = () => {
-    onChange?.();
-    refetch?.();
-};
+import { useCallback } from 'react';
+// (add useCallback to existing import)
+
+const handleChange = useCallback(() => {
+    onChange?.();
+    refetch();
+}, [onChange, refetch]);

Note: refetch from useQuery is always a stable function reference — the ?. optional-chaining is also unnecessary here.

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

In `@apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx` around lines
41 - 44, The handleChange function in EditCustomSound is recreated every render;
wrap it in useCallback to stabilize its reference so handleSave and
handleDeleteButtonClick no longer re-create on each parent render. Replace the
current const handleChange = () => { onChange?.(); refetch?.(); } with a
useCallback that calls onChange (if present) and refetch (no optional chaining)
and list onChange in the dependency array — e.g. useCallback(() => {
onChange?.(); refetch(); }, [onChange]) — so handleChange remains stable across
renders.
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2f8d686 and e76e5e1.

📒 Files selected for processing (6)
  • .changeset/hip-melons-bow.md
  • apps/meteor/app/api/server/v1/custom-sounds.ts
  • apps/meteor/client/views/admin/customSounds/AddCustomSound.tsx
  • apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx
  • apps/meteor/client/views/admin/customSounds/EditSound.tsx
  • apps/meteor/tests/end-to-end/api/custom-sounds.ts
💤 Files with no reviewable changes (3)
  • apps/meteor/tests/end-to-end/api/custom-sounds.ts
  • apps/meteor/client/views/admin/customSounds/AddCustomSound.tsx
  • .changeset/hip-melons-bow.md
🧰 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/api/server/v1/custom-sounds.ts
  • apps/meteor/client/views/admin/customSounds/EditSound.tsx
  • apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx
🧠 Learnings (1)
📚 Learning: 2026-01-17T01:51:47.764Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38219
File: packages/core-typings/src/cloud/Announcement.ts:5-6
Timestamp: 2026-01-17T01:51:47.764Z
Learning: In packages/core-typings/src/cloud/Announcement.ts, the AnnouncementSchema.createdBy field intentionally overrides IBannerSchema.createdBy (object with _id and optional username) with a string enum ['cloud', 'system'] to match existing runtime behavior. This is documented as technical debt with a FIXME comment at apps/meteor/app/cloud/server/functions/syncWorkspace/handleCommsSync.ts:53 and should not be flagged as an error until the runtime behavior is corrected.

Applied to files:

  • apps/meteor/app/api/server/v1/custom-sounds.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). (2)
  • GitHub Check: 📦 Build Packages
  • GitHub Check: CodeQL-Build
🔇 Additional comments (2)
apps/meteor/app/api/server/v1/custom-sounds.ts (1)

16-16: LGTM — _id cleanly removed from type and schema.

The narrowing of CustomSoundsList to PaginatedRequest<{ name?: string }> combined with additionalProperties: false on the schema correctly rejects any stray _id root-level query parameter. The generic query string param (handled by parseJsonQuery) remains available for callers that need richer MongoDB-style filters.

apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx (1)

23-23: The query parameter is deprecated and only functions with explicit environment variable enablement.

parseJsonQuery requires the ALLOW_UNSAFE_QUERY_AND_FIELDS_API_PARAMS=TRUE environment variable to parse the query parameter at all (lines 116-130 of parseJsonQuery.ts). Without it, the query remains empty in production. When enabled, the parameter is sanitized via the clean() function, which removes dangerous properties and filters out MongoDB operators not in the allowlist (['$or', '$and', '$regex']). However, field-level filtering including _id is allowed since it's not in the API's excluded fields list. The deprecation notice targets version 9.0.0 removal.

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

Inline comments:
In `@apps/meteor/client/views/admin/customSounds/EditSound.tsx`:
- Around line 97-100: The handler handleSave currently calls the async
saveAction in a fire-and-forget manner causing onChange()/refetch to run before
the save completes; update handleSave (the useCallback that references
saveAction, sound, onChange) to await saveAction(sound) and only call onChange()
after the await (and handle/rethrow/log any errors as appropriate) so that
EditCustomSound's refetch runs after the server mutation has committed.

---

Outside diff comments:
In `@apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx`:
- Around line 19-29: The useQuery call in EditCustomSound.tsx fires when _id is
undefined, causing getSounds to receive '{}' and returning the wrong sound;
update the useQuery invocation (the hook that destructures { data, isPending,
refetch }) to include an enabled guard that only runs when a valid _id exists
(e.g., enabled: Boolean(_id) or typeof _id === 'string'), so the queryFn (which
calls getSounds and returns sounds[0]) is suppressed until _id is defined.

In `@apps/meteor/client/views/admin/customSounds/EditSound.tsx`:
- Line 152: The Cancel Button inside the EditSound component currently calls an
optional prop close and becomes a silent no-op when close is undefined; update
the JSX around the Button (the Button that calls close) to either render the
Button only when the close prop exists or render a disabled/aria-disabled Button
with an explanatory title/tooltip when close is absent, so users get a visible
affordance—locate the EditSound component and the Button that references close
and implement the conditional render or disable logic accordingly.

---

Nitpick comments:
In `@apps/meteor/client/views/admin/customSounds/EditCustomSound.tsx`:
- Around line 41-44: The handleChange function in EditCustomSound is recreated
every render; wrap it in useCallback to stabilize its reference so handleSave
and handleDeleteButtonClick no longer re-create on each parent render. Replace
the current const handleChange = () => { onChange?.(); refetch?.(); } with a
useCallback that calls onChange (if present) and refetch (no optional chaining)
and list onChange in the dependency array — e.g. useCallback(() => {
onChange?.(); refetch(); }, [onChange]) — so handleChange remains stable across
renders.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.55%. Comparing base (ef86e77) to head (5dbc06f).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop   #38818      +/-   ##
===========================================
- Coverage    70.58%   70.55%   -0.04%     
===========================================
  Files         3182     3182              
  Lines       112430   112467      +37     
  Branches     20375    20390      +15     
===========================================
- Hits         79361    79351      -10     
- Misses       31017    31064      +47     
  Partials      2052     2052              
Flag Coverage Δ
unit 71.55% <ø> (+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.

@nazabucciarelli nazabucciarelli changed the title regression: Revert "fix: ContextualBar state and refresh behavior on custom sounds" chore: revert "fix: ContextualBar state and refresh behavior on custom sounds" Feb 19, 2026
@github-actions
Copy link
Copy Markdown
Contributor

📦 Docker Image Size Report

📈 Changes

Service Current Baseline Change Percent
sum of all images 1.1GiB 1.1GiB +11MiB
rocketchat 360MiB 349MiB +11MiB
omnichannel-transcript-service 134MiB 134MiB -2.1KiB
queue-worker-service 134MiB 134MiB +542B
ddp-streamer-service 128MiB 128MiB -319B
account-service 115MiB 115MiB +3.6KiB
authorization-service 112MiB 112MiB -1.4KiB
presence-service 112MiB 112MiB +660B

📊 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/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 20:15", "12/09 22:17", "12/10 23:26", "12/11 21:56", "12/12 22:45", "12/13 01:34", "12/15 22:31", "12/16 22:18", "12/17 21:04", "12/18 23:12", "12/19 23:27", "12/20 21:03", "12/22 18:54", "12/23 16:16", "12/24 19:38", "12/25 17:51", "12/26 13:18", "12/29 19:01", "12/30 20:52", "02/12 22:57", "02/13 22:38", "02/16 14:04", "02/18 23:15", "02/19 19:22", "02/19 19:28 (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, 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, 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, 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.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 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, 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.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 0.13, 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.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.34, 0.35]
Loading

Statistics (last 30 days):

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

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

  • Tag: pr-38818
  • Baseline: develop
  • Timestamp: 2026-02-19 19:28:56 UTC
  • Historical data points: 30

Updated: Thu, 19 Feb 2026 19:28:56 GMT

@ggazzo ggazzo changed the title chore: revert "fix: ContextualBar state and refresh behavior on custom sounds" Revert "fix: ContextualBar state and refresh behavior on custom sounds (#38442)" Feb 19, 2026
@nazabucciarelli nazabucciarelli added stat: ready to merge PR tested and approved waiting for merge stat: QA assured Means it has been tested and approved by a company insider labels Feb 19, 2026
@ggazzo ggazzo merged commit 968d73c into develop Feb 19, 2026
7 of 8 checks passed
@ggazzo ggazzo deleted the revert-38442-fix/custom-sounds-bug branch February 19, 2026 21:16
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.

4 participants