The best way to control Claude Code, Codex and more from any computer or phone
refactor(web): the keybindings panel keeps its caching without "use memo" hooks (#20782)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 16, 2026 at 23:29 UTC
1e436990c2a0b437ccab8ce442568b40a7b8d192
1 file changed
+9
-23
apps/web/src/components/settings/KeybindingsSettings.tsx
+9
-23
@@ -1260,25 +1260,6 @@ function BrowserKeybindingNotice() {
1260
);
1261
}
1262
1263
-// The panel calls hooks after these, so they would lose their caches inline. Separate hooks
1264
-// keep the command options from rebuilding on every search keystroke.
1265
-function useKeybindings(
1266
- serverKeybindings: Parameters<typeof mergeWithDefaultKeybindings>[0] | undefined,
1267
-) {
1268
- "use memo";
1269
- const keybindings = mergeWithDefaultKeybindings(serverKeybindings ?? []);
1270
- return { keybindings, commandOptions: buildKeybindingCommandOptions(keybindings) };
1271
-}
1272
-
1273
-function useKeybindingRows(
1274
- keybindings: ReturnType<typeof mergeWithDefaultKeybindings>,
1275
- query: string,
1276
-) {
1277
- "use memo";
1278
- const rows = buildKeybindingRows(keybindings, query);
1279
- return { rows, groups: groupKeybindingRows(rows), anchorIds: keybindingAnchorIds(rows) };
1280
-}
1281
-
1263
function keybindingAnchorIds(rows: ReturnType<typeof buildKeybindingRows>) {
1264
const ids = new Map<string, string>();
1265
const seen = new Set<KeybindingCommand>();
@@ -1300,9 +1281,6 @@ export function KeybindingsSettingsPanel() {
1281
const canWriteSettings =
1282
connectedEnvironments.length > 0 &&
1283
connectedEnvironments.every((target) => writableIds.has(target.environmentId));
1303
- const { keybindings, commandOptions } = useKeybindings(
1304
- primaryEnvironment?.serverConfig?.keybindings,
1305
- );
1284
const keybindingsConfigPath = primaryEnvironment?.serverConfig?.keybindingsConfigPath ?? null;
1285
const availableEditors = primaryEnvironment?.serverConfig?.availableEditors ?? [];
1286
const upsertKeybinding = useAtomCommand(serverEnvironment.upsertKeybinding, {
@@ -1319,7 +1297,6 @@ export function KeybindingsSettingsPanel() {
1297
const searchInputRef = useRef<HTMLInputElement>(null);
1298
const [savingCommand, setSavingCommand] = useState<KeybindingCommand | null>(null);
1299
const [isAddingBinding, setIsAddingBinding] = useState(false);
1322
- const { rows, groups, anchorIds } = useKeybindingRows(keybindings, query);
1300
const searchTargetId = useLocation({ select: (location) => location.hash.replace(/^#/, "") });
1301
const [handledSearchTargetId, setHandledSearchTargetId] = useState(searchTargetId);
1302
@@ -1328,6 +1305,15 @@ export function KeybindingsSettingsPanel() {
1305
if (searchTargetId.startsWith("keybinding-")) setQuery("");
1306
}
1307
const whenVariables = buildWhenVariableOptions();
1308
+ const serverKeybindings = primaryEnvironment?.serverConfig?.keybindings;
1309
+ // Each derivation merges the defaults itself so the command options key on the
1310
+ // server keybindings alone and do not rebuild on every search keystroke.
1311
+ const commandOptions = buildKeybindingCommandOptions(
1312
+ mergeWithDefaultKeybindings(serverKeybindings ?? []),
1313
+ );
1314
+ const rows = buildKeybindingRows(mergeWithDefaultKeybindings(serverKeybindings ?? []), query);
1315
+ const groups = groupKeybindingRows(rows);
1316
+ const anchorIds = keybindingAnchorIds(rows);
1317
1318
const openKeybindingsFile = () => {
1319
if (