Skip to content

Fix duplicate keybinding rule when replacing with an existing rule#3969

Open
kridaydave wants to merge 1 commit into
pingdotgg:mainfrom
kridaydave:fix/keybindings-replace-duplicate-rule
Open

Fix duplicate keybinding rule when replacing with an existing rule#3969
kridaydave wants to merge 1 commit into
pingdotgg:mainfrom
kridaydave:fix/keybindings-replace-duplicate-rule

Conversation

@kridaydave

@kridaydave kridaydave commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

In upsertKeybindingRule, the replace path only dropped the entry matching replaceTarget before appending the new rule. If that new rule already existed elsewhere in the config, the result contained a duplicate binding that survived downstream and got persisted.

The filter now also excludes any entry equal to the incoming rule, so it is appended exactly once. Added a regression test covering the case where the replacement rule already exists in the config.


Note

Low Risk
Narrow change to custom keybinding upsert/replace persistence with a targeted regression test; no auth or security impact.

Overview
Fixes duplicate keybinding entries when upsertKeybindingRule runs with a replace target and the new rule already exists elsewhere in custom config.

The pre-append filter used to drop only the replace entry, so an identical incoming rule could remain and get appended again and persisted. It now also removes any entry equal to the incoming rule, so the binding is written once.

Adds a regression test: replace mod+r with mod+alt+r when mod+alt+r is already present leaves a single mod+alt+r rule.

Reviewed by Cursor Bugbot for commit 6c419c6. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Fix duplicate keybinding rule when upserting with an existing replace target

When calling upsertKeybindingRule with a replace target, the new rule could be duplicated if it already existed elsewhere in the custom config. The fix extends the filter in keybindings.ts to remove entries matching either the replace target or the new rule before appending, ensuring only one instance appears in the persisted config.

Macroscope summarized 6c419c6.

In upsertKeybindingRule, the replace path only dropped the entry matching replaceTarget before appending the new rule. If that new rule already existed elsewhere in the config, the result contained a duplicate binding that survived downstream (no dedup in compile/merge) and got persisted.

The filter now also excludes any entry equal to the incoming rule, so it is appended exactly once. Added a regression test covering the case where the replacement rule already exists in the config.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0a777c13-9805-4dbb-81db-07b16637a253

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Jul 14, 2026
@macroscopeapp

macroscopeapp Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Straightforward bug fix that prevents duplicate keybinding entries when replacing a rule with one that already exists. The change is minimal (one additional filter condition) with a clear test demonstrating the fix.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant