The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 19:30 UTC
fix(web): a Usage toggle shortcut now goes back instead of staying on Usage (#22905)
Co-authored-by: Victor Vogel <satsdev@only21mil.xyz> Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Theo Browne committed
Oct 21, 2026 at 15:10 UTC
bee9ce829bb72503e3eaebeeb7397ba96b9762d0
3 files changed
+59
-2
apps/web/src/components/AppSidebarLayout.tsx
+4
-2
@@ -219,7 +219,8 @@ function routePanelsOpen(routeThreadRef: ReturnType<typeof useThreadRouteRef>) {
219
};
220
}
221
222
-function NavigationHistoryShortcuts() {
222
+export function NavigationHistoryShortcuts() {
223
+ const usagePageOpen = useLocation({ select: (location) => location.pathname === "/usage" });
224
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
225
const routeThreadRef = useThreadRouteRef();
226
@@ -239,6 +240,7 @@ function NavigationHistoryShortcuts() {
240
...routePanelsOpen(routeThreadRef),
241
editableFocus: isEditableFocused(event.target),
242
modelPickerOpen: isModelPickerOpen(),
243
+ usagePageOpen,
244
},
245
});
246
if (command !== "navigation.back" && command !== "navigation.forward") return;
@@ -251,7 +253,7 @@ function NavigationHistoryShortcuts() {
253
254
window.addEventListener("keydown", onKeyDown);
255
return () => window.removeEventListener("keydown", onKeyDown);
254
- }, [keybindings, routeThreadRef]);
256
+ }, [keybindings, routeThreadRef, usagePageOpen]);
257
258
return null;
259
}
apps/web/src/components/CommandPalette.tsx
+3
@@ -237,6 +237,7 @@ const EMPTY_BROWSE_ENTRIES: FilesystemBrowseResult["entries"] = [];
237
238
export function CommandPalette({ children }: { children: ReactNode }) {
239
const navigate = useNavigate();
240
+ const usagePageOpen = useLocation({ select: (location) => location.pathname === "/usage" });
241
const [state, dispatch] = useReducer(reduceCommandPaletteUiState, {
242
open: false,
243
mode: "command",
@@ -287,6 +288,7 @@ export function CommandPalette({ children }: { children: ReactNode }) {
288
previewFocus: isPreviewFocused(),
289
previewOpen,
290
modelPickerOpen: composerHandleRef.current?.isModelPickerOpen() ?? false,
291
+ usagePageOpen,
292
},
293
});
294
if (command === "appearance.cycle") {
@@ -352,6 +354,7 @@ export function CommandPalette({ children }: { children: ReactNode }) {
354
theme,
355
themeHalves,
356
toggleMode,
357
+ usagePageOpen,
358
]);
359
360
useEffect(
apps/web/src/components/UsageToggleShortcut.browser.test.tsx
new
+52
@@ -0,0 +1,52 @@
1
+import { compileResolvedKeybindingsConfig } from "@t3tools/shared/keybindings";
2
+import { describe, expect, it, vi } from "vite-plus/test";
3
+import { userEvent } from "vite-plus/test/browser";
4
+
5
+import { render } from "../../test/render";
6
+
7
+const state = vi.hoisted(() => ({ navigate: vi.fn() }));
8
+
9
+// One key toggles Usage: it opens Usage elsewhere and goes back from it.
10
+const keybindings = compileResolvedKeybindingsConfig([
11
+ { key: "mod+u", command: "navigation.back", when: "usagePageOpen" },
12
+ { key: "mod+u", command: "usage.open", when: "!usagePageOpen" },
13
+]);
14
+
15
+vi.mock(import("@effect/atom-react"), async (original) => ({
16
+ ...(await original()),
17
+ useAtomValue: (() => keybindings) as never,
18
+}));
19
+vi.mock(import("@tanstack/react-router"), async (original) => ({
20
+ ...(await original()),
21
+ useNavigate: (() => state.navigate) as never,
22
+}));
23
+
24
+import { NavigationHistoryShortcuts } from "./AppSidebarLayout";
25
+import { CommandPalette } from "./CommandPalette";
26
+
27
+// regression: #21357
28
+describe("usage toggle shortcut on Usage", () => {
29
+ it("goes back", async () => {
30
+ vi.clearAllMocks();
31
+ using _platform = vi.spyOn(navigator, "platform", "get").mockReturnValue("Linux x86_64");
32
+ await using _screen = await render(<NavigationHistoryShortcuts />, { router: "/usage" });
33
+
34
+ using back = vi.spyOn(window.history, "back").mockImplementation(() => undefined);
35
+ await userEvent.keyboard("{Control>}u{/Control}");
36
+
37
+ expect(back).toHaveBeenCalledOnce();
38
+ });
39
+
40
+ // Both listeners sit on window, so the palette must not claim the key whatever their order.
41
+ it("does not reopen Usage from the command palette", async () => {
42
+ vi.clearAllMocks();
43
+ using _platform = vi.spyOn(navigator, "platform", "get").mockReturnValue("Linux x86_64");
44
+ await using _screen = await render(<CommandPalette>{null}</CommandPalette>, {
45
+ router: "/usage",
46
+ });
47
+
48
+ await userEvent.keyboard("{Control>}u{/Control}");
49
+
50
+ expect(state.navigate).not.toHaveBeenCalled();
51
+ });
52
+});