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

feat(chat): add sidebar tools and consistent chat action shortcuts (#7295)

Louis Beaumont2972f4fa966b
diff --git a/apps/screenpipe-app-tauri/components/__tests__/chat-sidebar-focus.test.tsx b/apps/screenpipe-app-tauri/components/__tests__/chat-sidebar-focus.test.tsx
index 44f1904fb..c2e520de6 100644
--- a/apps/screenpipe-app-tauri/components/__tests__/chat-sidebar-focus.test.tsx
+++ b/apps/screenpipe-app-tauri/components/__tests__/chat-sidebar-focus.test.tsx
@@ -289,7 +289,7 @@ describe("menu letter shortcuts", () => {
fireEvent.contextMenu(screen.getByTestId("chat-row-chat-focus-test"));
const branchItem = await screen.findByText("Branch in new chat");
- expect(branchItem.closest('[role="menuitem"]')).toHaveAttribute("data-shortcut", "b");
+ expect(branchItem.closest('[role="menuitem"]')).toHaveAttribute("data-chat-shortcut", "branch_chat");
fireEvent.click(branchItem);
diff --git a/apps/screenpipe-app-tauri/components/browser-sidebar.test.tsx b/apps/screenpipe-app-tauri/components/browser-sidebar.test.tsx
index 796a123de..f86710842 100644
--- a/apps/screenpipe-app-tauri/components/browser-sidebar.test.tsx
+++ b/apps/screenpipe-app-tauri/components/browser-sidebar.test.tsx
@@ -167,6 +167,30 @@ describe("BrowserSidebar session access", () => {
vi.unstubAllGlobals();
});
+ it("opens useful destinations without creating a browser tab and resets on chat switch", async () => {
+ const view = render(<BrowserSidebar conversationId="chat-1" />);
+ await act(async () => { window.dispatchEvent(new CustomEvent("screenpipe:browser-sidebar-toggle")); });
+ expect(await screen.findByText("Keep your work close")).toBeVisible();
+ expect(mocks.ownedBrowserNavigate).not.toHaveBeenCalled();
+ fireEvent.click(screen.getByRole("button", {name:/Files and outputs/}));
+ expect(screen.getByText("No files in this chat yet")).toBeVisible();
+ fireEvent.click(screen.getByRole("button", {name:"Close right sidebar"}));
+ expect(screen.queryByText("No files in this chat yet")).toBeNull();
+ await act(async () => { window.dispatchEvent(new CustomEvent("screenpipe:browser-sidebar-toggle")); });
+ expect(await screen.findByText("Keep your work close")).toBeVisible();
+ view.rerender(<BrowserSidebar conversationId="chat-2" />);
+ expect(screen.queryByText("Keep your work close")).toBeNull();
+ });
+
+ it("lists this chat's output files and opens the selected path", async () => {
+ const open = vi.fn();
+ render(<BrowserSidebar conversationId="chat-1" outputs={[{id:"report",kind:"file",path:"/reports/weekly.md",title:"Weekly report"}]} onReplaceFilePreviewPath={open} />);
+ await act(async () => { window.dispatchEvent(new CustomEvent("screenpipe:browser-sidebar-toggle")); });
+ fireEvent.click(await screen.findByRole("button", {name:/Files and outputs/}));
+ fireEvent.click(screen.getByRole("button", {name:"Weekly report"}));
+ expect(open).toHaveBeenCalledWith("/reports/weekly.md");
+ });
+
it("shows a session prompt emitted immediately after a replacement navigation", async () => {
render(<BrowserSidebar conversationId="chat-1" />);
expect(mocks.listeners.has("owned-browser:navigate")).toBe(true);
diff --git a/apps/screenpipe-app-tauri/components/browser-sidebar.tsx b/apps/screenpipe-app-tauri/components/browser-sidebar.tsx
index f378cde3a..83a02e93e 100644
--- a/apps/screenpipe-app-tauri/components/browser-sidebar.tsx
+++ b/apps/screenpipe-app-tauri/components/browser-sidebar.tsx
@@ -58,6 +58,8 @@ import {
resolveNewestBrowserState,
setCachedBrowserState,
} from "@/lib/browser-state-cache";
+import { ChatPanelHome } from "@/components/chat/chat-panel-home";
+import type { SourceCitation } from "@/lib/source-citations";
import { Button } from "@/components/ui/button";
import { FilePreviewSidebar } from "@/components/file-preview-sidebar";
import {
@@ -88,10 +90,12 @@ const DEFAULT_WIDTH = 480;
const MIN_WIDTH = 320;
const MIN_CHAT_WIDTH = 360;
const EMPTY_FILE_PATHS: string[] = [];
+const EMPTY_OUTPUTS: SourceCitation[] = [];
const CHROME_WEBSTORE_URL =
"https://chromewebstore.google.com/search/screenpipe%20browser%20bridge";
interface BrowserSidebarProps {
+ outputs?: SourceCitation[];
conversationId: string | null;
/** Width already reserved by sibling panes such as the live chat split. */
additionalReservedWidth?: number;
@@ -192,6 +196,7 @@ function clampWidth(
export function BrowserSidebar({
conversationId,
+ outputs = EMPTY_OUTPUTS,
additionalReservedWidth = 0,
agentSessionId,
filePreview,
@@ -207,6 +212,8 @@ export function BrowserSidebar({
const { settings, updateSettings } = useSettings();
const [visible, setVisible] = useState(false);
const [collapsed, setCollapsed] = useState(false);
+ const [panelView, setPanelView] = useState<"home" | "files" | null>(null);
+ const openedHomeDuringRestoreRef = useRef(false);
const [currentUrl, setCurrentUrl] = useState<string | null>(null);
const [currentOwner, setCurrentOwner] = useState<string | null>(null);
const [currentNavigationId, setCurrentNavigationIdState] = useState<
@@ -279,8 +286,11 @@ export function BrowserSidebar({
);
const hasPanelContent = !!currentUrl || filePaths.length > 0;
const panelRequestedOpen = filePreview?.panelOpen ?? (visible && !collapsed);
- const panelOpen = panelRequestedOpen && hasPanelContent && effectiveWidth > 0;
- const previewActive = panelOpen && !!previewPath;
+ const panelOpen = panelRequestedOpen && (hasPanelContent || panelView !== null) && effectiveWidth > 0;
+ const homeActive = panelOpen && panelView !== null;
+ const previewActive = panelOpen && !!previewPath && !homeActive;
+
+ useEffect(() => { setPanelView(null); }, [conversationId, currentUrl, previewPath]);
useEffect(() => {
try {
@@ -464,11 +474,10 @@ export function BrowserSidebar({
// ---------------------------------------------------------------------------
useEffect(() => {
- // Only target full-page modal dialogs (with backdrop overlay), not small
- // popovers or dropdown menus. Our DialogOverlay and AlertDialogOverlay
- // components add data-modal-overlay; popovers/dropdowns don't have one.
+ // Chat action menus can overlap the native page just like modal dialogs.
+ // Hide it for those surfaces, then restore its bounds when they close.
const hasModalOverlay = () =>
- document.querySelectorAll("[data-modal-overlay]").length > 0;
+ document.querySelectorAll('[data-modal-overlay], [data-chat-actions-menu][data-state="open"]').length > 0;
const sync = () => {
const open = hasModalOverlay();
@@ -877,6 +886,7 @@ export function BrowserSidebar({
useEffect(() => {
let cancelled = false;
+ openedHomeDuringRestoreRef.current = false;
for (const tab of browserTabsRef.current) {
if (tab.id !== BROWSER_RIGHT_PANEL_TAB_ID) {
void commands.ownedBrowserTabClose(tab.id).catch(() => {});
@@ -906,7 +916,8 @@ export function BrowserSidebar({
let unlistenReady: (() => void) | null = null;
(async () => {
const conv = await loadConversationFile(conversationId).catch(() => null);
- if (cancelled) return;
+ // An explicit panel action wins over a slower disk restore.
+ if (cancelled || openedHomeDuringRestoreRef.current) return;
const state = resolveNewestBrowserState(
conv?.browserState,
getCachedBrowserStateEntry(conversationId),
@@ -985,10 +996,10 @@ export function BrowserSidebar({
}, [conversationId, hideNativeBrowserTab, updateBrowserTab]);
useEffect(() => {
- if (previewActive) {
+ if (previewActive || homeActive) {
hideNativeBrowserTab(activeBrowserTabIdRef.current).catch(() => {});
}
- }, [hideNativeBrowserTab, previewActive]);
+ }, [hideNativeBrowserTab, previewActive, homeActive]);
// ---------------------------------------------------------------------------
// Bounds tracking — covers slide-in, window resize, drag-resize, and
@@ -1002,7 +1013,7 @@ export function BrowserSidebar({
hideNativeBrowserTab(activeBrowserTabIdRef.current).catch(() => {});
return;
}
- if (previewActive) {
+ if (previewActive || homeActive) {
hideNativeBrowserTab(activeBrowserTabIdRef.current).catch(() => {});
return;
}
@@ -1028,6 +1039,7 @@ export function BrowserSidebar({
availableW,
schedulePushBounds,
previewActive,
+ homeActive,
hideNativeBrowserTab,
]);
@@ -1253,7 +1265,11 @@ export function BrowserSidebar({
const expand = useCallback(() => {
setCollapsed(false);
- if (currentUrl) setVisible(true);
+ setVisible(true);
+ if (!hasPanelContent) {
+ openedHomeDuringRestoreRef.current = true;
+ setPanelView("home");
+ }
if (!previewPath && !currentUrl && filePaths[0]) {
onSelectFilePreviewPath?.(filePaths[0]);
}
@@ -1261,6 +1277,7 @@ export function BrowserSidebar({
persistState({ collapsed: false });
}, [
currentUrl,
+ hasPanelContent,
filePaths,
onSelectFilePreviewPath,
onSetPanelOpen,
@@ -1270,7 +1287,6 @@ export function BrowserSidebar({
const toggleFromHeader = useCallback(
(action: "toggle" | "show" = "toggle") => {
- if (!hasPanelContent) return;
if (action === "show") {
expand();
return;
@@ -1369,6 +1385,7 @@ export function BrowserSidebar({
);
const createBrowserTab = useCallback(() => {
+ setPanelView(null);
const tabId = `tab-${crypto.randomUUID()}`;
const url = "about:blank";
const owner = conversationId ?? agentSessionId ?? null;
@@ -1593,9 +1610,11 @@ export function BrowserSidebar({
</div>
<RightPanelTabStrip
+ onHome={() => setPanelView("home")}
+ homeActive={homeActive}
tabs={panelTabs}
- activeTabId={activePanelTabId}
- onSelect={selectPanelTab}
+ activeTabId={homeActive ? null : activePanelTabId}
+ onSelect={tab => { setPanelView(null); selectPanelTab(tab); }}
onClose={closePanelTab}
onNewBrowserTab={createBrowserTab}
/>
@@ -1607,7 +1626,10 @@ export function BrowserSidebar({
}
className="flex min-h-0 flex-1 flex-col"
>
- {previewActive ? (
+ {homeActive ? (
+ <ChatPanelHome view={panelView!} onViewChange={setPanelView} outputs={outputs} paths={filePaths}
+ onOpenBrowser={createBrowserTab} onOpenFile={path => { setPanelView(null); onReplaceFilePreviewPath?.(path); }} onClose={collapse} />
+ ) : previewActive ? (
previewPath ? (
<FilePreviewSidebar
path={previewPath}
diff --git a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx b/apps/screenpipe-app-tauri/components/chat-sidebar.tsx
index f75791aef..12fb9d82c 100644
--- a/apps/screenpipe-app-tauri/components/chat-sidebar.tsx
+++ b/apps/screenpipe-app-tauri/components/chat-sidebar.tsx
@@ -52,6 +52,7 @@ import {
GitBranch,
LockKeyhole,
} from "lucide-react";
+import { ChatActionMenuItems, CHAT_MENU_CLASS, handleChatMenuShortcut } from "@/components/chat/chat-action-menu";
import { usePlatform } from "@/lib/hooks/use-platform";
import { emit, listen } from "@tauri-apps/api/event";
import { cn } from "@/lib/utils";
@@ -2854,13 +2855,6 @@ interface ChatRowProps {
setOpenConversationMenuId?: (id: string | null) => void;
}
-/**
- * Single-letter shortcuts shown on the right of each menu row (anthropic-style).
- * Each maps to an item carrying `data-shortcut={key}`; pressing the key while a
- * row menu is open selects that item. Keep in sync with `RowMenuItems`.
- */
-const ROW_MENU_SHORTCUT_KEYS = ["p", "r", "b", "a", "d"] as const;
-
/**
* Press a shortcut letter while a menu is open to fire the matching item. We
* forward Enter so radix runs its own onSelect + close — no second action path.
@@ -2888,7 +2882,7 @@ function handleRecentsMenuShortcut(e: React.KeyboardEvent<HTMLElement>) {
}
function handleRowMenuShortcut(e: React.KeyboardEvent<HTMLElement>) {
- handleMenuShortcut(e, ROW_MENU_SHORTCUT_KEYS);
+ handleChatMenuShortcut(e);
}
/**
@@ -2957,49 +2951,15 @@ function RowMenuItems({
const { isMac } = usePlatform();
const itemCls = "text-[11px] h-[30px] px-2 gap-2 rounded-sm focus:bg-muted/30";
const groupItemCls = "min-w-0 text-[11px] h-[30px] px-2 rounded-sm whitespace-nowrap focus:bg-muted/30";
- const shortcutCls = "text-[10px] tracking-normal text-muted-foreground/55";
- return (
+ return (
<>
- <P.Item
- data-shortcut="p"
- className={itemCls}
- onSelect={(e: Event) => {
- e.stopPropagation();
- void onTogglePin(session.id);
- }}
- >
- <Pin className="h-3 w-3 text-muted-foreground" />
- {session.pinned ? ui("Unpin") : ui("Pin")}
- <P.Shortcut className={shortcutCls}>P</P.Shortcut>
- </P.Item>
- <P.Item
- data-shortcut="r"
- className={itemCls}
- onSelect={(e: Event) => {
- e.stopPropagation();
- onRenameRequest(session.id);
- }}
- >
- <Pencil className="h-3 w-3 text-muted-foreground" />
- Rename
- <P.Shortcut className={shortcutCls}>R</P.Shortcut>
- </P.Item>
- {onBranch && (
- <P.Item
- data-shortcut="b"
- aria-keyshortcuts="B"
- className={itemCls}
- disabled={session.messageCount === 0}
- onSelect={(e: Event) => {
- e.stopPropagation();
- void onBranch(session.id);
- }}
- >
- <GitBranch className="h-3 w-3 text-muted-foreground" />
- Branch in new chat
- <P.Shortcut className={shortcutCls}>B</P.Shortcut>
- </P.Item>
- )}
+ <ChatActionMenuItems variant={variant} session={session} canBranch={Boolean(onBranch)} onAction={action => {
+ if (action === "rename_chat") onRenameRequest(session.id);
+ if (action === "pin_chat") void onTogglePin(session.id);
+ if (action === "branch_chat") void onBranch?.(session.id);
+ if (action === "archive_chat") void (session.hidden ? onUnarchive(session.id) : onArchive(session.id));
+ }} />
+ <P.Separator />
{onMoveToGroup && existingGroups && (
<P.Sub>
<P.SubTrigger
@@ -3069,36 +3029,8 @@ function RowMenuItems({
</P.SubContent>
</P.Sub>
)}
- {!session.hidden ? (
- <P.Item
- data-shortcut="a"
- className={itemCls}
- onSelect={(e: Event) => {
- e.stopPropagation();
- void onArchive(session.id);
- }}
- >
- <Archive className="h-3 w-3 text-muted-foreground" />
- Archive
- <P.Shortcut className={shortcutCls}>A</P.Shortcut>
- </P.Item>
- ) : (
- <P.Item
- data-shortcut="a"
- className={itemCls}
- onSelect={(e: Event) => {
- e.stopPropagation();
- void onUnarchive(session.id);
- }}
- >
- <Undo2 className="h-3 w-3 text-muted-foreground" />
- Unarchive
- <P.Shortcut className={shortcutCls}>A</P.Shortcut>
- </P.Item>
- )}
<P.Separator className="my-1 bg-border/70" />
<P.Item
- data-shortcut="d"
className="text-[11px] h-[30px] px-2 gap-2 rounded-none text-destructive focus:text-destructive focus:bg-destructive/10"
onSelect={(e: Event) => {
e.stopPropagation();
@@ -3107,7 +3039,6 @@ function RowMenuItems({
>
<Trash2 className="h-3 w-3 text-destructive" />
Delete
- <P.Shortcut className={cn(shortcutCls, "text-destructive/60")}>D</P.Shortcut>
</P.Item>
</>
);
@@ -3367,7 +3298,7 @@ export function SidebarChatRow({
side="bottom"
sideOffset={4}
collisionPadding={8}
- className="w-[156px] p-1 rounded-lg border border-border bg-background shadow-none"
+ className={CHAT_MENU_CLASS} data-chat-actions-menu=""
onClick={(e) => e.stopPropagation()}
onPointerDown={(e) => e.stopPropagation()}
onKeyDown={handleRowMenuShortcut}
@@ -3381,7 +3312,7 @@ export function SidebarChatRow({
</ContextMenuTrigger>
{canShowActions && (
<ContextMenuContent
- className="w-[156px] p-1 rounded-none border border-border bg-background shadow-none"
+ className={CHAT_MENU_CLASS} data-chat-actions-menu=""
onKeyDown={handleRowMenuShortcut}
>
<RowMenuItems variant="context" session={session} {...rowMenuActions} />
diff --git a/apps/screenpipe-app-tauri/components/chat/chat-action-menu.tsx b/apps/screenpipe-app-tauri/components/chat/chat-action-menu.tsx
new file mode 100644
index 000000000..472221b15
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/chat/chat-action-menu.tsx
@@ -0,0 +1,279 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+"use client";
+
+import type React from "react";
+import { useRef } from "react";
+import {
+ Archive,
+ Copy,
+ GitBranch,
+ MoreHorizontal,
+ Pencil,
+ Pin,
+ Undo2,
+} from "lucide-react";
+import * as Context from "@/components/ui/context-menu";
+import * as Dropdown from "@/components/ui/dropdown-menu";
+import { usePlatform } from "@/lib/hooks/use-platform";
+import { useOptionalSettings } from "@/lib/hooks/use-settings";
+import {
+ conflictsWithGlobalShortcut,
+ inAppShortcutLabel,
+ matchesInAppShortcut,
+ type InAppShortcutId,
+} from "@/lib/shortcuts";
+import {
+ isEphemeralSideConversation,
+ useChatStore,
+ type SessionRecord,
+} from "@/lib/stores/chat-store";
+import { commands } from "@/lib/utils/tauri";
+import { chatConversationLink } from "@/lib/chat/conversation-link";
+import { formatChatAsMarkdown } from "@/lib/chat/markdown-export";
+import type { Message } from "@/lib/chat/types";
+import { toast } from "@/components/ui/use-toast";
+import { useGT } from "gt-react";
+
+export const CHAT_MENU_ACTION_EVENT = "screenpipe:chat-menu-action";
+export const CHAT_MENU_ACTIONS = [
+ "rename_chat",
+ "pin_chat",
+ "branch_chat",
+ "archive_chat",
+] as const;
+export type ChatMenuAction = (typeof CHAT_MENU_ACTIONS)[number];
+export type ChatMenuRequest = { id: string; action: ChatMenuAction };
+
+export function useChatActionBindings() {
+ const { isMac } = usePlatform();
+ const settings = useOptionalSettings()?.settings ?? {};
+ const available = (id: InAppShortcutId) =>
+ !conflictsWithGlobalShortcut(id, isMac, settings);
+ return {
+ label: (id: InAppShortcutId) =>
+ available(id) ? inAppShortcutLabel(id, isMac) : "",
+ match: (event: KeyboardEvent, id: InAppShortcutId) =>
+ available(id) && matchesInAppShortcut(event, id, isMac),
+ };
+}
+
+/** Menus target the row they belong to; closed-menu shortcuts target the active chat. */
+export function handleChatMenuShortcut(
+ event: React.KeyboardEvent<HTMLElement>,
+) {
+ if (
+ event.defaultPrevented ||
+ event.repeat ||
+ event.nativeEvent.isComposing ||
+ event.nativeEvent.getModifierState?.("AltGraph")
+ )
+ return;
+ const items = event.currentTarget.querySelectorAll<HTMLElement>(
+ "[data-chat-shortcut]",
+ );
+ for (const item of items) {
+ if (
+ item.dataset.disabled !== undefined ||
+ item.getAttribute("aria-disabled") === "true"
+ )
+ continue;
+ const id = item.dataset.chatShortcut as InAppShortcutId;
+ const isMac = item.dataset.shortcutPlatform === "mac";
+ if (!matchesInAppShortcut(event.nativeEvent, id, isMac)) continue;
+ event.preventDefault();
+ event.stopPropagation();
+ item.click();
+ return;
+ }
+}
+
+const parts = {
+ context: {
+ Item: Context.ContextMenuItem,
+ Shortcut: Context.ContextMenuShortcut,
+ Separator: Context.ContextMenuSeparator,
+ Sub: Context.ContextMenuSub,
+ Trigger: Context.ContextMenuSubTrigger,
+ Content: Context.ContextMenuSubContent,
+ },
+ dropdown: {
+ Item: Dropdown.DropdownMenuItem,
+ Shortcut: Dropdown.DropdownMenuShortcut,
+ Separator: Dropdown.DropdownMenuSeparator,
+ Sub: Dropdown.DropdownMenuSub,
+ Trigger: Dropdown.DropdownMenuSubTrigger,
+ Content: Dropdown.DropdownMenuSubContent,
+ },
+};
+
+export const CHAT_MENU_CLASS =
+ "w-64 rounded-lg border border-border bg-popover p-1 shadow-md";
+
+export function ChatActionMenuItems({
+ variant,
+ session,
+ onAction,
+ onBeforeCopy,
+ canBranch = true,
+}: {
+ variant: "context" | "dropdown";
+ session: SessionRecord;
+ onAction: (action: ChatMenuAction) => void;
+ onBeforeCopy?: () => void;
+ canBranch?: boolean;
+}) {
+ const ui = useGT();
+ const P = parts[variant];
+ const bindings = useChatActionBindings();
+ const { isMac } = usePlatform();
+ if (isEphemeralSideConversation(session)) return null;
+ const items = [
+ { id: "rename_chat", label: ui("Rename"), Icon: Pencil },
+ {
+ id: "pin_chat",
+ label: session.pinned ? ui("Unpin") : ui("Pin"),
+ Icon: Pin,
+ },
+ { id: "branch_chat", label: ui("Branch in new chat"), Icon: GitBranch },
+ {
+ id: "archive_chat",
+ label: session.hidden ? ui("Unarchive") : ui("Archive"),
+ Icon: session.hidden ? Undo2 : Archive,
+ },
+ ] as const;
+ const copy = async (kind: "link" | "markdown" | "id" | "path") => {
+ onBeforeCopy?.();
+ try {
+ let text =
+ kind === "link"
+ ? chatConversationLink(session.id)
+ : kind === "path"
+ ? (session.codingWorkspace?.worktreePath ?? "")
+ : session.id;
+ if (kind === "markdown") {
+ const { loadConversationFile } = await import("@/lib/chat-storage");
+ const messages = session.messages?.length
+ ? session.messages
+ : ((await loadConversationFile(session.id))?.messages ?? []);
+ if (!messages.length) {
+ toast({ title: ui("No messages to copy") });
+ return;
+ }
+ text = formatChatAsMarkdown(messages as Message[], {
+ deferredMessageIds: new Set(),
+ aggregatedAfter: new Map(),
+ });
+ }
+ await commands.copyTextToClipboard(text);
+ toast({ title: ui("Copied") });
+ } catch {
+ toast({ title: ui("Couldn't copy chat"), variant: "destructive" });
+ }
+ };
+ return (
+ <>
+ {items.map(({ id, label, Icon }) => {
+ const hint = bindings.label(id);
+ return (
+ <P.Item
+ key={id}
+ className="min-h-8 gap-2 rounded-md px-2 text-xs"
+ disabled={
+ id === "branch_chat" && (!canBranch || session.messageCount === 0)
+ }
+ data-chat-shortcut={hint ? id : undefined}
+ data-shortcut-platform={isMac ? "mac" : "other"}
+ onSelect={(event) => {
+ event.stopPropagation();
+ onAction(id);
+ }}
+ >
+ <Icon className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
+ <span>{label}</span>
+ <P.Shortcut className="ml-auto pl-3 text-[10px] tracking-normal">
+ {hint}
+ </P.Shortcut>
+ </P.Item>
+ );
+ })}
+ <P.Separator />
+ <P.Sub>
+ <P.Trigger className="min-h-8 gap-2 rounded-md px-2 text-xs">
+ <Copy className="h-3.5 w-3.5 text-muted-foreground" />
+ {ui("Copy")}
+ </P.Trigger>
+ <P.Content className="w-48 rounded-lg p-1">
+ <P.Item onSelect={() => void copy("link")}>{ui("Copy link")}</P.Item>
+ <P.Item onSelect={() => void copy("markdown")}>
+ {ui("Copy as Markdown")}
+ </P.Item>
+ <P.Item onSelect={() => void copy("id")}>{ui("Copy chat ID")}</P.Item>
+ {session.codingWorkspace && (
+ <P.Item onSelect={() => void copy("path")}>
+ {ui("Copy worktree path")}
+ </P.Item>
+ )}
+ </P.Content>
+ </P.Sub>
+ </>
+ );
+}
+
+export function ChatActionsDropdown({
+ conversationId,
+}: {
+ conversationId: string | null;
+}) {
+ const session = useChatStore((state) =>
+ conversationId ? state.sessions[conversationId] : undefined,
+ );
+ const ui = useGT();
+ const pendingAction = useRef<ChatMenuRequest | null>(null);
+ return (
+ <Dropdown.DropdownMenu>
+ <Dropdown.DropdownMenuTrigger asChild>
+ <button
+ type="button"
+ aria-label={ui("Chat actions")}
+ title={ui("Chat actions")}
+ disabled={!session || isEphemeralSideConversation(session)}
+ onMouseDown={(event) => event.stopPropagation()}
+ className="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-40"
+ >
+ <MoreHorizontal className="h-4 w-4" />
+ </button>
+ </Dropdown.DropdownMenuTrigger>
+ <Dropdown.DropdownMenuContent
+ data-chat-actions-menu=""
+ align="end"
+ className={CHAT_MENU_CLASS}
+ onKeyDown={handleChatMenuShortcut}
+ onCloseAutoFocus={(event) => {
+ const request = pendingAction.current;
+ if (!request) return;
+ pendingAction.current = null;
+ event.preventDefault();
+ // Let the menu's focus trap finish before focusing a rename input.
+ requestAnimationFrame(() =>
+ window.dispatchEvent(
+ new CustomEvent<ChatMenuRequest>(CHAT_MENU_ACTION_EVENT, {
+ detail: request,
+ }),
+ ),
+ );
+ }}
+ >
+ {session && (
+ <ChatActionMenuItems
+ variant="dropdown"
+ session={session}
+ onAction={(action) => {
+ pendingAction.current = { id: session.id, action };
+ }}
+ />
+ )}
+ </Dropdown.DropdownMenuContent>
+ </Dropdown.DropdownMenu>
+ );
+}
diff --git a/apps/screenpipe-app-tauri/components/chat/chat-panel-home.tsx b/apps/screenpipe-app-tauri/components/chat/chat-panel-home.tsx
new file mode 100644
index 000000000..b72e3939c
--- /dev/null
+++ b/apps/screenpipe-app-tauri/components/chat/chat-panel-home.tsx
@@ -0,0 +1,172 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+"use client";
+
+import {
+ ArrowLeft,
+ ArrowRight,
+ FileText,
+ Globe2,
+ Plug,
+ PanelRightClose,
+} from "lucide-react";
+import type { SourceCitation } from "@/lib/source-citations";
+import { useGT } from "gt-react";
+
+export function ChatPanelHome({
+ view,
+ onViewChange,
+ outputs,
+ paths,
+ onOpenBrowser,
+ onOpenFile,
+ onClose,
+}: {
+ view: "home" | "files";
+ onViewChange: (view: "home" | "files") => void;
+ outputs: SourceCitation[];
+ paths: string[];
+ onOpenBrowser: () => void;
+ onOpenFile: (path: string) => void;
+ onClose: () => void;
+}) {
+ const ui = useGT();
+ const files = [
+ ...new Map([
+ ...paths.map(
+ (path) =>
+ [path, { path, title: path.split(/[\\/]/).pop() || path }] as const,
+ ),
+ ...outputs
+ .filter((output) => output.path)
+ .map(
+ (output) =>
+ [
+ output.path!,
+ { path: output.path!, title: output.title },
+ ] as const,
+ ),
+ ]).values(),
+ ];
+ const destinations = [
+ {
+ label: ui("Browser"),
+ detail: ui("Open a website beside your conversation."),
+ Icon: Globe2,
+ run: onOpenBrowser,
+ },
+ {
+ label: ui("Files and outputs"),
+ detail: files.length
+ ? ui("{count} available in this chat", { count: files.length })
+ : ui("Find files you preview and results created here."),
+ Icon: FileText,
+ run: () => onViewChange("files"),
+ },
+ {
+ label: ui("Connections"),
+ detail: ui("Add the apps your next task needs."),
+ Icon: Plug,
+ run: () =>
+ window.dispatchEvent(
+ new CustomEvent("open-settings", {
+ detail: { section: "connections" },
+ }),
+ ),
+ },
+ ];
+ return (
+ <section
+ className="flex min-h-0 flex-1 flex-col bg-background"
+ aria-label={ui("Chat tools")}
+ >
+ <div className="flex h-10 shrink-0 items-center justify-between border-b border-border/50 px-4">
+ {view === "files" ? (
+ <button
+ className="flex items-center gap-2 text-xs text-muted-foreground hover:text-foreground"
+ onClick={() => onViewChange("home")}
+ >
+ <ArrowLeft className="h-3.5 w-3.5" />
+ {ui("Chat tools")}
+ </button>
+ ) : (
+ <span className="text-xs font-medium">{ui("Chat tools")}</span>
+ )}
+ <button
+ aria-label={ui("Close right sidebar")}
+ onClick={onClose}
+ className="flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
+ >
+ <PanelRightClose className="h-3.5 w-3.5" />
+ </button>
+ </div>
+ <div className="flex min-h-0 flex-1 flex-col overflow-y-auto p-6">
+ {view === "home" ? (
+ <div className="my-auto w-full max-w-sm self-center">
+ <h2 className="text-base font-medium">
+ {ui("Keep your work close")}
+ </h2>
+ <p className="mt-2 text-sm leading-6 text-muted-foreground">
+ {ui(
+ "Browse a page, revisit a result, or connect an app while you chat.",
+ )}
+ </p>
+ <div className="mt-6 space-y-2">
+ {destinations.map(({ label, detail, Icon, run }) => (
+ <button
+ key={label}
+ onClick={run}
+ className="group flex w-full items-center gap-3 rounded-lg border border-border bg-background p-4 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
+ >
+ <Icon className="h-4 w-4 shrink-0 text-muted-foreground" />
+ <span className="min-w-0 flex-1">
+ <span className="block text-sm font-medium">{label}</span>
+ <span className="mt-1 block text-xs leading-5 text-muted-foreground">
+ {detail}
+ </span>
+ </span>
+ <ArrowRight className="h-3.5 w-3.5 shrink-0 text-muted-foreground" />
+ </button>
+ ))}
+ </div>
+ </div>
+ ) : (
+ <div className="w-full">
+ <h2 className="text-sm font-medium">{ui("Files and outputs")}</h2>
+ {files.length ? (
+ <ul className="mt-4 space-y-2">
+ {files.map((file) => (
+ <li key={file.path}>
+ <button
+ onClick={() => onOpenFile(file.path)}
+ title={file.path}
+ className="flex w-full items-center gap-3 rounded-lg border border-border p-3 text-left hover:bg-muted/60 focus-visible:ring-1 focus-visible:ring-ring"
+ >
+ <FileText className="h-4 w-4 shrink-0 text-muted-foreground" />
+ <span className="min-w-0 truncate text-xs">
+ {file.title}
+ </span>
+ <ArrowRight className="ml-auto h-3.5 w-3.5 shrink-0" />
+ </button>
+ </li>
+ ))}
+ </ul>
+ ) : (
+ <div className="mt-10 rounded-lg border border-dashed border-border p-6 text-center">
+ <FileText className="mx-auto mb-3 h-6 w-6 text-muted-foreground" />
+ <h3 className="text-sm font-medium">
+ {ui("No files in this chat yet")}
+ </h3>
+ <p className="mt-2 text-xs leading-5 text-muted-foreground">
+ {ui(
+ "Open a file from a response, or ask Screenpipe to create a report. It will appear here.",
+ )}
+ </p>
+ </div>
+ )}
+ </div>
+ )}
+ </div>
+ </section>
+ );
+}
diff --git a/apps/screenpipe-app-tauri/components/chat/chat-tab-strip.test.tsx b/apps/screenpipe-app-tauri/components/chat/chat-tab-strip.test.tsx
index 86594aefa..cf614b7aa 100644
--- a/apps/screenpipe-app-tauri/components/chat/chat-tab-strip.test.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/chat-tab-strip.test.tsx
@@ -4,12 +4,16 @@
import { act, fireEvent, render, screen, waitFor } from "@testing-library/react";
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
+import { ChatActionsDropdown } from "@/components/chat/chat-action-menu";
import { ChatTabStrip } from "@/components/chat/chat-tab-strip";
import { CloseTabOrWindowShortcut } from "@/components/close-tab-or-window-shortcut";
import { resetCloseShortcutForTests } from "@/lib/close-tab-shortcut";
import { useChatStore, type SessionRecord } from "@/lib/stores/chat-store";
const closeWindowMock = vi.fn(async () => undefined);
+const shortcutSettings = vi.hoisted(() => ({ current: {} as Record<string, unknown> }));
+vi.mock("@/lib/hooks/use-settings", () => ({ useOptionalSettings: () => ({ settings: shortcutSettings.current }) }));
+
vi.mock("@tauri-apps/api/window", () => ({
getCurrentWindow: () => ({ close: closeWindowMock }),
@@ -78,6 +82,7 @@ function resetStore() {
describe("ChatTabStrip", () => {
beforeEach(() => {
resetStore();
+ shortcutSettings.current = {};
resetCloseShortcutForTests();
closeWindowMock.mockClear();
copyTextToClipboard.mockClear();
@@ -90,6 +95,65 @@ describe("ChatTabStrip", () => {
resetCloseShortcutForTests();
});
+ it("renames and pins the active chat without a menu, with modifier guards", async () => {
+ useChatStore.getState().actions.upsert(record({ id: "chat-a" }));
+ const rename = vi.fn();
+ render(<ChatTabStrip activeId="chat-a" onActivate={vi.fn()} onNewChat={vi.fn()} renameConversation={rename} />);
+ fireEvent.keyDown(window, {key:"p"});
+ fireEvent.keyDown(window, {key:"p",code:"KeyP",ctrlKey:true,altKey:true,repeat:true});
+ fireEvent.keyDown(window, {key:"p",code:"KeyP",ctrlKey:true,altKey:true,isComposing:true});
+ expect(useChatStore.getState().sessions["chat-a"].pinned).toBe(false);
+ fireEvent.keyDown(window, {key:"p",code:"KeyP",ctrlKey:true,altKey:true});
+ expect(useChatStore.getState().sessions["chat-a"].pinned).toBe(true);
+ fireEvent.keyDown(window, {key:"r",code:"KeyR",ctrlKey:true,altKey:true});
+ const input = screen.getByRole("textbox", {name:"Rename first chat"});
+ fireEvent.change(input, {target:{value:"Updated title"}});
+ fireEvent.keyDown(input, {key:"Enter"});
+ await waitFor(() => expect(rename).toHaveBeenCalledWith("chat-a", "Updated title"));
+ });
+
+ it("does not dispatch through a hidden chat, dialog, or conflicting global shortcut", () => {
+ useChatStore.getState().actions.upsert(record({ id: "chat-a" }));
+ const props = {activeId:"chat-a", onActivate:vi.fn(), onNewChat:vi.fn()};
+ const view = render(<ChatTabStrip {...props} shortcutsEnabled={false} />);
+ const pin = () => fireEvent.keyDown(window, {key:"p",code:"KeyP",ctrlKey:true,altKey:true});
+ pin();
+ expect(useChatStore.getState().sessions["chat-a"].pinned).toBe(false);
+ shortcutSettings.current = {searchShortcut:"Control+Alt+P"};
+ view.rerender(<ChatTabStrip {...props} />);
+ pin();
+ expect(useChatStore.getState().sessions["chat-a"].pinned).toBe(false);
+ shortcutSettings.current = {};
+ view.rerender(<><ChatTabStrip {...props} /><div role="dialog" data-state="open" /></>);
+ pin();
+ expect(useChatStore.getState().sessions["chat-a"].pinned).toBe(false);
+ });
+
+ it("targets the right-clicked chat instead of the active chat when using a menu chord", async () => {
+ const actions = useChatStore.getState().actions;
+ actions.upsert(record({id:"chat-a",title:"first chat"}));
+ actions.upsert(record({id:"chat-b",title:"second chat"}));
+ actions.openChat("chat-b");
+ render(<ChatTabStrip activeId="chat-a" onActivate={vi.fn()} onNewChat={vi.fn()} />);
+ fireEvent.contextMenu(screen.getByRole("tab",{name:"second chat"}));
+ fireEvent.keyDown(await screen.findByRole("menu"), {key:"p",code:"KeyP",ctrlKey:true,altKey:true});
+ await waitFor(() => expect(useChatStore.getState().sessions["chat-b"].pinned).toBe(true));
+ expect(useChatStore.getState().sessions["chat-a"].pinned).toBe(false);
+ });
+
+ it("keeps the rename input focused after the header action menu closes", async () => {
+ useChatStore.getState().actions.upsert(record({id:"chat-a"}));
+ const rename = vi.fn();
+ render(<><ChatTabStrip activeId="chat-a" onActivate={vi.fn()} onNewChat={vi.fn()} renameConversation={rename} /><ChatActionsDropdown conversationId="chat-a" /></>);
+ fireEvent.pointerDown(screen.getByRole("button", {name:"Chat actions"}), {button:0, ctrlKey:false});
+ fireEvent.click(await screen.findByRole("menuitem", {name:/Rename/}));
+ const input = await screen.findByRole("textbox", {name:"Rename first chat"});
+ await waitFor(() => expect(input).toHaveFocus());
+ fireEvent.change(input,{target:{value:"Renamed from header"}});
+ fireEvent.keyDown(input,{key:"Enter"});
+ await waitFor(() => expect(rename).toHaveBeenCalledWith("chat-a","Renamed from header"));
+ });
+
it("renders the in-memory working set and activates another chat", () => {
const actions = useChatStore.getState().actions;
actions.upsert(record({ id: "chat-a", title: "first chat" }));
@@ -281,7 +345,7 @@ describe("ChatTabStrip", () => {
);
});
- it("archives the active tab on Ctrl+E and keeps the sibling open", async () => {
+ it("archives the active tab on Ctrl+Shift+A and keeps the sibling open", async () => {
const actions = useChatStore.getState().actions;
for (const [id, title] of [
["chat-a", "first"],
@@ -301,7 +365,7 @@ describe("ChatTabStrip", () => {
/>,
);
- fireEvent.keyDown(window, { key: "e", code: "KeyE", ctrlKey: true });
+ fireEvent.keyDown(window, { key: "A", code: "KeyA", ctrlKey: true, shiftKey: true });
await waitFor(() =>
expect(archiveConversation).toHaveBeenCalledWith("chat-b"),
@@ -310,7 +374,7 @@ describe("ChatTabStrip", () => {
expect(onActivate).toHaveBeenCalledWith("chat-a");
});
- it("closes an empty untitled draft on Ctrl+E instead of archiving it", async () => {
+ it("closes an empty untitled draft on Ctrl+Shift+A instead of archiving it", async () => {
const actions = useChatStore.getState().actions;
actions.upsert(
record({
@@ -340,7 +404,7 @@ describe("ChatTabStrip", () => {
/>,
);
- fireEvent.keyDown(window, { key: "e", code: "KeyE", ctrlKey: true });
+ fireEvent.keyDown(window, { key: "A", code: "KeyA", ctrlKey: true, shiftKey: true });
expect(archiveConversation).not.toHaveBeenCalled();
expect(useChatStore.getState().openChatIds).toEqual(["chat-a"]);
@@ -363,10 +427,10 @@ describe("ChatTabStrip", () => {
fireEvent.contextMenu(screen.getByRole("tab", { name: "crm" }));
expect(await screen.findByText("Archive")).toBeVisible();
- expect(screen.getByText("Ctrl+E")).toBeVisible();
+ expect(screen.getByText("Ctrl+Shift+A")).toBeVisible();
});
- it("starts a new chat on Ctrl+E when the last real tab is archived", async () => {
+ it("starts a new chat on Ctrl+Shift+A when the last real tab is archived", async () => {
const actions = useChatStore.getState().actions;
actions.upsert(record({ id: "chat-a", title: "only" }));
actions.openChat("chat-a");
@@ -381,7 +445,7 @@ describe("ChatTabStrip", () => {
/>,
);
- fireEvent.keyDown(window, { key: "e", code: "KeyE", ctrlKey: true });
+ fireEvent.keyDown(window, { key: "A", code: "KeyA", ctrlKey: true, shiftKey: true });
await waitFor(() =>
expect(archiveConversation).toHaveBeenCalledWith("chat-a"),
@@ -591,7 +655,7 @@ describe("ChatTabStrip", () => {
"screenpipe://chat/chat-a",
),
);
- expect(toast).toHaveBeenCalledWith({ title: "copied chat link" });
+ expect(toast).toHaveBeenCalledWith({ title: "Copied" });
});
it("copies the worktree path only when the chat has one", async () => {
diff --git a/apps/screenpipe-app-tauri/components/chat/chat-tab-strip.tsx b/apps/screenpipe-app-tauri/components/chat/chat-tab-strip.tsx
index d76985c83..ed3880eaa 100644
--- a/apps/screenpipe-app-tauri/components/chat/chat-tab-strip.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/chat-tab-strip.tsx
@@ -11,24 +11,16 @@ import {
ContextMenuItem,
ContextMenuSeparator,
ContextMenuShortcut,
- ContextMenuSub,
- ContextMenuSubContent,
- ContextMenuSubTrigger,
ContextMenuTrigger,
} from "@/components/ui/context-menu";
import { toast } from "@/components/ui/use-toast";
-import { chatConversationLink } from "@/lib/chat/conversation-link";
-import {
- formatChatAsMarkdown,
- type MarkdownCitationPlan,
-} from "@/lib/chat/markdown-export";
import type { Message } from "@/lib/chat/types";
import { isInjectedTitle } from "@/lib/chat-utils";
import { registerChatTabCloser } from "@/lib/close-tab-shortcut";
import { usePlatform } from "@/lib/hooks/use-platform";
import {
+ hasOpenShortcutBlockingLayer,
inAppShortcutLabel,
- matchesInAppShortcut,
} from "@/lib/shortcuts";
import {
isEphemeralSideConversation,
@@ -36,12 +28,15 @@ import {
useChatStore,
type SessionRecord,
} from "@/lib/stores/chat-store";
-import { commands } from "@/lib/utils/tauri";
import { cn } from "@/lib/utils";
import { useGT } from "gt-react";
+import { ChatActionMenuItems, CHAT_MENU_ACTION_EVENT, CHAT_MENU_ACTIONS, CHAT_MENU_CLASS, handleChatMenuShortcut, useChatActionBindings, type ChatMenuAction, type ChatMenuRequest } from "./chat-action-menu";
+import { createConversationBranch } from "@/lib/chat/branch-conversation";
+import { sessionRecordFromMeta } from "@/lib/stores/chat-store";
interface ChatTabStripProps {
+ shortcutsEnabled?: boolean;
activeId: string | null;
onActivate: (id: string) => void | Promise<void>;
onNewChat: () => void | Promise<void>;
@@ -50,16 +45,6 @@ interface ChatTabStripProps {
archiveConversation?: (id: string) => Promise<void> | void;
}
-const EMPTY_CITATION_PLAN: MarkdownCitationPlan = {
- deferredMessageIds: new Set(),
- aggregatedAfter: new Map(),
-};
-
-async function copyText(text: string, title: string) {
- await commands.copyTextToClipboard(text);
- toast({ title });
-}
-
async function messagesForExport(session: SessionRecord): Promise<Message[]> {
const live = session.messages;
if (Array.isArray(live) && live.length > 0) {
@@ -123,6 +108,7 @@ function TabGlyphMark({
export function ChatTabStrip({
activeId,
+ shortcutsEnabled = true,
onActivate,
onNewChat,
onClose,
@@ -166,7 +152,7 @@ export function ChatTabStrip({
const actions = useChatActions();
const { isMac } = usePlatform();
const closeShortcut = inAppShortcutLabel("close_tab", isMac);
- const archiveShortcut = inAppShortcutLabel("archive_chat", isMac);
+ const bindings = useChatActionBindings();
const scrollerRef = useRef<HTMLDivElement | null>(null);
const closingActiveIdRef = useRef<string | null>(null);
const [contextMenuRevision, setContextMenuRevision] = useState(0);
@@ -290,24 +276,62 @@ export function ChatTabStrip({
[archiveConversation, closeTab, sessions],
);
+ const runAction = async (id: string, action: ChatMenuAction) => {
+ const session = sessions[id];
+ if (!session || isEphemeralSideConversation(session)) return;
+ closeContextMenu();
+ if (action === "rename_chat") {
+ setRenameDraft(visibleTabTitle(session));
+ setRenamingId(id);
+ } else if (action === "pin_chat") {
+ const next = !session.pinned;
+ actions.togglePinned(id);
+ try {
+ const { updateConversationFlags } = await import("@/lib/chat-storage");
+ await updateConversationFlags(id, { pinned: next });
+ } catch { toast({ title: ui("Couldn't save pin"), variant: "destructive" }); }
+ } else if (action === "archive_chat") {
+ archiveTab(id);
+ } else if (session.messageCount > 0) {
+ try {
+ const { saveConversationFile, conversationMetaFromJson } = await import("@/lib/chat-storage");
+ const branch = createConversationBranch({ sourceId: id, title: session.title, messages: await messagesForExport(session) });
+ if (!branch) throw new Error("No messages to branch");
+ await saveConversationFile(branch);
+ const meta = conversationMetaFromJson(branch);
+ if (!meta) throw new Error("Invalid branch");
+ actions.upsert(sessionRecordFromMeta(meta));
+ actions.setMessages(branch.id, branch.messages as any);
+ await onActivate(branch.id);
+ } catch { toast({ title: ui("Couldn't branch chat"), variant: "destructive" }); }
+ }
+ };
+
useEffect(() => {
+ if (!shortcutsEnabled) return;
const onKey = (event: KeyboardEvent) => {
- if (!matchesInAppShortcut(event, "archive_chat", isMac)) return;
- if (document.querySelector('[role="dialog"][data-state="open"]')) return;
- if (renamingId) return;
- const id =
- (activeId && tabs.some((tab) => tab.id === activeId) && activeId) ||
- tabs[0]?.id;
- if (!id) return;
+ if (event.defaultPrevented || event.repeat || event.isComposing || event.getModifierState?.("AltGraph") || hasOpenShortcutBlockingLayer() || renamingId) return;
+ const action = CHAT_MENU_ACTIONS.find(id => bindings.match(event, id));
+ if (!action || !activeId || !tabs.some(tab => tab.id === activeId)) return;
event.preventDefault();
- event.stopPropagation();
- archiveTab(id);
+ void runAction(activeId, action);
+ };
+ const onAction = (event: Event) => {
+ const request = (event as CustomEvent<ChatMenuRequest>).detail;
+ if (!request || !CHAT_MENU_ACTIONS.includes(request.action)) return;
+ const { id, action } = request;
+ if (tabs.some(tab => tab.id === id)) void runAction(id, action);
};
- window.addEventListener("keydown", onKey, true);
- return () => window.removeEventListener("keydown", onKey, true);
- }, [activeId, archiveTab, isMac, renamingId, tabs]);
+ window.addEventListener("keydown", onKey);
+ window.addEventListener(CHAT_MENU_ACTION_EVENT, onAction);
+ return () => {
+ window.removeEventListener("keydown", onKey);
+ window.removeEventListener(CHAT_MENU_ACTION_EVENT, onAction);
+ };
+ });
useEffect(() => {
+ if (!shortcutsEnabled) return;
return registerChatTabCloser(() => {
const id =
(activeId && tabs.some((tab) => tab.id === activeId) && activeId) ||
@@ -316,7 +340,7 @@ export function ChatTabStrip({
closeTab(id);
return true;
});
- }, [activeId, closeTab, tabs]);
+ }, [activeId, closeTab, tabs, shortcutsEnabled]);
return (
<div
@@ -451,106 +475,11 @@ export function ChatTabStrip({
</button>
</div>
</ContextMenuTrigger>
- <ContextMenuContent className="w-52">
- {!temporary ? (
- <>
- <ContextMenuItem
- onSelect={() => {
- closeContextMenu();
- const next = !session.pinned;
- actions.togglePinned(session.id);
- void import("@/lib/chat-storage").then(
- ({ updateConversationFlags }) =>
- updateConversationFlags(session.id, {
- pinned: next,
- }),
- );
- }}
- >
- {session.pinned ? ui("Unpin") : ui("Pin")}
- </ContextMenuItem>
- <ContextMenuItem
- onSelect={() => {
- closeContextMenu();
- setRenameDraft(title);
- setRenamingId(session.id);
- }}
- >
- Rename
- </ContextMenuItem>
- <ContextMenuSub>
- <ContextMenuSubTrigger>Copy</ContextMenuSubTrigger>
- <ContextMenuSubContent className="w-48">
- <ContextMenuItem
- onSelect={() => {
- closeContextMenu();
- void copyText(
- chatConversationLink(session.id),
- "copied chat link",
- );
- }}
- >
- Copy link
- </ContextMenuItem>
- <ContextMenuItem
- onSelect={() => {
- closeContextMenu();
- void (async () => {
- const messages = await messagesForExport(session);
- if (messages.length === 0) {
- toast({ title: ui("No messages to copy") });
- return;
- }
- await copyText(
- formatChatAsMarkdown(
- messages,
- EMPTY_CITATION_PLAN,
- ),
- "copied chat as markdown",
- );
- })();
- }}
- >
- Copy as Markdown
- </ContextMenuItem>
- <ContextMenuItem
- onSelect={() => {
- closeContextMenu();
- void copyText(session.id, "copied chat ID");
- }}
- >
- Copy chat ID
- </ContextMenuItem>
- {codingWorkspace ? (
- <ContextMenuItem
- onSelect={() => {
- closeContextMenu();
- void copyText(
- codingWorkspace.worktreePath,
- "copied worktree path",
- );
- }}
- >
- Copy worktree path
- </ContextMenuItem>
- ) : null}
- </ContextMenuSubContent>
- </ContextMenuSub>
- <ContextMenuSeparator />
- <ContextMenuItem
- onSelect={() => {
- closeContextMenu();
- archiveTab(session.id);
- }}
- >
- Archive
- <ContextMenuShortcut className="text-[10px] tracking-normal text-muted-foreground/55">
- {archiveShortcut}
- </ContextMenuShortcut>
- </ContextMenuItem>
- <ContextMenuSeparator />
- </>
- ) : null}
+ <ContextMenuContent data-chat-actions-menu="" className={CHAT_MENU_CLASS} onKeyDown={handleChatMenuShortcut}>
+ {!temporary && <>
+ <ChatActionMenuItems variant="context" session={session} onBeforeCopy={closeContextMenu} onAction={action => void runAction(session.id, action)} />
+ <ContextMenuSeparator />
+ </>}
<ContextMenuItem
disabled={active || split || temporary}
onSelect={() => {
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/chat-title-menu.test.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/chat-title-menu.test.tsx
index be4f37b27..f151d1673 100644
--- a/apps/screenpipe-app-tauri/components/chat/standalone/chat-title-menu.test.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/standalone/chat-title-menu.test.tsx
@@ -107,7 +107,7 @@ describe("ChatTitleMenu", () => {
screen.getByRole("button", { name: "Chat options for day recap" }),
);
expect(await screen.findByRole("button", { name: "Archive" })).toBeVisible();
- expect(screen.getByText(/⌘E|Ctrl\+E/)).toBeVisible();
+ expect(screen.getByText(/⇧⌘A|Ctrl\+Shift\+A/)).toBeVisible();
});
it("renames the same conversation from the title-owned menu", async () => {
diff --git a/apps/screenpipe-app-tauri/components/chat/standalone/chat-title-menu.tsx b/apps/screenpipe-app-tauri/components/chat/standalone/chat-title-menu.tsx
index d29e26ecf..1dbf61550 100644
--- a/apps/screenpipe-app-tauri/components/chat/standalone/chat-title-menu.tsx
+++ b/apps/screenpipe-app-tauri/components/chat/standalone/chat-title-menu.tsx
@@ -9,7 +9,7 @@ import { Archive, MoreHorizontal, Pencil, Pin } from "lucide-react";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import type { Message } from "@/lib/chat/types";
import { usePlatform } from "@/lib/hooks/use-platform";
-import { inAppShortcutLabel, matchesInAppShortcut } from "@/lib/shortcuts";
+import { useChatActionBindings } from "@/components/chat/chat-action-menu";
import {
isEphemeralSideConversation,
useChatStore,
@@ -48,7 +48,8 @@ export function ChatTitleMenu({
const [draft, setDraft] = useState("");
const inputRef = useRef<HTMLInputElement | null>(null);
const { isMac } = usePlatform();
- const archiveShortcut = inAppShortcutLabel("archive_chat", isMac);
+ const bindings = useChatActionBindings();
+ const archiveShortcut = bindings.label("archive_chat");
// Title source order:
// 1. The session's title from the chat-store (in-memory, freshest;
@@ -81,7 +82,8 @@ export function ChatTitleMenu({
useEffect(() => {
if (!canArchive || !conversationId) return;
const onKey = (event: KeyboardEvent) => {
- if (!matchesInAppShortcut(event, "archive_chat", isMac)) return;
+ if (event.defaultPrevented || event.repeat || event.isComposing) return;
+ if (!bindings.match(event, "archive_chat")) return;
if (document.querySelector('[role="dialog"][data-state="open"]')) return;
if (renaming) return;
event.preventDefault();
@@ -93,6 +95,7 @@ export function ChatTitleMenu({
return () => window.removeEventListener("keydown", onKey, true);
}, [
archiveConversation,
+ bindings,
canArchive,
conversationId,
isMac,
diff --git a/apps/screenpipe-app-tauri/components/right-panel-tab-strip.tsx b/apps/screenpipe-app-tauri/components/right-panel-tab-strip.tsx
index e9522401c..ee125a673 100644
--- a/apps/screenpipe-app-tauri/components/right-panel-tab-strip.tsx
+++ b/apps/screenpipe-app-tauri/components/right-panel-tab-strip.tsx
@@ -5,7 +5,7 @@
"use client";
import React, { useEffect, useRef } from "react";
-import { FileText, Globe2, Loader2, Plus, X } from "lucide-react";
+import { Home, FileText, Globe2, Loader2, Plus, X } from "lucide-react";
import { cn } from "@/lib/utils";
import { useGT } from "gt-react";
@@ -31,6 +31,8 @@ export function rightPanelFileTabLabel(path: string): string {
}
interface RightPanelTabStripProps {
+ onHome?: () => void;
+ homeActive?: boolean;
tabs: RightPanelTab[];
activeTabId: string | null;
onSelect: (tab: RightPanelTab) => void;
@@ -39,6 +41,8 @@ interface RightPanelTabStripProps {
}
export function RightPanelTabStrip({
+ onHome,
+ homeActive,
tabs,
activeTabId,
onSelect,
@@ -85,6 +89,8 @@ export function RightPanelTabStrip({
className="flex h-9 min-w-0 shrink-0 items-stretch border-b border-border/60 bg-muted/20 pl-2"
data-testid="right-panel-tab-strip"
>
+ {onHome && <button type="button" aria-label={ui("Side panel home")} aria-pressed={Boolean(homeActive)} title={ui("Side panel home")} onClick={onHome}
+ className={cn("flex w-8 shrink-0 items-center justify-center border-r border-border/45 text-muted-foreground hover:bg-background/60 focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-ring", homeActive && "bg-background text-foreground")}><Home className="h-3.5 w-3.5" /></button>}
<div
className="flex min-w-0 flex-1 items-stretch overflow-x-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden"
role="tablist"
diff --git a/apps/screenpipe-app-tauri/components/shortcut-guide.tsx b/apps/screenpipe-app-tauri/components/shortcut-guide.tsx
index 393d08ea1..dfe5c5f10 100644
--- a/apps/screenpipe-app-tauri/components/shortcut-guide.tsx
+++ b/apps/screenpipe-app-tauri/components/shortcut-guide.tsx
@@ -22,12 +22,13 @@ import {
IN_APP_SHORTCUTS,
OPEN_SHORTCUT_GUIDE_EVENT,
globalShortcutHint,
+ conflictsWithGlobalShortcut,
inAppShortcutLabel,
matchesInAppShortcut,
type InAppShortcutSection,
} from "@/lib/shortcuts";
import { useExperimentalFeaturesEnabled } from "@/lib/experimental-features";
-import { useMessages } from "gt-react";
+import { useGT, useMessages } from "gt-react";
import { localizeDefinitions } from "@/lib/i18n/definitions";
import { useUiLocale as useLocale } from "@/lib/i18n/provider";
@@ -54,6 +55,7 @@ export function ShortcutGuide({
onOpenChange,
}: ShortcutGuideProps = {}) {
const uiLanguage = useLocale();
+ const ui = useGT();
const uiMessages = useMessages();
const { settings } = useSettings();
@@ -132,7 +134,7 @@ export function ShortcutGuide({
</p>
</div>
<ShortcutKeycap>
- {inAppShortcutLabel(item.id, isMac)}
+ {["rename_chat", "pin_chat", "branch_chat", "archive_chat", "toggle_right_sidebar"].includes(item.id) && conflictsWithGlobalShortcut(item.id, isMac, settings) ? ui("Assigned globally") : inAppShortcutLabel(item.id, isMac)}
</ShortcutKeycap>
</div>
))}
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index d45a70765..c09b28d1a 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -12,6 +12,7 @@ import { useSettings } from "@/lib/hooks/use-settings";
import { cn } from "@/lib/utils";
import {
hasOpenShortcutBlockingLayer,
+ conflictsWithGlobalShortcut,
inAppShortcutLabel,
matchesInAppShortcut,
} from "@/lib/shortcuts";
@@ -40,6 +41,7 @@ import { useChatFilePreview } from "@/lib/hooks/use-chat-file-preview";
import { useChatInspector } from "@/lib/hooks/use-chat-inspector";
import { ChatInspectorPopover } from "@/components/chat/chat-inspector";
import { ChatSplitPane } from "@/components/chat/chat-split-pane";
+import { ChatActionsDropdown } from "@/components/chat/chat-action-menu";
import { ChatTabStrip } from "@/components/chat/chat-tab-strip";
import { useSqlAutocomplete, useTagAutocomplete } from "@/lib/hooks/use-sql-autocomplete";
import { loadConversationFile } from "@/lib/chat-storage";
@@ -794,6 +796,8 @@ export function StandaloneChat({
const sidePanelHasContent =
(filePreview?.paths.length ?? 0) > 0 || browserPanelState.hasUrl;
const sidePanelOpen = browserPanelState.open;
+ const rightPanelShortcut = conflictsWithGlobalShortcut("toggle_right_sidebar", isMac, settings)
+ ? "" : inAppShortcutLabel("toggle_right_sidebar", isMac);
const inspectorHasContent =
inspectorOutputs.length > 0 ||
inspectorSources.length > 0;
@@ -807,16 +811,10 @@ export function StandaloneChat({
}, [inspectorOpen, setInspectorOpen]);
const toggleBrowserPanel = useCallback(() => {
- if (sidePanelHasContent) {
- window.dispatchEvent(
- new CustomEvent("screenpipe:browser-sidebar-toggle", {
- detail: { action: "toggle" },
- }),
- );
- } else {
- window.dispatchEvent(new CustomEvent("screenpipe:browser-sidebar-new-tab"));
- }
- }, [sidePanelHasContent]);
+ window.dispatchEvent(new CustomEvent("screenpipe:browser-sidebar-toggle", {
+ detail: { action: "toggle" },
+ }));
+ }, []);
useEffect(() => {
if (!chatShortcutsEnabled) return;
@@ -825,13 +823,14 @@ export function StandaloneChat({
event.defaultPrevented || event.repeat || event.isComposing ||
event.getModifierState?.("AltGraph") || hasOpenShortcutBlockingLayer()
) return;
- if (!matchesInAppShortcut(event, "toggle_right_sidebar", isMac)) return;
+ if (conflictsWithGlobalShortcut("toggle_right_sidebar", isMac, settings) ||
+ !matchesInAppShortcut(event, "toggle_right_sidebar", isMac)) return;
event.preventDefault();
toggleBrowserPanel();
};
window.addEventListener("keydown", onKeyDown);
return () => window.removeEventListener("keydown", onKeyDown);
- }, [chatShortcutsEnabled, isMac, toggleBrowserPanel]);
+ }, [chatShortcutsEnabled, isMac, settings, toggleBrowserPanel]);
const handlePanelStateChange = useCallback(
(nextState: { hasUrl: boolean; open: boolean }) => {
@@ -2230,6 +2229,7 @@ export function StandaloneChat({
hideInlineHistory ? (
<ChatTabStrip
activeId={conversationId}
+ shortcutsEnabled={chatShortcutsEnabled}
onActivate={activateChatTab}
onNewChat={startDurableNewConversation}
onClose={discardTemporarySideConversation}
@@ -2258,6 +2258,7 @@ export function StandaloneChat({
onNewChat={startDurableNewConversation}
rightActions={
<div className="relative z-20 flex items-center gap-1">
+ {hideInlineHistory && <ChatActionsDropdown conversationId={conversationId} />}
<ChatInspectorPopover
open={inspectorOpen}
onOpenChange={setInspectorOpen}
@@ -2278,9 +2279,9 @@ export function StandaloneChat({
"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")} (${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")}
+ title={`${ui("Toggle right sidebar")}${rightPanelShortcut ? ` (${rightPanelShortcut})` : ""}`}
+ aria-keyshortcuts={rightPanelShortcut ? (isMac ? "Alt+Meta+B" : "Control+Alt+B") : undefined}
+ aria-label={ui("Toggle right sidebar")}
aria-pressed={sidePanelOpen}
>
{sidePanelOpen ? (
@@ -2549,6 +2550,7 @@ export function StandaloneChat({
state). The actual page is rendered by a Tauri WebviewWindow
positioned over the placeholder div inside this component. */}
<BrowserSidebar
+ outputs={inspectorOutputs}
conversationId={conversationId}
additionalReservedWidth={
splitChatId && splitChatId !== conversationId ? 320 : 0
diff --git a/apps/screenpipe-app-tauri/lib/__tests__/shortcuts.test.ts b/apps/screenpipe-app-tauri/lib/__tests__/shortcuts.test.ts
index fee4146e9..5e95ae072 100644
--- a/apps/screenpipe-app-tauri/lib/__tests__/shortcuts.test.ts
+++ b/apps/screenpipe-app-tauri/lib/__tests__/shortcuts.test.ts
@@ -4,6 +4,8 @@
import { describe, expect, it } from "vitest";
import {
+ conflictsWithGlobalShortcut,
+ IN_APP_SHORTCUTS,
globalShortcutHint,
inAppShortcutLabel,
matchesInAppShortcut,
@@ -18,8 +20,8 @@ describe("in-app shortcut registry", () => {
expect(inAppShortcutLabel("new_chat", true)).toBe("⌘N");
expect(inAppShortcutLabel("close_tab", true)).toBe("⌘W");
expect(inAppShortcutLabel("close_tab", false)).toBe("Ctrl+W");
- expect(inAppShortcutLabel("archive_chat", true)).toBe("⌘E");
- expect(inAppShortcutLabel("archive_chat", false)).toBe("Ctrl+E");
+ expect(inAppShortcutLabel("archive_chat", true)).toBe("⇧⌘A");
+ expect(inAppShortcutLabel("archive_chat", false)).toBe("Ctrl+Shift+A");
expect(inAppShortcutLabel("next_recent_chat", false)).toBe("Ctrl+Tab");
});
@@ -59,24 +61,24 @@ describe("in-app shortcut registry", () => {
).toBe(false);
});
- it("matches Cmd+E on macOS and Ctrl+E elsewhere", () => {
+ it("matches Cmd+Shift+A on macOS and Ctrl+Shift+A elsewhere", () => {
expect(
matchesInAppShortcut(
- keyEvent({ key: "e", code: "KeyE", metaKey: true }),
+ keyEvent({ key: "A", code: "KeyA", metaKey: true, shiftKey: true }),
"archive_chat",
true,
),
).toBe(true);
expect(
matchesInAppShortcut(
- keyEvent({ key: "e", code: "KeyE", ctrlKey: true }),
+ keyEvent({ key: "A", code: "KeyA", ctrlKey: true, shiftKey: true }),
"archive_chat",
false,
),
).toBe(true);
expect(
matchesInAppShortcut(
- keyEvent({ key: "e", code: "KeyE", metaKey: true }),
+ keyEvent({ key: "A", code: "KeyA", metaKey: true, shiftKey: true }),
"close_tab",
true,
),
@@ -115,3 +117,27 @@ describe("in-app shortcut registry", () => {
).toBe("");
});
});
+
+describe("chat action shortcut conflicts", () => {
+ it("reserves configured global accelerators and respects disabled bindings", () => {
+ expect(conflictsWithGlobalShortcut("rename_chat", true, { searchShortcut: "Alt+Super+R" })).toBe(true);
+ expect(conflictsWithGlobalShortcut("rename_chat", true, { searchShortcut: "Alt+Super+R", disabledShortcuts: ["searchShortcut"] })).toBe(false);
+ expect(conflictsWithGlobalShortcut("archive_chat", false, { showChatShortcut: "Ctrl+Shift+A" })).toBe(true);
+ });
+ it("has distinct platform chords and avoids Screenpipe's default global shortcuts", () => {
+ const defaults = { showScreenpipeShortcut: "Control+Super+S", startRecordingShortcut: "Super+Alt+U", stopRecordingShortcut: "Super+Alt+X", startAudioShortcut: "Control+Super+A", stopAudioShortcut: "Control+Super+Z", showChatShortcut: "Control+Super+L", searchShortcut: "Control+Super+K", lockVaultShortcut: "Super+Shift+L" };
+ for (const mac of [true, false]) {
+ const labels = IN_APP_SHORTCUTS.map(item => inAppShortcutLabel(item.id, mac));
+ expect(new Set(labels).size).toBe(labels.length);
+ for (const id of ["rename_chat", "pin_chat", "branch_chat", "archive_chat"] as const) expect(conflictsWithGlobalShortcut(id, mac, defaults)).toBe(false);
+ }
+ });
+ it("never interprets plain letters or the old archive chord as chat actions", () => {
+ for (const id of ["rename_chat", "pin_chat", "branch_chat", "archive_chat"] as const) {
+ for (const key of ["r", "p", "f", "a", "e"]) {
+ expect(matchesInAppShortcut(keyEvent({key}), id, true)).toBe(false);
+ expect(matchesInAppShortcut(keyEvent({key, metaKey:true}), id, true)).toBe(false);
+ }
+ }
+ });
+});
diff --git a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
index 0142bcd7a..0aa50fe15 100644
--- a/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
+++ b/apps/screenpipe-app-tauri/lib/hooks/use-settings.tsx
@@ -2143,3 +2143,8 @@ export function useSettings(): SettingsContextType {
}
return context;
}
+
+/** Optional access for reusable shortcut menus rendered outside the app shell. */
+export function useOptionalSettings(): SettingsContextType | undefined {
+ return useContext(SettingsContext);
+}
diff --git a/apps/screenpipe-app-tauri/lib/shortcuts.ts b/apps/screenpipe-app-tauri/lib/shortcuts.ts
index b79dd7229..323158c8a 100644
--- a/apps/screenpipe-app-tauri/lib/shortcuts.ts
+++ b/apps/screenpipe-app-tauri/lib/shortcuts.ts
@@ -11,6 +11,9 @@ export type InAppShortcutId =
| "new_chat"
| "close_tab"
| "archive_chat"
+ | "rename_chat"
+ | "pin_chat"
+ | "branch_chat"
| "command_menu"
| "shortcut_guide"
| "toggle_sidebar"
@@ -46,6 +49,9 @@ export const IN_APP_SHORTCUTS: readonly InAppShortcutDefinition[] = [
label: msg("Archive chat", {}),
description: msg("Hide this conversation, stop the agent, and close the tab", {}),
},
+ { id: "rename_chat", section: "chat", label: msg("Rename chat", {}), description: msg("Change the current chat title", {}) },
+ { id: "pin_chat", section: "chat", label: msg("Pin chat", {}), description: msg("Pin or unpin the current chat", {}) },
+ { id: "branch_chat", section: "chat", label: msg("Branch chat", {}), description: msg("Continue this conversation in a new chat", {}) },
{
id: "next_recent_chat",
section: "chat",
@@ -132,7 +138,13 @@ export function inAppShortcutLabel(
case "close_tab":
return `${primary}W`;
case "archive_chat":
- return `${primary}E`;
+ return isMac ? "⇧⌘A" : "Ctrl+Shift+A";
+ case "rename_chat":
+ return isMac ? "⌥⌘R" : "Ctrl+Alt+R";
+ case "pin_chat":
+ return isMac ? "⌥⌘P" : "Ctrl+Alt+P";
+ case "branch_chat":
+ return isMac ? "⌥⌘F" : "Ctrl+Alt+F";
case "command_menu":
return `${primary}K`;
case "shortcut_guide":
@@ -170,7 +182,13 @@ function specFor(id: InAppShortcutId, isMac: boolean): ShortcutSpec {
case "close_tab":
return { ...primary, key: "w", code: "KeyW" };
case "archive_chat":
- return { ...primary, key: "e", code: "KeyE" };
+ return { ...primary, shift: true, key: "a", code: "KeyA" };
+ case "rename_chat":
+ return { ...primary, alt: true, key: "r", code: "KeyR" };
+ case "pin_chat":
+ return { ...primary, alt: true, key: "p", code: "KeyP" };
+ case "branch_chat":
+ return { ...primary, alt: true, key: "f", code: "KeyF" };
case "command_menu":
return { ...primary, key: "k", code: "KeyK" };
case "shortcut_guide":
@@ -243,3 +261,23 @@ export function dispatchOpenShortcutGuide(): void {
window.dispatchEvent(new Event(OPEN_SHORTCUT_GUIDE_EVENT));
}
}
+
+/** User-configured global bindings take precedence over in-app actions. */
+export function conflictsWithGlobalShortcut(
+ id: InAppShortcutId,
+ isMac: boolean,
+ settings: Record<string, unknown>,
+): boolean {
+ const spec = specFor(id, isMac);
+ const disabled = Array.isArray(settings.disabledShortcuts) ? settings.disabledShortcuts : [];
+ return Object.entries(settings).some(([name, value]) => {
+ if (!name.endsWith("Shortcut") || typeof value !== "string" || disabled.includes(name)) return false;
+ const parts = value.toLowerCase().split("+").map((part) => part.trim());
+ const has = (...aliases: string[]) => aliases.some((alias) => parts.includes(alias));
+ const primary = has("commandorcontrol", "cmdorctrl");
+ return parts.at(-1) === spec.key &&
+ (has("super", "meta", "command", "cmd") || (primary && isMac)) === spec.meta &&
+ (has("control", "ctrl") || (primary && !isMac)) === spec.ctrl &&
+ has("shift") === spec.shift && has("alt", "option") === spec.alt;
+ });
+}
diff --git a/apps/screenpipe-app-tauri/scripts/eval-chat-sidebar-actions.mjs b/apps/screenpipe-app-tauri/scripts/eval-chat-sidebar-actions.mjs
new file mode 100644
index 000000000..9d0e6fcb4
--- /dev/null
+++ b/apps/screenpipe-app-tauri/scripts/eval-chat-sidebar-actions.mjs
@@ -0,0 +1,107 @@
+// screenpipe — AI that knows everything you've seen, said, or heard
+// https://screenpipe.com
+// Browser-mock UI check. Start bun run dev:web first; no native or AI calls.
+import { chromium } from "../../screenpipe-workflows-web/node_modules/playwright/index.mjs";
+import { mkdir } from "node:fs/promises";
+import path from "node:path";
+const output = process.env.SCREENPIPE_CHAT_UI_OUTPUT;
+if (output) await mkdir(output, { recursive: true });
+const browser = await chromium.launch({
+ headless: true,
+ executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE || undefined,
+});
+const page = await browser.newPage({
+ viewport: { width: 1440, height: 1000 },
+ colorScheme: "light",
+});
+page.on("pageerror", (e) => console.log("pageerror", e.message));
+const snap = async (name) => {
+ if (!output) return;
+ await page.waitForTimeout(250);
+ await page.screenshot({ path: path.join(output, `actions-${name}.png`) });
+};
+try {
+ await page.goto(
+ `${process.env.SCREENPIPE_CHAT_UI_URL || "http://127.0.0.1:1420"}/home`,
+ );
+ await page.getByRole("button", { name: "Do later", exact: true }).click();
+ await page.getByRole("dialog").waitFor({ state: "hidden" });
+ await page.evaluate(() => {
+ document.documentElement.classList.remove("dark");
+ document.documentElement.classList.add("light");
+ });
+ await page.keyboard.press("Alt+Meta+b");
+ await page.getByRole("heading", { name: "Keep your work close" }).waitFor();
+ await snap("home-light");
+ await page.getByRole("button", { name: /Files and outputs/ }).click();
+ await page
+ .getByRole("heading", { name: "No files in this chat yet" })
+ .waitFor();
+ await snap("files-empty");
+ await page.getByRole("button", { name: "Chat tools", exact: true }).click();
+ await page.getByRole("button", { name: /Browser Open a website/ }).click();
+ await page.getByRole("textbox", { name: "Browser address" }).waitFor();
+ await page.getByRole("button", { name: "Side panel home" }).click();
+ await page.getByRole("heading", { name: "Keep your work close" }).waitFor();
+ await snap("home-with-tab");
+ await page.keyboard.press("Alt+Meta+b");
+ await page
+ .getByRole("heading", { name: "Keep your work close" })
+ .waitFor({ state: "hidden" });
+ await page.keyboard.press("Alt+Meta+b");
+ await page.getByRole("heading", { name: "Keep your work close" }).waitFor();
+ await page.getByRole("button", { name: "Chat actions", exact: true }).click();
+ await page.getByRole("menuitem", { name: /Rename/ }).waitFor();
+ await snap("top-menu-light");
+ await page.keyboard.press("Escape");
+ await page.getByRole("menu").waitFor({ state: "hidden" });
+ await page.waitForTimeout(200);
+ await page.keyboard.press("Alt+Meta+r");
+ await page.getByRole("textbox", { name: "Rename New chat" }).waitFor();
+ await page
+ .getByRole("textbox", { name: "Rename New chat" })
+ .fill("Planning the week");
+ await page.keyboard.press("Enter");
+ await page
+ .getByRole("tab", { name: "Planning the week", exact: true })
+ .waitFor();
+ await page.keyboard.press("Alt+Meta+p");
+ await page.getByRole("button", { name: "Chat actions", exact: true }).click();
+ await page.getByRole("menuitem", { name: /Unpin/ }).waitFor();
+ await page.keyboard.press("Escape");
+ await page.getByRole("menu").waitFor({ state: "hidden" });
+ await page.waitForTimeout(200);
+ await page
+ .getByRole("tab", { name: "Planning the week", exact: true })
+ .click({ button: "right" });
+ await page.getByRole("menuitem", { name: /Rename/ }).waitFor();
+ await snap("tab-menu-light");
+ await page.keyboard.press("Escape");
+ await page.getByRole("menu").waitFor({ state: "hidden" });
+ await page.waitForTimeout(200);
+ await page
+ .getByRole("button", { name: /Investigate audio device switching/ })
+ .click({ button: "right" });
+ await page.getByRole("menuitem", { name: /Branch in new chat/ }).waitFor();
+ await snap("sidebar-menu-light");
+ await page.keyboard.press("Escape");
+ await page.getByRole("menu").waitFor({ state: "hidden" });
+ await page.waitForTimeout(200);
+ await page.evaluate(() => {
+ document.documentElement.classList.remove("light");
+ document.documentElement.classList.add("dark");
+ });
+ await snap("home-dark");
+ await page.getByRole("button", { name: "Chat actions", exact: true }).click();
+ await snap("top-menu-dark");
+ await page.keyboard.press("Escape");
+ await page.getByRole("menu").waitFor({ state: "hidden" });
+ await page.waitForTimeout(200);
+ await page.setViewportSize({ width: 1100, height: 780 });
+ await snap("compact");
+ console.log(
+ "PASS: panel destinations, retained browser tab, repeat toggle, global rename and pin, menu parity, light/dark/compact",
+ );
+} finally {
+ await browser.close();
+}
diff --git a/docs/pr-assets/chat-sidebar-actions/README.md b/docs/pr-assets/chat-sidebar-actions/README.md
new file mode 100644
index 000000000..470b9be38
--- /dev/null
+++ b/docs/pr-assets/chat-sidebar-actions/README.md
@@ -0,0 +1,7 @@
+# Chat sidebar and action-menu evidence
+
+All screenshots use synthetic data in the maintained `/home` browser-mock app. No customer recordings or accounts are shown.
+
+Before images were recreated from `5e8fe66`. After images exercise the changes in this directory's commit: tools home, empty and populated outputs, file preview, retained browser tabs, header/tab/sidebar menus, and light/dark/compact layouts. The after tab-menu image also shows the renamed and pinned state. Desktop viewport: 1440 × 1000; compact: 1100 × 780.
+
+The populated-output and file-preview images used temporary synthetic fixtures; those fixture edits are not in the patch. Browser screenshots do not establish packaged native WebView focus or OS-level shortcut delivery.
diff --git a/docs/pr-assets/chat-sidebar-actions/before-panel.png b/docs/pr-assets/chat-sidebar-actions/before-panel.png
new file mode 100644
index 000000000..2770859cd
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/before-panel.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/before-sidebar-menu.png b/docs/pr-assets/chat-sidebar-actions/before-sidebar-menu.png
new file mode 100644
index 000000000..aa3b85975
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/before-sidebar-menu.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/before-tab-menu.png b/docs/pr-assets/chat-sidebar-actions/before-tab-menu.png
new file mode 100644
index 000000000..510460bae
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/before-tab-menu.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/compact.png b/docs/pr-assets/chat-sidebar-actions/compact.png
new file mode 100644
index 000000000..f0b9182d4
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/compact.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/file-preview.png b/docs/pr-assets/chat-sidebar-actions/file-preview.png
new file mode 100644
index 000000000..cf21342c6
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/file-preview.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/files-empty.png b/docs/pr-assets/chat-sidebar-actions/files-empty.png
new file mode 100644
index 000000000..811f13881
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/files-empty.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/files-populated.png b/docs/pr-assets/chat-sidebar-actions/files-populated.png
new file mode 100644
index 000000000..fda2153d6
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/files-populated.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/home-dark.png b/docs/pr-assets/chat-sidebar-actions/home-dark.png
new file mode 100644
index 000000000..1e5bc0699
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/home-dark.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/home-light.png b/docs/pr-assets/chat-sidebar-actions/home-light.png
new file mode 100644
index 000000000..0c85d7641
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/home-light.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/home-with-tab.png b/docs/pr-assets/chat-sidebar-actions/home-with-tab.png
new file mode 100644
index 000000000..f3b034595
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/home-with-tab.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/sidebar-menu-light.png b/docs/pr-assets/chat-sidebar-actions/sidebar-menu-light.png
new file mode 100644
index 000000000..c69c43a80
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/sidebar-menu-light.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/tab-menu-light.png b/docs/pr-assets/chat-sidebar-actions/tab-menu-light.png
new file mode 100644
index 000000000..82b9fe141
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/tab-menu-light.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/top-menu-dark.png b/docs/pr-assets/chat-sidebar-actions/top-menu-dark.png
new file mode 100644
index 000000000..6c8c7b9a0
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/top-menu-dark.png differ
diff --git a/docs/pr-assets/chat-sidebar-actions/top-menu-light.png b/docs/pr-assets/chat-sidebar-actions/top-menu-light.png
new file mode 100644
index 000000000..2d4bf634b
Binary files /dev/null and b/docs/pr-assets/chat-sidebar-actions/top-menu-light.png differ