Skip to content

Conversation

@vivekyadav-3
Copy link

🚀 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/api and @embeddedchat/auth to use the modern with { type: 'json' } syntax instead of the deprecated assert { type: 'json' }. This resolves build errors on newer Node.js versions (e.g., Node 22).

📄 Changes

  • packages/react/src/views/CommandList/CommandsList.js: Added logic to filter out duplicate descriptions for navigation shortcuts.
  • packages/api/rollup.config.js: Replaced assert with with for JSON imports.
  • packages/auth/rollup.config.js: Replaced assert with with for JSON imports.

🔗 Related Issues

Closes #968

🧪 How to Test

  1. Run yarn build to verify the build passes (especially for api/auth packages).
  2. Run yarn storybook in packages/react.
  3. Open the ChatInput or CommandsList story.
  4. Trigger the command list (e.g., verify the help menu).
  5. Confirm that "Move to the beginning of the message" and "Move to the end of the message" appear only once in the list.

Copilot AI review requested due to automatic review settings January 3, 2026 17:55
@CLAassistant
Copy link

CLAassistant commented Jan 3, 2026

CLA assistant check
All committers have signed the CLA.

Copy link

Copilot AI left a 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.useMemo to filter duplicate command descriptions
  • Updates rollup.config.js files to use the modern with { type: 'json' } syntax instead of deprecated assert

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.

Comment on lines 31 to 32
// Allow all commands that aren't navigation shortcuts or "shortcuts" in general
if (!cmd.description || !cmd.command) return true;
Copy link

Copilot AI Jan 3, 2026

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.

Suggested change
// 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;
}

Copilot uses AI. Check for mistakes.
Comment on lines 24 to 47
// 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;
}

Copy link

Copilot AI Jan 3, 2026

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.

Suggested change
// 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);

Copilot uses AI. Check for mistakes.
Comment on lines 34 to 35
// Strategies to identify duplicates we want to hide
// Strategy 1: exact description match for the specific known duplicates
Copy link

Copilot AI Jan 3, 2026

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.

Suggested change
// 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

Copilot uses AI. Check for mistakes.
…at#968)

Also updated rollup configs in api and auth packages to use 'with' syntax for JSON imports, supporting newer Node.js versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Duplicate keyboard shortcut description for message navigation

2 participants