: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(today): float the context panel over the scene (#119071)
Adam Leith9dc44cff8353
diff --git a/frontend/src/layout/navigation-3000/Navigation.tsx b/frontend/src/layout/navigation-3000/Navigation.tsxindex 74f90136dcfd..00a48a9a5d2d 100644--- a/frontend/src/layout/navigation-3000/Navigation.tsx+++ b/frontend/src/layout/navigation-3000/Navigation.tsx@@ -14,6 +14,7 @@ import { Scene, SceneConfig } from 'scenes/sceneTypes'import { PanelLayout } from '~/layout/panel-layout/PanelLayout'import { panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'import { ProjectDragAndDropProvider } from '~/layout/panel-layout/ProjectTree/ProjectDragAndDropContext'+import { TodayContextPanelFloating } from '~/layout/today/TodayContextPanelFloating'import { TodayShell } from '~/layout/today/TodayShell'import { TODAY_RAIL_WIDTH, todayShellLogic } from '~/layout/today/todayShellLogic'import { TodaySidePanel } from '~/layout/today/TodaySidePanel'@@ -57,6 +58,7 @@ export function Navigation({sidebarVisible: todaySidebarVisible,phoneLayout: todayPhoneLayout,phoneHeaderHidden: todayPhoneHeaderHidden,+ onAiPage: todayOnAiPage,} = useValues(todayShellLogic)const todayDrawerOpen = todayRail && mobileLayout && todaySidebarVisibleconst todayPhone = todayRail && todayPhoneLayout@@ -331,6 +333,7 @@ export function Navigation({</div></>)}+ {todayFramed && !todayOnAiPage && <TodayContextPanelFloating />}</div>{todayFramed && <TodaySidePanel />}</ProjectDragAndDropProvider>diff --git a/frontend/src/layout/today/TodayContextPanelCard.tsx b/frontend/src/layout/today/TodayContextPanelCard.tsxindex b8b016c7d6ef..24c9cf47dedf 100644--- a/frontend/src/layout/today/TodayContextPanelCard.tsx+++ b/frontend/src/layout/today/TodayContextPanelCard.tsx@@ -8,12 +8,14 @@ import { TodayContextPanelContent } from './TodayContextPanelContent'import { TodayContextPanelHeader } from './TodayContextPanelHeader'interface TodayContextPanelCardProps {+ docked: booleantab: SidePanelTab+ onDragStart?: (event: React.PointerEvent<HTMLDivElement>) => voidclassName?: string}export const TodayContextPanelCard = forwardRef<HTMLDivElement, TodayContextPanelCardProps>(- function TodayContextPanelCard({ tab, className }, ref) {+ function TodayContextPanelCard({ docked, tab, onDragStart, className }, ref) {return (// The header carries its own padding, so the card drops its top padding too. The panels paint the// app's surface, so the card takes the same one and the header and body read as one surface. The@@ -28,7 +30,7 @@ export const TodayContextPanelCard = forwardRef<HTMLDivElement, TodayContextPane)}data-attr="today-context-panel-card">- <TodayContextPanelHeader />+ <TodayContextPanelHeader docked={docked} onDragStart={onDragStart} /><CardContent className="flex min-h-0 flex-1 flex-col overflow-hidden"><TodayContextPanelContent tab={tab} /></CardContent>diff --git a/frontend/src/layout/today/TodayContextPanelFloating.tsx b/frontend/src/layout/today/TodayContextPanelFloating.tsxnew file mode 100644index 000000000000..961baafc922c--- /dev/null+++ b/frontend/src/layout/today/TodayContextPanelFloating.tsx@@ -0,0 +1,155 @@+import { useActions, useValues } from 'kea'+import { useRef } from 'react'++import { IconSparkles } from '@posthog/icons'+import {+ Button,+ Popover,+ PopoverContent,+ PopoverTrigger,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from '@posthog/quill'++import { SidePanelTab } from '~/types'++import { TodayContextPanelCard } from './TodayContextPanelCard'+import { TODAY_CONTEXT_PANEL_DOCK_EDGE, todayContextPanelLogic } from './todayContextPanelLogic'++/** Presses on these inside the header act on them instead of moving the panel. */+const NOT_A_DRAG_HANDLE = 'button, a, input, [role="menuitem"]'++export function TodayContextPanelFloating(): JSX.Element {+ const { floatingOpen, floatingOffset, floatingActiveTab, docked, dockHint, panelTabs } =+ useValues(todayContextPanelLogic)+ const { setFloatingOpen, setFloatingTab, setFloatingOffset, setDockHint, dock } = useActions(todayContextPanelLogic)+ const cardRef = useRef<HTMLDivElement>(null)+ const launcherHidden = docked || !panelTabs.includes(SidePanelTab.Max)++ const startDrag = (event: React.PointerEvent<HTMLDivElement>): void => {+ if (event.button !== 0 || (event.target as HTMLElement).closest(NOT_A_DRAG_HANDLE)) {+ return+ }+ event.preventDefault()+ const handle = event.currentTarget+ const origin = floatingOffset+ const start = { x: event.clientX, y: event.clientY }+ const nearDockEdge = (clientX: number): boolean => clientX >= window.innerWidth - TODAY_CONTEXT_PANEL_DOCK_EDGE+ // Keeps the whole card on screen, so the header stays in reach to drag it back.+ const card = cardRef.current?.getBoundingClientRect()+ const clamp = (delta: number, min: number, max: number): number => Math.min(Math.max(delta, min), max)++ const move = (moveEvent: PointerEvent): void => {+ let dx = moveEvent.clientX - start.x+ let dy = moveEvent.clientY - start.y+ if (card) {+ dx = clamp(dx, -card.left, window.innerWidth - card.right)+ dy = clamp(dy, -card.top, window.innerHeight - card.bottom)+ }+ setFloatingOffset({ x: origin.x + dx, y: origin.y + dy })+ setDockHint(nearDockEdge(moveEvent.clientX))+ }+ const end = (endEvent: PointerEvent): void => {+ handle.removeEventListener('pointermove', move)+ handle.removeEventListener('pointerup', end)+ handle.removeEventListener('pointercancel', end)+ if (endEvent.type === 'pointerup' && nearDockEdge(endEvent.clientX)) {+ // A docked panel that undocks comes back where it was picked up, not at the window edge.+ setFloatingOffset(origin)+ dock()+ } else {+ setDockHint(false)+ }+ }++ handle.setPointerCapture(event.pointerId)+ handle.addEventListener('pointermove', move)+ handle.addEventListener('pointerup', end)+ handle.addEventListener('pointercancel', end)+ }++ return (+ <>+ <Popover+ open={floatingOpen}+ onOpenChange={(open, details) => {+ // The panel stays up while the user works on the page around it.+ if (!open && (details.reason === 'outside-press' || details.reason === 'focus-out')) {+ return+ }+ // The button is the way to PostHog AI. Over another tab it switches the card to chat instead of+ // closing it, and it always opens on chat.+ if (floatingActiveTab !== SidePanelTab.Max) {+ setFloatingTab(SidePanelTab.Max)+ if (!open && details.reason === 'trigger-press') {+ return+ }+ }+ setFloatingOpen(open)+ }}+ >+ {/* Stays mounted while docked, so the button can sink away and rise back with the panel. Scenes+ without PostHog AI, like a canvas, hide it but keep the host for other undocked tabs. */}+ <div+ data-quill+ className="TodayContextPanelButton pointer-events-none absolute inset-x-0 bottom-4 z-[var(--z-main-nav)] flex justify-center"+ data-hidden={launcherHidden || undefined}+ {...(launcherHidden ? { inert: '' } : {})}+ >+ {/* The outline button is see-through, so an opaque pill sits behind it over the page. */}+ <span className="pointer-events-auto rounded-full bg-background shadow-md">+ <Tooltip>+ <TooltipTrigger+ delay={0}+ render={+ <PopoverTrigger+ render={+ <Button+ variant="outline"+ size="lg"+ aria-label="Ask PostHog AI"+ className="w-34 justify-center rounded-full"+ data-attr="today-ai-chat-button"+ />+ }+ />+ }+ >+ <IconSparkles />+ </TooltipTrigger>+ <TooltipContent side="top">Ask PostHog AI</TooltipContent>+ </Tooltip>+ </span>+ </div>+ <PopoverContent+ side="top"+ sideOffset={8}+ initialFocus={() =>+ cardRef.current?.querySelector<HTMLElement>('textarea, [contenteditable="true"]') ?? true+ }+ className="w-auto gap-0 border-0 bg-transparent p-0 shadow-none"+ // The drag offset changes on every pointer move, which a class can't express.+ // eslint-disable-next-line react/forbid-dom-props+ style={{ translate: `${floatingOffset.x}px ${floatingOffset.y}px` }}+ >+ {/* Fixed size: the panels scroll inside, and a size that followed a streaming thread would jump. */}+ <TodayContextPanelCard+ ref={cardRef}+ docked={false}+ tab={floatingActiveTab}+ onDragStart={startDrag}+ className="h-[min(40rem,calc(100vh-10rem))] w-85 shadow-lg"+ />+ </PopoverContent>+ </Popover>+ {dockHint && (+ <div+ data-quill+ aria-hidden+ className="pointer-events-none fixed top-10 right-1 bottom-1 z-[var(--z-layout-panel)] w-[min(32rem,40vw)] rounded-lg border border-dashed border-ring bg-[var(--fill-hover)] opacity-60"+ />+ )}+ </>+ )+}diff --git a/frontend/src/layout/today/TodayContextPanelHeader.tsx b/frontend/src/layout/today/TodayContextPanelHeader.tsxindex ddd26b250979..a8b4d4ed3bab 100644--- a/frontend/src/layout/today/TodayContextPanelHeader.tsx+++ b/frontend/src/layout/today/TodayContextPanelHeader.tsx@@ -1,7 +1,7 @@import { useActions, useValues } from 'kea'-import { IconExpand45, IconX } from '@posthog/icons'-import { Button, CardHeader, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'+import { IconExpand45, IconExternal, IconSidePanel, IconX } from '@posthog/icons'+import { Button, CardHeader, Tooltip, TooltipContent, TooltipTrigger, cn } from '@posthog/quill'import { LinkPrimitive } from 'lib/lemon-ui/Link'@@ -9,6 +9,12 @@ import { SIDE_PANEL_TABS } from '~/layout/navigation-3000/sidepanel/sidePanelTabimport { todayContextPanelLogic } from './todayContextPanelLogic'+interface TodayContextPanelHeaderProps {+ docked: boolean+ /** Starts moving the floating panel. Left out when docked, since a docked panel doesn't move. */+ onDragStart?: (event: React.PointerEvent<HTMLDivElement>) => void+}+function HeaderIconButton({label,dataAttr,@@ -44,12 +50,18 @@ function HeaderIconButton({)}-export function TodayContextPanelHeader(): JSX.Element {- const { activeTab, fullScreenUrl } = useValues(todayContextPanelLogic)- const { close, openFullScreen } = useActions(todayContextPanelLogic)+export function TodayContextPanelHeader({ docked, onDragStart }: TodayContextPanelHeaderProps): JSX.Element {+ const { activeTab, fullScreenUrl, canUndock } = useValues(todayContextPanelLogic)+ const { dock, undock, close, openFullScreen } = useActions(todayContextPanelLogic)return (- <CardHeader className="flex items-center gap-1 border-b border-border py-1.5 ps-1.5 pe-1.5">+ <CardHeader+ className={cn(+ 'flex items-center gap-1 border-b border-border py-1.5 ps-1.5 pe-1.5',+ onDragStart && 'cursor-grab touch-none select-none active:cursor-grabbing'+ )}+ onPointerDown={onDragStart}+ ><span className="flex h-7 min-w-0 items-center px-1.5 font-semibold"><span className="truncate">{SIDE_PANEL_TABS[activeTab].label}</span></span>@@ -64,6 +76,17 @@ export function TodayContextPanelHeader(): JSX.Element {<IconExpand45 /></HeaderIconButton>)}+ {docked ? (+ canUndock && (+ <HeaderIconButton label="Undock" onClick={undock} dataAttr="today-context-panel-undock">+ <IconExternal />+ </HeaderIconButton>+ )+ ) : (+ <HeaderIconButton label="Dock to the right" onClick={dock} dataAttr="today-context-panel-dock">+ <IconSidePanel />+ </HeaderIconButton>+ )}<HeaderIconButton label="Close" onClick={close} dataAttr="today-context-panel-close"><IconX /></HeaderIconButton>diff --git a/frontend/src/layout/today/TodayShell.scss b/frontend/src/layout/today/TodayShell.scssindex 5620721444af..4c9eb9b0add4 100644--- a/frontend/src/layout/today/TodayShell.scss+++ b/frontend/src/layout/today/TodayShell.scss@@ -1,9 +1,12 @@+// Resolved on body, outside any quill scope, so the sidebar, the content and the cards portaled out of the layout+// (the floating AI chat) share one corner value.+body {+ --today-frame-radius: var(--radius);+}+.TodayAppLayout {--today-frame-inset: 4px;- // Resolved here, outside any quill scope, so the sidebar and content corners share one value.- --today-frame-radius: var(--radius);-background: var(--today-paper);}@@ -382,3 +385,29 @@ body.has-today-phone-layout .Toastify__toast-container--bottom-right {transform: translateX(var(--today-context-panel-slide));}}++// The floating button sinks away when the panel docks and rises back when it closes, so the hand-off reads.+// Leaving is a little quicker than coming back.+.TodayContextPanelButton {+ transition:+ opacity 200ms var(--today-ease, cubic-bezier(0.23, 1, 0.32, 1)),+ transform 200ms var(--today-ease, cubic-bezier(0.23, 1, 0.32, 1)),+ visibility 0s;++ &[data-hidden] {+ visibility: hidden;+ opacity: 0;+ transition:+ opacity 160ms var(--today-ease, cubic-bezier(0.23, 1, 0.32, 1)),+ transform 160ms var(--today-ease, cubic-bezier(0.23, 1, 0.32, 1)),+ visibility 0s 160ms;+ transform: translateY(0.5rem);+ }++ @media (prefers-reduced-motion: reduce) {+ &,+ &[data-hidden] {+ transition: none;+ }+ }+}diff --git a/frontend/src/layout/today/TodaySidePanel.tsx b/frontend/src/layout/today/TodaySidePanel.tsxindex 4e7f5a5659ca..1f0014da08c8 100644--- a/frontend/src/layout/today/TodaySidePanel.tsx+++ b/frontend/src/layout/today/TodaySidePanel.tsx@@ -46,7 +46,7 @@ export function TodaySidePanel(): JSX.Element | null {{activeTab && (<><Resizer {...resizerLogicProps} visible={false} className="left-0 top-0 h-full" />- <TodayContextPanelCard tab={activeTab} className="h-full" />+ <TodayContextPanelCard docked tab={activeTab} className="h-full" /></>)}</div>diff --git a/frontend/src/layout/today/TodayTopBarPanelTabs.tsx b/frontend/src/layout/today/TodayTopBarPanelTabs.tsxindex 38cf5aa8c089..66097018ff1e 100644--- a/frontend/src/layout/today/TodayTopBarPanelTabs.tsx+++ b/frontend/src/layout/today/TodayTopBarPanelTabs.tsx@@ -17,16 +17,17 @@ const TODAY_TAB_ICONS: Partial<Record<SidePanelTab, ComponentType>> = {}export function TodayTopBarPanelTabs(): JSX.Element {- const { panelTabs, activeTab, docked } = useValues(todayContextPanelLogic)+ const { panelTabs, activeTab, docked, floatingOpen } = useValues(todayContextPanelLogic)const { togglePanelTab } = useActions(todayContextPanelLogic)const { unreadCount } = useValues(sidePanelNotificationsLogic)+ const panelOpen = docked || floatingOpenreturn (<div className="flex items-center gap-0.5">{panelTabs.map((tab) => {const { label: tabLabel } = SIDE_PANEL_TABS[tab]const Icon = TODAY_TAB_ICONS[tab] ?? SIDE_PANEL_TABS[tab].Icon- const pressed = docked && activeTab === tab+ const pressed = panelOpen && activeTab === tabconst label = pressed ? `Close ${tabLabel}` : tabLabelconst unread = tab === SidePanelTab.Activity ? unreadCount : 0return (diff --git a/frontend/src/layout/today/todayContextPanelLogic.ts b/frontend/src/layout/today/todayContextPanelLogic.tsindex 070b90e0c56f..3bd80f519d98 100644--- a/frontend/src/layout/today/todayContextPanelLogic.ts+++ b/frontend/src/layout/today/todayContextPanelLogic.ts@@ -1,13 +1,25 @@-import { MakeLogicType, actions, connect, kea, listeners, path, selectors } from 'kea'+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'import posthog from 'posthog-js'import { notebookPanelLogic } from 'scenes/notebooks/NotebookPanel/notebookPanelLogic'import { urls } from 'scenes/urls'-import { sidePanelLogic } from '~/layout/navigation-3000/sidepanel/sidePanelLogic'+import { CANVAS_SIDE_PANEL_TABS, sidePanelLogic } from '~/layout/navigation-3000/sidepanel/sidePanelLogic'import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'import { SidePanelTab } from '~/types'+import { todayShellLogic } from './todayShellLogic'++export interface TodayContextPanelOffset {+ x: number+ y: number+}++/** How close to the right edge of the window a dragged panel must be released to dock. */+export const TODAY_CONTEXT_PANEL_DOCK_EDGE = 64++const NO_OFFSET: TodayContextPanelOffset = { x: 0, y: 0 }+/*** Tabs the top bar doesn't offer. Info is on its way out under the Today layout. Exports, Notebooks and Discussion* still open docked from their own entry points, such as "Add to notebook" or a comment button.@@ -20,8 +32,15 @@ export interface todayContextPanelLogicValues {enabledTabs: SidePanelTab[] // sidePanelLogicselectedTab: SidePanelTab | null // sidePanelStateLogicsidePanelOpen: boolean // sidePanelStateLogic+ onAiPage: boolean // todayShellLogicactiveTab: SidePanelTab+ canUndock: boolean+ dockHint: booleandocked: boolean+ floatingActiveTab: SidePanelTab+ floatingOffset: TodayContextPanelOffset+ floatingOpen: boolean+ floatingTab: SidePanelTabfullScreenUrl: string | nullpanelTabs: SidePanelTab[]}@@ -41,12 +60,30 @@ export interface todayContextPanelLogicActions {close: () => {value: true}+ dock: () => {+ value: true+ }openFullScreen: () => {value: true}+ setDockHint: (dockHint: boolean) => {+ dockHint: boolean+ }+ setFloatingOffset: (offset: TodayContextPanelOffset) => {+ offset: TodayContextPanelOffset+ }+ setFloatingOpen: (open: boolean) => {+ open: boolean+ }+ setFloatingTab: (tab: SidePanelTab) => {+ tab: SidePanelTab+ }togglePanelTab: (tab: SidePanelTab) => {tab: SidePanelTab}+ undock: () => {+ value: true+ }}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -54,7 +91,9 @@ export interface todayContextPanelLogicMeta {__keaTypeGenInternalSelectorTypes: {docked: (sidePanelOpen: boolean) => booleanpanelTabs: (enabledTabs: SidePanelTab[]) => SidePanelTab[]- activeTab: (selectedTab: SidePanelTab | null) => SidePanelTab+ floatingActiveTab: (floatingTab: SidePanelTab, enabledTabs: SidePanelTab[]) => SidePanelTab+ canUndock: (activeTab: SidePanelTab, onAiPage: boolean) => boolean+ activeTab: (docked: boolean, selectedTab: SidePanelTab | null, floatingActiveTab: SidePanelTab) => SidePanelTabfullScreenUrl: (activeTab: SidePanelTab, selectedNotebook: string) => string | null}}@@ -66,7 +105,10 @@ export type todayContextPanelLogicType = MakeLogicType<todayContextPanelLogicMeta>-/** The context panel outside the scene, docked in its own column beside it. PostHog AI is the panel's home tab. */+/**+ * The context panel outside the scene: a floating card over the main content, or docked in the side panel.+ * Both show the same panel, so only one of them is open at a time. PostHog AI is the panel's home tab.+ */export const todayContextPanelLogic = kea<todayContextPanelLogicType>([path(['layout', 'today', 'todayContextPanelLogic']),connect(() => ({@@ -77,14 +119,53 @@ export const todayContextPanelLogic = kea<todayContextPanelLogicType>([['enabledTabs'],notebookPanelLogic,['selectedNotebook'],+ todayShellLogic,+ ['onAiPage'],],actions: [sidePanelStateLogic, ['openSidePanel', 'closeSidePanel']],})),actions({+ setFloatingOpen: (open: boolean) => ({ open }),+ setFloatingTab: (tab: SidePanelTab) => ({ tab }),+ setFloatingOffset: (offset: TodayContextPanelOffset) => ({ offset }),+ setDockHint: (dockHint: boolean) => ({ dockHint }),togglePanelTab: (tab: SidePanelTab) => ({ tab }),+ dock: true,+ undock: true,close: true,openFullScreen: true,}),+ reducers({+ floatingOpen: [+ false,+ {+ setFloatingOpen: (_, { open }) => open,+ dock: () => false,+ undock: () => true,+ },+ ],+ floatingTab: [+ SidePanelTab.Max as SidePanelTab,+ {+ setFloatingTab: (_, { tab }) => tab,+ },+ ],+ // Kept across opens, so the panel comes back where the user left it.+ floatingOffset: [+ NO_OFFSET as TodayContextPanelOffset,+ {+ setFloatingOffset: (_, { offset }) => offset,+ },+ ],+ dockHint: [+ false,+ {+ setDockHint: (_, { dockHint }) => dockHint,+ dock: () => false,+ setFloatingOpen: () => false,+ },+ ],+ }),selectors({docked: [(s) => [s.sidePanelOpen], (sidePanelOpen: boolean): boolean => sidePanelOpen],panelTabs: [@@ -95,9 +176,30 @@ export const todayContextPanelLogic = kea<todayContextPanelLogicType>([...(enabledTabs.includes(SidePanelTab.Max) ? [SidePanelTab.Max] : []),],],+ /**+ * A tab the scene no longer offers falls back to PostHog AI, like the docked panel closing on navigation.+ * Checked against every enabled tab, so an undocked tab the top bar leaves out stays open.+ */+ floatingActiveTab: [+ (s) => [s.floatingTab, s.enabledTabs],+ (floatingTab: SidePanelTab, enabledTabs: SidePanelTab[]): SidePanelTab =>+ enabledTabs.includes(floatingTab) && !CANVAS_SIDE_PANEL_TABS.includes(floatingTab)+ ? floatingTab+ : SidePanelTab.Max,+ ],+ /**+ * Canvas tabs read their body from the docked panel's selected tab, so they only dock. The AI page has no+ * floating panel to undock into.+ */+ canUndock: [+ (s) => [s.activeTab, s.onAiPage],+ (activeTab: SidePanelTab, onAiPage: boolean): boolean =>+ !onAiPage && !CANVAS_SIDE_PANEL_TABS.includes(activeTab),+ ],activeTab: [- (s) => [s.selectedTab],- (selectedTab: SidePanelTab | null): SidePanelTab => selectedTab ?? SidePanelTab.Max,+ (s) => [s.docked, s.selectedTab, s.floatingActiveTab],+ (docked: boolean, selectedTab: SidePanelTab | null, floatingActiveTab: SidePanelTab): SidePanelTab =>+ docked && selectedTab ? selectedTab : floatingActiveTab,],fullScreenUrl: [(s) => [s.activeTab, s.selectedNotebook],@@ -114,20 +216,54 @@ export const todayContextPanelLogic = kea<todayContextPanelLogicType>([],}),listeners(({ actions, values }) => ({- // The top bar's tab buttons: the open tab closes the panel, and any other tab opens docked.+ setFloatingOpen: ({ open }) => {+ // pinned: analytics event names+ posthog.capture(open ? 'today context panel opened' : 'today context panel closed', {+ mode: 'floating',+ tab: values.floatingActiveTab,+ })+ if (open && values.docked) {+ actions.closeSidePanel()+ }+ },+ // The top bar's tab buttons: the open tab closes the panel, a floating panel switches in place, and with the+ // panel closed the tab opens docked.togglePanelTab: ({ tab }) => {- posthog.capture('today context panel tab toggled', { tab, docked: values.docked, open: values.docked })- if (values.docked && values.activeTab === tab) {+ const open = values.docked || values.floatingOpen+ posthog.capture('today context panel tab toggled', { tab, docked: values.docked, open })+ if (open && values.activeTab === tab) {actions.close()+ } else if (values.floatingOpen && !CANVAS_SIDE_PANEL_TABS.includes(tab)) {+ actions.setFloatingTab(tab)} else {actions.openSidePanel(tab)}},- close: () => {+ dock: () => {+ posthog.capture('today context panel docked', { tab: values.floatingActiveTab })+ actions.openSidePanel(values.floatingActiveTab)+ },+ undock: () => {+ const tab = values.selectedTab ?? SidePanelTab.Max+ posthog.capture('today context panel undocked', { tab })+ actions.setFloatingTab(tab)actions.closeSidePanel()},+ close: () => {+ if (values.docked) {+ actions.closeSidePanel()+ } else {+ actions.setFloatingOpen(false)+ }+ },openFullScreen: () => {actions.close()},+ // The floating and docked panel are one panel, so docking any tab takes the floating card away.+ openSidePanel: () => {+ if (values.floatingOpen) {+ actions.setFloatingOpen(false)+ }+ },})),])