fix: show offline users' custom status text and expiration#41087
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (3)
📜 Recent review details⏰ Context from checks skipped due to timeout. (4)
|
| Layer / File(s) | Summary |
|---|---|
Query contract and filter packages/model-typings/src/models/IUsersModel.ts, packages/models/src/models/Users.ts |
findPresenceUsersByIds replaces findNotOfflineByIds, and the query matches users by status, non-empty statusText, or statusExpiresAt. |
Offline transition behavior ee/packages/presence/src/lib/presenceEngine.spec.ts |
processPresence keeps OFFLINE transitions from clearing custom status text or expiration data. |
API lookup and end-to-end coverage apps/meteor/app/api/server/v1/users.ts, apps/meteor/tests/end-to-end/api/users.ts |
users.presence switches ID lookups to the new model method, and the end-to-end test checks status, statusText, and statusExpiresAt in the response. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
- RocketChat/Rocket.Chat#40557: Also updates
ee/packages/presence/src/lib/presenceEngine.spec.tsaround OFFLINE/custom status persistence behavior. - RocketChat/Rocket.Chat#41052: Touches the presence data returned by
users.presence, which is the API path changed in this PR.
Suggested labels
type: bug
Suggested reviewers
- KevLehman
🚥 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 matches the main change: preserving offline users' custom status text and expiration. |
| 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. |
Warning
Review ran into problems
🔥 Problems
Errors were encountered while retrieving linked issues.
Errors (1)
- PRES-59: Request failed with status code 401
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.
Comment @coderabbitai help to get the list of available commands.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feat/presence-expiration-ui #41087 +/- ##
===============================================================
- Coverage 70.17% 70.15% -0.02%
===============================================================
Files 3371 3371
Lines 130417 130417
Branches 22593 22591 -2
===============================================================
- Hits 91522 91499 -23
- Misses 35575 35590 +15
- Partials 3320 3328 +8
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
22598e3 to
636966e
Compare
|
636966e to
220bed3
Compare
a98223d to
5bea13b
Compare
220bed3 to
c6bd374
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
apps/meteor/tests/end-to-end/api/users.ts (1)
1852-1878: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: guarantee cleanup if an assertion fails.
deleteUser(vacationUser)only runs when all assertions pass; an earlier failure leaks the created user into the rest of the suite. Consider tracking the user and deleting it in anafter/finallyhook.🤖 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/tests/end-to-end/api/users.ts` around lines 1852 - 1878, The end-to-end test in users.ts leaks the created vacation user if any assertion fails because deleteUser(vacationUser) is only reached on success. Update the test around createUser, login, and users.presence to guarantee cleanup with a finally block or a scoped after hook so the user is always deleted even when an expectation throws.
🤖 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/tests/end-to-end/api/users.ts`:
- Around line 1852-1878: The end-to-end test in users.ts leaks the created
vacation user if any assertion fails because deleteUser(vacationUser) is only
reached on success. Update the test around createUser, login, and users.presence
to guarantee cleanup with a finally block or a scoped after hook so the user is
always deleted even when an expectation throws.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 0fadee2d-5ec9-4a98-a065-48ec0b63dcb4
📒 Files selected for processing (5)
apps/meteor/app/api/server/v1/users.tsapps/meteor/tests/end-to-end/api/users.tsee/packages/presence/src/lib/presenceEngine.spec.tspackages/model-typings/src/models/IUsersModel.tspackages/models/src/models/Users.ts
📜 Review details
⏰ Context from checks skipped due to timeout. (1)
- GitHub Check: cubic · AI code reviewer
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{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:
packages/model-typings/src/models/IUsersModel.tspackages/models/src/models/Users.tsapps/meteor/app/api/server/v1/users.tsee/packages/presence/src/lib/presenceEngine.spec.tsapps/meteor/tests/end-to-end/api/users.ts
**/*.spec.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
**/*.spec.ts: Use descriptive test names that clearly communicate expected behavior in Playwright tests
Use.spec.tsextension for test files (e.g.,login.spec.ts)
Files:
ee/packages/presence/src/lib/presenceEngine.spec.ts
🧠 Learnings (10)
📚 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:
packages/model-typings/src/models/IUsersModel.tspackages/models/src/models/Users.tsapps/meteor/app/api/server/v1/users.tsee/packages/presence/src/lib/presenceEngine.spec.tsapps/meteor/tests/end-to-end/api/users.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:
packages/model-typings/src/models/IUsersModel.tspackages/models/src/models/Users.tsapps/meteor/app/api/server/v1/users.tsee/packages/presence/src/lib/presenceEngine.spec.tsapps/meteor/tests/end-to-end/api/users.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:
packages/model-typings/src/models/IUsersModel.tspackages/models/src/models/Users.tsapps/meteor/app/api/server/v1/users.tsee/packages/presence/src/lib/presenceEngine.spec.tsapps/meteor/tests/end-to-end/api/users.ts
📚 Learning: 2026-02-23T17:53:06.802Z
Learnt from: ggazzo
Repo: RocketChat/Rocket.Chat PR: 35995
File: apps/meteor/app/api/server/v1/rooms.ts:1107-1112
Timestamp: 2026-02-23T17:53:06.802Z
Learning: During PR reviews that touch endpoint files under apps/meteor/app/api/server/v1, enforce strict scope: if a PR targets a specific endpoint (e.g., rooms.favorite), do not propose changes to unrelated endpoints (e.g., rooms.invite) unless maintainers explicitly request them. Focus feedback on the touched endpoint's behavior, API surface, and related tests; avoid broad cross-endpoint changes in the same PR unless requested.
Applied to files:
apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2026-02-24T19:09:01.522Z
Learnt from: ahmed-n-abdeltwab
Repo: RocketChat/Rocket.Chat PR: 38974
File: apps/meteor/app/api/server/v1/im.ts:220-221
Timestamp: 2026-02-24T19:09:01.522Z
Learning: In Rocket.Chat OpenAPI migration PRs for endpoints under apps/meteor/app/api/server/v1, avoid introducing logic changes. Only perform scope-tight changes that preserve behavior; style-only cleanups (e.g., removing inline comments) may be deferred to follow-ups to keep the migration PR focused.
Applied to files:
apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2026-03-15T14:31:25.380Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39647
File: apps/meteor/app/api/server/v1/users.ts:710-757
Timestamp: 2026-03-15T14:31:25.380Z
Learning: Do not flag this type/schema misalignment in the OpenAPI/migration review for apps/meteor/app/api/server/v1/users.ts. The UserCreateParamsPOST type intentionally uses non-optional fields: fields: string and settings?: IUserSettings without an AJV schema entry, carried over from the original rest-typings (PR `#39647`). Treat this as a known pre-existing divergence and document it as a separate follow-up fix; do not block or mark it as a review issue during the migration.
Applied to files:
apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2026-03-16T23:33:11.443Z
Learnt from: amitb0ra
Repo: RocketChat/Rocket.Chat PR: 39676
File: apps/meteor/app/api/server/v1/users.ts:862-869
Timestamp: 2026-03-16T23:33:11.443Z
Learning: In rockets OpenAPI/AJV migration reviews for RocketChat/Rocket.Chat, when reviewing migrations that involve apps/meteor/app/api/server/v1/users.ts, do not require or flag a missing query AJV schema for the fields consumed by parseJsonQuery() (i.e., fields, sort, query) as part of this endpoint's migration PR. The addition of global query-param schemas for parseJsonQuery() usage is a cross-cutting concern and out of scope for individual endpoint migrations. Only flag violations related to the specific scope of the migration, not the absence of a query schema for parseJsonQuery() in this file.
Applied to files:
apps/meteor/app/api/server/v1/users.ts
📚 Learning: 2025-12-10T21:00:43.645Z
Learnt from: KevLehman
Repo: RocketChat/Rocket.Chat PR: 37091
File: ee/packages/abac/jest.config.ts:4-7
Timestamp: 2025-12-10T21:00:43.645Z
Learning: Adopt the monorepo-wide Jest testMatch pattern: <rootDir>/src/**/*.spec.{ts,js,mjs} (represented here as '**/src/**/*.spec.{ts,js,mjs}') to ensure spec files under any package's src directory are picked up consistently across all packages in the Rocket.Chat monorepo. Apply this pattern in jest.config.ts for all relevant packages to maintain uniform test discovery.
Applied to files:
ee/packages/presence/src/lib/presenceEngine.spec.ts
📚 Learning: 2026-02-24T19:22:48.358Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/omnichannel/omnichannel-send-pdf-transcript.spec.ts:66-67
Timestamp: 2026-02-24T19:22:48.358Z
Learning: In Playwright end-to-end tests (e.g., under apps/meteor/tests/e2e/...), prefer locating elements by translated text (getByText) and ARIA roles (getByRole) over data-qa attributes. If translation values change, update the corresponding test locators accordingly. Never use data-qa locators. This guideline applies to all Playwright e2e test specs in the repository and helps keep tests robust to UI text changes and accessible semantics.
Applied to files:
ee/packages/presence/src/lib/presenceEngine.spec.ts
📚 Learning: 2026-03-06T18:10:15.268Z
Learnt from: tassoevan
Repo: RocketChat/Rocket.Chat PR: 39397
File: packages/gazzodown/src/code/CodeBlock.spec.tsx:47-68
Timestamp: 2026-03-06T18:10:15.268Z
Learning: In tests (especially those using testing-library/dom/jsdom) for Rocket.Chat components, the HTML <code> element has an implicit ARIA role of 'code'. Therefore, screen.getByRole('code') or screen.findByRole('code') will locate <code> elements even without a role attribute. Do not flag findByRole('code') as invalid in reviews; prefer using the implicit role instead of adding role="code" unless necessary for accessibility.
Applied to files:
ee/packages/presence/src/lib/presenceEngine.spec.ts
🔇 Additional comments (4)
packages/model-typings/src/models/IUsersModel.ts (1)
384-384: LGTM!packages/models/src/models/Users.ts (1)
2491-2501: LGTM!ee/packages/presence/src/lib/presenceEngine.spec.ts (1)
51-64: LGTM!apps/meteor/app/api/server/v1/users.ts (1)
1549-1549: 🗄️ Data Integrity & IntegrationThe projection already includes the custom status fields.
Theoptionsobject passed tofindByIdsForPresenceon line 1549 explicitly defines a projection containingstatusText,statusSource, andstatusExpiresAt. Consequently, the query correctly preserves these fields for all returned users, including offline ones.
There was a problem hiding this comment.
3 issues found across 5 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/meteor/tests/end-to-end/api/users.ts">
<violation number="1" location="apps/meteor/tests/end-to-end/api/users.ts:1875">
P2: The test does not verify that `statusExpiresAt` matches the value set by the request, so incorrect expiration propagation could still pass.</violation>
<violation number="2" location="apps/meteor/tests/end-to-end/api/users.ts:1877">
P2: Test cleanup is not protected with `finally`, so assertion failures can leak created users and make the suite flaky over time.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
c6bd374 to
6a4ad7c
Compare
dba082e
into
feat/presence-expiration-ui
Proposed changes (including videos or screenshots)
With the new presence engine, a custom status (text + expiration) should stay visible after a user goes offline — e.g. "On vacation until next week". The engine persists it and the live stream already broadcasts it, but it was dropped on the REST cold-load (page reload / first card open), so offline users showed as a plain "Offline" with no message.
Root cause:
GET /api/v1/users.presence?ids=<uid>usedUsers.findNotOfflineByIds, which filteredstatus ∈ { online, away, busy }and excluded every offline user. The client then fell back to{ status: OFFLINE }with nostatusText/statusExpiresAt. That filter is a legacy optimization that is wrong now that offline users can keep a displayable custom status.Fix: a dedicated
Users.findByIdsForPresencebacks theidsbranch, returning online/away/busy users plus offline users that still carry a custom status (statusTextorstatusExpiresAt). Silently-offline users are still omitted and inferred offline by the client fallback, keeping the payload optimization. The oldfindNotOfflineByIds(only used here) is removed; bulk/incremental paths unchanged.Issue(s)
Steps to test or reproduce
Expected: "Offline - On vacation until next week" + expiration, until it expires.
Before: plain "Offline", no text/expiration.
Further comments
Summary by CodeRabbit
users.presenceto verify custom status fields are returned for offline users.