-
Notifications
You must be signed in to change notification settings - Fork 334
fix(react): remove duplicate keyboard shortcut descriptions & fix rollup build config #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR addresses duplicate keyboard shortcut descriptions in the CommandsList component and modernizes the JSON import syntax in rollup configuration files. The main fix implements client-side deduplication for navigation shortcuts that were appearing multiple times due to server responses, while the rollup changes ensure compatibility with newer Node.js versions.
- Adds deduplication logic using
React.useMemoto filter duplicate command descriptions - Updates rollup.config.js files to use the modern
with { type: 'json' }syntax instead of deprecatedassert
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/react/src/views/CommandList/CommandsList.js | Implements deduplication logic to filter out duplicate keyboard shortcut descriptions for message navigation commands |
| packages/auth/rollup.config.js | Updates JSON import to use modern with syntax instead of deprecated assert |
| packages/api/rollup.config.js | Updates JSON import to use modern with syntax instead of deprecated assert |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Allow all commands that aren't navigation shortcuts or "shortcuts" in general | ||
| if (!cmd.description || !cmd.command) return true; |
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic for handling commands without description or command properties is inconsistent with the deduplication intent. When a command is missing description or command, it returns true to allow it through. However, this means commands without these properties could bypass deduplication entirely. Consider whether these edge cases should be handled differently or if they should be filtered out as invalid commands.
| // Allow all commands that aren't navigation shortcuts or "shortcuts" in general | |
| if (!cmd.description || !cmd.command) return true; | |
| // Filter out commands that don't have the required properties | |
| if (!cmd.description || !cmd.command) { | |
| return false; | |
| } |
| // The server returns multiple shortcuts with the same description for message navigation. | ||
| // We want to dedup them here to avoid confusing the user. | ||
| const filteredCommands = React.useMemo(() => { | ||
| if (!propsFilteredCommands) return []; | ||
|
|
||
| const seenDescriptions = new Set(); | ||
| return propsFilteredCommands.filter((cmd) => { | ||
| // Allow all commands that aren't navigation shortcuts or "shortcuts" in general | ||
| if (!cmd.description || !cmd.command) return true; | ||
|
|
||
| // Strategies to identify duplicates we want to hide | ||
| // Strategy 1: exact description match for the specific known duplicates | ||
| const isDuplicateTarget = | ||
| cmd.description === 'Move to the beginning of the message' || | ||
| cmd.description === 'Move to the end of the message'; | ||
|
|
||
| if (isDuplicateTarget) { | ||
| if (seenDescriptions.has(cmd.description)) { | ||
| return false; // Skip duplicate | ||
| } | ||
| seenDescriptions.add(cmd.description); | ||
| return true; | ||
| } | ||
|
|
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deduplication implementation only targets two specific hardcoded descriptions. This approach is brittle and not scalable. If other duplicate descriptions appear in the future, they won't be deduplicated. Consider implementing a more general deduplication strategy that removes all duplicate descriptions, not just these two specific ones. For example, you could track all seen descriptions in the Set and filter any duplicates, regardless of the description text.
| // The server returns multiple shortcuts with the same description for message navigation. | |
| // We want to dedup them here to avoid confusing the user. | |
| const filteredCommands = React.useMemo(() => { | |
| if (!propsFilteredCommands) return []; | |
| const seenDescriptions = new Set(); | |
| return propsFilteredCommands.filter((cmd) => { | |
| // Allow all commands that aren't navigation shortcuts or "shortcuts" in general | |
| if (!cmd.description || !cmd.command) return true; | |
| // Strategies to identify duplicates we want to hide | |
| // Strategy 1: exact description match for the specific known duplicates | |
| const isDuplicateTarget = | |
| cmd.description === 'Move to the beginning of the message' || | |
| cmd.description === 'Move to the end of the message'; | |
| if (isDuplicateTarget) { | |
| if (seenDescriptions.has(cmd.description)) { | |
| return false; // Skip duplicate | |
| } | |
| seenDescriptions.add(cmd.description); | |
| return true; | |
| } | |
| // The server may return multiple shortcuts with the same description. | |
| // We deduplicate by description here to avoid confusing the user. | |
| const filteredCommands = React.useMemo(() => { | |
| if (!propsFilteredCommands) return []; | |
| const seenDescriptions = new Set(); | |
| return propsFilteredCommands.filter((cmd) => { | |
| // Allow commands without a description or without a command as-is | |
| if (!cmd.description || !cmd.command) { | |
| return true; | |
| } | |
| if (seenDescriptions.has(cmd.description)) { | |
| return false; // Skip duplicate description | |
| } | |
| seenDescriptions.add(cmd.description); |
| // Strategies to identify duplicates we want to hide | ||
| // Strategy 1: exact description match for the specific known duplicates |
Copilot
AI
Jan 3, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment mentions "Strategies to identify duplicates" (plural) but only implements one strategy. This is misleading. Either remove the plural "Strategies" and "Strategy 1:" prefix, or clarify the comment to reflect that only one approach is being used.
| // Strategies to identify duplicates we want to hide | |
| // Strategy 1: exact description match for the specific known duplicates | |
| // Identify duplicates we want to hide | |
| // Exact description match for the specific known duplicates |
…at#968) Also updated rollup configs in api and auth packages to use 'with' syntax for JSON imports, supporting newer Node.js versions.
🚀 Description
This PR addresses Issue #968 by filtering out duplicate keyboard shortcut descriptions in the CommandsList component. Specifically, the "Move to the beginning of the message" and "Move to the end of the message" shortcuts were appearing multiple times due to server responses. They are now deduplicated on the client side.
Additionally, I updated the rollup.config.js files in
@embeddedchat/apiand@embeddedchat/authto use the modernwith { type: 'json' }syntax instead of the deprecatedassert { type: 'json' }. This resolves build errors on newer Node.js versions (e.g., Node 22).📄 Changes
assertwithwithfor JSON imports.assertwithwithfor JSON imports.🔗 Related Issues
Closes #968
🧪 How to Test
yarn buildto verify the build passes (especially for api/auth packages).yarn storybookinpackages/react.