: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
fix(desktop): open canvas chat when editing (#82870)
Peter Kirkham18223d99fec4
diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.test.tsxindex 25669880618c..5dd5e0e8815b 100644--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.test.tsx@@ -11,6 +11,7 @@ vi.mock("@posthog/host-router/react", () => ({dashboards: { saveContext: { mutationKey: () => ["save-context"] } },}),}));+vi.mock("@posthog/ui/shell/analytics", () => ({ track: vi.fn() }));const { useChannelTasks, useDashboard, useParams, usePathname, useTasks } =vi.hoisted(() => ({@@ -167,6 +168,26 @@ describe("WebsiteLayout task header actions", () => {},);+ it("opens the chat panel when entering edit mode", () => {+ renderLayout({+ pathname: "/website/chan-1/dashboards/canvas-1",+ params: { channelId: "chan-1", dashboardId: "canvas-1" },+ dashboard: {+ name: "Launch",+ templateId: "freeform",+ generationTaskId: "task-1",+ },+ });++ useCanvasChatPanelStore.setState({ collapsed: true, tab: "comments" });+ fireEvent.click(screen.getByRole("button", { name: "Edit" }));++ expect(useCanvasChatPanelStore.getState()).toMatchObject({+ collapsed: false,+ tab: "chat",+ });+ });+it("renders the task action row on a channel task detail", () => {renderLayout({pathname: "/website/chan-1/tasks/task-1",diff --git a/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.tsx b/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.tsxindex 0322f77208ac..e88b16f0ee2a 100644--- a/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/WebsiteLayout.tsx@@ -84,6 +84,7 @@ function FreeformEditControls({const containerNoun = spacesLayout ? "space" : "channel";const editing = useIsDashboardEditing(dashboardId);const setEditing = useDashboardEditStore((s) => s.setEditing);+ const openChat = useCanvasChatPanelStore((state) => state.openChat);const { dashboard } = useDashboard(dashboardId);const { setPinned, invalidateDashboards } = useDashboardMutations();const isPinned = dashboard?.pinnedAt != null;@@ -260,6 +261,7 @@ function FreeformEditControls({kind: "freeform",editing: !editing,});+ if (!editing) openChat();setEditing(dashboardId, !editing);}}>diff --git a/products/desktop/packages/ui/src/features/canvas/stores/canvasChatPanelStore.ts b/products/desktop/packages/ui/src/features/canvas/stores/canvasChatPanelStore.tsindex d23a7fdf5ca2..19b492e2e35c 100644--- a/products/desktop/packages/ui/src/features/canvas/stores/canvasChatPanelStore.ts+++ b/products/desktop/packages/ui/src/features/canvas/stores/canvasChatPanelStore.ts@@ -20,6 +20,7 @@ interface CanvasChatPanelState {setCollapsed: (collapsed: boolean) => void;setWidth: (width: number) => void;setTab: (tab: CanvasPanelTab) => void;+ openChat: () => void;openComments: () => void;}@@ -36,6 +37,7 @@ export const useCanvasChatPanelStore = create<CanvasChatPanelState>()(set(collapsed ? { collapsed, viewOpen: false } : { collapsed }),setWidth: (width) => set({ width }),setTab: (tab) => set({ tab }),+ openChat: () => set({ collapsed: false, tab: "chat", viewOpen: false }),openComments: () =>set({ collapsed: false, tab: "comments", viewOpen: true }),}),