Skip to content

fix(audit): forward visitor and agent fields in Omnichannel audit mutation - #41665

Open
surjeetkumar8006 wants to merge 1 commit into
RocketChat:developfrom
surjeetkumar8006:fix/omnichannel-audit-visitor-agent-filter
Open

fix(audit): forward visitor and agent fields in Omnichannel audit mutation#41665
surjeetkumar8006 wants to merge 1 commit into
RocketChat:developfrom
surjeetkumar8006:fix/omnichannel-audit-visitor-agent-filter

Conversation

@surjeetkumar8006

@surjeetkumar8006 surjeetkumar8006 commented Aug 3, 2026

Copy link
Copy Markdown

Proposal
Fixes Omnichannel audit filtering by forwarding visitor and agent parameters to the REST API endpoint, resolving #41583.

Endpoints
/v1/audit.omnichannelMessages

Notes

  • Forward visitor and agent fields collected from the Omnichannel audit form in useAuditMutation.ts to getOmnichannelAuditMessages.
  • Remove hardcoded empty strings and TODO comment in useAuditMutation.ts.
  • Add changeset for patch release.

Task: #41583

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Omnichannel audit logs now correctly filter results by the selected visitor and agent.
    • Audit requests now retain the chosen filter values when retrieving messages.

@surjeetkumar8006
surjeetkumar8006 requested a review from a team as a code owner August 3, 2026 14:09
@dionisio-bot

dionisio-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@changeset-bot

changeset-bot Bot commented Aug 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6c1551c

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

This PR includes changesets to release 3 packages
Name Type
@rocket.chat/meteor Patch
@rocket.chat/core-typings Patch
@rocket.chat/rest-typings 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

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

The omnichannel audit mutation now forwards selected visitor and agent IDs to the audit messages API. A patch changeset documents the fix.

Changes

Omnichannel audit filtering

Layer / File(s) Summary
Forward selected audit filters
apps/meteor/client/views/audit/hooks/useAuditMutation.ts, .changeset/omnichannel-audit-visitor-agent-filtering.md
The audit request uses the mutation’s visitor and agent values instead of empty strings. The changeset documents the patch release.

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

Possibly related issues

Possibly related PRs

Suggested labels: type: bug

Suggested reviewers: ggazzo, martinschoeler

🚥 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 and concisely describes the main change: forwarding visitor and agent fields in the Omnichannel audit mutation.
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.

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.

@coderabbitai coderabbitai Bot left a comment

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.

🧹 Nitpick comments (1)
apps/meteor/client/views/audit/hooks/useAuditMutation.ts (1)

26-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a regression test for the forwarded filters.

When the audit mutation receives non-empty visitor and agent values, assert that both values are included in the POST /v1/audit.omnichannelMessages request. The supplied endpoint tests cover requests with users, but do not verify this new forwarding path.

Based on the supplied endpoint tests, add coverage for the new visitor and agent request fields.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/meteor/client/views/audit/hooks/useAuditMutation.ts` around lines 26 -
27, Add a regression test for the audit mutation’s forwarded filters, covering
non-empty visitor and agent values and asserting both are included in the POST
/v1/audit.omnichannelMessages request. Extend the existing endpoint test
coverage near the audit mutation tests without altering the users-field
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/meteor/client/views/audit/hooks/useAuditMutation.ts`:
- Around line 26-27: Add a regression test for the audit mutation’s forwarded
filters, covering non-empty visitor and agent values and asserting both are
included in the POST /v1/audit.omnichannelMessages request. Extend the existing
endpoint test coverage near the audit mutation tests without altering the
users-field behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 16a75fd7-b808-4ce2-81bc-13d8b3f06aac

📥 Commits

Reviewing files that changed from the base of the PR and between 0c5bcc9 and 6c1551c.

📒 Files selected for processing (2)
  • .changeset/omnichannel-audit-visitor-agent-filtering.md
  • apps/meteor/client/views/audit/hooks/useAuditMutation.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
  • GitHub Check: cubic · AI code reviewer
🧰 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/audit/hooks/useAuditMutation.ts
🧠 Learnings (6)
📚 Learning: 2026-02-10T16:32:42.586Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 38528
File: apps/meteor/client/startup/roles.ts:14-14
Timestamp: 2026-02-10T16:32:42.586Z
Learning: In Rocket.Chat's Meteor client code, DDP streams use EJSON and Date fields arrive as Date objects; do not manually construct new Date() in stream handlers (for example, in sdk.stream()). Only REST API responses return plain JSON where dates are strings, so implement explicit conversion there if needed. Apply this guidance to all TypeScript files under apps/meteor/client to ensure consistent date handling in DDP streams and REST responses.

Applied to files:

  • apps/meteor/client/views/audit/hooks/useAuditMutation.ts
📚 Learning: 2026-05-11T20:30:35.265Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 40480
File: apps/meteor/client/meteor/startup/accounts.ts:59-61
Timestamp: 2026-05-11T20:30:35.265Z
Learning: In Rocket.Chat’s Meteor client code, when calling `dispatchToastMessage` with `{ type: 'error' }`, pass the raw caught error object as `message` without manual normalization. `dispatchToastMessage` is designed to accept `message: unknown` for error toasts, so avoid converting errors to strings (e.g., `String(error)`) or extracting `error.message` before passing them.

Applied to files:

  • apps/meteor/client/views/audit/hooks/useAuditMutation.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 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/client/views/audit/hooks/useAuditMutation.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/client/views/audit/hooks/useAuditMutation.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/client/views/audit/hooks/useAuditMutation.ts
📚 Learning: 2026-03-16T21:50:37.589Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: .changeset/migrate-users-register-openapi.md:3-3
Timestamp: 2026-03-16T21:50:37.589Z
Learning: For changes related to OpenAPI migrations in Rocket.Chat/OpenAPI, when removing endpoint types and validators from rocket.chat/rest-typings (e.g., UserRegisterParamsPOST, /v1/users.register) document this as a minor changeset (not breaking) per RocketChat/Rocket.Chat-Open-API#150 Rule 7. Note that the endpoint type is re-exposed via a module augmentation .d.ts in the consuming package (e.g., packages/web-ui-registration/src/users-register.d.ts). In reviews, ensure the changeset clearly states: this is a non-breaking change, the major version should not be bumped, and the changeset reflects a minor version bump. Do not treat this as a breaking change during OpenAPI migrations.

Applied to files:

  • .changeset/omnichannel-audit-visitor-agent-filtering.md
🔇 Additional comments (1)
.changeset/omnichannel-audit-visitor-agent-filtering.md (1)

1-6: LGTM!

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

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.

No issues found across 2 files

Re-trigger cubic

@surjeetkumar8006

Copy link
Copy Markdown
Author

Hi @ggazzo

Could you please review this PR when you have time?

Thanks!

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