Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
Fix duplicate keybinding rule when replacing with an existing rule (#3969)
Kriday Dave7dc75127c232
diff --git a/apps/server/src/keybindings.test.ts b/apps/server/src/keybindings.test.tsindex a51ad20af..2eef6ac84 100644--- a/apps/server/src/keybindings.test.ts+++ b/apps/server/src/keybindings.test.ts@@ -411,6 +411,28 @@ it.layer(NodeServices.layer)("keybindings", (it) => {}).pipe(Effect.provide(makeKeybindingsLayer())),);+ it.effect("replacing with a rule that already exists elsewhere does not duplicate it", () =>+ Effect.gen(function* () {+ const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;+ yield* writeKeybindingsConfig(keybindingsConfigPath, [+ { key: "mod+r", command: "script.run-tests.run" },+ { key: "mod+alt+r", command: "script.run-tests.run" },+ ]);+ yield* Effect.gen(function* () {+ const keybindings = yield* Keybindings.Keybindings;+ return yield* keybindings.upsertKeybindingRule({+ key: "mod+alt+r",+ command: "script.run-tests.run",+ replace: { key: "mod+r", command: "script.run-tests.run" },+ });+ });++ const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);+ const persistedView = persisted.map(({ key, command }) => ({ key, command }));+ assert.deepEqual(persistedView, [{ key: "mod+alt+r", command: "script.run-tests.run" }]);+ }).pipe(Effect.provide(makeKeybindingsLayer())),+ );+it.effect("removes only the targeted custom keybinding", () =>Effect.gen(function* () {const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;diff --git a/apps/server/src/keybindings.ts b/apps/server/src/keybindings.tsindex 5ddae4943..18a78fe36 100644--- a/apps/server/src/keybindings.ts+++ b/apps/server/src/keybindings.ts@@ -644,7 +644,9 @@ const make = Effect.gen(function* () {const nextConfig = [...customConfig.filter((entry) => {if (replaceTarget) {- return !isSameKeybindingRule(entry, replaceTarget);+ return (+ !isSameKeybindingRule(entry, replaceTarget) && !isSameKeybindingRule(entry, rule)+ );}return !isSameKeybindingRule(entry, rule);}),