refactor: extract composer autocomplete engine to ui-client#40925
refactor: extract composer autocomplete engine to ui-client#40925ricardogarim wants to merge 1 commit into
Conversation
|
Looks like this PR is not ready to merge, because of the following issues:
Please fix the issues and try again If you have any trouble, please check the PR guidelines |
|
WalkthroughThis PR refactors the composer autocomplete system from composer-specific components to a new generic autocomplete infrastructure in the UI client package, then migrates all popup triggers (people, channels, emoji, canned responses, commands) to use the new configuration-driven approach. ChangesAutocomplete Infrastructure and Migration
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsErrors were encountered while retrieving linked issues. Errors (1)
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 |
ec46dbc to
0938c32
Compare
0938c32 to
f6ed427
Compare
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## develop #40925 +/- ##
===========================================
+ Coverage 70.04% 70.07% +0.02%
===========================================
Files 3355 3352 -3
Lines 129162 129086 -76
Branches 22372 22296 -76
===========================================
- Hits 90474 90452 -22
+ Misses 35396 35349 -47
+ Partials 3292 3285 -7
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
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 (1)
packages/ui-client/src/components/AutocompletePopup/AutocompletePopup.tsx (1)
86-90:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winOnly set
aria-labelledbywhen the title element exists.When
titleis falsy, the header<Box id={id}>is not rendered but the popup still pointsaria-labelledbyat that missing node. That leaves the no-title case with a broken accessible-name reference.Suggested fix
- <Tile ref={popupRef} padding={0} role='menu' mbe={8} overflow='hidden' aria-labelledby={id} name='AutocompletePopup'> + <Tile + ref={popupRef} + padding={0} + role='menu' + mbe={8} + overflow='hidden' + {...(title ? { 'aria-labelledby': id } : {})} + name='AutocompletePopup' + >🤖 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 `@packages/ui-client/src/components/AutocompletePopup/AutocompletePopup.tsx` around lines 86 - 90, The Tile currently always sets aria-labelledby={id} even when title is falsy and the header Box (id) isn't rendered; update the AutocompletePopup rendering so aria-labelledby is only set when title exists (e.g., conditionally pass id or undefined/omit the attribute). Locate the Tile element using identifiers Tile, popupRef, id and the title prop in AutocompletePopup and change the prop to be conditional on title so the accessible-name reference is not broken when no header is rendered.
🧹 Nitpick comments (1)
apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx (1)
188-242: ⚡ Quick winThe
+:emoji option is already drifting from the shared emoji config.This block duplicates the emoji filtering/tone logic you just extracted into
createEmojiPopupConfig, but with a different ranking implementation and no coverage fromapps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.spec.tsx. Please extract the common local search/sort helper so both:and+:stay behaviorally aligned.🤖 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/room/providers/ComposerPopupProvider.tsx` around lines 188 - 242, The local emoji filtering/sorting logic duplicated inside the getItemsFromLocal of the createAutocompletePopupConfig (the '+:' config) should be extracted into a shared helper used by both createEmojiPopupConfig and the '+:' getItemsFromLocal; specifically factor out the regexes (exactFinalTone, colorBlind, seeColor), the recents mapping and emojiSort comparator, and the filter/sort/slice pipeline (currently using escapeRegExp, key, recents, collection) into a function (e.g., createEmojiLocalSearch or filterAndSortEmojis) and replace the inline implementation in getItemsFromLocal and createEmojiPopupConfig to call it; also add/adjust tests in emojiPopupConfig.spec.tsx to cover the shared helper behavior for both ':' and '+:' cases so ranking stays aligned.
🤖 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.
Inline comments:
In `@apps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts`:
- Around line 7-19: The composer-level Escape is still handled before the popup
because useAutocompletePopup only consumes Escape on keyup; fix by intercepting
Escape on keydown inside useComposerBoxPopup so the popup gets first dibs: when
mounting, add a keydown listener that checks for key === 'Escape' and popup-open
state (from the popup hook—expose or derive an isOpen flag from
useAutocompletePopup's return value) and when open calls event.preventDefault()
and event.stopImmediatePropagation()/stopPropagation() so MessageBox's Escape
handler doesn't run; ensure you clean up the listener on unmount and keep the
existing return shape of useComposerBoxPopup so consumers (MessageBox) don't
need changes. Reference symbols: useComposerBoxPopup, useAutocompletePopup, and
the Escape handler in MessageBox (MessageBox.tsx).
---
Outside diff comments:
In `@packages/ui-client/src/components/AutocompletePopup/AutocompletePopup.tsx`:
- Around line 86-90: The Tile currently always sets aria-labelledby={id} even
when title is falsy and the header Box (id) isn't rendered; update the
AutocompletePopup rendering so aria-labelledby is only set when title exists
(e.g., conditionally pass id or undefined/omit the attribute). Locate the Tile
element using identifiers Tile, popupRef, id and the title prop in
AutocompletePopup and change the prop to be conditional on title so the
accessible-name reference is not broken when no header is rendered.
---
Nitpick comments:
In `@apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx`:
- Around line 188-242: The local emoji filtering/sorting logic duplicated inside
the getItemsFromLocal of the createAutocompletePopupConfig (the '+:' config)
should be extracted into a shared helper used by both createEmojiPopupConfig and
the '+:' getItemsFromLocal; specifically factor out the regexes (exactFinalTone,
colorBlind, seeColor), the recents mapping and emojiSort comparator, and the
filter/sort/slice pipeline (currently using escapeRegExp, key, recents,
collection) into a function (e.g., createEmojiLocalSearch or
filterAndSortEmojis) and replace the inline implementation in getItemsFromLocal
and createEmojiPopupConfig to call it; also add/adjust tests in
emojiPopupConfig.spec.tsx to cover the shared helper behavior for both ':' and
'+:' cases so ranking stays aligned.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6622c386-3f4e-4e4c-bda3-a06bb8ed5135
📒 Files selected for processing (17)
apps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.spec.tsxapps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.tsxapps/meteor/client/views/room/composer/ComposerBoxPopupEmoji.tsxapps/meteor/client/views/room/composer/ComposerBoxPopupPreview.tsxapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.spec.tsxapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.tsapps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.tsapps/meteor/client/views/room/composer/hooks/useEnablePopupPreview.tsapps/meteor/client/views/room/composer/messageBox/MessageBox.tsxapps/meteor/client/views/room/contexts/ComposerPopupContext.tsapps/meteor/client/views/room/providers/ComposerPopupProvider.tsxapps/meteor/tests/e2e/page-objects/fragments/composer.tspackages/ui-client/src/components/AutocompletePopup/AutocompletePopup.tsxpackages/ui-client/src/components/AutocompletePopup/index.tspackages/ui-client/src/components/index.tspackages/ui-client/src/hooks/index.tspackages/ui-client/src/hooks/useAutocompletePopup.ts
💤 Files with no reviewable changes (3)
- apps/meteor/client/views/room/composer/ComposerBoxPopupEmoji.tsx
- apps/meteor/client/views/room/composer/hooks/useEnablePopupPreview.ts
- apps/meteor/client/views/room/composer/hooks/useComposerBoxPopupQueries.ts
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{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/ui-client/src/hooks/index.tsapps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.spec.tsxapps/meteor/tests/e2e/page-objects/fragments/composer.tspackages/ui-client/src/components/index.tsapps/meteor/client/views/room/contexts/ComposerPopupContext.tspackages/ui-client/src/components/AutocompletePopup/index.tsapps/meteor/client/views/room/composer/ComposerBoxPopupPreview.tsxapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.tsapps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.tsxapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.spec.tsxpackages/ui-client/src/components/AutocompletePopup/AutocompletePopup.tsxapps/meteor/client/views/room/composer/messageBox/MessageBox.tsxpackages/ui-client/src/hooks/useAutocompletePopup.tsapps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
apps/meteor/tests/e2e/page-objects/**/*.ts
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
Utilize existing page objects pattern from
apps/meteor/tests/e2e/page-objects/
Files:
apps/meteor/tests/e2e/page-objects/fragments/composer.ts
apps/meteor/tests/e2e/**/*.{ts,spec.ts}
📄 CodeRabbit inference engine (.cursor/rules/playwright.mdc)
apps/meteor/tests/e2e/**/*.{ts,spec.ts}: Store commonly used locators in variables/constants for reuse
Follow Page Object Model pattern consistently in Playwright tests
Files:
apps/meteor/tests/e2e/page-objects/fragments/composer.ts
🧠 Learnings (10)
📚 Learning: 2026-01-19T18:08:05.314Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 38169
File: packages/ui-client/src/hooks/useGoToDirectMessage.ts:20-27
Timestamp: 2026-01-19T18:08:05.314Z
Learning: Rule of Hooks: In React, hooks (including custom hooks like useGoToDirectMessage and useUserSubscriptionByName) must be called unconditionally and in the same order on every render. Do not conditionally call hooks based on values; instead, derive safe inputs if a value may be undefined (e.g., pass an empty string or undefined) and handle variations in logic outside the hook invocation. This preserves hook order and avoids violations. Apply this guideline to all files under packages/ui-client/src/hooks where hooks are used.
Applied to files:
packages/ui-client/src/hooks/index.tspackages/ui-client/src/hooks/useAutocompletePopup.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:
packages/ui-client/src/hooks/index.tsapps/meteor/tests/e2e/page-objects/fragments/composer.tspackages/ui-client/src/components/index.tsapps/meteor/client/views/room/contexts/ComposerPopupContext.tspackages/ui-client/src/components/AutocompletePopup/index.tsapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.tspackages/ui-client/src/hooks/useAutocompletePopup.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/ui-client/src/hooks/index.tsapps/meteor/tests/e2e/page-objects/fragments/composer.tspackages/ui-client/src/components/index.tsapps/meteor/client/views/room/contexts/ComposerPopupContext.tspackages/ui-client/src/components/AutocompletePopup/index.tsapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.tspackages/ui-client/src/hooks/useAutocompletePopup.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/ui-client/src/hooks/index.tsapps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.spec.tsxapps/meteor/tests/e2e/page-objects/fragments/composer.tspackages/ui-client/src/components/index.tsapps/meteor/client/views/room/contexts/ComposerPopupContext.tspackages/ui-client/src/components/AutocompletePopup/index.tsapps/meteor/client/views/room/composer/ComposerBoxPopupPreview.tsxapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.tsapps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.tsxapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.spec.tsxpackages/ui-client/src/components/AutocompletePopup/AutocompletePopup.tsxapps/meteor/client/views/room/composer/messageBox/MessageBox.tsxpackages/ui-client/src/hooks/useAutocompletePopup.tsapps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 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:
apps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.spec.tsxapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.spec.tsx
📚 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/components/EmojiAutocomplete/emojiPopupConfig.spec.tsxapps/meteor/client/views/room/composer/ComposerBoxPopupPreview.tsxapps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.tsxapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.spec.tsxpackages/ui-client/src/components/AutocompletePopup/AutocompletePopup.tsxapps/meteor/client/views/room/composer/messageBox/MessageBox.tsxapps/meteor/client/views/room/providers/ComposerPopupProvider.tsx
📚 Learning: 2025-12-16T17:29:40.430Z
Learnt from: gabriellsh
Repo: RocketChat/Rocket.Chat PR: 37834
File: apps/meteor/tests/e2e/page-objects/fragments/admin-flextab-emoji.ts:12-22
Timestamp: 2025-12-16T17:29:40.430Z
Learning: In all page-object files under apps/meteor/tests/e2e/page-objects/, import expect from ../../utils/test (Playwright's async expect) instead of from Jest. Jest's expect is synchronous and incompatible with web-first assertions like toBeVisible, which can cause TypeScript errors.
Applied to files:
apps/meteor/tests/e2e/page-objects/fragments/composer.ts
📚 Learning: 2026-02-24T19:39:42.247Z
Learnt from: juliajforesti
Repo: RocketChat/Rocket.Chat PR: 38493
File: apps/meteor/tests/e2e/page-objects/fragments/message.ts:7-7
Timestamp: 2026-02-24T19:39:42.247Z
Learning: In RocketChat e2e tests, avoid using data-qa attributes to locate elements. Prefer semantic locators such as getByRole, getByLabel, getByText, getByTitle and ARIA-based selectors. Apply this rule to all TypeScript files under apps/meteor/tests/e2e to improve test reliability, accessibility, and maintainability.
Applied to files:
apps/meteor/tests/e2e/page-objects/fragments/composer.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/views/room/contexts/ComposerPopupContext.tsapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.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/room/contexts/ComposerPopupContext.tsapps/meteor/client/views/room/composer/hooks/useComposerBoxPopup.ts
🪛 ast-grep (0.43.0)
packages/ui-client/src/hooks/useAutocompletePopup.ts
[warning] 210-210: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp((?:^| |\n)(${option.trigger})([^\\s]*$))
Note: [CWE-1333] Inefficient Regular Expression Complexity
(regexp-from-variable)
[warning] 210-210: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp((?:^)(${option.trigger})([^\\s]*$))
Note: [CWE-1333] Inefficient Regular Expression Complexity
(regexp-from-variable)
[warning] 238-238: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp((?:^| |\n)(${trigger})[^\\s]*$)
Note: [CWE-1333] Inefficient Regular Expression Complexity
(regexp-from-variable)
[warning] 238-238: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp((?:^)(${trigger})[^\\s]*$)
Note: [CWE-1333] Inefficient Regular Expression Complexity
(regexp-from-variable)
[warning] 256-256: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp((?:^| |\n)(${option.trigger})([^\\s]*$))
Note: [CWE-1333] Inefficient Regular Expression Complexity
(regexp-from-variable)
[warning] 256-256: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp((?:^)(${option.trigger})([^\\s]*$))
Note: [CWE-1333] Inefficient Regular Expression Complexity
(regexp-from-variable)
🔇 Additional comments (2)
packages/ui-client/src/hooks/useAutocompletePopup.ts (1)
210-211: Escapetriggerbefore interpolating it into selectorRegExps (3 call sites).
useAutocompletePopupbuilds regexes vianew RegExp(\...(${option.trigger})...`)/new RegExp(`...(${trigger})...`)at lines 210-211, 238-239, and 256-257, without escaping metacharacters. The repo currently supplies the composer “plus” trigger astrigger: '\+:'(i.e.,+:), but other consumers/configs could pass unescaped triggers like+:/?/(, which would produce an invalid/incorrect selector and break matching (and may throw). Add an internalescapeRegExp(or equivalent) and apply it totrigger` at all three construction sites.apps/meteor/tests/e2e/page-objects/fragments/composer.ts (1)
111-111: LGTM!
There was a problem hiding this comment.
2 issues found across 17 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/client/components/EmojiAutocomplete/emojiPopupConfig.tsx">
<violation number="1" location="apps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.tsx:49">
P2: Recent emoji ranking is reversed: older recents are prioritized over newer ones.</violation>
</file>
<file name="packages/ui-client/src/hooks/useAutocompletePopup.ts">
<violation number="1" location="packages/ui-client/src/hooks/useAutocompletePopup.ts:106">
P2: Server autocomplete query can run prematurely on filter changes because `counter` reset happens after render.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| let bScore = bExact + bPartial; | ||
|
|
||
| if (recents.includes(a._id)) { | ||
| aScore += recents.indexOf(a._id) + 1; |
There was a problem hiding this comment.
P2: Recent emoji ranking is reversed: older recents are prioritized over newer ones.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/client/components/EmojiAutocomplete/emojiPopupConfig.tsx, line 49:
<comment>Recent emoji ranking is reversed: older recents are prioritized over newer ones.</comment>
<file context>
@@ -0,0 +1,84 @@
+ let bScore = bExact + bPartial;
+
+ if (recents.includes(a._id)) {
+ aScore += recents.indexOf(a._id) + 1;
+ }
+ if (recents.includes(b._id)) {
</file context>
| aScore += recents.indexOf(a._id) + 1; | |
| aScore += recents.length - recents.indexOf(a._id); |
| placeholderData: keepPreviousData, | ||
| queryKey: ['message-popup', 'server', filter, popup], | ||
| queryFn: () => popup?.getItemsFromServer?.(filter) || [], | ||
| enabled: counter > 0, |
There was a problem hiding this comment.
P2: Server autocomplete query can run prematurely on filter changes because counter reset happens after render.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/ui-client/src/hooks/useAutocompletePopup.ts, line 106:
<comment>Server autocomplete query can run prematurely on filter changes because `counter` reset happens after render.</comment>
<file context>
@@ -0,0 +1,403 @@
+ placeholderData: keepPreviousData,
+ queryKey: ['message-popup', 'server', filter, popup],
+ queryFn: () => popup?.getItemsFromServer?.(filter) || [],
+ enabled: counter > 0,
+ },
+ ],
</file context>
Proposed changes (including videos or screenshots)
Moves the message composer's autocomplete to
@rocket.chat/ui-clientwith no behavior change, so other inputs can reuse it. It was coupled toChatContext/ChatAPI; now text access is injected (EditableTextAdapter), so the composer plugs inchat.composerand any plain input plugs in the providedfromInputElementhelper.apps/meteor)ComposerBoxPopup.tsxcomponents/AutocompletePopupuseComposerBoxPopup.ts+useComposerBoxPopupQueries.ts+useEnablePopupPreview.tshooks/useAutocompletePopup.tsComposerPopupOption+createMessageBoxPopupConfigAutocompletePopupOption+createAutocompletePopupConfig:config inline inComposerPopupProvider.tsxclient/components/EmojiAutocomplete/emojiPopupConfig.tsx(stays in apps/meteor - depends onemoji.list)The engine is trigger-agnostic: it takes an array of configs and an adapter. Only the emoji config is extracted to a shared module - it's what the next consumer needs and the only one not room-coupled; the other five triggers (
@,#,+:,/,!) stay inline inComposerPopupProvider. The popup's e2e selector was renamed (ComposerBoxPopup->AutocompletePopup) and the composer page object updated.Tests were added for the popup behavior (
useComposerBoxPopup.spec.tsx) and for the shared emoji config (emojiPopupConfig.spec.tsx).Issue(s)
PRES-30
Steps to test or reproduce
Further comments
First planned consumer: emoji autocomplete in the custom status modal (follow-up PR).
Summary by CodeRabbit
New Features
Bug Fixes
Refactor