fix: show faster spotlight results using cached subscriptions - #40965
Conversation
|
Looks like this PR is ready to merge! 🎉 |
|
Walkthrough
ChangesNavBar Search: debounced server calls, skeleton loading UI
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ 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. Comment |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #40965 +/- ##
===========================================
- Coverage 70.11% 70.07% -0.05%
===========================================
Files 3357 3358 +1
Lines 129542 129567 +25
Branches 22404 22477 +73
===========================================
- Hits 90832 90795 -37
- Misses 35420 35472 +52
- Partials 3290 3300 +10
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
62f5622 to
bc05cb6
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (2)
apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemSkeleton.tsx (1)
3-6: ⚡ Quick winRemove the implementation comment block.
This block should be removed to match repository JS/TS guideline expectations.
As per coding guidelines:
**/*.{ts,tsx,js}: “Avoid code comments in the implementation.”🤖 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/navbar/NavBarSearch/NavBarSearchItemSkeleton.tsx` around lines 3 - 6, Remove the implementation comment block at the beginning of NavBarSearchItemSkeleton.tsx that documents the placeholder row behavior. Delete the multi-line comment (the four lines starting with "// Placeholder row shown..." and ending with "// it out of reach of focus and mouse clicks. Loading is conveyed via aria-busy.") as it violates the repository guideline to avoid code comments in implementation for TypeScript and JavaScript files.Source: Coding guidelines
apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts (1)
34-35: ⚡ Quick winRemove inline implementation comments from the hook.
Please drop these explanatory comments from the implementation and keep the rationale in PR/docs instead.
As per coding guidelines:
**/*.{ts,tsx,js}: “Avoid code comments in the implementation.”Also applies to: 38-39, 59-63, 104-106, 114-115, 118-131
🤖 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/navbar/NavBarSearch/hooks/useSearchItems.ts` around lines 34 - 35, Remove all inline implementation comments from the useSearchItems hook in apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts across multiple locations (lines 34-35, 38-39, 59-63, 104-106, 114-115, and 118-131) as they violate the coding guideline that prohibits code comments in implementation. Delete the comment blocks at each of these locations, keeping the functional code intact. The rationale for these implementation decisions should be documented separately in PR descriptions or external documentation rather than as inline comments in the code.Source: Coding guidelines
🤖 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/navbar/NavBarSearch/hooks/useSearchItems.ts`:
- Around line 34-35: Remove all inline implementation comments from the
useSearchItems hook in
apps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts across multiple
locations (lines 34-35, 38-39, 59-63, 104-106, 114-115, and 118-131) as they
violate the coding guideline that prohibits code comments in implementation.
Delete the comment blocks at each of these locations, keeping the functional
code intact. The rationale for these implementation decisions should be
documented separately in PR descriptions or external documentation rather than
as inline comments in the code.
In `@apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemSkeleton.tsx`:
- Around line 3-6: Remove the implementation comment block at the beginning of
NavBarSearchItemSkeleton.tsx that documents the placeholder row behavior. Delete
the multi-line comment (the four lines starting with "// Placeholder row
shown..." and ending with "// it out of reach of focus and mouse clicks. Loading
is conveyed via aria-busy.") as it violates the repository guideline to avoid
code comments in implementation for TypeScript and JavaScript files.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: bc4b8921-b2e6-40a1-af6a-b436a7ac604c
📒 Files selected for processing (3)
apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemSkeleton.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchListbox.tsxapps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
📜 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). (2)
- GitHub Check: cubic · AI code reviewer
- GitHub Check: Hacktron Security Check
🧰 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/navbar/NavBarSearch/NavBarSearchItemSkeleton.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchListbox.tsxapps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
🧠 Learnings (6)
📚 Learning: 2026-03-27T14:52:56.865Z
Learnt from: dougfabris
Repo: RocketChat/Rocket.Chat PR: 39892
File: apps/meteor/client/views/room/contextualBar/Threads/Thread.tsx:150-155
Timestamp: 2026-03-27T14:52:56.865Z
Learning: In Rocket.Chat, there are two different `ModalBackdrop` components with different prop APIs. During review, confirm the import source: (1) `rocket.chat/fuselage` `ModalBackdrop` uses `ModalBackdropProps` based on `BoxProps` (so it supports `onClick` and other Box/DOM props) and does not have an `onDismiss` prop; (2) `rocket.chat/ui-client` `ModalBackdrop` uses a narrower props interface like `{ children?: ReactNode; onDismiss?: () => void }` and handles Escape keypress and outside mouse-up, and it does not forward arbitrary DOM props such as `onClick`. Flag mismatched props (e.g., `onDismiss` passed to the fuselage component or `onClick` passed to the ui-client component) and ensure the usage matches the correct component being imported.
Applied to files:
apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemSkeleton.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchListbox.tsx
📚 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/navbar/NavBarSearch/NavBarSearchItemSkeleton.tsxapps/meteor/client/navbar/NavBarSearch/NavBarSearchListbox.tsxapps/meteor/client/navbar/NavBarSearch/hooks/useSearchItems.ts
📚 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/navbar/NavBarSearch/hooks/useSearchItems.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/navbar/NavBarSearch/hooks/useSearchItems.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/navbar/NavBarSearch/hooks/useSearchItems.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/navbar/NavBarSearch/hooks/useSearchItems.ts
🔇 Additional comments (3)
apps/meteor/client/navbar/NavBarSearch/NavBarSearchItemSkeleton.tsx (1)
7-20: LGTM!apps/meteor/client/navbar/NavBarSearch/NavBarSearchListbox.tsx (2)
54-55: LGTM!Also applies to: 57-67
31-31: Form defaults guaranteefilterTextis always initialized; no action needed.
filterTextis initialized withdefaultValues: { filterText: '' }in the parent form setup (line 24 of NavBarSearchInput.tsx). Thewatch()call in NavBarSearchListbox will always return this field with a string value (at minimum empty string), neverundefined. The.match()call at line 21 of useSearchItems handles empty strings correctly.
There was a problem hiding this comment.
1 issue found across 3 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
The local subscription query lived inside useSearchItems but received the
500ms-debounced filter, so cached results were delayed just like the server
call. Run the local useUserSubscriptions query against the immediate filter
text and debounce only the /v1/spotlight request, then merge local + server
results reactively (outside the query) so joined rooms render instantly while
the server response loads. Returns an explicit { items, isLoading } shape.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Pass the raw filter text to useSearchItems (the hook now owns debouncing) and render an accessible Throbber at the bottom of the results while the server spotlight request is in flight, so users see cached results immediately and know more are still loading. The spinner is decorative (aria-hidden, not a listbox option); loading is announced via aria-busy plus a role="status" live region. Reuses the existing "Loading" i18n key. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c6f4ad7 to
7375939
Compare
|
/jira ARCH-2167 |
Proposed changes (including videos or screenshots)
The navbar search ("spotlight") used to show instant results from the client-side subscription cache (the user's joined rooms) while the server
spotlightrequest resolved in the background. That fast-feedback behavior had been lost, and there was no visible "still loading" affordance.Two problems defeated the original UX:
NavBarSearchListboxdebounced the filter text by 500ms and passed the debounced value intouseSearchItems. Because the local subscription query (useUserSubscriptions) lived inside that hook, the cached results were delayed by the full 500ms too.aria-busy; nothing told a sighted user that more results were still arriving.Video showing the results (bare in mind there is a 5s delay for backend response)
instant-spotlight-v3.mp4
What changed
useSearchItems— the localuseUserSubscriptionsquery now runs against the immediate filter text, so joined rooms appear instantly. Only the/v1/spotlightrequest is debounced (500ms, keyed on the debounced term). Local + server results are merged reactively (in auseMemo, outside the query) so cached rooms render the moment the user types and server results fold in — deduped — once they arrive. The hook now returns an explicit{ items, isLoading }shape (resolving the previous "return type is UTTERLY wrong" FIXME).NavBarSearchListbox— passes the raw filter text (the hook now owns debouncing) and renders a few skeleton rows (NavBarSearchItemSkeleton) at the bottom of the list while the server request is in flight, so cached results stay visible above them and the loading state mimics the real result rows.Accessibility & i18n
aria-hidden, norole="option"(so arrow-key navigation skips them), andtabIndex={-1}+pointer-events: none(not focusable, not clickable).aria-busyon the listbox plus arole="status"live region announcing the existingLoadingtranslation key — no new user-facing strings were added.Issue(s)
Steps to test or reproduce
Cmd/Ctrl+K) and type part of a joined channel's name.#prefix → channels only;@prefix → users/DMs only (existing behavior preserved).Summary by CodeRabbit
Task: ARCH-2181