:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(desktop): add activity panel shortcut (#80645)
Matt Pua947e0ba46c4d
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ThreadSidebar.tsx b/products/desktop/packages/ui/src/features/canvas/components/ThreadSidebar.tsxindex 03255bffc0e2..51fef2d6cbf7 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ThreadSidebar.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ThreadSidebar.tsx@@ -46,6 +46,7 @@ export function ThreadSidebar({task_id: taskId,});};+const panelProps = {taskId,channelId,diff --git a/products/desktop/packages/ui/src/features/canvas/toggleActivityPanel.test.ts b/products/desktop/packages/ui/src/features/canvas/toggleActivityPanel.test.tsnew file mode 100644index 000000000000..a12929e63801--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/toggleActivityPanel.test.ts@@ -0,0 +1,61 @@+import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";+import { useThreadPanelStore } from "@posthog/ui/features/canvas/stores/threadPanelStore";+import { beforeEach, describe, expect, it, vi } from "vitest";++const { track } = vi.hoisted(() => ({ track: vi.fn() }));+vi.mock("@posthog/ui/shell/analytics", () => ({ track }));++import { toggleActivityPanel } from "./toggleActivityPanel";++describe("toggleActivityPanel", () => {+ beforeEach(() => {+ track.mockClear();+ useCurrentChannelStore.setState({ currentChannelId: "channel-1" });+ useThreadPanelStore.setState({+ collapsed: false,+ openByChannel: { "channel-1": "task-1" },+ });+ });++ it("does nothing when the current channel has no open thread", () => {+ useThreadPanelStore.setState({ openByChannel: {} });++ toggleActivityPanel();++ expect(useThreadPanelStore.getState().collapsed).toBe(false);+ expect(track).not.toHaveBeenCalled();+ });++ it("does nothing when no channel is current", () => {+ useCurrentChannelStore.setState({ currentChannelId: null });++ toggleActivityPanel();++ expect(useThreadPanelStore.getState().collapsed).toBe(false);+ expect(track).not.toHaveBeenCalled();+ });++ it("collapses the open thread's panel and tracks the action", () => {+ toggleActivityPanel();++ expect(useThreadPanelStore.getState().collapsed).toBe(true);+ expect(track).toHaveBeenCalledWith("Channel action", {+ action_type: "collapse_thread",+ surface: "activity_panel",+ task_id: "task-1",+ });+ });++ it("expands an already-collapsed panel and tracks the action", () => {+ useThreadPanelStore.setState({ collapsed: true });++ toggleActivityPanel();++ expect(useThreadPanelStore.getState().collapsed).toBe(false);+ expect(track).toHaveBeenCalledWith("Channel action", {+ action_type: "expand_thread",+ surface: "activity_panel",+ task_id: "task-1",+ });+ });+});diff --git a/products/desktop/packages/ui/src/features/canvas/toggleActivityPanel.ts b/products/desktop/packages/ui/src/features/canvas/toggleActivityPanel.tsnew file mode 100644index 000000000000..45007b481f11--- /dev/null+++ b/products/desktop/packages/ui/src/features/canvas/toggleActivityPanel.ts@@ -0,0 +1,26 @@+import { ANALYTICS_EVENTS } from "@posthog/shared/analytics-events";+import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore";+import { useThreadPanelStore } from "@posthog/ui/features/canvas/stores/threadPanelStore";+import { track } from "@posthog/ui/shell/analytics";++/**+ * Toggle the activity panel from the global shortcut. Reads the open thread+ * for the current channel directly from the stores (no hook), so it works+ * from anywhere in the channels layout, not just while a thread panel happens+ * to be mounted.+ */+export function toggleActivityPanel(): void {+ const { currentChannelId } = useCurrentChannelStore.getState();+ const openTaskId = currentChannelId+ ? useThreadPanelStore.getState().openByChannel[currentChannelId]+ : null;+ if (!openTaskId) return;++ const { collapsed, setCollapsed } = useThreadPanelStore.getState();+ setCollapsed(!collapsed);+ track(ANALYTICS_EVENTS.CHANNEL_ACTION, {+ action_type: collapsed ? "expand_thread" : "collapse_thread",+ surface: "activity_panel",+ task_id: openTaskId,+ });+}diff --git a/products/desktop/packages/ui/src/features/command/keyboard-shortcuts.ts b/products/desktop/packages/ui/src/features/command/keyboard-shortcuts.tsindex 0105127deea6..38108842c45a 100644--- a/products/desktop/packages/ui/src/features/command/keyboard-shortcuts.ts+++ b/products/desktop/packages/ui/src/features/command/keyboard-shortcuts.ts@@ -13,6 +13,7 @@ export const SHORTCUTS = {GO_BACK_ALT: "mod+left",GO_FORWARD_ALT: "mod+right",TOGGLE_LEFT_SIDEBAR: "mod+b",+ TOGGLE_ACTIVITY_PANEL: "mod+alt+b",TOGGLE_REVIEW_PANEL: "mod+shift+b",PREV_TASK: "mod+shift+[,ctrl+shift+tab",NEXT_TASK: "mod+shift+],ctrl+tab",@@ -206,6 +207,14 @@ export const KEYBOARD_SHORTCUTS: KeyboardShortcut[] = [description: "Toggle left sidebar",category: "navigation",},+ {+ id: "toggle-activity-panel",+ keys: SHORTCUTS.TOGGLE_ACTIVITY_PANEL,+ description: "Toggle activity panel",+ category: "panels",+ context: "Spaces",+ availability: "channels-layout",+ },{id: "toggle-review-panel",keys: SHORTCUTS.TOGGLE_REVIEW_PANEL,diff --git a/products/desktop/packages/ui/src/shell/GlobalEventHandlers.tsx b/products/desktop/packages/ui/src/shell/GlobalEventHandlers.tsxindex a0215da751b1..f7f25b81d582 100644--- a/products/desktop/packages/ui/src/shell/GlobalEventHandlers.tsx+++ b/products/desktop/packages/ui/src/shell/GlobalEventHandlers.tsx@@ -9,6 +9,7 @@ import { useHostTRPC } from "@posthog/host-router/react";import { PROJECT_BLUEBIRD_FLAG } from "@posthog/shared";import type { Task } from "@posthog/shared/domain-types";import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";+import { toggleActivityPanel } from "@posthog/ui/features/canvas/toggleActivityPanel";import { getDefaultReviewMode } from "@posthog/ui/features/code-review/getDefaultReviewMode";import { useReviewNavigationStore } from "@posthog/ui/features/code-review/reviewNavigationStore";import { SHORTCUTS } from "@posthog/ui/features/command/keyboard-shortcuts";@@ -203,6 +204,10 @@ export function GlobalEventHandlers({);useHotkeys(SHORTCUTS.TOGGLE_LEFT_SIDEBAR, toggleLeftSidebar, globalOptions);useHotkeys(SHORTCUTS.TOGGLE_REVIEW_PANEL, handleToggleReview, globalOptions);+ useHotkeys(SHORTCUTS.TOGGLE_ACTIVITY_PANEL, toggleActivityPanel, {+ ...globalOptions,+ enabled: channelsLayout,+ });useHotkeys(SHORTCUTS.SHORTCUTS_SHEET, onToggleShortcutsSheet, globalOptions);useHotkeys(SHORTCUTS.INBOX, navigateToInbox, globalOptions);useHotkeys(SHORTCUTS.PREV_TASK, handlePrevTask, globalOptions, [