Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix(chat): toggle right sidebar with Option Cmd B

louis5e8fe66c3fa9
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index 617d6068f..d45a70765 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -10,6 +10,11 @@ import { deleteConversationFile } from "@/lib/chat-storage";
import { writeActiveAiPresetId } from "@/lib/active-ai-preset";
import { useSettings } from "@/lib/hooks/use-settings";
import { cn } from "@/lib/utils";
+import {
+ hasOpenShortcutBlockingLayer,
+ inAppShortcutLabel,
+ matchesInAppShortcut,
+} from "@/lib/shortcuts";
import { PanelRightClose, PanelRightOpen } from "lucide-react";
import { Button } from "@/components/ui/button";
import { SchedulePromptDialog } from "@/components/chat/schedule-prompt-dialog";
@@ -808,9 +813,26 @@ export function StandaloneChat({
detail: { action: "toggle" },
}),
);
+ } else {
+ window.dispatchEvent(new CustomEvent("screenpipe:browser-sidebar-new-tab"));
}
}, [sidePanelHasContent]);
+ useEffect(() => {
+ if (!chatShortcutsEnabled) return;
+ const onKeyDown = (event: KeyboardEvent) => {
+ if (
+ event.defaultPrevented || event.repeat || event.isComposing ||
+ event.getModifierState?.("AltGraph") || hasOpenShortcutBlockingLayer()
+ ) return;
+ if (!matchesInAppShortcut(event, "toggle_right_sidebar", isMac)) return;
+ event.preventDefault();
+ toggleBrowserPanel();
+ };
+ window.addEventListener("keydown", onKeyDown);
+ return () => window.removeEventListener("keydown", onKeyDown);
+ }, [chatShortcutsEnabled, isMac, toggleBrowserPanel]);
+
const handlePanelStateChange = useCallback(
(nextState: { hasUrl: boolean; open: boolean }) => {
setBrowserPanelState((currentState) =>
@@ -2250,19 +2272,14 @@ export function StandaloneChat({
onMouseDown={(e) => e.stopPropagation()}
onClick={(e) => {
e.stopPropagation();
- if (sidePanelHasContent) {
- toggleBrowserPanel();
- } else {
- window.dispatchEvent(
- new CustomEvent("screenpipe:browser-sidebar-new-tab"),
- );
- }
+ toggleBrowserPanel();
}}
className={cn(
"h-7 w-7",
sidePanelOpen && "bg-muted ring-2 ring-primary ring-offset-1 ring-offset-background",
)}
- title={sidePanelHasContent ? ui("Toggle side panel") : ui("Open browser tab")}
+ title={`${sidePanelHasContent ? ui("Toggle side panel") : ui("Open browser tab")} (${inAppShortcutLabel("toggle_right_sidebar", isMac)})`}
+ aria-keyshortcuts={isMac ? "Alt+Meta+B" : "Control+Alt+B"}
aria-label={sidePanelHasContent ? ui("Toggle side panel") : ui("Open browser tab")}
aria-pressed={sidePanelOpen}
>
diff --git a/apps/screenpipe-app-tauri/lib/__tests__/shortcuts.test.ts b/apps/screenpipe-app-tauri/lib/__tests__/shortcuts.test.ts
index b6d1c3319..fee4146e9 100644
--- a/apps/screenpipe-app-tauri/lib/__tests__/shortcuts.test.ts
+++ b/apps/screenpipe-app-tauri/lib/__tests__/shortcuts.test.ts
@@ -23,6 +23,18 @@ describe("in-app shortcut registry", () => {
expect(inAppShortcutLabel("next_recent_chat", false)).toBe("Ctrl+Tab");
});
+ it("matches the right sidebar chord even when macOS Option changes the key", () => {
+ const mac = keyEvent({ key: "∫", code: "KeyB", metaKey: true, altKey: true });
+ expect(matchesInAppShortcut(mac, "toggle_right_sidebar", true)).toBe(true);
+ expect(matchesInAppShortcut(mac, "toggle_sidebar", true)).toBe(false);
+ expect(matchesInAppShortcut(mac, "toggle_right_sidebar", false)).toBe(false);
+ expect(inAppShortcutLabel("toggle_right_sidebar", true)).toBe("⌥⌘B");
+ expect(inAppShortcutLabel("toggle_right_sidebar", false)).toBe("Ctrl+Alt+B");
+ expect(matchesInAppShortcut(keyEvent({ key: "b", ctrlKey: true, altKey: true }), "toggle_right_sidebar", false)).toBe(true);
+ expect(matchesInAppShortcut(keyEvent({ key: "b", metaKey: true }), "toggle_right_sidebar", true)).toBe(false);
+ expect(matchesInAppShortcut(keyEvent({ key: "b", metaKey: true, altKey: true, shiftKey: true }), "toggle_right_sidebar", true)).toBe(false);
+ });
+
it("matches Cmd+W on macOS and Ctrl+W elsewhere", () => {
expect(
matchesInAppShortcut(
diff --git a/apps/screenpipe-app-tauri/lib/shortcuts.ts b/apps/screenpipe-app-tauri/lib/shortcuts.ts
index 643e6d608..b79dd7229 100644
--- a/apps/screenpipe-app-tauri/lib/shortcuts.ts
+++ b/apps/screenpipe-app-tauri/lib/shortcuts.ts
@@ -14,6 +14,7 @@ export type InAppShortcutId =
| "command_menu"
| "shortcut_guide"
| "toggle_sidebar"
+ | "toggle_right_sidebar"
| "next_recent_chat"
| "previous_recent_chat";
@@ -63,6 +64,12 @@ export const IN_APP_SHORTCUTS: readonly InAppShortcutDefinition[] = [
label: msg("Toggle sidebar", {}),
description: msg("Show or hide the durable chat index", {}),
},
+ {
+ id: "toggle_right_sidebar",
+ section: "app",
+ label: msg("Toggle right sidebar", {}),
+ description: msg("Show or hide the browser and file preview panel", {}),
+ },
{
id: "command_menu",
section: "app",
@@ -132,6 +139,8 @@ export function inAppShortcutLabel(
return `${primary}/`;
case "toggle_sidebar":
return `${primary}B`;
+ case "toggle_right_sidebar":
+ return isMac ? "⌥⌘B" : "Ctrl+Alt+B";
case "next_recent_chat":
return isMac ? "⌃Tab" : "Ctrl+Tab";
case "previous_recent_chat":
@@ -168,6 +177,8 @@ function specFor(id: InAppShortcutId, isMac: boolean): ShortcutSpec {
return { ...primary, key: "/", code: "Slash" };
case "toggle_sidebar":
return { ...primary, key: "b", code: "KeyB" };
+ case "toggle_right_sidebar":
+ return { ...primary, alt: true, key: "b", code: "KeyB" };
case "next_recent_chat":
return { key: "Tab", meta: false, ctrl: true, shift: false, alt: false };
case "previous_recent_chat":