: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): dock the context panel beside the scene (#119070)
Adam Leithe9d1190d1a89
diff --git a/frontend/src/layout/navigation-3000/Navigation.tsx b/frontend/src/layout/navigation-3000/Navigation.tsxindex 065eca8b9fe3..74f90136dcfd 100644--- a/frontend/src/layout/navigation-3000/Navigation.tsx+++ b/frontend/src/layout/navigation-3000/Navigation.tsx@@ -16,6 +16,7 @@ import { panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'import { ProjectDragAndDropProvider } from '~/layout/panel-layout/ProjectTree/ProjectDragAndDropContext'import { TodayShell } from '~/layout/today/TodayShell'import { TODAY_RAIL_WIDTH, todayShellLogic } from '~/layout/today/todayShellLogic'+import { TodaySidePanel } from '~/layout/today/TodaySidePanel'import { TodayTopBar } from '~/layout/today/TodayTopBar'import { navigationLogic } from '../navigation/navigationLogic'@@ -60,6 +61,8 @@ export function Navigation({const todayDrawerOpen = todayRail && mobileLayout && todaySidebarVisibleconst todayPhone = todayRail && todayPhoneLayoutconst todayFramed = todayRail && !todayPhone+ // The framed Today layout gives the side panel its own grid column, so the panel no longer overlaps the scene.+ const sidePanelOverlapsMain = sidePanelOpen && !todayFramed// SceneMenuBar (when enabled) replaces ProjectNotice's role of conveying project-level// context above scene content, so we hide the notice for users on the new menu bar.@@ -210,6 +213,7 @@ export function Navigation({'TodayAppLayout__content',// A docked sidebar owns the corner and the seam, so the content draws them only without one.(mobileLayout || !todaySidebarVisible) && 'TodayAppLayout__content--corner',+ sidePanelWidth > 0 && 'TodayAppLayout__content--side-panel',]: ['lg:rounded border-t lg:border lg:mr-1 lg:mb-1 lg:mt-1',@@ -243,7 +247,8 @@ export function Navigation({// The Today layout's content meets the chrome on straight seams.'rounded-t': !todayRail,'p-0': noPaddingScene,- 'lg:max-w-[calc(100%-var(--side-panel-width))] rounded-r-none': sidePanelOpen,+ 'lg:max-w-[calc(100%-var(--side-panel-width))] rounded-r-none':+ sidePanelOverlapsMain,})}>@@ -279,7 +284,7 @@ export function Navigation({)}{children}</div>- <SidePanel />+ {!todayFramed && <SidePanel />}</SceneLayout></main>@@ -295,7 +300,7 @@ export function Navigation({'absolute inset-0 z-50 bg-[var(--scene-layout-background)] flex flex-col outline-none',{hidden: !sceneTakeoverActive,- 'lg:max-w-[calc(100%-var(--side-panel-width))]': sidePanelOpen,+ 'lg:max-w-[calc(100%-var(--side-panel-width))]': sidePanelOverlapsMain,})}/>@@ -327,6 +332,7 @@ export function Navigation({</>)}</div>+ {todayFramed && <TodaySidePanel />}</ProjectDragAndDropProvider></div></>diff --git a/frontend/src/layout/today/TodayContextPanelCard.tsx b/frontend/src/layout/today/TodayContextPanelCard.tsxnew file mode 100644index 000000000000..b8b016c7d6ef--- /dev/null+++ b/frontend/src/layout/today/TodayContextPanelCard.tsx@@ -0,0 +1,38 @@+import { forwardRef } from 'react'++import { Card, CardContent, cn } from '@posthog/quill'++import { SidePanelTab } from '~/types'++import { TodayContextPanelContent } from './TodayContextPanelContent'+import { TodayContextPanelHeader } from './TodayContextPanelHeader'++interface TodayContextPanelCardProps {+ tab: SidePanelTab+ className?: string+}++export const TodayContextPanelCard = forwardRef<HTMLDivElement, TodayContextPanelCardProps>(+ function TodayContextPanelCard({ tab, 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+ // radius and the border are the Today frame's, so the card's edges match the content and the floating+ // sidebar.+ <Card+ ref={ref}+ flush+ className={cn(+ 'min-h-0 rounded-[var(--today-frame-radius)] border border-border bg-[var(--color-bg-surface-primary)] pt-0 shadow-none',+ className+ )}+ data-attr="today-context-panel-card"+ >+ <TodayContextPanelHeader />+ <CardContent className="flex min-h-0 flex-1 flex-col overflow-hidden">+ <TodayContextPanelContent tab={tab} />+ </CardContent>+ </Card>+ )+ }+)diff --git a/frontend/src/layout/today/TodayContextPanelContent.tsx b/frontend/src/layout/today/TodayContextPanelContent.tsxnew file mode 100644index 000000000000..c13af96693b1--- /dev/null+++ b/frontend/src/layout/today/TodayContextPanelContent.tsx@@ -0,0 +1,49 @@+import { useValues } from 'kea'+import { ComponentType, Suspense, memo, useState } from 'react'++import { Spinner } from '@posthog/quill'++import { ChunkLoadErrorBoundary } from 'scenes/ChunkLoadErrorBoundary'++import { ErrorBoundary } from '~/layout/ErrorBoundary'+import { SIDE_PANEL_TABS } from '~/layout/navigation-3000/sidepanel/sidePanelTabs'+import { SidePanelTab } from '~/types'++import { todayContextPanelLogic } from './todayContextPanelLogic'++// The quill rebuilds of the side panel tabs. Every other tab keeps its own panel.+const QUILL_TAB_PANELS: Partial<Record<SidePanelTab, ComponentType>> = {}++type SwitchDirection = 'forward' | 'backward'++// Memoized, so resizing or dragging the panel doesn't rerender the open tab's content on every frame.+export const TodayContextPanelContent = memo(function TodayContextPanelContent({+ tab,+}: {+ tab: SidePanelTab+}): JSX.Element {+ const { panelTabs } = useValues(todayContextPanelLogic)+ const [shownTab, setShownTab] = useState(tab)+ const [direction, setDirection] = useState<SwitchDirection | null>(null)++ // Adjusting state during render, so the panel mounts with its direction already set and never flashes still.+ if (shownTab !== tab) {+ setDirection(panelTabs.indexOf(tab) >= panelTabs.indexOf(shownTab) ? 'forward' : 'backward')+ setShownTab(tab)+ }++ const Content = QUILL_TAB_PANELS[tab] ?? SIDE_PANEL_TABS[tab].Content++ return (+ <div key={tab} data-direction={direction ?? undefined} className="TodayContextPanelContent">+ <ErrorBoundary>+ {/* Keep chunk-load failures out of the panel error reporter so stale assets reload once instead. */}+ <ChunkLoadErrorBoundary>+ <Suspense fallback={<Spinner className="mx-auto mt-16" />}>+ <Content />+ </Suspense>+ </ChunkLoadErrorBoundary>+ </ErrorBoundary>+ </div>+ )+})diff --git a/frontend/src/layout/today/TodayContextPanelHeader.tsx b/frontend/src/layout/today/TodayContextPanelHeader.tsxnew file mode 100644index 000000000000..ddd26b250979--- /dev/null+++ b/frontend/src/layout/today/TodayContextPanelHeader.tsx@@ -0,0 +1,73 @@+import { useActions, useValues } from 'kea'++import { IconExpand45, IconX } from '@posthog/icons'+import { Button, CardHeader, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'++import { LinkPrimitive } from 'lib/lemon-ui/Link'++import { SIDE_PANEL_TABS } from '~/layout/navigation-3000/sidepanel/sidePanelTabs'++import { todayContextPanelLogic } from './todayContextPanelLogic'++function HeaderIconButton({+ label,+ dataAttr,+ onClick,+ render,+ children,+}: {+ label: string+ dataAttr: string+ onClick?: () => void+ render?: React.ReactElement+ children: React.ReactNode+}): JSX.Element {+ return (+ <Tooltip>+ <TooltipTrigger+ delay={0}+ render={+ <Button+ size="icon"+ aria-label={label}+ className="text-muted-foreground hover:text-foreground"+ onClick={onClick}+ render={render}+ data-attr={dataAttr}+ />+ }+ >+ {children}+ </TooltipTrigger>+ <TooltipContent side="bottom">{label}</TooltipContent>+ </Tooltip>+ )+}++export function TodayContextPanelHeader(): JSX.Element {+ const { activeTab, fullScreenUrl } = useValues(todayContextPanelLogic)+ const { 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">+ <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>+ <div className="ms-auto flex shrink-0 items-center gap-0.5">+ {fullScreenUrl && (+ <HeaderIconButton+ label="Open full screen"+ dataAttr="today-context-panel-full-screen"+ onClick={openFullScreen}+ render={<LinkPrimitive to={fullScreenUrl} />}+ >+ <IconExpand45 />+ </HeaderIconButton>+ )}+ <HeaderIconButton label="Close" onClick={close} dataAttr="today-context-panel-close">+ <IconX />+ </HeaderIconButton>+ </div>+ </CardHeader>+ )+}diff --git a/frontend/src/layout/today/TodayShell.scss b/frontend/src/layout/today/TodayShell.scssindex 6e2d16f4f36d..5620721444af 100644--- a/frontend/src/layout/today/TodayShell.scss+++ b/frontend/src/layout/today/TodayShell.scss@@ -10,12 +10,12 @@.TodayAppLayout--top-bar {--today-top-bar-height: 40px;- // The rail runs the full height. The top bar spans the sidebar and the content beside it.+ // The rail runs the full height. The top bar spans the sidebar, the content and the side panel.grid-template:- 'rail top top' var(--today-top-bar-height)- 'rail left content' minmax(0, 1fr) / var(--today-rail-width) calc(+ 'rail top top top' var(--today-top-bar-height)+ 'rail left content side' minmax(0, 1fr) / var(--today-rail-width) calc(var(--left-nav-width) - var(--today-rail-width)- ) minmax(0, 1fr);+ ) minmax(0, 1fr) var(--side-panel-width, 0);// The shell's rail and sidebar take separate grid cells, so the shell itself drops out of the layout..TodayShell {@@ -29,6 +29,10 @@.TodayShell__sidebar--framed {grid-area: left;}++ .TodayAppLayout__side-panel {+ grid-area: side;+ }}// Spans the sidebar and the content, so one soft shadow off their shared top-left edge lifts both above the chrome.@@ -36,7 +40,7 @@.TodayAppLayout__shadow {position: relative;grid-row: 2;- grid-column: 2 / -1;+ grid-column: 2 / span 2;pointer-events: none;border-top-left-radius: var(--today-frame-radius);box-shadow: -20px -20px 18px -24px #00000021;@@ -89,14 +93,21 @@}}+// Spans the content and the side panel, so the gaps around the side panel card show the chrome like the top bar..TodayAppLayout__backdrop {- grid-area: content;+ grid-row: 2;+ grid-column: content-start / side-end;}.TodayAppLayout .TodayAppLayout__content {&.TodayAppLayout__content--corner {border-top-left-radius: var(--today-frame-radius);}++ // An open side panel is a card of its own, so the content rounds the corner it shares with the gap.+ &.TodayAppLayout__content--side-panel {+ border-top-right-radius: var(--today-frame-radius);+ }}.TodayAppLayout__frame {@@ -110,6 +121,10 @@.TodayAppLayout__content--corner > & {border-left: 1px solid var(--border);}++ .TodayAppLayout__content--side-panel > & {+ border-right: 1px solid var(--border);+ }}.TodayShell__scrim {@@ -335,3 +350,35 @@ body.has-today-phone-layout .Toastify__toast-container--bottom-right {.TodayPaneSearchList:has([data-highlighted]) [role='option']:not([data-highlighted]):hover {background: transparent;}++// A context panel tab fills the card. Switching tabs fades the new one in with a short slide from the side of+// the tab that was picked, so the order of the header icons reads as a direction.+.TodayContextPanelContent {+ --today-context-panel-slide: 0.5rem;++ display: flex;+ flex: 1;+ flex-direction: column;+ min-height: 0;++ &[data-direction] {+ animation: TodayContextPanelContent__switch 200ms var(--today-ease, cubic-bezier(0.23, 1, 0.32, 1)) both;+ }++ &[data-direction='backward'] {+ --today-context-panel-slide: -0.5rem;+ }++ @media (prefers-reduced-motion: reduce) {+ &[data-direction] {+ animation: none;+ }+ }+}++@keyframes TodayContextPanelContent__switch {+ from {+ opacity: 0;+ transform: translateX(var(--today-context-panel-slide));+ }+}diff --git a/frontend/src/layout/today/TodaySidePanel.tsx b/frontend/src/layout/today/TodaySidePanel.tsxnew file mode 100644index 000000000000..4e7f5a5659ca--- /dev/null+++ b/frontend/src/layout/today/TodaySidePanel.tsx@@ -0,0 +1,54 @@+import { useValues } from 'kea'++import { Resizer } from 'lib/components/Resizer/Resizer'+import { useWindowSize } from 'lib/hooks/useWindowSize'+import { cn } from 'lib/utils/css-classes'++import { SIDE_PANEL_MIN_WIDTH_COMPACT, useSidePanelFrame } from '~/layout/navigation-3000/sidepanel/useSidePanelFrame'++import { TodayContextPanelCard } from './TodayContextPanelCard'+import { todayShellLogic } from './todayShellLogic'++// The Today layout gives the panel its own grid column, so a wider panel takes the space from the scene.+const TODAY_SIDE_PANEL_MAX_WIDTH = 720+// Matches the floating card, so docking keeps the panel's width.+const TODAY_SIDE_PANEL_DEFAULT_WIDTH = 340+// The scene keeps at least this much width beside a wide panel, so a narrow window never collapses it.+const TODAY_SCENE_MIN_WIDTH = 320++export function TodaySidePanel(): JSX.Element | null {+ const { leftNavWidth } = useValues(todayShellLogic)+ const { windowSize } = useWindowSize()+ const roomBesideNav = windowSize.width != null ? windowSize.width - leftNavWidth - TODAY_SCENE_MIN_WIDTH : Infinity+ const { ref, resizerLogicProps, isResizeInProgress, activeTab, width, hasTabs } = useSidePanelFrame({+ defaultWidth: TODAY_SIDE_PANEL_DEFAULT_WIDTH,+ // Never below the panel's own minimum: in a very narrow window the scene gives up the width instead.+ maxWidth: Math.max(SIDE_PANEL_MIN_WIDTH_COMPACT, Math.min(TODAY_SIDE_PANEL_MAX_WIDTH, roomBesideNav)),+ })++ if (!hasTabs) {+ return null+ }++ return (+ <div+ className={cn(+ 'TodayAppLayout__side-panel @container/side-panel relative flex h-full min-h-0 flex-col px-1 pb-1',+ '[--side-panel-width:initial] [--scene-layout-rect-width:initial] [--scene-layout-rect-right:initial]',+ isResizeInProgress && 'pointer-events-none',+ !activeTab && 'hidden'+ )}+ ref={ref}+ // eslint-disable-next-line react/forbid-dom-props+ style={{ width }}+ id="side-panel"+ >+ {activeTab && (+ <>+ <Resizer {...resizerLogicProps} visible={false} className="left-0 top-0 h-full" />+ <TodayContextPanelCard tab={activeTab} className="h-full" />+ </>+ )}+ </div>+ )+}diff --git a/frontend/src/layout/today/TodayTopBar.tsx b/frontend/src/layout/today/TodayTopBar.tsxindex b90efd075069..87d91455874e 100644--- a/frontend/src/layout/today/TodayTopBar.tsx+++ b/frontend/src/layout/today/TodayTopBar.tsx@@ -1,7 +1,7 @@import { TodayProjectMenu } from './TodayProjectMenu'+import { TodayTopBarPanelTabs } from './TodayTopBarPanelTabs'import { TodayTopBarQuickStartButton } from './TodayTopBarQuickStartButton'import { TodayTopBarSearch } from './TodayTopBarSearch'-import { TodayTopBarSidePanelButton } from './TodayTopBarSidePanelButton'/** The equal outer columns keep the search centered. */export function TodayTopBar(): JSX.Element {@@ -17,7 +17,7 @@ export function TodayTopBar(): JSX.Element {<div className="flex min-w-0 items-center gap-2"><TodayTopBarQuickStartButton /><div className="ms-auto">- <TodayTopBarSidePanelButton />+ <TodayTopBarPanelTabs /></div></div></header>diff --git a/frontend/src/layout/today/TodayTopBarPanelTabs.tsx b/frontend/src/layout/today/TodayTopBarPanelTabs.tsxnew file mode 100644index 000000000000..38cf5aa8c089--- /dev/null+++ b/frontend/src/layout/today/TodayTopBarPanelTabs.tsx@@ -0,0 +1,73 @@+import { useActions, useValues } from 'kea'+import { ComponentType } from 'react'++import { IconPulse, IconSparkles } from '@posthog/icons'+import { Button, Kbd, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'++import { sidePanelNotificationsLogic } from '~/layout/navigation-3000/sidepanel/panels/activity/sidePanelNotificationsLogic'+import { SIDE_PANEL_TABS } from '~/layout/navigation-3000/sidepanel/sidePanelTabs'+import { SidePanelTab } from '~/types'++import { todayContextPanelLogic } from './todayContextPanelLogic'++// The top bar's own icons where the side panel's would read wrong at this size.+const TODAY_TAB_ICONS: Partial<Record<SidePanelTab, ComponentType>> = {+ [SidePanelTab.Max]: IconSparkles,+ [SidePanelTab.Activity]: IconPulse,+}++export function TodayTopBarPanelTabs(): JSX.Element {+ const { panelTabs, activeTab, docked } = useValues(todayContextPanelLogic)+ const { togglePanelTab } = useActions(todayContextPanelLogic)+ const { unreadCount } = useValues(sidePanelNotificationsLogic)++ return (+ <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 label = pressed ? `Close ${tabLabel}` : tabLabel+ const unread = tab === SidePanelTab.Activity ? unreadCount : 0+ return (+ // The unread dot sits beside the button, so it never shifts the button's centered icon.+ <span key={tab} className="relative flex">+ <Tooltip disableHoverablePopup>+ <TooltipTrigger+ delay={0}+ render={+ <Button+ size="icon"+ aria-label={unread > 0 ? `${label}, ${unread} unread` : label}+ aria-pressed={pressed}+ className="text-muted-foreground hover:text-foreground aria-pressed:bg-[var(--fill-selected)] aria-pressed:text-foreground"+ onClick={() => togglePanelTab(tab)}+ // pinned: the PostHog AI button keeps the side panel button's data-attr+ data-attr={+ tab === SidePanelTab.Max+ ? 'today-top-bar-side-panel'+ : `today-top-bar-panel-tab-${tab}`+ }+ />+ }+ >+ <Icon />+ </TooltipTrigger>+ <TooltipContent side="bottom" align="end">+ {label}+ {unread > 0 && <span className="opacity-70">{unread} unread</span>}+ {tab === SidePanelTab.Max && <Kbd>]</Kbd>}+ </TooltipContent>+ </Tooltip>+ {unread > 0 && (+ <span+ aria-hidden+ className="pointer-events-none absolute top-0.5 right-0.5 size-2 rounded-full bg-primary"+ />+ )}+ </span>+ )+ })}+ </div>+ )+}diff --git a/frontend/src/layout/today/TodayTopBarSidePanelButton.tsx b/frontend/src/layout/today/TodayTopBarSidePanelButton.tsxdeleted file mode 100644index e9c4de767a96..000000000000--- a/frontend/src/layout/today/TodayTopBarSidePanelButton.tsx+++ /dev/null@@ -1,38 +0,0 @@-import { useActions, useValues } from 'kea'--import { IconSidePanel } from '@posthog/icons'-import { Button, Kbd, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'--import { sidePanelLogic } from '~/layout/navigation-3000/sidepanel/sidePanelLogic'-import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'--export function TodayTopBarSidePanelButton(): JSX.Element {- const { sidePanelOpen } = useValues(sidePanelStateLogic)- const { defaultTab } = useValues(sidePanelLogic)- const { openSidePanel, closeSidePanel } = useActions(sidePanelStateLogic)- const label = sidePanelOpen ? 'Close context panel' : 'Open context panel'-- return (- <Tooltip disableHoverablePopup>- <TooltipTrigger- delay={0}- render={- <Button- size="icon"- aria-label={label}- aria-pressed={sidePanelOpen}- className="text-muted-foreground hover:text-foreground aria-pressed:bg-[var(--fill-selected)] aria-pressed:text-foreground"- onClick={() => (sidePanelOpen ? closeSidePanel() : openSidePanel(defaultTab))}- data-attr="today-top-bar-side-panel"- />- }- >- <IconSidePanel />- </TooltipTrigger>- <TooltipContent side="bottom" align="end">- {label}- <Kbd>]</Kbd>- </TooltipContent>- </Tooltip>- )-}diff --git a/frontend/src/layout/today/todayContextPanelLogic.ts b/frontend/src/layout/today/todayContextPanelLogic.tsnew file mode 100644index 000000000000..070b90e0c56f--- /dev/null+++ b/frontend/src/layout/today/todayContextPanelLogic.ts@@ -0,0 +1,133 @@+import { MakeLogicType, actions, connect, kea, listeners, path, 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 { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'+import { SidePanelTab } from '~/types'++/**+ * 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.+ */+const TABS_LEFT_OUT = [SidePanelTab.Info, SidePanelTab.Exports, SidePanelTab.Notebooks, SidePanelTab.Discussion]++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface todayContextPanelLogicValues {+ selectedNotebook: string // notebookPanelLogic+ enabledTabs: SidePanelTab[] // sidePanelLogic+ selectedTab: SidePanelTab | null // sidePanelStateLogic+ sidePanelOpen: boolean // sidePanelStateLogic+ activeTab: SidePanelTab+ docked: boolean+ fullScreenUrl: string | null+ panelTabs: SidePanelTab[]+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface todayContextPanelLogicActions {+ closeSidePanel: (tab?: SidePanelTab | undefined) => {+ tab: SidePanelTab | undefined+ } // sidePanelStateLogic+ openSidePanel: (+ tab: SidePanelTab,+ options?: string | undefined+ ) => {+ options: string | undefined+ tab: SidePanelTab+ } // sidePanelStateLogic+ close: () => {+ value: true+ }+ openFullScreen: () => {+ value: true+ }+ togglePanelTab: (tab: SidePanelTab) => {+ tab: SidePanelTab+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface todayContextPanelLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ docked: (sidePanelOpen: boolean) => boolean+ panelTabs: (enabledTabs: SidePanelTab[]) => SidePanelTab[]+ activeTab: (selectedTab: SidePanelTab | null) => SidePanelTab+ fullScreenUrl: (activeTab: SidePanelTab, selectedNotebook: string) => string | null+ }+}++export type todayContextPanelLogicType = MakeLogicType<+ todayContextPanelLogicValues,+ todayContextPanelLogicActions,+ Record<string, any>,+ todayContextPanelLogicMeta+>++/** The context panel outside the scene, docked in its own column beside it. PostHog AI is the panel's home tab. */+export const todayContextPanelLogic = kea<todayContextPanelLogicType>([+ path(['layout', 'today', 'todayContextPanelLogic']),+ connect(() => ({+ values: [+ sidePanelStateLogic,+ ['sidePanelOpen', 'selectedTab'],+ sidePanelLogic,+ ['enabledTabs'],+ notebookPanelLogic,+ ['selectedNotebook'],+ ],+ actions: [sidePanelStateLogic, ['openSidePanel', 'closeSidePanel']],+ })),+ actions({+ togglePanelTab: (tab: SidePanelTab) => ({ tab }),+ close: true,+ openFullScreen: true,+ }),+ selectors({+ docked: [(s) => [s.sidePanelOpen], (sidePanelOpen: boolean): boolean => sidePanelOpen],+ panelTabs: [+ (s) => [s.enabledTabs],+ // PostHog AI goes last, and only where the scene offers it. Canvas scenes bring their own chat.+ (enabledTabs: SidePanelTab[]): SidePanelTab[] => [+ ...enabledTabs.filter((tab) => tab !== SidePanelTab.Max && !TABS_LEFT_OUT.includes(tab)),+ ...(enabledTabs.includes(SidePanelTab.Max) ? [SidePanelTab.Max] : []),+ ],+ ],+ activeTab: [+ (s) => [s.selectedTab],+ (selectedTab: SidePanelTab | null): SidePanelTab => selectedTab ?? SidePanelTab.Max,+ ],+ fullScreenUrl: [+ (s) => [s.activeTab, s.selectedNotebook],+ (activeTab: SidePanelTab, selectedNotebook: string): string | null => {+ switch (activeTab) {+ case SidePanelTab.Activity:+ return urls.advancedActivityLogs()+ case SidePanelTab.Notebooks:+ return urls.notebook(selectedNotebook)+ default:+ return null+ }+ },+ ],+ }),+ listeners(({ actions, values }) => ({+ // The top bar's tab buttons: the open tab closes the panel, and any other 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) {+ actions.close()+ } else {+ actions.openSidePanel(tab)+ }+ },+ close: () => {+ actions.closeSidePanel()+ },+ openFullScreen: () => {+ actions.close()+ },+ })),+])