mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-08-22 07:04:58 +00:00
The #5074 sidebar request is largely implemented (session list, search, rename, delete, collapse persistence), but the keyboard shortcut item was still missing: there was no way to toggle the sidebar without reaching for the mouse. Add the editor-convention binding: Cmd+B (macOS) / Ctrl+B collapses and expands the sidebar, persisting the preference through the existing writeSidebarCollapsed path. Phone-width layouts render the sidebar as a drawer, so the shortcut toggles the drawer there instead. Shift/Alt variants and the ambiguous Cmd+Ctrl combination are left untouched for the browser and other bindings, and the matcher lives in a small pure module with its own tests. Refs #5074 Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
23 lines
682 B
TypeScript
23 lines
682 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2026 Qwen Team
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* Cmd+B (macOS) / Ctrl+B toggles the session sidebar (#5074), mirroring the
|
|
* convention editors like VS Code use. Plain modifier+B only: Shift/Alt
|
|
* variants stay available to the browser and other bindings, and
|
|
* Cmd+Ctrl combined presses are rejected as ambiguous.
|
|
*/
|
|
export function isSidebarToggleShortcut(event: {
|
|
key: string;
|
|
metaKey: boolean;
|
|
ctrlKey: boolean;
|
|
altKey: boolean;
|
|
shiftKey: boolean;
|
|
}): boolean {
|
|
if (event.key !== 'b' && event.key !== 'B') return false;
|
|
if (event.altKey || event.shiftKey) return false;
|
|
return event.metaKey !== event.ctrlKey;
|
|
}
|