feat(web): assign a thread details panel shortcut (#16694)

Co-authored-by: maria-rcks <[email protected]>
This commit is contained in:
mariaandmaria-rcks authored and GitHub committed 2026-10-09 12:54:10 -03:00
1 parent 22ccf8a3df
commit b1508672a6
4 files changed
+62 -13

No files matched your search

+17 -5
View File
@@ -258,12 +258,16 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
yield* writeKeybindingsConfig(keybindingsConfigPath, [
{ key: "mod+shift+y", command: "terminal.toggle" },
{ key: "mod+shift+r", command: "script.run-tests.run" },
{ key: "mod+shift+b", command: "script.custom-panel.run" },
{
key: "mod+shift+b",
command: "script.custom-composer.run",
when: "composerFocus",
},
]);
yield* Effect.gen(function* () {
const keybindings = yield* Keybindings.Keybindings;
yield* keybindings.syncDefaultKeybindingsOnStartup;
});
const keybindings = yield* Keybindings.Keybindings;
yield* keybindings.syncDefaultKeybindingsOnStartup;
const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
const byCommand = new Map(persisted.map((entry) => [entry.command, entry]));
@@ -279,6 +283,14 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
assert.isTrue(byCommand.has(defaultRule.command), `expected ${defaultRule.command}`);
}
assert.isTrue(byCommand.has("script.run-tests.run"));
const configState = yield* keybindings.loadConfigState;
assert.deepEqual(
configState.keybindings
.filter((entry) => entry.shortcut.key === "b" && entry.shortcut.shiftKey)
.map((entry) => entry.command),
["threadPanel.toggle", "script.custom-panel.run", "script.custom-composer.run"],
);
}).pipe(Effect.provide(layerKeybindings())),
);
@@ -295,8 +307,8 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
yield* keybindings.syncDefaultKeybindingsOnStartup;
assert.deepStrictEqual(yield* backgroundRules, [
existing,
{ key: "mod+enter", command: "composer.sendBackground", when },
existing,
]);
// Removing the added rule later must survive the next startup.
+3 -3
View File
@@ -592,8 +592,8 @@ const make = Effect.gen(function* () {
}
}
// Startup backfill must never evict persisted user rules: append only
// the defaults that fit and skip the rest.
// Keep only defaults that fit, before persisted rules so existing
// custom shortcuts retain priority when their conditions overlap.
const availableSlots = Math.max(0, MAX_KEYBINDINGS_COUNT - customConfig.length);
const defaultsToAppend = missingDefaults.slice(0, availableSlots);
const skippedDefaults = missingDefaults.slice(availableSlots);
@@ -605,7 +605,7 @@ const make = Effect.gen(function* () {
});
}
if (defaultsToAppend.length > 0) {
yield* writeConfigAtomically([...customConfig, ...defaultsToAppend]);
yield* writeConfigAtomically([...defaultsToAppend, ...customConfig]);
}
// A late default skipped at max entries stays pending for a later start.
const settledLateDefaults = pendingLateDefaults.filter(
+41 -5
View File
@@ -748,16 +748,52 @@ describe("chat/editor shortcuts", () => {
);
});
it("resolves a user-configured thread panel shortcut without assigning a default", () => {
const bindings = compile([
{ shortcut: modShortcut("b", { shiftKey: true }), command: "threadPanel.toggle" },
]);
it("toggles the thread panel by default without taking terminal keystrokes", () => {
for (const platform of ["MacIntel", "Win32", "Linux"]) {
const input = event({
key: "b",
metaKey: platform === "MacIntel",
ctrlKey: platform !== "MacIntel",
shiftKey: true,
});
assert.strictEqual(
resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
platform,
context: { terminalFocus: false, editableFocus: true },
}),
"threadPanel.toggle",
);
assert.isNull(
resolveShortcutCommand(input, DEFAULT_RESOLVED_KEYBINDINGS, {
platform,
context: { terminalFocus: true },
}),
);
}
});
it("preserves a user-configured thread panel shortcut instead of its default", () => {
const bindings = mergeWithDefaultKeybindings(
compile([
{
shortcut: modShortcut("b", { altKey: true, shiftKey: true }),
command: "threadPanel.toggle",
},
]),
);
assert.strictEqual(
resolveShortcutCommand(
event({ key: "b", metaKey: true, altKey: true, shiftKey: true }),
bindings,
{ platform: "MacIntel" },
),
"threadPanel.toggle",
);
assert.isNull(
resolveShortcutCommand(event({ key: "b", metaKey: true, shiftKey: true }), bindings, {
platform: "MacIntel",
}),
"threadPanel.toggle",
);
});
+1
View File
@@ -126,6 +126,7 @@ export const DEFAULT_KEYBINDINGS: ReadonlyArray<KeybindingRule> = [
{ key: "mod+]", command: "navigation.forward", when: "!terminalFocus" },
{ key: "mod+j", command: "terminal.toggle" },
{ key: "mod+alt+b", command: "rightPanel.toggle" },
{ key: "mod+shift+b", command: "threadPanel.toggle", when: "!terminalFocus" },
{ key: "mod+t", command: "rightPanel.new", when: "rightPanelOpen && !terminalFocus" },
{ key: "mod+d", command: "terminal.split", when: "terminalFocus" },
{ key: "mod+shift+d", command: "terminal.splitVertical", when: "terminalFocus" },