Skip to content

fix(cli): reset slash-command conflict dedupe when conflicts reappear#27860

Open
aniruddhaadak80 wants to merge 1 commit into
google-gemini:mainfrom
aniruddhaadak80:fix/slash-command-conflict-dedupe
Open

fix(cli): reset slash-command conflict dedupe when conflicts reappear#27860
aniruddhaadak80 wants to merge 1 commit into
google-gemini:mainfrom
aniruddhaadak80:fix/slash-command-conflict-dedupe

Conversation

@aniruddhaadak80

Copy link
Copy Markdown
Contributor

Fixes #24333

Description

This PR fixes the slash-command conflict notifier deduplication bug where a conflict that has been resolved (and disappears) is not re-notified if it subsequently reappears.

Changes

  • Updated \handleConflicts\ in \SlashCommandConflictHandler\ to rebuild the
    otifiedConflicts\ set based on the active conflicts in the current payload. This ensures that when a conflict is resolved and no longer active, its key is removed from
    otifiedConflicts, allowing it to be re-notified if it reappears in a later reload.
  • Added a unit test in \SlashCommandConflictHandler.test.ts\ to verify the resolve-then-reappear behavior.

@aniruddhaadak80 aniruddhaadak80 requested a review from a team as a code owner June 12, 2026 14:53
@github-actions github-actions Bot added the size/s A small PR label Jun 12, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 44
  • Additions: +38
  • Deletions: -6
  • Files changed: 2

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a bug in the slash-command conflict notification system where resolved conflicts remained in the 'notified' state indefinitely. By modifying the conflict handler to synchronize the tracking set with the current active conflicts, the system now correctly allows for re-notification if a conflict is resolved and later recurs, improving the reliability of user feedback.

Highlights

  • Conflict Deduplication Logic: Updated the SlashCommandConflictHandler to dynamically rebuild the notifiedConflicts set based on the current payload, ensuring that resolved conflicts are removed from the tracking state.
  • Re-notification Support: Enabled the system to correctly re-notify users if a previously resolved slash-command conflict reappears in subsequent reloads.
  • Regression Testing: Added a new unit test case to verify the lifecycle of a conflict: occurrence, resolution, and subsequent reappearance.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the SlashCommandConflictHandler to re-notify users of a slash command conflict if it disappears and then reappears, and adds a corresponding unit test. A review comment identifies a potential duplication bug during the debounce window when multiple conflict payloads are received in rapid succession, which could lead to duplicate entries in pendingConflicts. A code suggestion is provided to filter out conflicts already present in pendingConflicts before pushing them.

Comment on lines +43 to 61
const currentKeys = new Set<string>();
const newConflicts: SlashCommandConflict[] = [];

for (const c of payload.conflicts) {
// Use a unique key to prevent duplicate notifications for the same conflict
const sourceId =
c.loserExtensionName || c.loserMcpServerName || c.loserKind;
const key = `${c.name}:${sourceId}:${c.renamedTo}`;
if (this.notifiedConflicts.has(key)) {
return false;
currentKeys.add(key);

if (!this.notifiedConflicts.has(key)) {
newConflicts.push(c);
}
this.notifiedConflicts.add(key);
return true;
});
}

this.notifiedConflicts = currentKeys;

if (newConflicts.length > 0) {
this.pendingConflicts.push(...newConflicts);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There is a potential duplication bug during the debounce window when multiple conflict payloads are received in rapid succession (e.g., during startup or incremental loading of extensions/MCP servers).

Scenario:

  1. Payload 1: [conflictA] is received. this.notifiedConflicts becomes {'conflictA'} and conflictA is added to this.pendingConflicts.
  2. Payload 2 (within 500ms): [] or [conflictB] is received. this.notifiedConflicts is overwritten and conflictA is removed from it, but conflictA remains in this.pendingConflicts awaiting flush.
  3. Payload 3 (within 500ms): [conflictA] is received again. Since conflictA is not in this.notifiedConflicts, it is treated as a new conflict and added to this.pendingConflicts again, resulting in duplicate entries (e.g., [conflictA, conflictA]).

When flush() runs, this causes duplicate notifications or incorrect grouping (e.g., showing a single conflict as a grouped list of duplicates).

Solution:

Extract the key generation logic to a local helper and filter out conflicts that are already present in this.pendingConflicts before pushing them.

    const getConflictKey = (c: SlashCommandConflict) => {
      const sourceId = c.loserExtensionName || c.loserMcpServerName || c.loserKind;
      return c.name + ":" + sourceId + ":" + c.renamedTo;
    };

    const currentKeys = new Set<string>();
    const newConflicts: SlashCommandConflict[] = [];

    for (const c of payload.conflicts) {
      const key = getConflictKey(c);
      currentKeys.add(key);

      if (!this.notifiedConflicts.has(key)) {
        newConflicts.push(c);
      }
    }

    this.notifiedConflicts = currentKeys;

    if (newConflicts.length > 0) {
      const pendingKeys = new Set(this.pendingConflicts.map(getConflictKey));
      const uniqueNewConflicts = newConflicts.filter(c => !pendingKeys.has(getConflictKey(c)));
      this.pendingConflicts.push(...uniqueNewConflicts);
    }

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! priority/p2 Important but can be addressed in a future release. size/s A small PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): reset slash-command conflict dedupe when conflicts reappear

1 participant