Skip to content

Commit 090ed60

Browse files
0xjjjjjjclaude
andcommitted
fix: make 'b' shortcut route-aware to match hamburger behavior
On sessions route, 'b' toggles the sidebar. On other routes, 'b' navigates back to sessions and opens the sidebar, matching the hamburger button's context-aware behavior. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cd29a13 commit 090ed60

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

frontend/src/lib/utils/keyboard.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
import { ui } from "../stores/ui.svelte.js";
1010
import { sessions } from "../stores/sessions.svelte.js";
1111
import { starred } from "../stores/starred.svelte.js";
12+
import { router } from "../stores/router.svelte.js";
1213
import { registerShortcuts } from "./keyboard.js";
1314

1415
function fireKey(
@@ -283,7 +284,8 @@ describe("registerShortcuts", () => {
283284
});
284285

285286
describe("b shortcut (toggle sidebar)", () => {
286-
it("should toggle sidebar open/closed", () => {
287+
it("should toggle sidebar on sessions route", () => {
288+
router.navigate("sessions");
287289
ui.sidebarOpen = true;
288290
fireKey("b");
289291
expect(ui.sidebarOpen).toBe(false);
@@ -292,14 +294,24 @@ describe("registerShortcuts", () => {
292294
expect(ui.sidebarOpen).toBe(true);
293295
});
294296

297+
it("should navigate to sessions on non-session routes", () => {
298+
router.navigate("insights");
299+
ui.sidebarOpen = false;
300+
fireKey("b");
301+
expect(router.route).toBe("sessions");
302+
expect(ui.sidebarOpen).toBe(true);
303+
});
304+
295305
it("should not toggle sidebar when modal is open", () => {
306+
router.navigate("sessions");
296307
ui.sidebarOpen = true;
297308
ui.activeModal = "shortcuts";
298309
fireKey("b");
299310
expect(ui.sidebarOpen).toBe(true);
300311
});
301312

302313
it("should not toggle sidebar when input is focused", () => {
314+
router.navigate("sessions");
303315
ui.sidebarOpen = true;
304316
const input = document.createElement("input");
305317
document.body.appendChild(input);

frontend/src/lib/utils/keyboard.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,15 @@ export function registerShortcuts(
204204
"?": () => {
205205
ui.activeModal = "shortcuts";
206206
},
207-
b: () => ui.toggleSidebar(),
207+
b: () => {
208+
if (router.route === "sessions") {
209+
ui.toggleSidebar();
210+
} else {
211+
sessions.deselectSession();
212+
router.navigate("sessions");
213+
ui.sidebarOpen = true;
214+
}
215+
},
208216
};
209217

210218
const action = keyActions[e.key];

0 commit comments

Comments
 (0)