Skip to content

: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.

feat(frontend): add today homepage and rail navigation behind a flag (#108039)

Peter Kirkham09284f84e682
diff --git a/frontend/bin/build-app-url-manifest.mjs b/frontend/bin/build-app-url-manifest.mjs
index 5d5177f9c24a..55f4f8612df9 100644
--- a/frontend/bin/build-app-url-manifest.mjs
+++ b/frontend/bin/build-app-url-manifest.mjs
@@ -62,7 +62,7 @@ const EXCLUDED_HELPERS = new Set(['absolute', 'default', 'project', 'currentProj
// to a scene that renders its missing-parameter error, so an entry would be a confident dead link.
const EXCLUDED_BUILDERS = new Set(['tracingOperation'])
// Flag-gated surfaces for PostHog staff only: a link an agent hands a customer would land on a scene that refuses them.
-const INTERNAL_BUILDERS = new Set(['decisionPlayground'])
+const INTERNAL_BUILDERS = new Set(['decisionPlayground', 'library', 'todayReport'])
const sentinel = (name) => `:${name}`
diff --git a/frontend/src/layout/navigation-3000/Navigation.tsx b/frontend/src/layout/navigation-3000/Navigation.tsx
index 0a22a4b958d7..cda04ceee39a 100644
--- a/frontend/src/layout/navigation-3000/Navigation.tsx
+++ b/frontend/src/layout/navigation-3000/Navigation.tsx
@@ -15,6 +15,8 @@ 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 { TodayShell } from '~/layout/today/TodayShell'
+import { todayShellLogic } from '~/layout/today/todayShellLogic'
import { navigationLogic } from '../navigation/navigationLogic'
import { ProjectNotice } from '../navigation/ProjectNotice'
@@ -48,10 +50,13 @@ export function Navigation({
const { scenePanelIsPresent, scenePanelOpenManual, sceneTakeoverActive } = useValues(sceneLayoutLogic)
const { sidePanelOpen } = useValues(sidePanelStateLogic)
const { sidePanelWidth } = useValues(panelLayoutLogic)
+ const { leftNavWidth: todayLeftNavWidth } = useValues(todayShellLogic)
// 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.
const sceneMenuBarEnabled = useFeatureFlag('SCENE_MENU_BAR')
+ // The rail layout has no overlay mode, so narrow windows keep the regular navigation.
+ const todayRail = useFeatureFlag('TODAY_RAIL_NAV') && !mobileLayout
const inlinePanelRef = useRef<HTMLDivElement | null>(null)
const inlinePanelCallbackRef = useCallback(
(node: HTMLDivElement | null) => {
@@ -144,6 +149,7 @@ export function Navigation({
<div
className={cn('app-layout bg-surface-tertiary', {
'app-layout--mobile': mobileLayout,
+ TodayAppLayout: todayRail,
})}
style={
{
@@ -163,14 +169,16 @@ export function Navigation({
// --project-navbar-width. Collapsed/mobile fall back to the base default.
'--project-navbar-width':
!mobileLayout && !isLayoutNavCollapsed ? `${navbarWidth}px` : undefined,
- '--left-nav-width': isLayoutNavCollapsed
- ? 'var(--project-navbar-width-collapsed)'
- : 'var(--project-navbar-width)',
+ '--left-nav-width': todayRail
+ ? `${todayLeftNavWidth}px`
+ : isLayoutNavCollapsed
+ ? 'var(--project-navbar-width-collapsed)'
+ : 'var(--project-navbar-width)',
} as React.CSSProperties
}
>
<ProjectDragAndDropProvider>
- <PanelLayout className="left-nav" />
+ {todayRail ? <TodayShell className="left-nav" /> : <PanelLayout className="left-nav" />}
<div
className={cn(
diff --git a/frontend/src/layout/today/TodayLibrarySidebar.tsx b/frontend/src/layout/today/TodayLibrarySidebar.tsx
new file mode 100644
index 000000000000..0088b9f48a7c
--- /dev/null
+++ b/frontend/src/layout/today/TodayLibrarySidebar.tsx
@@ -0,0 +1,47 @@
+import { useValues } from 'kea'
+import { router } from 'kea-router'
+
+import { IconFolder } from '@posthog/icons'
+
+import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
+import { LibraryCreateButton } from 'scenes/library/LibraryCreateButton'
+import { libraryLogic } from 'scenes/library/libraryLogic'
+import { urls } from 'scenes/urls'
+
+import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
+import { FileSystemIconType } from '~/queries/schema/schema-general'
+
+import { TodayPaneRow } from './TodayPaneRow'
+
+/** The Library sub-nav: every saved object type, each opening a filtered list in the main area. */
+export function TodayLibrarySidebar(): JSX.Element {
+ const { objectTypes } = useValues(libraryLogic)
+ const { location } = useValues(router)
+ const path = removeProjectIdIfPresent(location.pathname)
+
+ return (
+ <div className="TodayPane">
+ <div className="TodayPane__scroll">
+ <div className="TodayPane__heading Today__label">Library</div>
+ <TodayPaneRow
+ label="All objects"
+ icon={<IconFolder />}
+ to={urls.library()}
+ active={path === urls.library()}
+ dataAttr="today-library-all"
+ />
+ {objectTypes.map((type) => (
+ <TodayPaneRow
+ key={type.value}
+ label={type.pluralLabel}
+ icon={iconForType(type.value as FileSystemIconType)}
+ to={urls.library(type.value)}
+ active={path === urls.library(type.value)}
+ action={<LibraryCreateButton objectType={type.value} />}
+ dataAttr="today-library-type"
+ />
+ ))}
+ </div>
+ </div>
+ )
+}
diff --git a/frontend/src/layout/today/TodayPaneRow.tsx b/frontend/src/layout/today/TodayPaneRow.tsx
new file mode 100644
index 000000000000..76808a46ac45
--- /dev/null
+++ b/frontend/src/layout/today/TodayPaneRow.tsx
@@ -0,0 +1,62 @@
+import { Link } from 'lib/lemon-ui/Link'
+import { cn } from 'lib/utils/css-classes'
+
+interface TodayPaneRowProps {
+ label: string
+ meta?: string
+ icon?: JSX.Element | null
+ to?: string
+ active?: boolean
+ onClick?: () => void
+ trailing?: JSX.Element | null
+ /** A control that sits on the row's right edge and shows on hover, outside the row's own link or button. */
+ action?: JSX.Element | null
+ depth?: number
+ dataAttr?: string
+}
+
+/** One row in the Spaces, Library and Tools sidebars. It is a link when it has `to`, otherwise a button. */
+export function TodayPaneRow({
+ label,
+ meta,
+ icon,
+ to,
+ active = false,
+ onClick,
+ trailing,
+ action,
+ depth = 0,
+ dataAttr,
+}: TodayPaneRowProps): JSX.Element {
+ const content = (
+ <>
+ {icon && (
+ <span className="TodayPaneRow__icon" aria-hidden>
+ {icon}
+ </span>
+ )}
+ <span className="TodayPaneRow__label">{label}</span>
+ {meta && <span className="TodayPaneRow__meta">{meta}</span>}
+ {trailing}
+ </>
+ )
+ const className = cn('TodayPaneRow', depth > 0 && 'TodayPaneRow--nested', action && 'TodayPaneRow--withAction')
+ const row = to ? (
+ <Link to={to} className={className} data-active={active} data-attr={dataAttr} subtle onClick={onClick}>
+ {content}
+ </Link>
+ ) : (
+ <button type="button" className={className} data-active={active} data-attr={dataAttr} onClick={onClick}>
+ {content}
+ </button>
+ )
+ if (!action) {
+ return row
+ }
+ return (
+ <div className="TodayPaneRow__wrap">
+ {row}
+ <span className="TodayPaneRow__action">{action}</span>
+ </div>
+ )
+}
diff --git a/frontend/src/layout/today/TodayRail.tsx b/frontend/src/layout/today/TodayRail.tsx
new file mode 100644
index 000000000000..6d28e6a5d3a1
--- /dev/null
+++ b/frontend/src/layout/today/TodayRail.tsx
@@ -0,0 +1,92 @@
+import { useActions, useValues } from 'kea'
+
+import {
+ IconBook,
+ IconChat,
+ IconHome,
+ IconLogomark,
+ IconSearch,
+ IconSidebarClose,
+ IconSidebarOpen,
+ IconWrench,
+} from '@posthog/icons'
+
+import { NewAccountMenu } from 'lib/components/Account/NewAccountMenu'
+import { commandLogic } from 'lib/components/Command/commandLogic'
+import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
+import { cn } from 'lib/utils/css-classes'
+
+import { TODAY_RAIL_WIDTH, TodayRailPane, todayShellLogic } from './todayShellLogic'
+
+const RAIL_ITEMS: { pane: TodayRailPane; label: string; icon: JSX.Element }[] = [
+ { pane: 'home', label: 'Home', icon: <IconHome /> },
+ { pane: 'spaces', label: 'Spaces', icon: <IconChat /> },
+ { pane: 'library', label: 'Library', icon: <IconBook /> },
+ { pane: 'tools', label: 'Tools', icon: <IconWrench /> },
+]
+
+export function TodayRail(): JSX.Element {
+ const { activePane, sidebarOpen } = useValues(todayShellLogic)
+ const { pickPane, toggleSidebar } = useActions(todayShellLogic)
+ const { toggleCommand } = useActions(commandLogic)
+
+ return (
+ <nav
+ aria-label="Main"
+ className="flex flex-col items-center gap-1 py-3 shrink-0"
+ // eslint-disable-next-line react/forbid-dom-props
+ style={{ width: TODAY_RAIL_WIDTH }}
+ >
+ <div className="flex items-center justify-center size-9 mb-2 text-primary" aria-hidden>
+ <IconLogomark className="size-6" />
+ </div>
+ {RAIL_ITEMS.map(({ pane, label, icon }) => {
+ const active = activePane === pane
+ return (
+ <ButtonPrimitive
+ key={pane}
+ iconOnly
+ size="lg"
+ active={active}
+ aria-label={label}
+ aria-current={active ? 'page' : undefined}
+ tooltip={label}
+ tooltipPlacement="right"
+ data-attr={`today-rail-${pane}`}
+ className={cn('text-secondary [&_svg]:size-5', active && 'text-primary')}
+ onClick={() => pickPane(pane)}
+ >
+ {icon}
+ </ButtonPrimitive>
+ )
+ })}
+ <div className="mt-auto flex flex-col items-center gap-1">
+ <ButtonPrimitive
+ iconOnly
+ size="lg"
+ aria-label="Search"
+ tooltip="Search"
+ tooltipPlacement="right"
+ data-attr="today-rail-search"
+ className="text-secondary [&_svg]:size-5"
+ onClick={() => toggleCommand('nav-search-button')}
+ >
+ <IconSearch />
+ </ButtonPrimitive>
+ <ButtonPrimitive
+ iconOnly
+ size="lg"
+ aria-label={sidebarOpen ? 'Hide sidebar' : 'Show sidebar'}
+ tooltip={sidebarOpen ? 'Hide sidebar' : 'Show sidebar'}
+ tooltipPlacement="right"
+ data-attr="today-rail-toggle-sidebar"
+ className="text-secondary [&_svg]:size-5"
+ onClick={toggleSidebar}
+ >
+ {sidebarOpen ? <IconSidebarClose /> : <IconSidebarOpen />}
+ </ButtonPrimitive>
+ <NewAccountMenu isLayoutNavCollapsed />
+ </div>
+ </nav>
+ )
+}
diff --git a/frontend/src/layout/today/TodayShell.scss b/frontend/src/layout/today/TodayShell.scss
new file mode 100644
index 000000000000..70e418f1604f
--- /dev/null
+++ b/frontend/src/layout/today/TodayShell.scss
@@ -0,0 +1,164 @@
+.TodayAppLayout {
+ background: var(--today-paper);
+}
+
+.TodayShell {
+ display: flex;
+ height: 100%;
+ min-height: 0;
+ overflow: hidden;
+ background: transparent;
+}
+
+.TodayShell__sidebar {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+ height: 100%;
+}
+
+.TodayShell__pane {
+ flex: 1 1 auto;
+ min-height: 0;
+}
+
+.TodayPane {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ min-height: 0;
+ padding: 18px 12px 0;
+}
+
+.TodayPane__filters {
+ display: flex;
+ flex-direction: column;
+ gap: 6px;
+}
+
+.TodayPane__scroll {
+ flex: 1 1 auto;
+ min-height: 0;
+ padding: 0 4px 24px;
+ margin-top: 6px;
+ overflow-y: auto;
+ scrollbar-color: var(--today-input-border) transparent;
+ scrollbar-width: thin;
+}
+
+.TodayPane__heading {
+ margin: 26px 8px 8px;
+ letter-spacing: 0.08em;
+}
+
+.TodayPane__state {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+ align-items: flex-start;
+ padding: 8px;
+ font-size: 12px;
+ line-height: 1.5;
+ color: var(--today-muted);
+
+ &--nested {
+ padding-left: 30px;
+ }
+}
+
+.TodayPane__hash {
+ font-family: var(--font-mono);
+ font-size: 13px;
+ color: var(--today-faint);
+}
+
+.TodayPaneRow {
+ display: flex;
+ gap: 9px;
+ align-items: center;
+ width: 100%;
+ min-height: 32px;
+ padding: 6px 8px;
+ font-size: 12.5px;
+ color: var(--today-body-text);
+ text-align: left;
+ border-radius: 8px;
+
+ &--nested {
+ padding-left: 30px;
+ }
+
+ &[data-active='true'] {
+ color: var(--today-ink);
+ background: var(--today-soft);
+ }
+
+ @media (hover: hover) and (pointer: fine) {
+ &:hover {
+ color: var(--today-ink);
+ background: var(--today-soft);
+ }
+ }
+}
+
+.TodayPaneRow__icon {
+ display: flex;
+ flex: 0 0 18px;
+ align-items: center;
+ justify-content: center;
+ width: 18px;
+ height: 18px;
+
+ svg {
+ width: 16px;
+ height: 16px;
+ }
+}
+
+.TodayPaneRow__label {
+ flex: 1;
+ min-width: 0;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.TodayPaneRow__meta {
+ flex: 0 0 auto;
+ max-width: 40%;
+ overflow: hidden;
+ font-size: 10.5px;
+ color: var(--today-faint);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.TodayPaneRow__chevron {
+ flex: 0 0 14px;
+ width: 14px;
+ height: 14px;
+ color: var(--today-faint);
+ transition: transform 0.16s;
+}
+
+.TodayPaneRow__wrap {
+ position: relative;
+
+ .TodayPaneRow--withAction {
+ padding-right: 36px;
+ }
+}
+
+.TodayPaneRow__action {
+ position: absolute;
+ top: 50%;
+ right: 4px;
+ opacity: 0;
+ transition: opacity 0.16s;
+ transform: translateY(-50%);
+
+ .TodayPaneRow__wrap:hover &,
+ .TodayPaneRow__wrap:focus-within & {
+ opacity: 1;
+ }
+}
diff --git a/frontend/src/layout/today/TodayShell.tsx b/frontend/src/layout/today/TodayShell.tsx
new file mode 100644
index 000000000000..18ee213477ca
--- /dev/null
+++ b/frontend/src/layout/today/TodayShell.tsx
@@ -0,0 +1,72 @@
+import './TodayShell.scss'
+
+import { useActions, useValues } from 'kea'
+import { useEffect, useRef } from 'react'
+
+import 'scenes/project-homepage/today/Today.scss'
+import { Resizer } from 'lib/components/Resizer/Resizer'
+import { ResizerLogicProps, resizerLogic } from 'lib/components/Resizer/resizerLogic'
+import { cn } from 'lib/utils/css-classes'
+import { TodayHomeSidebar } from 'scenes/project-homepage/today/TodayHomeSidebar'
+
+import { TodayLibrarySidebar } from './TodayLibrarySidebar'
+import { TodayRail } from './TodayRail'
+import { TODAY_SIDEBAR_CLOSE_THRESHOLD, clampSidebarWidth, todayShellLogic } from './todayShellLogic'
+import { TodaySidebarFooter } from './TodaySidebarFooter'
+import { TodaySpacesSidebar } from './TodaySpacesSidebar'
+import { TodayToolsSidebar } from './TodayToolsSidebar'
+
+const PANE_LABELS = { home: 'Today', spaces: 'Spaces', library: 'Library', tools: 'Tools' }
+
+/** The left navigation under the Today layout: the rail, then the sidebar for the pane the rail has open. */
+export function TodayShell({ className }: { className?: string }): JSX.Element {
+ const { activePane, sidebarOpen, sidebarWidth } = useValues(todayShellLogic)
+ const { setSidebarOpen, setSidebarWidth, toggleSidebar } = useActions(todayShellLogic)
+ const sidebarRef = useRef<HTMLDivElement | null>(null)
+
+ const resizerLogicProps: ResizerLogicProps = {
+ // pinned: storage key for the persisted width. Renaming it resets everyone's sidebar width.
+ logicKey: 'today-sidebar',
+ placement: 'right',
+ containerRef: sidebarRef,
+ persistent: true,
+ closeThreshold: TODAY_SIDEBAR_CLOSE_THRESHOLD,
+ onToggleClosed: (closed) => setSidebarOpen(!closed),
+ onDoubleClick: toggleSidebar,
+ }
+ const { desiredSize } = useValues(resizerLogic(resizerLogicProps))
+
+ // The app layout reads the width from the shell logic to size the main column, so copy each change there.
+ useEffect(() => {
+ setSidebarWidth(clampSidebarWidth(desiredSize))
+ }, [desiredSize, setSidebarWidth])
+
+ return (
+ <div className={cn('Today TodayShell', className)}>
+ <TodayRail />
+ {sidebarOpen && (
+ <aside
+ ref={sidebarRef}
+ className="TodayShell__sidebar relative"
+ aria-label={PANE_LABELS[activePane]}
+ // eslint-disable-next-line react/forbid-dom-props
+ style={{ width: sidebarWidth }}
+ >
+ <div className="TodayShell__pane">
+ {activePane === 'home' ? (
+ <TodayHomeSidebar />
+ ) : activePane === 'spaces' ? (
+ <TodaySpacesSidebar />
+ ) : activePane === 'library' ? (
+ <TodayLibrarySidebar />
+ ) : (
+ <TodayToolsSidebar />
+ )}
+ </div>
+ <TodaySidebarFooter />
+ <Resizer {...resizerLogicProps} className="z-2" offset={0} />
+ </aside>
+ )}
+ </div>
+ )
+}
diff --git a/frontend/src/layout/today/TodaySidebarFooter.tsx b/frontend/src/layout/today/TodaySidebarFooter.tsx
new file mode 100644
index 000000000000..7cfa4757ee29
--- /dev/null
+++ b/frontend/src/layout/today/TodaySidebarFooter.tsx
@@ -0,0 +1,49 @@
+import { useValues } from 'kea'
+
+import { IconChevronDown, IconGear } from '@posthog/icons'
+
+import { ProjectCombobox } from 'lib/components/Account/ProjectCombobox'
+import { Link } from 'lib/lemon-ui/Link'
+import {
+ PopoverPrimitive,
+ PopoverPrimitiveContent,
+ PopoverPrimitiveTrigger,
+} from 'lib/ui/PopoverPrimitive/PopoverPrimitive'
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+export function TodaySidebarFooter(): JSX.Element {
+ const { currentTeam } = useValues(teamLogic)
+ const projectName = currentTeam?.name ?? 'Project'
+
+ return (
+ <div className="TodaySidebarFooter">
+ <PopoverPrimitive>
+ <PopoverPrimitiveTrigger asChild>
+ <button type="button" className="TodaySidebarFooter__project" data-attr="today-project-menu">
+ <span className="TodaySidebarFooter__avatar" aria-hidden>
+ {String.fromCodePoint(projectName.codePointAt(0) ?? 80).toLocaleUpperCase()}
+ </span>
+ <span className="TodaySidebarFooter__projectText">
+ <small>Project</small>
+ <strong>{projectName}</strong>
+ </span>
+ <IconChevronDown />
+ </button>
+ </PopoverPrimitiveTrigger>
+ <PopoverPrimitiveContent align="start" side="top" className="min-w-[280px] max-w-fit">
+ <ProjectCombobox />
+ </PopoverPrimitiveContent>
+ </PopoverPrimitive>
+ <Link
+ to={urls.settings('project')}
+ className="TodaySidebarFooter__settings"
+ data-attr="today-settings"
+ subtle
+ >
+ <IconGear />
+ <span>Settings</span>
+ </Link>
+ </div>
+ )
+}
diff --git a/frontend/src/layout/today/TodaySpacesSidebar.tsx b/frontend/src/layout/today/TodaySpacesSidebar.tsx
new file mode 100644
index 000000000000..e099c0c39f9b
--- /dev/null
+++ b/frontend/src/layout/today/TodaySpacesSidebar.tsx
@@ -0,0 +1,135 @@
+import { useActions, useValues } from 'kea'
+import { router } from 'kea-router'
+
+import { IconChevronRight, IconPlus } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { Spinner } from 'lib/lemon-ui/Spinner'
+import { cn } from 'lib/utils/css-classes'
+import { urls } from 'scenes/urls'
+
+import { TodayPaneRow } from './TodayPaneRow'
+import { spaceLabel, todaySpacesLogic } from './todaySpacesLogic'
+
+export function TodaySpacesSidebar(): JSX.Element {
+ const {
+ sortedSpaces,
+ spacesLoading,
+ spacesUnavailable,
+ expandedSpaceIds,
+ spaceTasks,
+ loadingSpaceIds,
+ failedSpaceIds,
+ recentChats,
+ conversationHistoryLoading,
+ } = useValues(todaySpacesLogic)
+ const { toggleSpace, loadSpaces, loadSpaceTasks } = useActions(todaySpacesLogic)
+ const { location, searchParams } = useValues(router)
+ const onAi = location.pathname.endsWith('/ai')
+
+ return (
+ <div className="TodayPane">
+ <button
+ type="button"
+ className="TodaySidebar__new"
+ data-attr="today-spaces-new-chat"
+ onClick={() => router.actions.push(urls.ai())}
+ >
+ <IconPlus />
+ New chat
+ </button>
+ <div className="TodayPane__scroll">
+ <div className="TodayPane__heading Today__label">Spaces</div>
+ {spacesLoading && !sortedSpaces.length ? (
+ <div className="TodayPane__state">
+ <Spinner />
+ </div>
+ ) : spacesUnavailable ? (
+ <div className="TodayPane__state">
+ <span>Spaces didn’t load.</span>
+ <LemonButton size="small" type="secondary" onClick={() => loadSpaces()}>
+ Try again
+ </LemonButton>
+ </div>
+ ) : !sortedSpaces.length ? (
+ <div className="TodayPane__state">
+ Spaces group the sessions you and your agents work on. Create one from PostHog Desktop.
+ </div>
+ ) : (
+ sortedSpaces.map((space) => {
+ const expanded = expandedSpaceIds.includes(space.id)
+ const tasks = spaceTasks[space.id]
+ return (
+ <div key={space.id}>
+ <TodayPaneRow
+ label={spaceLabel(space)}
+ icon={<span className="TodayPane__hash">#</span>}
+ dataAttr="today-space-row"
+ onClick={() => toggleSpace(space.id)}
+ trailing={
+ <IconChevronRight
+ className={cn('TodayPaneRow__chevron', expanded && 'rotate-90')}
+ />
+ }
+ />
+ {expanded &&
+ (tasks === undefined ? (
+ loadingSpaceIds.includes(space.id) ? (
+ <div className="TodayPane__state TodayPane__state--nested">
+ <Spinner />
+ </div>
+ ) : failedSpaceIds.includes(space.id) ? (
+ <div className="TodayPane__state TodayPane__state--nested">
+ <span>Couldn’t load this space’s sessions.</span>
+ <LemonButton
+ size="xsmall"
+ type="secondary"
+ onClick={() => loadSpaceTasks(space.id)}
+ data-attr="today-space-tasks-retry"
+ >
+ Try again
+ </LemonButton>
+ </div>
+ ) : null
+ ) : tasks.length === 0 ? (
+ <div className="TodayPane__state TodayPane__state--nested">
+ No sessions yet.
+ </div>
+ ) : (
+ tasks.map((task) => (
+ <TodayPaneRow
+ key={task.id}
+ depth={1}
+ label={task.title || 'Untitled session'}
+ to={urls.aiTask(task.id)}
+ active={onAi && searchParams.task === task.id}
+ dataAttr="today-space-task"
+ />
+ ))
+ ))}
+ </div>
+ )
+ })
+ )}
+ <div className="TodayPane__heading Today__label">Recent chats</div>
+ {conversationHistoryLoading && !recentChats.length ? (
+ <div className="TodayPane__state">
+ <Spinner />
+ </div>
+ ) : !recentChats.length ? (
+ <div className="TodayPane__state">Chats with PostHog AI show up here.</div>
+ ) : (
+ recentChats.map((conversation) => (
+ <TodayPaneRow
+ key={conversation.id}
+ label={conversation.title || 'Untitled chat'}
+ to={urls.ai(conversation.id)}
+ active={onAi && searchParams.chat === conversation.id}
+ dataAttr="today-recent-chat"
+ />
+ ))
+ )}
+ </div>
+ </div>
+ )
+}
diff --git a/frontend/src/layout/today/TodayToolsSidebar.tsx b/frontend/src/layout/today/TodayToolsSidebar.tsx
new file mode 100644
index 000000000000..450270e89a61
--- /dev/null
+++ b/frontend/src/layout/today/TodayToolsSidebar.tsx
@@ -0,0 +1,59 @@
+import { useActions, useValues } from 'kea'
+import { router } from 'kea-router'
+
+import { LemonInput } from '@posthog/lemon-ui'
+
+import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
+import { FileSystemIconType } from '~/queries/schema/schema-general'
+
+import { TodayPaneRow } from './TodayPaneRow'
+import { todayToolsLogic, toolLabel } from './todayToolsLogic'
+
+export function TodayToolsSidebar(): JSX.Element {
+ const { toolGroups, search } = useValues(todayToolsLogic)
+ const { setSearch } = useActions(todayToolsLogic)
+ const { location } = useValues(router)
+
+ return (
+ <div className="TodayPane">
+ <div className="TodayPane__filters">
+ <LemonInput
+ type="search"
+ size="small"
+ placeholder="Search tools"
+ value={search}
+ onChange={setSearch}
+ data-attr="today-tools-search"
+ fullWidth
+ />
+ </div>
+ <div className="TodayPane__scroll">
+ {!toolGroups.length ? (
+ <div className="TodayPane__state">No tools match that search.</div>
+ ) : (
+ toolGroups.map((group) => (
+ <div key={group.category}>
+ <div className="TodayPane__heading Today__label">{group.category}</div>
+ {group.tools.map((tool) => {
+ const href = tool.href ?? ''
+ return (
+ <TodayPaneRow
+ key={href}
+ label={toolLabel(tool)}
+ icon={iconForType(
+ (tool.iconType ?? tool.type) as FileSystemIconType,
+ tool.iconColor
+ )}
+ to={href}
+ active={!!href && location.pathname.endsWith(href.split('?')[0])}
+ dataAttr="today-tool"
+ />
+ )
+ })}
+ </div>
+ ))
+ )}
+ </div>
+ </div>
+ )
+}
diff --git a/frontend/src/layout/today/todayShellLogic.test.ts b/frontend/src/layout/today/todayShellLogic.test.ts
new file mode 100644
index 000000000000..0468d15dc8c0
--- /dev/null
+++ b/frontend/src/layout/today/todayShellLogic.test.ts
@@ -0,0 +1,49 @@
+import { router } from 'kea-router'
+
+import { initKeaTests } from '~/test/init'
+
+import { TODAY_RAIL_WIDTH, TODAY_SIDEBAR_MAX_WIDTH, railPaneForPath, todayShellLogic } from './todayShellLogic'
+
+describe('todayShellLogic', () => {
+ beforeEach(() => {
+ initKeaTests()
+ })
+
+ test.each([
+ ['/project/1/home', 'home'],
+ ['/project/1/home/reports/abc', 'home'],
+ ['/project/1/library', 'library'],
+ ['/project/1/library/feature_flag', 'library'],
+ ['/project/1/ai', 'spaces'],
+ ['/project/1/ai/history', 'spaces'],
+ ['/project/1/insights/abc', null],
+ ['/project/1/airplane', null],
+ ['/project/1/homework', null],
+ ])('puts %s under %s', (pathname, pane) => {
+ expect(railPaneForPath(pathname)).toBe(pane)
+ })
+
+ it('keeps the last pane open on pages that belong to no pane', () => {
+ const logic = todayShellLogic()
+ logic.mount()
+
+ logic.actions.pickPane('tools')
+ router.actions.push('/project/1/insights/abc')
+ expect(logic.values.activePane).toBe('tools')
+
+ router.actions.push('/project/1/ai')
+ expect(logic.values.activePane).toBe('spaces')
+ })
+
+ it('sizes the left navigation from the clamped sidebar width, and from the rail alone when hidden', () => {
+ const logic = todayShellLogic()
+ logic.mount()
+
+ logic.actions.setSidebarOpen(true)
+ logic.actions.setSidebarWidth(10_000)
+ expect(logic.values.leftNavWidth).toBe(TODAY_RAIL_WIDTH + TODAY_SIDEBAR_MAX_WIDTH)
+
+ logic.actions.setSidebarOpen(false)
+ expect(logic.values.leftNavWidth).toBe(TODAY_RAIL_WIDTH)
+ })
+})
diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.ts
new file mode 100644
index 000000000000..b406966c54ae
--- /dev/null
+++ b/frontend/src/layout/today/todayShellLogic.ts
@@ -0,0 +1,164 @@
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { router } from 'kea-router'
+import type { LocationChangedPayload } from 'kea-router/lib/types'
+import posthog from 'posthog-js'
+
+import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
+import { urls } from 'scenes/urls'
+
+export type TodayRailPane = 'home' | 'spaces' | 'library' | 'tools'
+
+export const TODAY_RAIL_WIDTH = 56
+export const TODAY_SIDEBAR_DEFAULT_WIDTH: number = 312
+export const TODAY_SIDEBAR_MIN_WIDTH = 240
+export const TODAY_SIDEBAR_MAX_WIDTH = 480
+/** Dragging the sidebar narrower than this hides it. */
+export const TODAY_SIDEBAR_CLOSE_THRESHOLD = 180
+
+export function clampSidebarWidth(width: number | null): number {
+ return Math.min(
+ Math.max(Math.round(width ?? TODAY_SIDEBAR_DEFAULT_WIDTH), TODAY_SIDEBAR_MIN_WIDTH),
+ TODAY_SIDEBAR_MAX_WIDTH
+ )
+}
+
+function isUnder(path: string, root: string): boolean {
+ return path === root || path.startsWith(`${root}/`)
+}
+
+/** The pane a route belongs to, or null for pages that keep whichever pane was open. */
+export function railPaneForPath(pathname: string): TodayRailPane | null {
+ const path = removeProjectIdIfPresent(pathname)
+ if (path === '/' || isUnder(path, urls.projectHomepage())) {
+ return 'home'
+ }
+ if (isUnder(path, '/ai')) {
+ return 'spaces'
+ }
+ if (isUnder(path, urls.library())) {
+ return 'library'
+ }
+ return null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayShellLogicValues {
+ activePane: TodayRailPane
+ leftNavWidth: number
+ pickedPane: TodayRailPane | null
+ routePane: TodayRailPane | null
+ sidebarOpen: boolean
+ sidebarWidth: number
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayShellLogicActions {
+ locationChanged: ({
+ method,
+ pathname,
+ search,
+ searchParams,
+ hash,
+ hashParams,
+ initial,
+ url,
+ routerState,
+ }: LocationChangedPayload) => {
+ hash: string
+ hashParams: Record<string, any>
+ initial: boolean
+ method: 'POP' | 'PUSH' | 'REPLACE'
+ pathname: string
+ routerState: Record<string, any>
+ search: string
+ searchParams: Record<string, any>
+ url: string
+ } // router
+ pickPane: (pane: TodayRailPane) => {
+ pane: TodayRailPane
+ }
+ setSidebarOpen: (open: boolean) => {
+ open: boolean
+ }
+ setSidebarWidth: (width: number) => {
+ width: number
+ }
+ toggleSidebar: () => {
+ value: true
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayShellLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ routePane: (location: { hash: string; pathname: string; search: string }) => TodayRailPane | null
+ activePane: (pickedPane: TodayRailPane | null, routePane: TodayRailPane | null) => TodayRailPane
+ leftNavWidth: (sidebarOpen: boolean, sidebarWidth: number) => number
+ }
+}
+
+export type todayShellLogicType = MakeLogicType<
+ todayShellLogicValues,
+ todayShellLogicActions,
+ Record<string, any>,
+ todayShellLogicMeta
+>
+
+export const todayShellLogic = kea<todayShellLogicType>([
+ path(['layout', 'today', 'todayShellLogic']),
+ connect(() => ({ actions: [router, ['locationChanged']] })),
+ actions({
+ pickPane: (pane: TodayRailPane) => ({ pane }),
+ setSidebarOpen: (open: boolean) => ({ open }),
+ setSidebarWidth: (width: number) => ({ width }),
+ toggleSidebar: true,
+ }),
+ reducers({
+ // The last pane picked on the rail, or reached through a route that belongs to one, stays open on other pages.
+ pickedPane: [
+ null as TodayRailPane | null,
+ {
+ pickPane: (_, { pane }) => pane,
+ locationChanged: (state, { pathname }) => railPaneForPath(pathname) ?? state,
+ },
+ ],
+ sidebarOpen: [
+ true,
+ { persist: true },
+ {
+ setSidebarOpen: (_, { open }) => open,
+ toggleSidebar: (state) => !state,
+ pickPane: () => true,
+ },
+ ],
+ // The resizer persists the width itself. This copy lets the app layout size the main column from it.
+ sidebarWidth: [TODAY_SIDEBAR_DEFAULT_WIDTH, { setSidebarWidth: (_, { width }) => clampSidebarWidth(width) }],
+ }),
+ selectors({
+ routePane: [
+ () => [router.selectors.location],
+ (location: { pathname: string }): TodayRailPane | null => railPaneForPath(location.pathname),
+ ],
+ activePane: [
+ (s) => [s.pickedPane, s.routePane],
+ (pickedPane: TodayRailPane | null, routePane: TodayRailPane | null): TodayRailPane =>
+ pickedPane ?? routePane ?? 'home',
+ ],
+ leftNavWidth: [
+ (s) => [s.sidebarOpen, s.sidebarWidth],
+ (sidebarOpen: boolean, sidebarWidth: number): number => TODAY_RAIL_WIDTH + (sidebarOpen ? sidebarWidth : 0),
+ ],
+ }),
+ listeners(({ values }) => ({
+ pickPane: ({ pane }) => {
+ // pinned: analytics event name and property. Renaming them breaks dashboards.
+ posthog.capture('today rail pane picked', { pane })
+ if (pane === 'home' && values.routePane !== 'home') {
+ router.actions.push(urls.projectHomepage())
+ }
+ if (pane === 'library' && values.routePane !== 'library') {
+ router.actions.push(urls.library())
+ }
+ },
+ })),
+])
diff --git a/frontend/src/layout/today/todaySpacesLogic.test.ts b/frontend/src/layout/today/todaySpacesLogic.test.ts
new file mode 100644
index 000000000000..91814ab9533a
--- /dev/null
+++ b/frontend/src/layout/today/todaySpacesLogic.test.ts
@@ -0,0 +1,48 @@
+import { expectLogic } from 'kea-test-utils'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { todaySpacesLogic } from './todaySpacesLogic'
+
+describe('todaySpacesLogic', () => {
+ beforeEach(() => {
+ useMocks({
+ get: {
+ '/api/projects/:team_id/task_channels/': [],
+ '/api/projects/:team_id/tasks/': ({ request }) => {
+ const channel = new URL(request.url).searchParams.get('channel')
+ if (channel === 'space-broken') {
+ return [500, { detail: 'Server error' }]
+ }
+ return [200, { results: [{ id: `task-${channel}`, title: `Session in ${channel}` }], count: 1 }]
+ },
+ },
+ })
+ initKeaTests()
+ })
+
+ it('keeps the sessions of every space expanded at the same time', async () => {
+ const logic = todaySpacesLogic()
+ logic.mount()
+
+ logic.actions.toggleSpace('space-a')
+ logic.actions.toggleSpace('space-b')
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(Object.keys(logic.values.spaceTasks).sort()).toEqual(['space-a', 'space-b'])
+ expect(logic.values.spaceTasks['space-a'][0].id).toBe('task-space-a')
+ expect(logic.values.loadingSpaceIds).toEqual([])
+ })
+
+ it('marks a space whose sessions fail to load, so the sidebar can offer a retry', async () => {
+ const logic = todaySpacesLogic()
+ logic.mount()
+
+ logic.actions.toggleSpace('space-broken')
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.failedSpaceIds).toEqual(['space-broken'])
+ expect(logic.values.spaceTasks['space-broken']).toBeUndefined()
+ })
+})
diff --git a/frontend/src/layout/today/todaySpacesLogic.ts b/frontend/src/layout/today/todaySpacesLogic.ts
new file mode 100644
index 000000000000..83d84215b26e
--- /dev/null
+++ b/frontend/src/layout/today/todaySpacesLogic.ts
@@ -0,0 +1,190 @@
+import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { ConversationDetail } from '~/types'
+
+import { taskChannelsList, tasksList } from 'products/tasks/frontend/generated/api'
+import { ChannelDTOApi, TaskListItemApi } from 'products/tasks/frontend/generated/api.schemas'
+
+const SPACE_TASK_LIMIT = 8
+const RECENT_CHAT_LIMIT = 12
+
+/** The personal space first, then the team's general space, then starred spaces, then the rest by name. */
+export function sortSpaces(spaces: ChannelDTOApi[]): ChannelDTOApi[] {
+ const rank = (space: ChannelDTOApi): number =>
+ space.system_role === 'personal' ? 0 : space.system_role === 'general' ? 1 : space.starred ? 2 : 3
+ return [...spaces].sort((first, second) => rank(first) - rank(second) || first.name.localeCompare(second.name))
+}
+
+export function spaceLabel(space: Pick<ChannelDTOApi, 'name' | 'system_role'>): string {
+ return space.system_role === 'personal' ? 'Me' : space.name
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todaySpacesLogicValues {
+ conversationHistory: ConversationDetail[] // maxGlobalLogic
+ conversationHistoryLoading: boolean // maxGlobalLogic
+ currentTeamId: number | null // teamLogic
+ expandedSpaceIds: string[]
+ failedSpaceIds: string[]
+ loadingSpaceIds: string[]
+ recentChats: ConversationDetail[]
+ sortedSpaces: ChannelDTOApi[]
+ spaceTasks: Record<string, TaskListItemApi[]>
+ spaces: ChannelDTOApi[]
+ spacesLoading: boolean
+ spacesUnavailable: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todaySpacesLogicActions {
+ loadSpaceTasks: (spaceId: string) => {
+ spaceId: string
+ }
+ loadSpaceTasksFailure: (spaceId: string) => {
+ spaceId: string
+ }
+ loadSpaces: () => any
+ loadSpacesFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadSpacesSuccess: (
+ spaces: ChannelDTOApi[],
+ payload?: any
+ ) => {
+ spaces: ChannelDTOApi[]
+ payload?: any
+ }
+ setSpaceTasks: (
+ spaceId: string,
+ tasks: TaskListItemApi[]
+ ) => {
+ spaceId: string
+ tasks: TaskListItemApi[]
+ }
+ toggleSpace: (spaceId: string) => {
+ spaceId: string
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todaySpacesLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ sortedSpaces: (spaces: ChannelDTOApi[]) => ChannelDTOApi[]
+ recentChats: (conversationHistory: ConversationDetail[]) => ConversationDetail[]
+ }
+}
+
+export type todaySpacesLogicType = MakeLogicType<
+ todaySpacesLogicValues,
+ todaySpacesLogicActions,
+ Record<string, any>,
+ todaySpacesLogicMeta
+>
+
+export const todaySpacesLogic = kea<todaySpacesLogicType>([
+ path(['layout', 'today', 'todaySpacesLogic']),
+ connect(() => ({
+ values: [teamLogic, ['currentTeamId'], maxGlobalLogic, ['conversationHistory', 'conversationHistoryLoading']],
+ })),
+ actions({
+ toggleSpace: (spaceId: string) => ({ spaceId }),
+ loadSpaceTasks: (spaceId: string) => ({ spaceId }),
+ setSpaceTasks: (spaceId: string, tasks: TaskListItemApi[]) => ({ spaceId, tasks }),
+ loadSpaceTasksFailure: (spaceId: string) => ({ spaceId }),
+ }),
+ loaders(({ values }) => ({
+ spaces: [
+ [] as ChannelDTOApi[],
+ {
+ loadSpaces: async () => {
+ if (!values.currentTeamId) {
+ return []
+ }
+ const response = await taskChannelsList(String(values.currentTeamId))
+ // Without `limit` the endpoint answers with a bare array rather than a page.
+ return Array.isArray(response) ? (response as ChannelDTOApi[]) : response.results
+ },
+ },
+ ],
+ })),
+ reducers({
+ expandedSpaceIds: [
+ [] as string[],
+ { persist: true },
+ {
+ toggleSpace: (state, { spaceId }) =>
+ state.includes(spaceId) ? state.filter((id) => id !== spaceId) : [...state, spaceId],
+ },
+ ],
+ spacesUnavailable: [false, { loadSpaces: () => false, loadSpacesFailure: () => true }],
+ // Each space loads on its own, so expanding several at once never drops one space's sessions.
+ spaceTasks: [
+ {} as Record<string, TaskListItemApi[]>,
+ { setSpaceTasks: (state, { spaceId, tasks }) => ({ ...state, [spaceId]: tasks }) },
+ ],
+ loadingSpaceIds: [
+ [] as string[],
+ {
+ loadSpaceTasks: (state, { spaceId }) => (state.includes(spaceId) ? state : [...state, spaceId]),
+ setSpaceTasks: (state, { spaceId }) => state.filter((id) => id !== spaceId),
+ loadSpaceTasksFailure: (state, { spaceId }) => state.filter((id) => id !== spaceId),
+ },
+ ],
+ failedSpaceIds: [
+ [] as string[],
+ {
+ loadSpaceTasks: (state, { spaceId }) => state.filter((id) => id !== spaceId),
+ loadSpaceTasksFailure: (state, { spaceId }) => (state.includes(spaceId) ? state : [...state, spaceId]),
+ },
+ ],
+ }),
+ selectors({
+ sortedSpaces: [(s) => [s.spaces], (spaces: ChannelDTOApi[]): ChannelDTOApi[] => sortSpaces(spaces)],
+ recentChats: [
+ (s) => [s.conversationHistory],
+ (conversationHistory: ConversationDetail[]): ConversationDetail[] =>
+ conversationHistory.slice(0, RECENT_CHAT_LIMIT),
+ ],
+ }),
+ listeners(({ actions, values }) => ({
+ loadSpaceTasks: async ({ spaceId }) => {
+ if (!values.currentTeamId) {
+ actions.loadSpaceTasksFailure(spaceId)
+ return
+ }
+ try {
+ const response = await tasksList(String(values.currentTeamId), {
+ channel: spaceId,
+ basic: true,
+ limit: SPACE_TASK_LIMIT,
+ })
+ actions.setSpaceTasks(spaceId, response.results)
+ } catch {
+ actions.loadSpaceTasksFailure(spaceId)
+ }
+ },
+ toggleSpace: ({ spaceId }) => {
+ if (values.expandedSpaceIds.includes(spaceId) && !values.spaceTasks[spaceId]) {
+ actions.loadSpaceTasks(spaceId)
+ }
+ },
+ loadSpacesSuccess: ({ spaces }) => {
+ for (const space of spaces) {
+ if (values.expandedSpaceIds.includes(space.id)) {
+ actions.loadSpaceTasks(space.id)
+ }
+ }
+ },
+ })),
+ afterMount(({ actions }) => {
+ actions.loadSpaces()
+ }),
+])
diff --git a/frontend/src/layout/today/todayToolsLogic.ts b/frontend/src/layout/today/todayToolsLogic.ts
new file mode 100644
index 000000000000..1c50a663cca6
--- /dev/null
+++ b/frontend/src/layout/today/todayToolsLogic.ts
@@ -0,0 +1,106 @@
+import { MakeLogicType, actions, connect, kea, path, reducers, selectors } from 'kea'
+
+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'
+import { TOOL_FILE_SYSTEM_TYPES } from 'scenes/library/libraryUtils'
+
+import { fileSystemTypes, getTreeItemsMetadata, getTreeItemsProducts } from '~/products'
+import { FileSystemImport } from '~/queries/schema/schema-general'
+
+export interface ToolGroup {
+ category: string
+ tools: FileSystemImport[]
+}
+
+// Workspaces for building queries and writing things up come first, apart from the product pages.
+const PINNED_TOOL_ICONS = ['sql_editor', 'notebook']
+export const PINNED_TOOLS_CATEGORY = 'Workspace'
+
+export function toolLabel(tool: FileSystemImport): string {
+ return tool.displayLabel || tool.path
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayToolsLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
+ search: string
+ toolGroups: ToolGroup[]
+ tools: FileSystemImport[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayToolsLogicActions {
+ setSearch: (search: string) => {
+ search: string
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayToolsLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ tools: (featureFlags: FeatureFlagsSet) => FileSystemImport[]
+ toolGroups: (tools: FileSystemImport[], search: string) => ToolGroup[]
+ }
+}
+
+export type todayToolsLogicType = MakeLogicType<
+ todayToolsLogicValues,
+ todayToolsLogicActions,
+ Record<string, any>,
+ todayToolsLogicMeta
+>
+
+export const todayToolsLogic = kea<todayToolsLogicType>([
+ path(['layout', 'today', 'todayToolsLogic']),
+ connect(() => ({ values: [featureFlagLogic, ['featureFlags']] })),
+ actions({ setSearch: (search: string) => ({ search }) }),
+ reducers({ search: ['', { setSearch: (_, { search }) => search }] }),
+ selectors({
+ tools: [
+ (s) => [s.featureFlags],
+ (featureFlags: FeatureFlagsSet): FileSystemImport[] => {
+ const seen = new Set<string>()
+ return [...getTreeItemsProducts(), ...getTreeItemsMetadata()]
+ .filter((item) => {
+ const type = item.type?.split('/')[0] || item.iconType || ''
+ if (
+ !item.href ||
+ seen.has(item.href) ||
+ // Saved object types live in Library, except the ones that are working pages.
+ (type in fileSystemTypes && !TOOL_FILE_SYSTEM_TYPES.has(type)) ||
+ (item.flag && !featureFlags[item.flag as keyof FeatureFlagsSet]) ||
+ getProductAccessDisabledReason(item)
+ ) {
+ return false
+ }
+ seen.add(item.href)
+ return true
+ })
+ .sort((first, second) => toolLabel(first).localeCompare(toolLabel(second)))
+ },
+ ],
+ toolGroups: [
+ (s) => [s.tools, s.search],
+ (tools: FileSystemImport[], search: string): ToolGroup[] => {
+ const query = search.trim().toLowerCase()
+ const groups = new Map<string, FileSystemImport[]>()
+ for (const tool of tools) {
+ const pinned = PINNED_TOOL_ICONS.includes(tool.iconType ?? '')
+ const category = pinned ? PINNED_TOOLS_CATEGORY : tool.category || 'Other'
+ if (query && !`${toolLabel(tool)} ${category}`.toLowerCase().includes(query)) {
+ continue
+ }
+ groups.set(category, [...(groups.get(category) ?? []), tool])
+ }
+ return [...groups.entries()]
+ .map(([category, groupTools]) => ({ category, tools: groupTools }))
+ .sort(
+ (first, second) =>
+ Number(second.category === PINNED_TOOLS_CATEGORY) -
+ Number(first.category === PINNED_TOOLS_CATEGORY) ||
+ first.category.localeCompare(second.category)
+ )
+ },
+ ],
+ }),
+])
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 19543dfc4ab6..689655fe6034 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -537,6 +537,7 @@ export const FEATURE_FLAGS = {
TAXONOMIC_FILTER_MENU_REBUILD: 'taxonomic-filter-menu-rebuild', // owner: @adamleith, opt-in to the rebuilt TaxonomicFilter — headless filter panel + new popover menu (column / preview-pane)
TAXONOMIC_FILTER_SEARCH_INTENT: 'taxonomic-filter-search-intent', // owner: @pauldambra multivariate=control,banner,promote, classifies a picker search with the decision model. Every arm promotes the predicted group on the All tab; only banner also suggests the right tab
TEXT_CARD_WORD_ART: 'text-card-word-art', // owner: @jonmcwest, gates the word art insert button in dashboard text cards
+ TODAY_RAIL_NAV: 'today-rail-nav', // owner: @k11kirky, replaces the left navigation with a rail (Home, Spaces, Library, Tools) and makes the Today briefing the homepage
TOOLBAR_PAID_HEATMAPS: 'toolbar-paid-heatmaps', // owner: #team-web-analytics
TRACING: 'tracing', // owner: #team-apm (@jonmcwest, @frankh)
TRACING_AI_EVENTS: 'tracing-ai-events', // owner: #team-apm — shows a trace's LLM analytics events inline in the trace drawer waterfall
@@ -612,7 +613,10 @@ export const FEATURE_FLAGS = {
export type FeatureFlagLookupKey = keyof typeof FEATURE_FLAGS
export type FeatureFlagKey = (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS]
-export const STORYBOOK_FEATURE_FLAGS = Object.values(FEATURE_FLAGS)
+// The Today rail swaps out the whole navigation, so stories that render the app opt in to it explicitly.
+export const STORYBOOK_FEATURE_FLAGS = Object.values(FEATURE_FLAGS).filter(
+ (flag) => flag !== FEATURE_FLAGS.TODAY_RAIL_NAV
+)
export const INSIGHT_VISUAL_ORDER = {
trends: 10,
diff --git a/frontend/src/scenes/appScenes.ts b/frontend/src/scenes/appScenes.ts
index 9741993dc4fe..edf1f79541fe 100644
--- a/frontend/src/scenes/appScenes.ts
+++ b/frontend/src/scenes/appScenes.ts
@@ -77,6 +77,7 @@ export const appScenes: Record<Scene | string, () => any> = {
[Scene.PreflightCheck]: () => import('./PreflightCheck/PreflightCheck'),
[Scene.ProjectCreateFirst]: () => import('./project/Create'),
[Scene.ProjectHomepage]: () => import('./project-homepage/ProjectHomepage'),
+ [Scene.Library]: () => import('./library/Library'),
[Scene.PropertyDefinitionEdit]: () => import('./data-management/definition/DefinitionEdit'),
[Scene.PropertyDefinition]: () => import('./data-management/definition/DefinitionView'),
[Scene.SqlVariableEdit]: () => import('./data-management/variables/SqlVariableEditScene'),
diff --git a/frontend/src/scenes/library/Library.tsx b/frontend/src/scenes/library/Library.tsx
new file mode 100644
index 000000000000..aef4be4fb833
--- /dev/null
+++ b/frontend/src/scenes/library/Library.tsx
@@ -0,0 +1,143 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonBanner, LemonButton, LemonInput, LemonTable, LemonTableColumns, Link } from '@posthog/lemon-ui'
+
+import { NotFound } from 'lib/components/NotFound'
+import { TZLabel } from 'lib/components/TZLabel'
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
+import { SceneExport } from 'scenes/sceneTypes'
+
+import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
+import { SceneContent } from '~/layout/scenes/components/SceneContent'
+import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
+import { FileSystemEntry, FileSystemIconType } from '~/queries/schema/schema-general'
+
+import { LibraryCreateButton } from './LibraryCreateButton'
+import { libraryLogic } from './libraryLogic'
+import { baseObjectType, libraryObjectHref, libraryObjectName } from './libraryUtils'
+
+export const scene: SceneExport = {
+ component: Library,
+ logic: libraryLogic,
+}
+
+/** Saved objects across the project, filtered by the type in the URL. */
+export function Library(): JSX.Element {
+ const libraryEnabled = useFeatureFlag('TODAY_RAIL_NAV')
+ // The page ships behind the Today navigation, so without the flag `/library` stays a missing page.
+ return libraryEnabled ? <LibraryContent /> : <NotFound object="page" />
+}
+
+function LibraryContent(): JSX.Element {
+ const { objectType, objectTypeByValue, visibleObjects, objectsLoading, loadFailed, search, hasMore } =
+ useValues(libraryLogic)
+ const { setSearch, loadObjects, loadMoreObjects } = useActions(libraryLogic)
+ const selectedType = objectType ? objectTypeByValue[objectType] : undefined
+ const title = selectedType?.pluralLabel ?? 'All objects'
+
+ const columns: LemonTableColumns<FileSystemEntry> = [
+ {
+ title: 'Name',
+ key: 'name',
+ render: (_, entry) => {
+ const href = libraryObjectHref(entry)
+ const name = libraryObjectName(entry)
+ return (
+ <span className="flex items-center gap-2 min-w-0">
+ <span className="shrink-0 flex">{iconForType(entry.type as FileSystemIconType)}</span>
+ {href ? (
+ <Link to={href} className="truncate font-semibold" data-attr="library-object">
+ {name}
+ </Link>
+ ) : (
+ <span className="truncate font-semibold">{name}</span>
+ )}
+ </span>
+ )
+ },
+ },
+ ...(objectType
+ ? []
+ : [
+ {
+ title: 'Type',
+ key: 'type',
+ render: (_: unknown, entry: FileSystemEntry) =>
+ objectTypeByValue[baseObjectType(entry.type)]?.label ?? baseObjectType(entry.type),
+ },
+ ]),
+ {
+ title: 'Created',
+ key: 'created_at',
+ align: 'right',
+ render: (_, entry) => (entry.created_at ? <TZLabel time={entry.created_at} /> : null),
+ },
+ ]
+
+ return (
+ <SceneContent>
+ <SceneTitleSection
+ name={title}
+ description={
+ selectedType
+ ? null
+ : 'Everything saved in this project. Pick a type in the sidebar to narrow the list.'
+ }
+ resourceType={{ type: objectType || 'folder' }}
+ actions={
+ selectedType ? (
+ <LibraryCreateButton
+ objectType={selectedType.value}
+ label={`New ${selectedType.label.toLowerCase()}`}
+ />
+ ) : undefined
+ }
+ />
+ <LemonInput
+ type="search"
+ placeholder={`Search ${title.toLowerCase()}`}
+ value={search}
+ onChange={setSearch}
+ data-attr="library-search"
+ fullWidth
+ />
+ {loadFailed && !visibleObjects.length ? (
+ <LemonBanner
+ type="error"
+ action={{ children: 'Try again', onClick: () => loadObjects(), loading: objectsLoading }}
+ >
+ Couldn’t load your library. Try again, and if it keeps happening contact support.
+ </LemonBanner>
+ ) : (
+ <LemonTable
+ dataSource={visibleObjects}
+ columns={columns}
+ loading={objectsLoading}
+ rowKey="id"
+ emptyState={
+ hasMore
+ ? 'Nothing to show on the pages loaded so far. Select Show more to keep looking.'
+ : search
+ ? 'Nothing matches that search.'
+ : selectedType
+ ? `No ${selectedType.pluralLabel.toLowerCase()} yet. Create one to see it here.`
+ : 'Insights, dashboards, flags and everything else you save show up here.'
+ }
+ />
+ )}
+ {hasMore && (
+ <div className="flex justify-center">
+ <LemonButton
+ type="secondary"
+ size="small"
+ loading={objectsLoading}
+ onClick={() => loadMoreObjects()}
+ data-attr="library-load-more"
+ >
+ Show more
+ </LemonButton>
+ </div>
+ )}
+ </SceneContent>
+ )
+}
diff --git a/frontend/src/scenes/library/LibraryCreateButton.tsx b/frontend/src/scenes/library/LibraryCreateButton.tsx
new file mode 100644
index 000000000000..aa7e2b318ddb
--- /dev/null
+++ b/frontend/src/scenes/library/LibraryCreateButton.tsx
@@ -0,0 +1,47 @@
+import { useValues } from 'kea'
+
+import { IconPlus } from '@posthog/icons'
+import { LemonButton, LemonMenu } from '@posthog/lemon-ui'
+
+import { libraryLogic } from './libraryLogic'
+
+interface LibraryCreateButtonProps {
+ objectType: string
+ /** Shown on the button. Without it the button is a small plus icon. */
+ label?: string
+}
+
+/** Creates an object of one Library type. Types with several kinds (insights) open a menu of kinds. */
+export function LibraryCreateButton({ objectType, label }: LibraryCreateButtonProps): JSX.Element | null {
+ const { createItemsByType, objectTypeByValue } = useValues(libraryLogic)
+ const items = createItemsByType[objectType] ?? []
+ const typeLabel = objectTypeByValue[objectType]?.label.toLowerCase() ?? 'object'
+ if (!items.length) {
+ return null
+ }
+ const buttonProps = label
+ ? { type: 'primary' as const, size: 'small' as const, icon: <IconPlus />, children: label }
+ : { size: 'xsmall' as const, icon: <IconPlus />, tooltip: `New ${typeLabel}` }
+
+ if (items.length === 1) {
+ return (
+ <LemonButton
+ {...buttonProps}
+ to={items[0].href}
+ aria-label={`New ${typeLabel}`}
+ data-attr="library-new-object"
+ />
+ )
+ }
+ return (
+ <LemonMenu
+ items={items.map((item) => ({
+ label: item.path.split('/').pop() ?? item.path,
+ to: item.href,
+ 'data-attr': 'library-new-object',
+ }))}
+ >
+ <LemonButton {...buttonProps} aria-label={`New ${typeLabel}`} />
+ </LemonMenu>
+ )
+}
diff --git a/frontend/src/scenes/library/libraryLogic.ts b/frontend/src/scenes/library/libraryLogic.ts
new file mode 100644
index 000000000000..e7425d5b1369
--- /dev/null
+++ b/frontend/src/scenes/library/libraryLogic.ts
@@ -0,0 +1,249 @@
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+import { urlToAction } from 'kea-router'
+
+import api from 'lib/api'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { urls } from 'scenes/urls'
+
+import { fileSystemTypes, getTreeItemsNew } from '~/products'
+import { FileSystemEntry, FileSystemImport } from '~/queries/schema/schema-general'
+
+import {
+ LibraryObjectType,
+ TOOL_FILE_SYSTEM_TYPES,
+ baseObjectType,
+ isToolEntry,
+ sortLibraryTypes,
+} from './libraryUtils'
+
+export const LIBRARY_PAGE_SIZE = 50
+// "All objects" drops tool entries after each page loads, so it reads ahead until a page has something
+// to show. This caps how far it reads ahead in one go.
+const MAX_PAGES_PER_LOAD = 5
+
+const PLURAL_LABELS: Record<string, string> = {
+ session_recording_playlist: 'Replay playlists',
+ user_interview: 'User research',
+}
+
+export interface LibraryObjects {
+ results: FileSystemEntry[]
+ count: number
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface libraryLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
+ createItemsByType: Record<string, FileSystemImport[]>
+ hasMore: boolean
+ loadFailed: boolean
+ objectType: string
+ objectTypeByValue: Record<string, LibraryObjectType>
+ objectTypes: LibraryObjectType[]
+ objects: LibraryObjects
+ objectsLoading: boolean
+ search: string
+ visibleObjects: FileSystemEntry[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface libraryLogicActions {
+ loadMoreObjects: (_: void) => void
+ loadMoreObjectsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadMoreObjectsSuccess: (
+ objects: {
+ count: number
+ results: FileSystemEntry[]
+ },
+ payload?: void
+ ) => {
+ objects: {
+ count: number
+ results: FileSystemEntry[]
+ }
+ payload?: void
+ }
+ loadObjects: (_: void) => void
+ loadObjectsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadObjectsSuccess: (
+ objects: LibraryObjects,
+ payload?: void
+ ) => {
+ objects: LibraryObjects
+ payload?: void
+ }
+ setObjectType: (objectType: string) => {
+ objectType: string
+ }
+ setSearch: (search: string) => {
+ search: string
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface libraryLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ objectTypes: (featureFlags: FeatureFlagsSet) => LibraryObjectType[]
+ objectTypeByValue: (objectTypes: LibraryObjectType[]) => Record<string, LibraryObjectType>
+ createItemsByType: (featureFlags: FeatureFlagsSet) => Record<string, FileSystemImport[]>
+ visibleObjects: (objects: LibraryObjects) => FileSystemEntry[]
+ hasMore: (objects: LibraryObjects) => boolean
+ }
+}
+
+export type libraryLogicType = MakeLogicType<
+ libraryLogicValues,
+ libraryLogicActions,
+ Record<string, any>,
+ libraryLogicMeta
+>
+
+export const libraryLogic = kea<libraryLogicType>([
+ path(['scenes', 'library', 'libraryLogic']),
+ connect(() => ({ values: [featureFlagLogic, ['featureFlags']] })),
+ actions({
+ setObjectType: (objectType: string) => ({ objectType }),
+ setSearch: (search: string) => ({ search }),
+ }),
+ reducers({
+ objectType: ['', { setObjectType: (_, { objectType }) => objectType }],
+ search: ['', { setSearch: (_, { search }) => search }],
+ }),
+ loaders(({ values }) => {
+ const fetchPage = (offset: number): Promise<LibraryObjects> =>
+ api.fileSystem
+ .list({
+ search: values.search || undefined,
+ notType: 'folder',
+ ...(values.objectType === 'insight'
+ ? { type__startswith: 'insight' }
+ : values.objectType
+ ? { type: values.objectType }
+ : {}),
+ orderBy: '-created_at',
+ offset,
+ limit: LIBRARY_PAGE_SIZE,
+ })
+ .then((response) => ({ results: response.results, count: response.count }))
+ const fetchVisiblePage = async (offset: number): Promise<LibraryObjects> => {
+ const results: FileSystemEntry[] = []
+ let count = 0
+ for (let page = 0; page < MAX_PAGES_PER_LOAD; page++) {
+ const next = await fetchPage(offset + results.length)
+ results.push(...next.results)
+ count = next.count
+ const exhausted = next.results.length === 0 || offset + results.length >= count
+ if (exhausted || values.objectType || results.some((entry) => !isToolEntry(entry))) {
+ break
+ }
+ }
+ return { results, count }
+ }
+ return {
+ objects: [
+ { results: [], count: 0 } as LibraryObjects,
+ {
+ loadObjects: async (_: void, breakpoint) => {
+ await breakpoint(250)
+ const page = await fetchVisiblePage(0)
+ breakpoint()
+ return page
+ },
+ loadMoreObjects: async (_: void, breakpoint) => {
+ const page = await fetchVisiblePage(values.objects.results.length)
+ breakpoint()
+ return { results: [...values.objects.results, ...page.results], count: page.count }
+ },
+ },
+ ],
+ }
+ }),
+ reducers({
+ loadFailed: [
+ false,
+ {
+ loadObjects: () => false,
+ loadObjectsFailure: () => true,
+ loadMoreObjectsFailure: () => true,
+ },
+ ],
+ }),
+ selectors({
+ objectTypes: [
+ (s) => [s.featureFlags],
+ (featureFlags: FeatureFlagsSet): LibraryObjectType[] =>
+ sortLibraryTypes(
+ Object.entries(fileSystemTypes)
+ .filter(
+ ([type, entry]) =>
+ !TOOL_FILE_SYSTEM_TYPES.has(type) &&
+ (!('flag' in entry) || !!featureFlags[entry.flag as keyof FeatureFlagsSet])
+ )
+ .map(([value, entry]) => ({
+ value,
+ label: entry.name,
+ pluralLabel: PLURAL_LABELS[value] ?? `${entry.name}s`,
+ }))
+ ),
+ ],
+ objectTypeByValue: [
+ (s) => [s.objectTypes],
+ (objectTypes: LibraryObjectType[]): Record<string, LibraryObjectType> =>
+ Object.fromEntries(objectTypes.map((type) => [type.value, type])),
+ ],
+ createItemsByType: [
+ (s) => [s.featureFlags],
+ (featureFlags: FeatureFlagsSet): Record<string, FileSystemImport[]> => {
+ const byType: Record<string, FileSystemImport[]> = {}
+ for (const item of getTreeItemsNew()) {
+ const type = baseObjectType(item.type)
+ if (!item.href || (item.flag && !featureFlags[item.flag as keyof FeatureFlagsSet])) {
+ continue
+ }
+ byType[type] = [...(byType[type] ?? []), item]
+ }
+ return byType
+ },
+ ],
+ // "All objects" asks for every type, so drop the ones that live in Tools.
+ visibleObjects: [
+ (s) => [s.objects],
+ (objects: LibraryObjects): FileSystemEntry[] => objects.results.filter((entry) => !isToolEntry(entry)),
+ ],
+ hasMore: [(s) => [s.objects], (objects: LibraryObjects): boolean => objects.results.length < objects.count],
+ }),
+ listeners(({ actions }) => ({
+ setObjectType: () => actions.loadObjects(),
+ setSearch: () => actions.loadObjects(),
+ })),
+ urlToAction(({ actions, values, cache }) => {
+ const openType = (objectType: string): void => {
+ // The Library scene renders nothing without the flag, so it must not load anything either.
+ if (!values.featureFlags[FEATURE_FLAGS.TODAY_RAIL_NAV]) {
+ return
+ }
+ if (objectType !== values.objectType || !cache.loaded) {
+ cache.loaded = true
+ actions.setObjectType(objectType)
+ }
+ }
+ return {
+ [urls.library()]: () => openType(''),
+ [urls.library(':objectType')]: ({ objectType }) => openType(objectType ?? ''),
+ }
+ }),
+])
diff --git a/frontend/src/scenes/library/libraryUtils.test.ts b/frontend/src/scenes/library/libraryUtils.test.ts
new file mode 100644
index 000000000000..e79979dadca8
--- /dev/null
+++ b/frontend/src/scenes/library/libraryUtils.test.ts
@@ -0,0 +1,20 @@
+import { libraryObjectHref, libraryObjectName } from './libraryUtils'
+
+describe('libraryUtils', () => {
+ test.each([
+ ['Unfiled/Insights/Checkout funnel', 'Checkout funnel'],
+ ['Unfiled/Insights/Signups a\\/b test', 'Signups a/b test'],
+ ['Top level', 'Top level'],
+ ])('names %s as %s', (path, name) => {
+ expect(libraryObjectName({ path })).toBe(name)
+ })
+
+ test.each([
+ ['its own href first', { href: '/custom', type: 'insight', ref: 'abc' }, '/custom'],
+ ['the registered page for its type', { type: 'feature_flag', ref: '7' }, '/feature_flags/7'],
+ ['no link without a ref', { type: 'feature_flag' }, null],
+ ['no link for an unknown type', { type: 'not_a_type', ref: '7' }, null],
+ ])('links an object to %s', (_, entry, href) => {
+ expect(libraryObjectHref(entry)).toBe(href)
+ })
+})
diff --git a/frontend/src/scenes/library/libraryUtils.ts b/frontend/src/scenes/library/libraryUtils.ts
new file mode 100644
index 000000000000..9da21afb93f3
--- /dev/null
+++ b/frontend/src/scenes/library/libraryUtils.ts
@@ -0,0 +1,50 @@
+import { fileSystemTypes } from '~/products'
+import { FileSystemEntry } from '~/queries/schema/schema-general'
+
+// These file system types are working pages rather than saved objects, so they belong to Tools.
+export const TOOL_FILE_SYSTEM_TYPES = new Set(['endpoints', 'live_debugger', 'notebook', 'task'])
+
+// The objects people reach for most come first. Any other type follows in name order.
+const LIBRARY_TYPE_ORDER = ['insight', 'dashboard', 'feature_flag', 'experiment', 'survey', 'cohort', 'action']
+
+export interface LibraryObjectType {
+ value: string
+ /** Singular, for "New feature flag". */
+ label: string
+ /** Plural, for the sub-nav. */
+ pluralLabel: string
+}
+
+export function baseObjectType(type: string | undefined): string {
+ return type?.split('/')[0] ?? ''
+}
+
+export function isToolEntry(entry: Pick<FileSystemEntry, 'type'>): boolean {
+ return TOOL_FILE_SYSTEM_TYPES.has(baseObjectType(entry.type))
+}
+
+/** The page a saved object opens, from the entry itself or from its type's registered URL. */
+export function libraryObjectHref(entry: Pick<FileSystemEntry, 'href' | 'type' | 'ref'>): string | null {
+ if (entry.href) {
+ return entry.href
+ }
+ const baseType = baseObjectType(entry.type)
+ const definition = Object.hasOwn(fileSystemTypes, baseType)
+ ? fileSystemTypes[baseType as keyof typeof fileSystemTypes]
+ : null
+ return entry.ref && definition ? definition.href(entry.ref) : null
+}
+
+/** The last segment of a file system path, with escaped slashes restored. */
+export function libraryObjectName(entry: Pick<FileSystemEntry, 'path'>): string {
+ const segments = entry.path.split(/(?<!\\)\//)
+ return (segments[segments.length - 1] || entry.path).replace(/\\\//g, '/')
+}
+
+export function sortLibraryTypes(types: LibraryObjectType[]): LibraryObjectType[] {
+ const rank = (type: LibraryObjectType): number => {
+ const index = LIBRARY_TYPE_ORDER.indexOf(type.value)
+ return index === -1 ? LIBRARY_TYPE_ORDER.length : index
+ }
+ return [...types].sort((first, second) => rank(first) - rank(second) || first.label.localeCompare(second.label))
+}
diff --git a/frontend/src/scenes/project-homepage/ProjectHomepage.tsx b/frontend/src/scenes/project-homepage/ProjectHomepage.tsx
index c615f924d2e0..37f9a7282fdf 100644
--- a/frontend/src/scenes/project-homepage/ProjectHomepage.tsx
+++ b/frontend/src/scenes/project-homepage/ProjectHomepage.tsx
@@ -1,9 +1,12 @@
import './ProjectHomepage.scss'
+import { useValues } from 'kea'
+
import { projectHomepageLogic } from 'scenes/project-homepage/projectHomepageLogic'
import { SceneExport } from 'scenes/sceneTypes'
import { AiFirstHomepage } from './ai-first/AiFirstHomepage'
+import { TodayHome } from './today/TodayHome'
export const scene: SceneExport = {
component: ProjectHomepage,
@@ -11,9 +14,6 @@ export const scene: SceneExport = {
}
export function ProjectHomepage(): JSX.Element {
- return (
- <div className="flex-1 min-h-0">
- <AiFirstHomepage />
- </div>
- )
+ const { todayHomeEnabled } = useValues(projectHomepageLogic)
+ return <div className="flex-1 min-h-0">{todayHomeEnabled ? <TodayHome /> : <AiFirstHomepage />}</div>
}
diff --git a/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx b/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx
index c5cb7c2e6038..de509609e1ec 100644
--- a/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx
+++ b/frontend/src/scenes/project-homepage/projectHomepageLogic.tsx
@@ -1,10 +1,15 @@
import { MakeLogicType, actions, connect, kea, path, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
+import { router, urlToAction } from 'kea-router'
import api from 'lib/api'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { MaxContextInput } from 'scenes/max/maxTypes'
import { projectLogic } from 'scenes/projectLogic'
+import { urls } from 'scenes/urls'
+import { navigationLogic } from '~/layout/navigation/navigationLogic'
import { getQueryBasedInsightModel } from '~/queries/nodes/InsightViz/utils'
import { Breadcrumb, InsightModel } from '~/types'
@@ -12,12 +17,15 @@ import type { Node } from '../../queries/schema/schema-general'
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface projectHomepageLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
+ mobileLayout: boolean // navigationLogic
currentProjectId: number | null // projectLogic
breadcrumbs: Breadcrumb[]
expandedInsightIds: Set<string>
maxContext: MaxContextInput[]
recentInsights: InsightModel[]
recentInsightsLoading: boolean
+ todayHomeEnabled: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -42,12 +50,31 @@ export interface projectHomepageLogicActions {
}
}
-export type projectHomepageLogicType = MakeLogicType<projectHomepageLogicValues, projectHomepageLogicActions>
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface projectHomepageLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ todayHomeEnabled: (featureFlags: FeatureFlagsSet, mobileLayout: boolean) => boolean
+ }
+}
+
+export type projectHomepageLogicType = MakeLogicType<
+ projectHomepageLogicValues,
+ projectHomepageLogicActions,
+ Record<string, any>,
+ projectHomepageLogicMeta
+>
export const projectHomepageLogic = kea<projectHomepageLogicType>([
path(['scenes', 'project-homepage', 'projectHomepageLogic']),
connect(() => ({
- values: [projectLogic, ['currentProjectId']],
+ values: [
+ projectLogic,
+ ['currentProjectId'],
+ featureFlagLogic,
+ ['featureFlags'],
+ navigationLogic,
+ ['mobileLayout'],
+ ],
})),
actions({
@@ -83,6 +110,12 @@ export const projectHomepageLogic = kea<projectHomepageLogicType>([
})),
selectors({
+ // Matches the condition that swaps in the Today rail, because Today has no way around without it.
+ todayHomeEnabled: [
+ (s) => [s.featureFlags, s.mobileLayout],
+ (featureFlags: FeatureFlagsSet, mobileLayout: boolean): boolean =>
+ !!featureFlags[FEATURE_FLAGS.TODAY_RAIL_NAV] && !mobileLayout,
+ ],
maxContext: [
() => [],
// Context is only added explicitly via the @Context button.
@@ -99,4 +132,13 @@ export const projectHomepageLogic = kea<projectHomepageLogicType>([
],
],
}),
+
+ urlToAction(({ values }) => ({
+ // A Today report link opened where Today is off lands on the same report in the Inbox.
+ [urls.todayReport(':reportId')]: ({ reportId }) => {
+ if (reportId && !values.todayHomeEnabled) {
+ router.actions.replace(urls.inboxReport('reports', reportId))
+ }
+ },
+ })),
])
diff --git a/frontend/src/scenes/project-homepage/today/Today.scss b/frontend/src/scenes/project-homepage/today/Today.scss
new file mode 100644
index 000000000000..3576dd6742c2
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/Today.scss
@@ -0,0 +1,668 @@
+// The Today layout keeps its own "paper" palette. Colours that also appear on tinted surfaces stay literal,
+// the rest switch with the app theme. The app layout shares it so the page behind the rail matches.
+.Today,
+.TodayAppLayout {
+ --today-ink: #151515;
+ --today-muted: #8d8d88;
+ --today-faint: #a3a39e;
+ --today-paper: #f7f7f5;
+ --today-line: #e5e5e0;
+ --today-card: #fff;
+ --today-soft: #efefeb;
+ --today-soft-2: #f2f2ee;
+ --today-drawer: #fbfbf9;
+ --today-secondary-text: #5f5f5a;
+ --today-body-text: #454541;
+ --today-input-border: #deded8;
+ --today-focus-border: #a7a7a0;
+ --today-success-text: #24733a;
+ --today-success-fill: #e8f6eb;
+ --today-button: #151515;
+ --today-button-hover: #33332f;
+ --today-button-text: #fff;
+ --today-pill: #eeeeea;
+ --today-pill-border: #e2e2dc;
+ --today-ease: cubic-bezier(0.23, 1, 0.32, 1);
+ --today-ease-in-out: cubic-bezier(0.645, 0.045, 0.355, 1);
+ --today-ease-rise: cubic-bezier(0.22, 1, 0.36, 1);
+ --today-ease-nudge: cubic-bezier(0.2, 0.8, 0.2, 1);
+ --today-card-shadow: 0 1px 2px #00000008, 0 12px 32px -24px #00000059;
+
+ [theme='dark'] & {
+ --today-ink: #f1f1ee;
+ --today-muted: #a6a6a0;
+ --today-faint: #82827c;
+ --today-paper: #161615;
+ --today-line: #2c2c2a;
+ --today-card: #1f1f1d;
+ --today-soft: #262624;
+ --today-soft-2: #232321;
+ --today-drawer: #1b1b1a;
+ --today-secondary-text: #b5b5ae;
+ --today-body-text: #d4d4ce;
+ --today-input-border: #353532;
+ --today-focus-border: #5c5c57;
+ --today-success-text: #7fd694;
+ --today-success-fill: #1d3323;
+ --today-button: #f1f1ee;
+ --today-button-hover: #d9d9d4;
+ --today-button-text: #151515;
+ --today-pill: #262624;
+ --today-pill-border: #333331;
+ }
+}
+
+.Today {
+ font-family: var(--font-sans);
+ color: var(--today-ink);
+ background: var(--today-paper);
+ -webkit-font-smoothing: antialiased;
+}
+
+.Today__label {
+ font-family: var(--font-mono);
+ font-size: 10px;
+ color: var(--today-faint);
+ text-transform: uppercase;
+ letter-spacing: 0.07em;
+}
+
+.Today__page {
+ animation: Today__page-in 0.18s ease-out both;
+}
+
+// Zero-specificity resets, so component classes below and shared buttons keep their own styles.
+:where(.Today) button {
+ font: inherit;
+ color: inherit;
+ cursor: pointer;
+}
+
+:where(.Today) :focus-visible {
+ outline: 2px solid var(--today-ink);
+ outline-offset: 3px;
+}
+
+// Text fields show focus on their container's border instead.
+:where(.Today) :is(input, textarea):focus-visible {
+ outline: none;
+}
+
+// Sidebar
+
+.TodaySidebar {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ min-height: 0;
+ padding: 18px 12px 0;
+}
+
+.TodaySidebar__new {
+ display: flex;
+ gap: 8px;
+ align-items: center;
+ justify-content: center;
+ width: 100%;
+ padding: 11px 14px;
+ margin-top: 2px;
+ font-size: 13px;
+ font-weight: 550;
+ color: var(--today-button-text);
+ background: var(--today-button);
+ border: 1px solid var(--today-button);
+ border-radius: 9px;
+ transition:
+ background 0.16s,
+ transform 0.1s;
+
+ &:active {
+ transform: translateY(1px);
+ }
+
+ svg {
+ width: 15px;
+ height: 15px;
+ }
+
+ @media (hover: hover) and (pointer: fine) {
+ &:hover {
+ background: var(--today-button-hover);
+ }
+ }
+}
+
+.TodaySidebar__scroll {
+ flex: 1 1 auto;
+ min-height: 0;
+ padding: 0 4px 24px;
+ overflow-y: auto;
+ scrollbar-color: var(--today-input-border) transparent;
+ scrollbar-width: thin;
+}
+
+.TodaySidebar__sectionLabel {
+ margin: 42px 11px 14px;
+ letter-spacing: 0.08em;
+}
+
+.TodaySidebar__more {
+ display: block;
+ margin: 14px 11px 0;
+ font-size: 12px;
+}
+
+.TodaySidebar__list {
+ display: flex;
+ flex-direction: column;
+ gap: 8px;
+}
+
+.TodayNavItem {
+ --report-color: #5c5c57;
+
+ display: flex;
+ gap: 14px;
+ align-items: center;
+ width: 100%;
+ padding: 11px;
+ text-align: left;
+ border-radius: 10px;
+ transition:
+ background 0.16s,
+ transform 0.2s var(--today-ease-nudge);
+
+ &[data-active='true'] {
+ background: var(--today-soft);
+ transform: translateX(3px);
+
+ .TodayNavItem__marker {
+ color: #fff;
+ background: var(--report-color);
+ border-color: var(--report-color);
+ }
+
+ .TodayNavItem__title {
+ color: var(--today-ink);
+ }
+ }
+
+ @media (hover: hover) and (pointer: fine) {
+ &:hover {
+ background: var(--today-soft);
+ }
+ }
+}
+
+.TodayNavItem__marker {
+ position: relative;
+ display: flex;
+ flex: 0 0 40px;
+ align-items: center;
+ justify-content: center;
+ width: 40px;
+ height: 40px;
+ color: var(--report-color);
+ background: color-mix(in sRGB, var(--report-color) 10%, var(--today-card));
+ border: 1px solid color-mix(in sRGB, var(--report-color) 25%, var(--today-card));
+ border-radius: 11px;
+ transition:
+ color 0.16s,
+ background 0.16s,
+ border-color 0.16s;
+
+ svg {
+ width: 21px;
+ height: 21px;
+ }
+}
+
+.TodayNavItem__copy {
+ min-width: 0;
+}
+
+.TodayNavItem__title,
+.TodayNavItem__meta {
+ display: block;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+.TodayNavItem__title {
+ font-size: 13px;
+ line-height: 1.4;
+ color: var(--today-body-text);
+}
+
+.TodayNavItem__meta {
+ margin-top: 3px;
+ font-size: 11px;
+ color: var(--today-faint);
+}
+
+// Shared sidebar footer
+
+.TodaySidebarFooter {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) auto;
+ gap: 7px;
+ padding: 12px 4px 14px;
+ margin: 0 4px;
+ border-top: 1px solid var(--today-line);
+}
+
+.TodaySidebarFooter__project,
+.TodaySidebarFooter__settings {
+ min-height: 48px;
+ color: var(--today-body-text);
+ background: var(--today-soft-2);
+ border: 1px solid var(--today-line);
+ border-radius: 10px;
+
+ @media (hover: hover) and (pointer: fine) {
+ &:hover {
+ color: var(--today-ink);
+ background: var(--today-soft);
+ }
+ }
+}
+
+.TodaySidebarFooter__project {
+ display: flex;
+ gap: 9px;
+ align-items: center;
+ min-width: 0;
+ padding: 6px 9px;
+ text-align: left;
+
+ > svg {
+ flex: 0 0 14px;
+ width: 14px;
+ height: 14px;
+ margin-left: auto;
+ color: #969690;
+ }
+}
+
+.TodaySidebarFooter__avatar {
+ display: flex;
+ flex: 0 0 32px;
+ align-items: center;
+ justify-content: center;
+ width: 32px;
+ height: 32px;
+ font-family: var(--font-mono);
+ font-size: 10px;
+ font-weight: 700;
+ color: #b84413;
+ background: #ffe7da;
+ border: 1px solid #ffd4bf;
+ border-radius: 8px;
+}
+
+.TodaySidebarFooter__projectText {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ min-width: 0;
+
+ small {
+ font-family: var(--font-mono);
+ font-size: 8px;
+ color: var(--today-faint);
+ text-transform: uppercase;
+ letter-spacing: 0.06em;
+ }
+
+ strong {
+ overflow: hidden;
+ font-size: 11.5px;
+ font-weight: 560;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ }
+}
+
+.TodaySidebarFooter__settings {
+ display: flex;
+ flex-direction: column;
+ gap: 2px;
+ align-items: center;
+ justify-content: center;
+ width: 66px;
+ padding: 4px;
+ font-size: 9px;
+
+ svg {
+ width: 17px;
+ height: 17px;
+ }
+}
+
+// Home
+
+.TodayHome,
+.TodayReport {
+ width: min(840px, 100% - 144px);
+ margin: 0 auto;
+
+ @container main-content (max-width: 900px) {
+ width: min(100% - 72px, 700px);
+ }
+}
+
+.TodayHome {
+ padding: 94px 0 140px;
+}
+
+.TodayReport {
+ padding: 56px 0 140px;
+}
+
+.TodayHome__meta {
+ font-family: var(--font-mono);
+ font-size: 11px;
+ color: var(--today-faint);
+ letter-spacing: 0.02em;
+
+ time {
+ font-variant-numeric: tabular-nums;
+ color: var(--today-ink);
+ }
+}
+
+.TodayHome__intro {
+ max-width: 680px;
+ margin-top: clamp(72px, 12vh, 120px);
+ font-size: 16px;
+ line-height: 1.7;
+ color: var(--today-muted);
+ letter-spacing: -0.005em;
+
+ p {
+ margin: 0;
+ }
+
+ p + p {
+ margin-top: 7px;
+ }
+}
+
+.TodayHome__greeting {
+ margin-bottom: 10px;
+ font-size: 21px;
+ font-weight: 560;
+ color: var(--today-ink);
+ letter-spacing: -0.015em;
+}
+
+.TodayChipStack {
+ position: relative;
+ display: inline-block;
+ width: 130px;
+ height: 26px;
+ margin-left: 10px;
+ vertical-align: -8px;
+ isolation: isolate;
+}
+
+.TodayChipStack__chip {
+ --index: 0;
+ --report-color: #5c5c57;
+
+ position: absolute;
+ top: 0;
+ left: 0;
+ z-index: calc(6 - var(--index));
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: 26px;
+ height: 26px;
+ color: #fff;
+ background: var(--report-color);
+ border: 3px solid var(--today-paper);
+ border-radius: 8px;
+ box-shadow: 0 1px 2px #00000024;
+ transition: transform 0.18s;
+ transform: translateX(calc(var(--index) * 16px)) rotate(var(--tilt));
+
+ svg {
+ width: 13px;
+ height: 13px;
+ }
+
+ .TodayChipStack:hover & {
+ transform: translateX(calc(var(--index) * 23px)) rotate(0);
+ }
+
+ .TodayChipStack:hover &:hover {
+ z-index: 20;
+ transform: translateX(calc(var(--index) * 23px)) translateY(-4px) rotate(-6deg) scale(1.08);
+ }
+
+ &[data-active='true'] {
+ z-index: 20;
+ transform: translateX(calc(var(--index) * 16px)) translateY(-4px) rotate(-8deg) scale(1.08);
+ }
+}
+
+.TodayReportLink {
+ padding: 0;
+ color: inherit;
+ text-align: inherit;
+ text-decoration: underline;
+ text-decoration-thickness: 1.5px;
+ text-decoration-color: color-mix(in sRGB, var(--today-ink) 18%, transparent);
+ text-underline-offset: 5px;
+ transition:
+ color 0.16s,
+ text-decoration-color 0.16s;
+
+ &:hover,
+ &[data-active='true'] {
+ color: var(--today-ink);
+ text-decoration-color: var(--today-ink);
+ }
+}
+
+.TodayHome__highlight {
+ padding: 0.02em 0.2em 0.08em;
+ margin: 0 -0.03em;
+ background: #ffbda380;
+ border-radius: 0.26em;
+ box-decoration-break: clone;
+
+ .TodayReportLink,
+ .TodayReportLink:hover,
+ .TodayReportLink[data-active='true'] {
+ font-weight: 500;
+ color: #ff4800;
+ text-decoration: none;
+ }
+}
+
+.TodayHome__foot {
+ margin-top: 48px;
+
+ button {
+ color: var(--today-ink);
+ text-decoration: underline;
+ text-decoration-color: color-mix(in sRGB, var(--today-ink) 20%, transparent);
+ text-underline-offset: 5px;
+
+ &:hover {
+ color: #ff5c1c;
+ }
+ }
+}
+
+// Ask box
+
+.TodayAsk {
+ display: flex;
+ gap: 8px;
+ align-items: center;
+ max-width: 760px;
+ padding: 7px 8px 7px 20px;
+ margin-top: 76px;
+ background: var(--today-card);
+ border: 1px solid var(--today-input-border);
+ border-radius: 16px;
+ box-shadow: var(--today-card-shadow);
+ transition:
+ border-color 0.16s,
+ box-shadow 0.16s;
+
+ &:focus-within {
+ border-color: var(--today-focus-border);
+ box-shadow:
+ 0 0 0 3px #1515150d,
+ 0 14px 36px -24px #0006;
+ }
+
+ input {
+ flex: 1;
+ min-width: 0;
+ height: 42px;
+ font-size: 14px;
+ color: var(--today-ink);
+ background: transparent;
+ border: 0;
+ outline: none;
+
+ &::placeholder {
+ color: #aaa9a4;
+ }
+ }
+}
+
+.TodaySend {
+ display: flex;
+ flex: 0 0 auto;
+ align-items: center;
+ justify-content: center;
+ width: 38px;
+ height: 38px;
+ color: var(--today-button-text);
+ background: var(--today-button);
+ border-radius: 11px;
+ transition:
+ opacity 0.16s,
+ transform 0.1s;
+
+ &:active {
+ transform: scale(0.97);
+ }
+
+ &:disabled {
+ cursor: default;
+ opacity: 0.18;
+ }
+
+ svg {
+ width: 17px;
+ height: 17px;
+ transform: rotate(-90deg);
+ }
+}
+
+.TodayAsk__sent {
+ margin: 12px 2px 0;
+ overflow: hidden;
+ font-family: var(--font-mono);
+ font-size: 10.5px;
+ color: var(--today-faint);
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
+// Report page
+
+.TodayReport__kicker {
+ display: flex;
+ gap: 10px;
+ align-items: center;
+ font-family: var(--font-mono);
+ font-size: 10.5px;
+ color: var(--report-color);
+ text-transform: uppercase;
+ letter-spacing: 0.04em;
+}
+
+.TodayTile {
+ display: flex;
+ flex: 0 0 auto;
+ align-items: center;
+ justify-content: center;
+ width: 28px;
+ height: 28px;
+ color: #fff;
+ background: var(--tile-color, var(--report-color));
+ border-radius: 8px;
+
+ svg {
+ width: 15px;
+ height: 15px;
+ }
+}
+
+.TodayReport__heading {
+ max-width: 560px;
+ margin: 14px 0 12px;
+ font-size: 18px;
+ font-weight: 560;
+ line-height: 1.3;
+ text-wrap: balance;
+ letter-spacing: -0.015em;
+}
+
+.TodayReport__body {
+ max-width: 600px;
+ margin-top: 24px;
+ font-size: 14px;
+ line-height: 1.65;
+ color: var(--today-muted);
+
+ > * + * {
+ margin-top: 20px;
+ }
+}
+
+// Evidence and prompts
+
+.TodayEvidence,
+.TodayPrompts {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ max-width: 600px;
+ margin-top: 48px;
+}
+
+.TodayEvidence__note,
+.TodayPrompts__hint {
+ margin: 0;
+ font-size: 12px;
+ color: var(--today-muted);
+}
+
+// Keyframes
+
+@keyframes Today__page-in {
+ from {
+ opacity: 0;
+ transform: translateY(2px);
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .Today *,
+ .Today *::before,
+ .Today *::after {
+ transition: none !important;
+ animation-duration: 1ms !important;
+ animation-iteration-count: 1 !important;
+ }
+}
diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
new file mode 100644
index 000000000000..9130a2e329ed
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
@@ -0,0 +1,215 @@
+import type { Meta, StoryObj } from '@storybook/react'
+import { within } from '@testing-library/dom'
+import userEvent from '@testing-library/user-event'
+
+import { FEATURE_FLAGS } from 'lib/constants'
+import { App } from 'scenes/App'
+import { urls } from 'scenes/urls'
+
+import { mswDecorator } from '~/mocks/browser'
+import { EMPTY_PAGINATED_RESPONSE } from '~/mocks/handlers'
+
+import { makeReport, mockSignals } from 'products/signals/frontend/inbox/__mocks__/inboxMocks'
+import { SignalReportStatus } from 'products/signals/frontend/inbox/types'
+
+const SPACES = [
+ {
+ id: 'space-me',
+ name: 'me',
+ channel_type: 'private',
+ github_integration: null,
+ repositories: [],
+ auto_archive_after_days: null,
+ created_at: '2026-09-01T09:00:00Z',
+ starred: true,
+ system_role: 'personal',
+ },
+ {
+ id: 'space-general',
+ name: 'general',
+ channel_type: 'public',
+ github_integration: null,
+ repositories: [],
+ auto_archive_after_days: null,
+ created_at: '2026-09-01T09:00:00Z',
+ starred: false,
+ system_role: 'general',
+ },
+ {
+ id: 'space-checkout',
+ name: 'checkout',
+ channel_type: 'public',
+ github_integration: null,
+ repositories: [],
+ auto_archive_after_days: null,
+ created_at: '2026-09-02T09:00:00Z',
+ starred: true,
+ system_role: null,
+ },
+]
+
+const CONVERSATIONS = [
+ { id: 'chat-1', title: 'Why did signups spike on Monday?', status: 'idle', type: 'assistant' },
+ { id: 'chat-2', title: 'Weekly retention by plan', status: 'idle', type: 'assistant' },
+]
+
+const LIBRARY = [
+ { id: 'fs-1', path: 'Unfiled/Insights/Checkout funnel', type: 'insight', ref: 'abc123' },
+ { id: 'fs-2', path: 'Unfiled/Dashboards/Growth overview', type: 'dashboard', ref: '12' },
+ { id: 'fs-3', path: 'Unfiled/Feature flags/one-page-checkout', type: 'feature_flag', ref: '7' },
+]
+
+const REPORTS = [
+ makeReport({
+ id: 'report-1',
+ title: 'Signup form rejects plus-addressed emails',
+ summary:
+ 'Sign-ups with a plus sign in the email address fail validation since the last release.\n\n## Impact\n\nNew teams that use plus addressing cannot finish signing up.',
+ status: SignalReportStatus.READY,
+ signal_count: 12,
+ updated_at: '2026-09-28T07:00:00Z',
+ priority: 'P1',
+ actionability: 'immediately_actionable',
+ source_products: ['error_tracking', 'session_replay'],
+ implementation_pr_url: 'https://github.com/example/app/pull/42',
+ }),
+ makeReport({
+ id: 'report-2',
+ title: 'Pricing page visitors drop off at the plan table',
+ summary: 'Most visitors who reach the plan table leave without starting a trial.',
+ status: SignalReportStatus.READY,
+ signal_count: 5,
+ updated_at: '2026-09-27T16:00:00Z',
+ priority: 'P3',
+ actionability: 'requires_human_input',
+ source_products: ['analytics'],
+ suggested_prompts: [
+ 'Which plans do visitors compare before they leave?',
+ 'Draft an experiment for the plan table',
+ ],
+ }),
+ makeReport({
+ id: 'report-3',
+ title: 'LLM costs doubled for the summarize tool',
+ summary: 'Token usage for the summarize tool doubled after the prompt change.',
+ status: SignalReportStatus.PENDING_INPUT,
+ signal_count: 3,
+ updated_at: '2026-09-27T10:00:00Z',
+ priority: 'P2',
+ actionability: 'immediately_actionable',
+ source_products: ['llm_analytics'],
+ }),
+]
+
+// Today keeps sample mode, the open pane and the sidebar width in local storage, which outlives a story.
+// Clearing it makes each story start clean, so only the sample stories show sample reports.
+function clearTodayStorage(Story: () => JSX.Element): JSX.Element {
+ for (const key of Object.keys(window.localStorage)) {
+ if (/today/i.test(key)) {
+ window.localStorage.removeItem(key)
+ }
+ }
+ return <Story />
+}
+
+const meta: Meta = {
+ component: App,
+ title: 'Scenes-App/Project Homepage/Today',
+ // No snapshots while the Today layout is still changing quickly. The stories stay for local development.
+ tags: ['test-skip'],
+ decorators: [
+ clearTodayStorage,
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/signals/reports/': { results: REPORTS, count: 7 },
+ '/api/projects/:team_id/signals/reports/:id/': (req) => [
+ 200,
+ REPORTS.find((report) => report.id === req.params.id) ?? REPORTS[0],
+ ],
+ '/api/projects/:team_id/signals/reports/:id/signals/': (req) => [
+ 200,
+ // Error tracking signals fetch their issue, which these stories do not mock.
+ {
+ signals: mockSignals(String(req.params.id), 6).filter(
+ (signal) => signal.source_product !== 'error_tracking'
+ ),
+ },
+ ],
+ '/api/projects/:team_id/task_channels/': SPACES,
+ '/api/projects/:team_id/tasks/': EMPTY_PAGINATED_RESPONSE,
+ '/api/environments/:team_id/conversations/': { results: CONVERSATIONS, next: null },
+ '/api/environments/:team_id/file_system/': ({ request }) => {
+ const type = new URL(request.url).searchParams.get('type')
+ const results = type ? LIBRARY.filter((entry) => entry.type === type) : LIBRARY
+ return [200, { results, count: results.length }]
+ },
+ '/api/environments/:team_id/file_system/unfiled/': { results: [], count: 0 },
+ },
+ }),
+ ],
+ parameters: {
+ layout: 'fullscreen',
+ viewMode: 'story',
+ mockDate: '2026-09-28 18:30:00',
+ pageUrl: urls.projectHomepage(),
+ featureFlags: [FEATURE_FLAGS.TODAY_RAIL_NAV],
+ testOptions: { waitForLoadersToDisappear: true },
+ },
+}
+export default meta
+
+type Story = StoryObj<{}>
+
+export const Home: Story = {}
+
+export const HomeWithSampleReports: Story = {
+ parameters: { pageUrl: `${urls.projectHomepage()}?sample=1` },
+}
+
+export const SampleReportPage: Story = {
+ parameters: { pageUrl: `${urls.todayReport('sample-pr')}?sample=1` },
+}
+
+export const HomeWithNoReports: Story = {
+ decorators: [
+ mswDecorator({
+ get: { '/api/projects/:team_id/signals/reports/': EMPTY_PAGINATED_RESPONSE },
+ }),
+ ],
+}
+
+export const HomeWhenReportsFailToLoad: Story = {
+ decorators: [
+ mswDecorator({
+ get: { '/api/projects/:team_id/signals/reports/': () => [500, { detail: 'Server error' }] },
+ }),
+ ],
+}
+
+export const ReportWithPullRequest: Story = {
+ parameters: { pageUrl: urls.todayReport('report-1') },
+}
+
+export const ReportWithSuggestedPrompts: Story = {
+ parameters: { pageUrl: urls.todayReport('report-2') },
+}
+
+export const SpacesPane: Story = {
+ play: async ({ canvasElement }) => {
+ await userEvent.click(await within(canvasElement).findByLabelText('Spaces'))
+ },
+}
+
+export const LibraryAllObjects: Story = {
+ parameters: { pageUrl: urls.library() },
+}
+
+export const LibraryFeatureFlags: Story = {
+ parameters: { pageUrl: urls.library('feature_flag') },
+}
+
+export const ToolsPane: Story = {
+ play: async ({ canvasElement }) => {
+ await userEvent.click(await within(canvasElement).findByLabelText('Tools'))
+ },
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx b/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx
new file mode 100644
index 000000000000..d3bb54e98114
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx
@@ -0,0 +1,48 @@
+import { useActions } from 'kea'
+import { useState } from 'react'
+
+import { IconArrowRight } from '@posthog/icons'
+
+import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
+
+/** Sends the question to PostHog AI, which answers in a new tab. */
+export function TodayAskBox(): JSX.Element {
+ const { askSidePanelMax } = useActions(maxGlobalLogic)
+ const [question, setQuestion] = useState('')
+ const [sentQuestion, setSentQuestion] = useState<string | null>(null)
+
+ return (
+ <>
+ <form
+ className="TodayAsk"
+ onSubmit={(event) => {
+ event.preventDefault()
+ const trimmed = question.trim()
+ if (trimmed) {
+ askSidePanelMax(trimmed)
+ setSentQuestion(trimmed)
+ setQuestion('')
+ }
+ }}
+ >
+ <input
+ value={question}
+ onChange={(event) => setQuestion(event.target.value)}
+ placeholder="What would you like to know?"
+ aria-label="Ask PostHog AI"
+ data-attr="today-ask-input"
+ />
+ <button
+ type="submit"
+ className="TodaySend"
+ aria-label="Send question"
+ disabled={!question.trim()}
+ data-attr="today-ask-send"
+ >
+ <IconArrowRight />
+ </button>
+ </form>
+ {sentQuestion && <div className="TodayAsk__sent">{`Asked PostHog AI: “${sentQuestion}”`}</div>}
+ </>
+ )
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodayBriefing.tsx b/frontend/src/scenes/project-homepage/today/TodayBriefing.tsx
new file mode 100644
index 000000000000..10bcffe4744c
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodayBriefing.tsx
@@ -0,0 +1,165 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonBanner } from '@posthog/lemon-ui'
+
+import { Link } from 'lib/lemon-ui/Link'
+import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
+import { urls } from 'scenes/urls'
+
+import { TodayAskBox } from './TodayAskBox'
+import { TodayIcon } from './TodayIcon'
+import { todayLogic } from './todayLogic'
+import { TodaySampleBanner } from './TodaySampleBanner'
+import { TodayBriefingSegment, reportIcon, reportSource } from './todaySignalReports'
+
+const DATE_FORMAT = new Intl.DateTimeFormat(undefined, { weekday: 'short', day: 'numeric', month: 'short' })
+const TIME_FORMAT = new Intl.DateTimeFormat(undefined, { hour: '2-digit', minute: '2-digit' })
+
+function TodayMetaLine(): JSX.Element {
+ const { now, currentTeam } = useValues(todayLogic)
+ const date = new Date(now)
+ return (
+ <div className="TodayHome__meta">
+ <span>{`${currentTeam?.name ?? 'Your project'} · ${DATE_FORMAT.format(date)} · `}</span>
+ <time translate="no">{TIME_FORMAT.format(date)}</time>
+ </div>
+ )
+}
+
+function BriefingSegment({ segment }: { segment: TodayBriefingSegment }): JSX.Element {
+ const { hoveredReportId, reports } = useValues(todayLogic)
+ const { reportOpened, setHoveredReportId } = useActions(todayLogic)
+ const { reportId } = segment
+ if (!reportId) {
+ return <span>{segment.text}</span>
+ }
+ // A briefing can link a report outside the top five, which has no row to open it from.
+ const report = reports.find((candidate) => candidate.id === reportId)
+ const link = (
+ <Link
+ to={urls.todayReport(reportId)}
+ subtle
+ className="TodayReportLink"
+ data-active={hoveredReportId === reportId}
+ data-attr="today-briefing-report"
+ onClick={() => report && reportOpened(report, 'briefing')}
+ onMouseEnter={() => setHoveredReportId(reportId)}
+ onMouseLeave={() => setHoveredReportId(null)}
+ >
+ {segment.text}
+ </Link>
+ )
+ return segment.highlight ? <span className="TodayHome__highlight">{link}</span> : link
+}
+
+function TodayBriefingReports(): JSX.Element {
+ const { reportSummary, reports, briefing, hoveredReportId, moreReportCount } = useValues(todayLogic)
+ const { openReport, setHoveredReportId } = useActions(todayLogic)
+ const { askSidePanelMax } = useActions(maxGlobalLogic)
+
+ return (
+ <>
+ <p className="TodayHome__count">
+ <span>{reportSummary}</span>
+ <span className="TodayChipStack">
+ {reports.map((report, index) => (
+ <button
+ key={report.id}
+ type="button"
+ className="TodayChipStack__chip"
+ aria-label={`Open ${report.title ?? 'report'}`}
+ data-active={hoveredReportId === report.id}
+ data-attr="today-briefing-chip"
+ // eslint-disable-next-line react/forbid-dom-props
+ style={
+ {
+ '--index': index,
+ '--tilt': index % 2 === 0 ? '-3deg' : '3deg',
+ '--report-color': reportSource(report).color,
+ } as React.CSSProperties
+ }
+ onClick={() => openReport(report, 'chip')}
+ onMouseEnter={() => setHoveredReportId(report.id)}
+ onMouseLeave={() => setHoveredReportId(null)}
+ >
+ <TodayIcon icon={reportIcon(report)} />
+ </button>
+ ))}
+ </span>
+ </p>
+ {briefing.map((paragraph, index) => (
+ <p key={index}>
+ {paragraph.map((segment, segmentIndex) => (
+ <BriefingSegment key={segmentIndex} segment={segment} />
+ ))}
+ </p>
+ ))}
+ <p className="TodayHome__foot">
+ {moreReportCount > 0 && (
+ <>
+ <Link to={urls.inbox()} data-attr="today-briefing-inbox">
+ {`${moreReportCount} more ${moreReportCount === 1 ? 'report is' : 'reports are'} in the Inbox`}
+ </Link>
+ <span>. </span>
+ </>
+ )}
+ <span>Or </span>
+ <button
+ type="button"
+ data-attr="today-ask-about-edition"
+ onClick={() => askSidePanelMax('Walk me through what changed in my product today.')}
+ >
+ ask PostHog AI to walk you through it
+ </button>
+ <span>.</span>
+ </p>
+ </>
+ )
+}
+
+export function TodayBriefing(): JSX.Element {
+ const { greeting, topReports, topReportsLoading, reportsFailed, reports } = useValues(todayLogic)
+ const { loadTopReports } = useActions(todayLogic)
+
+ return (
+ <div className="TodayHome Today__page">
+ <TodaySampleBanner />
+ <TodayMetaLine />
+ <section className="TodayHome__intro" aria-label="Daily brief">
+ <div className="TodayHome__greeting">{greeting}</div>
+ {topReports === null && reportsFailed ? (
+ <LemonBanner
+ type="error"
+ action={{
+ children: 'Try again',
+ onClick: () => loadTopReports(),
+ loading: topReportsLoading,
+ 'data-attr': 'today-reports-retry',
+ }}
+ >
+ Couldn’t load your reports. Try again, or open the Inbox to see them there.
+ </LemonBanner>
+ ) : topReports === null ? (
+ <p>Reading what changed in your project…</p>
+ ) : reports.length === 0 ? (
+ <>
+ <p className="TodayHome__count">Nothing needs your attention</p>
+ <p>
+ <span>
+ Self-driving turns signals from across PostHog into reports worth acting on. New ones
+ show up here as it finds them.{' '}
+ </span>
+ <Link to={urls.inbox()} data-attr="today-empty-inbox">
+ Open the Inbox
+ </Link>
+ <span> to see everything it’s tracking.</span>
+ </p>
+ </>
+ ) : (
+ <TodayBriefingReports />
+ )}
+ </section>
+ <TodayAskBox />
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodayHome.tsx b/frontend/src/scenes/project-homepage/today/TodayHome.tsx
new file mode 100644
index 000000000000..538ae70aa715
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodayHome.tsx
@@ -0,0 +1,18 @@
+import './Today.scss'
+
+import { useValues } from 'kea'
+
+import { TodayBriefing } from './TodayBriefing'
+import { todayLogic } from './todayLogic'
+import { TodayReportPage } from './TodayReportPage'
+
+/** The Today homepage: the daily briefing at `/home`, or one report at `/home/reports/:reportId`. */
+export function TodayHome(): JSX.Element {
+ const { reportId } = useValues(todayLogic)
+
+ return (
+ <div className="Today flex-1 min-h-full @container/today">
+ {reportId ? <TodayReportPage key={reportId} reportId={reportId} /> : <TodayBriefing />}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodayHomeSidebar.tsx b/frontend/src/scenes/project-homepage/today/TodayHomeSidebar.tsx
new file mode 100644
index 000000000000..bcfc7fbabe78
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodayHomeSidebar.tsx
@@ -0,0 +1,73 @@
+import { useActions, useValues } from 'kea'
+
+import { IconHome, IconPlus } from '@posthog/icons'
+import { LemonButton, LemonSkeleton } from '@posthog/lemon-ui'
+
+import { Link } from 'lib/lemon-ui/Link'
+import { urls } from 'scenes/urls'
+
+import { TodayIcon } from './TodayIcon'
+import { todayLogic } from './todayLogic'
+import { TodayNavItem } from './TodayNavItem'
+import { reportIcon, reportMeta, reportSource, reportTitle } from './todaySignalReports'
+
+export function TodayHomeSidebar(): JSX.Element {
+ const { reportId, reports, topReports, reportsFailed, hoveredReportId, reportSummary, moreReportCount } =
+ useValues(todayLogic)
+ const { reportOpened, setHoveredReportId } = useActions(todayLogic)
+
+ return (
+ <div className="TodaySidebar">
+ <LemonButton type="primary" fullWidth center icon={<IconPlus />} to={urls.ai()} data-attr="today-new-chat">
+ New chat
+ </LemonButton>
+ <div className="TodaySidebar__scroll">
+ <div className="TodaySidebar__sectionLabel Today__label">Today</div>
+ <div className="TodaySidebar__list">
+ <TodayNavItem
+ title="Home"
+ meta={
+ topReports === null
+ ? reportsFailed
+ ? 'Reports didn’t load'
+ : 'Reading your project…'
+ : reportSummary
+ }
+ color="var(--color-text-secondary)"
+ icon={<IconHome />}
+ to={urls.projectHomepage()}
+ current={reportId === null}
+ dataAttr="today-nav-home"
+ />
+ {topReports === null && !reportsFailed ? (
+ <>
+ <LemonSkeleton className="h-12" />
+ <LemonSkeleton className="h-12" />
+ </>
+ ) : (
+ reports.map((report) => (
+ <TodayNavItem
+ key={report.id}
+ title={reportTitle(report)}
+ meta={reportMeta(report)}
+ color={reportSource(report).color}
+ icon={<TodayIcon icon={reportIcon(report)} />}
+ to={urls.todayReport(report.id)}
+ active={hoveredReportId === report.id}
+ current={reportId === report.id}
+ dataAttr="today-nav-report"
+ onClick={() => reportOpened(report, 'sidebar')}
+ onHoverChange={(hovered) => setHoveredReportId(hovered ? report.id : null)}
+ />
+ ))
+ )}
+ </div>
+ {moreReportCount > 0 && (
+ <Link to={urls.inbox()} className="TodaySidebar__more" data-attr="today-nav-inbox">
+ {`${moreReportCount} more in the Inbox`}
+ </Link>
+ )}
+ </div>
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodayIcon.tsx b/frontend/src/scenes/project-homepage/today/TodayIcon.tsx
new file mode 100644
index 000000000000..07c5036d2b62
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodayIcon.tsx
@@ -0,0 +1,27 @@
+import {
+ IconBell,
+ IconMessage,
+ IconPullRequest,
+ IconPulse,
+ IconRewindPlay,
+ IconSparkles,
+ IconTrends,
+ IconWarning,
+} from '@posthog/icons'
+
+import { TodayReportIcon } from './todaySignalReports'
+
+const REPORT_ICONS: Record<TodayReportIcon, JSX.Element> = {
+ pr: <IconPullRequest />,
+ replay: <IconRewindPlay />,
+ error: <IconWarning />,
+ llm: <IconSparkles />,
+ survey: <IconMessage />,
+ analytics: <IconTrends />,
+ trace: <IconPulse />,
+ inbox: <IconBell />,
+}
+
+export function TodayIcon({ icon }: { icon: TodayReportIcon }): JSX.Element {
+ return REPORT_ICONS[icon]
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodayNavItem.tsx b/frontend/src/scenes/project-homepage/today/TodayNavItem.tsx
new file mode 100644
index 000000000000..3050f9bb10f2
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodayNavItem.tsx
@@ -0,0 +1,55 @@
+import { Link } from 'lib/lemon-ui/Link'
+
+interface TodayNavItemProps {
+ title: string
+ meta: string
+ color: string
+ icon: JSX.Element
+ to: string
+ /** Highlighted because the matching report is hovered elsewhere on the page. */
+ active?: boolean
+ current?: boolean
+ onClick?: () => void
+ onHoverChange?: (hovered: boolean) => void
+ dataAttr?: string
+}
+
+export function TodayNavItem({
+ title,
+ meta,
+ color,
+ icon,
+ to,
+ active = false,
+ current = false,
+ onClick,
+ onHoverChange,
+ dataAttr,
+}: TodayNavItemProps): JSX.Element {
+ return (
+ <Link
+ to={to}
+ subtle
+ className="TodayNavItem"
+ data-active={active || current}
+ aria-current={current ? 'page' : undefined}
+ data-attr={dataAttr}
+ onClick={onClick}
+ onMouseEnter={() => onHoverChange?.(true)}
+ onMouseLeave={() => onHoverChange?.(false)}
+ >
+ <span
+ className="TodayNavItem__marker"
+ aria-hidden
+ // eslint-disable-next-line react/forbid-dom-props
+ style={{ '--report-color': color } as React.CSSProperties}
+ >
+ {icon}
+ </span>
+ <span className="TodayNavItem__copy">
+ <span className="TodayNavItem__title">{title}</span>
+ <span className="TodayNavItem__meta">{meta}</span>
+ </span>
+ </Link>
+ )
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodayReportEvidence.tsx b/frontend/src/scenes/project-homepage/today/TodayReportEvidence.tsx
new file mode 100644
index 000000000000..2e8607bec348
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodayReportEvidence.tsx
@@ -0,0 +1,56 @@
+import { useValues } from 'kea'
+
+import { LemonSkeleton } from '@posthog/lemon-ui'
+
+import { Link } from 'lib/lemon-ui/Link'
+import { urls } from 'scenes/urls'
+
+import { SignalCard } from 'products/signals/frontend/inbox/SignalCard'
+
+import { todayReportLogic } from './todayReportLogic'
+import { isSampleReportId } from './todaySampleReports'
+
+const SHOWN_SIGNAL_COUNT = 3
+
+/** The newest signals behind the report. The full list stays in the Inbox. */
+export function TodayReportEvidence({ reportId }: { reportId: string }): JSX.Element {
+ const { signals, reportSignals, reportSignalsLoading } = useValues(todayReportLogic({ reportId }))
+ const inboxUrl = urls.inboxReport('reports', reportId)
+
+ return (
+ <section className="TodayEvidence" aria-label="Evidence">
+ <div className="Today__label">
+ {reportSignals === null
+ ? 'Evidence'
+ : `Evidence · ${signals.length} ${signals.length === 1 ? 'signal' : 'signals'}`}
+ </div>
+ {reportSignals === null && reportSignalsLoading ? (
+ <div className="flex flex-col gap-3">
+ <LemonSkeleton className="h-20" />
+ <LemonSkeleton className="h-20" />
+ </div>
+ ) : reportSignals === null ? (
+ <p className="TodayEvidence__note">
+ <span>Couldn’t load the evidence. </span>
+ <Link to={inboxUrl} data-attr="today-evidence-inbox">
+ Open the report in the Inbox
+ </Link>
+ <span> to see it there.</span>
+ </p>
+ ) : signals.length === 0 ? (
+ <p className="TodayEvidence__note">No signals are attached to this report yet.</p>
+ ) : (
+ <div className="flex flex-col gap-3">
+ {signals.slice(0, SHOWN_SIGNAL_COUNT).map((signal) => (
+ <SignalCard key={signal.signal_id} signal={signal} />
+ ))}
+ {signals.length > SHOWN_SIGNAL_COUNT && !isSampleReportId(reportId) && (
+ <Link to={inboxUrl} className="text-sm" data-attr="today-evidence-inbox">
+ {`See all ${signals.length} signals in the Inbox`}
+ </Link>
+ )}
+ </div>
+ )}
+ </section>
+ )
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodayReportPage.tsx b/frontend/src/scenes/project-homepage/today/TodayReportPage.tsx
new file mode 100644
index 000000000000..ea9872e87f3b
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodayReportPage.tsx
@@ -0,0 +1,112 @@
+import { useActions, useValues } from 'kea'
+
+import { IconExternal } from '@posthog/icons'
+import { LemonButton, LemonSkeleton, LemonTag } from '@posthog/lemon-ui'
+
+import { urls } from 'scenes/urls'
+
+import { ReportChart } from 'products/signals/frontend/inbox/components/detail/ReportChart'
+import { ReportSummaryBody } from 'products/signals/frontend/inbox/components/detail/ReportSummaryBody'
+
+import { TodayIcon } from './TodayIcon'
+import { TodayReportEvidence } from './TodayReportEvidence'
+import { todayReportLogic } from './todayReportLogic'
+import { TodayReportPrompts } from './TodayReportPrompts'
+import { TodaySampleBanner } from './TodaySampleBanner'
+import { isSampleReportId } from './todaySampleReports'
+import { reportIcon, reportMeta, reportSource, reportTitle } from './todaySignalReports'
+
+export function TodayReportPage({ reportId }: { reportId: string }): JSX.Element {
+ const logic = todayReportLogic({ reportId })
+ const { currentReport, reportFailed, fullReportLoading, chartPlacements, trailingCharts, reportUrl } =
+ useValues(logic)
+ const { loadFullReport } = useActions(logic)
+ const sampleDisabledReason = isSampleReportId(reportId) ? 'This is a sample report.' : undefined
+
+ if (!currentReport) {
+ return reportFailed ? (
+ <div className="TodayReport Today__page">
+ <TodaySampleBanner />
+ <h1 className="TodayReport__heading">Couldn’t open this report.</h1>
+ <div className="TodayReport__body">
+ <p>It may have been deleted, or the request failed. Try again, or go back to today’s briefing.</p>
+ </div>
+ <div className="flex flex-wrap gap-2 mt-6">
+ <LemonButton
+ type="primary"
+ onClick={() => loadFullReport()}
+ loading={fullReportLoading}
+ data-attr="today-report-retry"
+ >
+ Try again
+ </LemonButton>
+ <LemonButton type="secondary" to={urls.projectHomepage()} data-attr="today-report-missing-home">
+ Back to Home
+ </LemonButton>
+ </div>
+ </div>
+ ) : (
+ <div className="TodayReport Today__page flex flex-col gap-4">
+ <LemonSkeleton className="h-4 w-48" />
+ <LemonSkeleton className="h-10 w-3/4" />
+ <LemonSkeleton className="h-24" />
+ </div>
+ )
+ }
+
+ return (
+ <div
+ className="TodayReport Today__page"
+ // eslint-disable-next-line react/forbid-dom-props
+ style={{ '--report-color': reportSource(currentReport).color } as React.CSSProperties}
+ >
+ <TodaySampleBanner />
+ <article>
+ <div className="TodayReport__kicker">
+ <span className="TodayTile">
+ <TodayIcon icon={reportIcon(currentReport)} />
+ </span>
+ <span>{reportMeta(currentReport)}</span>
+ {currentReport.priority && <LemonTag type="muted">{currentReport.priority}</LemonTag>}
+ </div>
+ <h1 className="TodayReport__heading">{reportTitle(currentReport)}</h1>
+ <div className="flex flex-wrap gap-2 mt-4">
+ {currentReport.implementation_pr_url && (
+ <LemonButton
+ type="primary"
+ size="small"
+ to={currentReport.implementation_pr_url}
+ targetBlank
+ sideIcon={<IconExternal />}
+ disabledReason={sampleDisabledReason}
+ data-attr="today-report-pull-request"
+ >
+ Review the pull request
+ </LemonButton>
+ )}
+ <LemonButton
+ type="secondary"
+ size="small"
+ to={urls.inboxReport('reports', currentReport.id)}
+ disabledReason={sampleDisabledReason}
+ data-attr="today-report-open-inbox"
+ >
+ Open in Inbox
+ </LemonButton>
+ </div>
+ <div className="TodayReport__body">
+ {currentReport.summary ? (
+ <ReportSummaryBody summary={currentReport.summary} chartPlacements={chartPlacements} />
+ ) : (
+ <p>No summary yet. An agent is still investigating.</p>
+ )}
+ {trailingCharts.map((chart) => (
+ <ReportChart key={chart.chart_id} chartId={chart.chart_id} />
+ ))}
+ </div>
+ </article>
+ <TodayReportEvidence reportId={currentReport.id} />
+ <TodayReportPrompts report={currentReport} reportUrl={reportUrl} />
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodayReportPrompts.tsx b/frontend/src/scenes/project-homepage/today/TodayReportPrompts.tsx
new file mode 100644
index 000000000000..91a8bad8b648
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodayReportPrompts.tsx
@@ -0,0 +1,110 @@
+import { useActions, useValues } from 'kea'
+import { useRef, useState } from 'react'
+
+import { IconSparkles } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import { Composer } from 'products/posthog_ai/frontend/api/primitives'
+import {
+ InboxQuestionSource,
+ captureInboxReportAction,
+ discussQuestionProperties,
+} from 'products/signals/frontend/inbox/inboxAnalytics'
+import {
+ REPORT_DISCUSSION_QUESTION_MAX_LENGTH,
+ inboxTaskKickoffLogic,
+} from 'products/signals/frontend/inbox/inboxTaskKickoffLogic'
+import { SignalReport } from 'products/signals/frontend/inbox/types'
+
+import { isSampleReportId } from './todaySampleReports'
+import { reportPrompts } from './todaySignalReports'
+
+/** Prompts that fill the composer, which starts a PostHog AI session about the report. */
+export function TodayReportPrompts({ report, reportUrl }: { report: SignalReport; reportUrl: string }): JSX.Element {
+ const { isDiscussing, isCreatingPr, aiConsentDisabledReason } = useValues(inboxTaskKickoffLogic)
+ const { openReportDiscussion, discussReport } = useActions(inboxTaskKickoffLogic)
+ const textAreaRef = useRef<HTMLTextAreaElement>(null)
+ const [draft, setDraft] = useState('')
+ const [pickedPrompt, setPickedPrompt] = useState<string | null>(null)
+ const prompts = reportPrompts(report)
+ const loading = isDiscussing || isCreatingPr
+ const isOverLengthLimit = Array.from(draft.trim()).length > REPORT_DISCUSSION_QUESTION_MAX_LENGTH
+ const disabledReason = isSampleReportId(report.id)
+ ? 'Sample reports can’t start a session. Turn off sample reports to ask about a real one.'
+ : isOverLengthLimit
+ ? `Your message is too long. Shorten it to ${REPORT_DISCUSSION_QUESTION_MAX_LENGTH.toLocaleString()} characters or fewer.`
+ : (aiConsentDisabledReason ?? undefined)
+
+ const pickPrompt = (prompt: string): void => {
+ setDraft(prompt)
+ setPickedPrompt(prompt)
+ textAreaRef.current?.focus()
+ }
+
+ const submit = (): void => {
+ const question = draft.trim()
+ if (!question || loading || disabledReason) {
+ return
+ }
+ const source: InboxQuestionSource =
+ pickedPrompt === null ? 'typed' : pickedPrompt === question ? 'suggested' : 'edited_suggestion'
+ captureInboxReportAction({
+ report,
+ actionType: 'discuss',
+ surface: 'today',
+ extra: discussQuestionProperties({ source, suggestionCount: prompts.length }),
+ })
+ // Pointing the side panel at this report first makes the new session open there, even when the
+ // panel still shows a discussion about another report.
+ openReportDiscussion(report, reportUrl)
+ discussReport(report, reportUrl, question)
+ setDraft('')
+ setPickedPrompt(null)
+ }
+
+ return (
+ <section className="TodayPrompts" aria-label="Ask about this report">
+ <div className="Today__label">Ask about this report</div>
+ <div className="flex flex-wrap gap-2">
+ {prompts.map((prompt) => (
+ <LemonButton
+ key={prompt}
+ type="secondary"
+ size="small"
+ icon={<IconSparkles />}
+ onClick={() => pickPrompt(prompt)}
+ disabledReason={loading ? 'A session is starting.' : undefined}
+ data-attr="today-report-prompt"
+ >
+ {prompt}
+ </LemonButton>
+ ))}
+ </div>
+ <Composer.Root
+ value={draft}
+ onChange={(value) => {
+ setDraft(value)
+ if (!value) {
+ setPickedPrompt(null)
+ }
+ }}
+ onSubmit={submit}
+ loading={loading}
+ disabled={loading}
+ disabledReason={disabledReason}
+ textAreaRef={textAreaRef}
+ >
+ <Composer.Frame>
+ <Composer.Field>
+ <Composer.Placeholder>Ask a question, or pick a prompt above</Composer.Placeholder>
+ <Composer.Textarea data-attr="today-report-prompt-input" />
+ </Composer.Field>
+ </Composer.Frame>
+ <Composer.Submit data-attr="today-report-prompt-submit" />
+ </Composer.Root>
+ <p className="TodayPrompts__hint">
+ Starts a PostHog AI session with this report attached. It opens in the side panel.
+ </p>
+ </section>
+ )
+}
diff --git a/frontend/src/scenes/project-homepage/today/TodaySampleBanner.tsx b/frontend/src/scenes/project-homepage/today/TodaySampleBanner.tsx
new file mode 100644
index 000000000000..e8c0779ec001
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/TodaySampleBanner.tsx
@@ -0,0 +1,27 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonBanner } from '@posthog/lemon-ui'
+
+import { todayLogic } from './todayLogic'
+
+/** Says the page shows sample reports, so nobody mistakes them for the project's own. */
+export function TodaySampleBanner(): JSX.Element | null {
+ const { useSampleData } = useValues(todayLogic)
+ const { setUseSampleData } = useActions(todayLogic)
+ if (!useSampleData) {
+ return null
+ }
+ return (
+ <LemonBanner
+ type="info"
+ className="mb-8"
+ action={{
+ children: 'Show my reports',
+ onClick: () => setUseSampleData(false),
+ 'data-attr': 'today-sample-data-off',
+ }}
+ >
+ You’re looking at sample reports, not your project’s. They stay on until you turn them off.
+ </LemonBanner>
+ )
+}
diff --git a/frontend/src/scenes/project-homepage/today/todayLogic.test.ts b/frontend/src/scenes/project-homepage/today/todayLogic.test.ts
new file mode 100644
index 000000000000..481f7232d03e
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/todayLogic.test.ts
@@ -0,0 +1,107 @@
+import { router } from 'kea-router'
+import { expectLogic } from 'kea-test-utils'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { makeReport } from 'products/signals/frontend/inbox/__mocks__/inboxMocks'
+import { SignalReport } from 'products/signals/frontend/inbox/types'
+
+import { TOP_REPORT_COUNT, reportIdFromPath, todayLogic } from './todayLogic'
+import { isSampleReportId } from './todaySampleReports'
+import { GENERAL_REPORT_PROMPTS, briefingForReports, reportPrompts } from './todaySignalReports'
+
+describe('todayLogic', () => {
+ let listResponse: [number, any]
+ let listParams: URLSearchParams | null
+
+ beforeEach(() => {
+ listResponse = [200, { results: [], count: 0 }]
+ listParams = null
+ useMocks({
+ get: {
+ '/api/projects/:team_id/signals/reports/': ({ request }) => {
+ listParams = new URL(request.url).searchParams
+ return listResponse
+ },
+ },
+ })
+ initKeaTests()
+ })
+
+ it('asks for the top actionable reports by priority and counts the rest', async () => {
+ const reports = [makeReport({ id: 'a' }), makeReport({ id: 'b' })]
+ listResponse = [200, { results: reports, count: 9 }]
+ const logic = todayLogic()
+ logic.mount()
+
+ await expectLogic(logic).toFinishAllListeners().toMatchValues({ reports, moreReportCount: 7 })
+ expect(Object.fromEntries(listParams!.entries())).toMatchObject({
+ status: 'ready,pending_input',
+ actionability: 'immediately_actionable,requires_human_input',
+ ordering: 'priority,-updated_at',
+ limit: String(TOP_REPORT_COUNT),
+ })
+ })
+
+ it('shows sample reports from ?sample=1 without asking the API, until ?sample=0', async () => {
+ router.actions.push('/project/1/home', { sample: '1' })
+ const logic = todayLogic()
+ logic.mount()
+
+ await expectLogic(logic).toFinishAllListeners()
+ expect(listParams).toBeNull()
+ expect(logic.values.reports.map((report) => isSampleReportId(report.id))).toEqual(
+ Array(TOP_REPORT_COUNT).fill(true)
+ )
+
+ router.actions.push('/project/1/home', { sample: '0' })
+ await expectLogic(logic).toFinishAllListeners().toMatchValues({ useSampleData: false, reports: [] })
+ expect(listParams).not.toBeNull()
+ })
+
+ it('keeps a failed load apart from an empty list', async () => {
+ listResponse = [500, { detail: 'Server error' }]
+ const logic = todayLogic()
+ logic.mount()
+
+ await expectLogic(logic).toFinishAllListeners().toMatchValues({ topReports: null, reportsFailed: true })
+ })
+
+ test.each([
+ ['/project/1/home/reports/abc', 'abc'],
+ ['/home/reports/abc/', 'abc'],
+ ['/project/1/home', null],
+ ['/project/1/home/reports/abc/signals', null],
+ ['/project/1/inbox/reports/abc', null],
+ ])('reads the report id from %s', (pathname, reportId) => {
+ expect(reportIdFromPath(pathname)).toBe(reportId)
+ })
+
+ it('links every report from the briefing and keeps acronyms in titles', () => {
+ const briefing = briefingForReports([
+ makeReport({
+ id: 'a',
+ title: 'Signup form rejects emails',
+ implementation_pr_url: 'https://example.com/1',
+ }),
+ makeReport({ id: 'b', title: 'Pricing page drops off' }),
+ makeReport({ id: 'c', title: 'LLM costs doubled' }),
+ ])
+
+ expect(briefing.flat().filter((segment) => segment.reportId)).toEqual([
+ { text: 'Signup form rejects emails', reportId: 'a', highlight: true },
+ { text: 'pricing page drops off', reportId: 'b' },
+ { text: 'LLM costs doubled', reportId: 'c' },
+ ])
+ })
+
+ test.each([
+ ['an action-capable report', {}, ['Draft the fix']],
+ ['a report with a pull request', { implementation_pr_url: 'https://example.com/1' }, GENERAL_REPORT_PROMPTS],
+ ['a report judged not actionable', { actionability: 'not_actionable' }, GENERAL_REPORT_PROMPTS],
+ ])('offers the right prompts for %s', (_, overrides, expected) => {
+ const report = makeReport({ suggested_prompts: ['Draft the fix'], ...(overrides as Partial<SignalReport>) })
+ expect(reportPrompts(report)).toEqual(expected)
+ })
+})
diff --git a/frontend/src/scenes/project-homepage/today/todayLogic.ts b/frontend/src/scenes/project-homepage/today/todayLogic.ts
new file mode 100644
index 000000000000..4bb48fe298a0
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/todayLogic.ts
@@ -0,0 +1,306 @@
+import { MakeLogicType, actions, afterMount, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+import { router } from 'kea-router'
+import type { LocationChangedPayload } from 'kea-router/lib/types'
+import posthog from 'posthog-js'
+
+import api from 'lib/api'
+import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+import { userLogic } from 'scenes/userLogic'
+
+import { TeamType, UserType } from '~/types'
+
+import { SignalReport } from 'products/signals/frontend/inbox/types'
+
+import type { TeamPublicType } from '../../../types'
+import { SAMPLE_BRIEFING, parseSampleParam, sampleTopReports } from './todaySampleReports'
+import { TodayBriefingSegment, briefingForReports } from './todaySignalReports'
+
+export const TOP_REPORT_COUNT = 5
+const CLOCK_MS = 30_000
+
+/** Where a report was opened from, sent with the `today report opened` event. */
+export type TodayReportOpenSource = 'briefing' | 'chip' | 'sidebar'
+
+export interface TodayReports {
+ results: SignalReport[]
+ /** Every report that matches the filter, including the ones past the top five. */
+ count: number
+}
+
+const COUNT_WORDS = ['No', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten']
+
+/** The report a Today report page shows, read from a path such as `/project/1/home/reports/abc`. */
+export function reportIdFromPath(pathname: string): string | null {
+ const match = removeProjectIdIfPresent(pathname).match(/^\/home\/reports\/([^/]+)\/?$/)
+ return match ? decodeURIComponent(match[1]) : null
+}
+
+export function countWord(count: number): string {
+ return COUNT_WORDS[count] ?? String(count)
+}
+
+export function greetingForHour(hour: number, name: string | null | undefined): string {
+ const suffix = name ? `, ${name}.` : '.'
+ if (hour < 5) {
+ return `You’re up late${suffix}`
+ }
+ if (hour < 12) {
+ return `Morning${suffix}`
+ }
+ if (hour < 17) {
+ return `Afternoon${suffix}`
+ }
+ return `Evening${suffix}`
+}
+
+export function reportSummaryForHour(hour: number, count: number): string {
+ if (count === 0) {
+ return 'Nothing needs your attention'
+ }
+ const reports = `${countWord(count)} ${count === 1 ? 'report' : 'reports'}`
+ const verb = count === 1 ? 'needs' : 'need'
+ if (hour < 5) {
+ return `${reports} ${count === 1 ? 'is' : 'are'} ready for tomorrow`
+ }
+ if (hour < 12) {
+ return `${reports} ${verb} your attention this morning`
+ }
+ if (hour < 17) {
+ return `${reports} ${verb} your attention this afternoon`
+ }
+ return `${reports} still ${verb} your attention`
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayLogicValues {
+ currentTeam: TeamPublicType | TeamType | null // teamLogic
+ user: UserType | null // userLogic
+ briefing: TodayBriefingSegment[][]
+ greeting: string
+ hour: number
+ hoveredReportId: string | null
+ moreReportCount: number
+ now: number
+ reportId: string | null
+ reportSummary: string
+ reports: SignalReport[]
+ reportsFailed: boolean
+ topReports: TodayReports | null
+ topReportsLoading: boolean
+ useSampleData: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayLogicActions {
+ locationChanged: ({
+ method,
+ pathname,
+ search,
+ searchParams,
+ hash,
+ hashParams,
+ initial,
+ url,
+ routerState,
+ }: LocationChangedPayload) => {
+ hash: string
+ hashParams: Record<string, any>
+ initial: boolean
+ method: 'POP' | 'PUSH' | 'REPLACE'
+ pathname: string
+ routerState: Record<string, any>
+ search: string
+ searchParams: Record<string, any>
+ url: string
+ } // router
+ loadTopReports: () => any
+ loadTopReportsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadTopReportsSuccess: (
+ topReports: TodayReports,
+ payload?: any
+ ) => {
+ topReports: TodayReports
+ payload?: any
+ }
+ openReport: (
+ report: SignalReport,
+ source: TodayReportOpenSource
+ ) => {
+ report: SignalReport
+ source: TodayReportOpenSource
+ }
+ reportOpened: (
+ report: SignalReport,
+ source: TodayReportOpenSource
+ ) => {
+ report: SignalReport
+ source: TodayReportOpenSource
+ }
+ setHoveredReportId: (reportId: string | null) => {
+ reportId: string | null
+ }
+ setUseSampleData: (useSampleData: boolean) => {
+ useSampleData: boolean
+ }
+ tick: () => {
+ value: true
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ reportId: (location: { hash: string; pathname: string; search: string }) => string | null
+ reports: (topReports: TodayReports | null) => SignalReport[]
+ moreReportCount: (topReports: TodayReports | null) => number
+ briefing: (reports: SignalReport[], useSampleData: boolean) => TodayBriefingSegment[][]
+ hour: (now: number) => number
+ greeting: (hour: number, user: UserType | null) => string
+ reportSummary: (hour: number, reports: SignalReport[]) => string
+ }
+}
+
+export type todayLogicType = MakeLogicType<todayLogicValues, todayLogicActions, Record<string, any>, todayLogicMeta>
+
+export const todayLogic = kea<todayLogicType>([
+ path(['scenes', 'project-homepage', 'today', 'todayLogic']),
+ connect(() => ({
+ values: [userLogic, ['user'], teamLogic, ['currentTeam']],
+ actions: [router, ['locationChanged']],
+ })),
+ actions({
+ setHoveredReportId: (reportId: string | null) => ({ reportId }),
+ openReport: (report: SignalReport, source: TodayReportOpenSource) => ({ report, source }),
+ reportOpened: (report: SignalReport, source: TodayReportOpenSource) => ({ report, source }),
+ setUseSampleData: (useSampleData: boolean) => ({ useSampleData }),
+ tick: true,
+ }),
+ loaders(({ values }) => ({
+ topReports: [
+ null as TodayReports | null,
+ {
+ loadTopReports: async (): Promise<TodayReports> => {
+ if (values.useSampleData) {
+ return sampleTopReports(TOP_REPORT_COUNT)
+ }
+ // The same filter as the Inbox's actionable view, ranked by priority, so Today shows
+ // the reports most worth acting on first.
+ // nosemgrep: prefer-codegen-api-namespaced-signals -- Today passes reports to the Inbox's helpers, which take the handwritten SignalReport. The generated report type is wider (string status and priority, read-only arrays), so this call moves to generated types together with the Inbox.
+ const response = await api.signalReports.list({
+ status: 'ready,pending_input',
+ actionability: 'immediately_actionable,requires_human_input',
+ ordering: 'priority,-updated_at',
+ limit: TOP_REPORT_COUNT,
+ })
+ return { results: response.results, count: response.count }
+ },
+ },
+ ],
+ })),
+ reducers({
+ // Turned on with `?sample=1` and kept until `?sample=0`, so the sample survives moving between pages.
+ useSampleData: [false, { persist: true }, { setUseSampleData: (_, { useSampleData }) => useSampleData }],
+ hoveredReportId: [
+ null as string | null,
+ {
+ setHoveredReportId: (_, { reportId }) => reportId,
+ locationChanged: () => null,
+ },
+ ],
+ reportsFailed: [
+ false,
+ {
+ loadTopReports: () => false,
+ loadTopReportsFailure: () => true,
+ },
+ ],
+ now: [Date.now(), { tick: () => Date.now() }],
+ }),
+ selectors({
+ reportId: [
+ () => [router.selectors.location],
+ (location: { pathname: string }): string | null => reportIdFromPath(location.pathname),
+ ],
+ reports: [
+ (s) => [s.topReports],
+ (topReports: TodayReports | null): SignalReport[] => topReports?.results ?? [],
+ ],
+ moreReportCount: [
+ (s) => [s.topReports],
+ (topReports: TodayReports | null): number =>
+ topReports ? Math.max(topReports.count - topReports.results.length, 0) : 0,
+ ],
+ briefing: [
+ (s) => [s.reports, s.useSampleData],
+ (reports: SignalReport[], useSampleData: boolean): TodayBriefingSegment[][] =>
+ useSampleData ? SAMPLE_BRIEFING : briefingForReports(reports),
+ ],
+ hour: [(s) => [s.now], (now: number): number => new Date(now).getHours()],
+ greeting: [
+ (s) => [s.hour, s.user],
+ (hour: number, user: UserType | null): string => greetingForHour(hour, user?.first_name),
+ ],
+ reportSummary: [
+ (s) => [s.hour, s.reports],
+ (hour: number, reports: SignalReport[]): string => reportSummaryForHour(hour, reports.length),
+ ],
+ }),
+ listeners(({ actions, values }) => ({
+ openReport: ({ report, source }) => {
+ router.actions.push(urls.todayReport(report.id))
+ actions.reportOpened(report, source)
+ },
+ setUseSampleData: () => {
+ actions.loadTopReports()
+ },
+ locationChanged: ({ searchParams }) => {
+ const useSampleData = parseSampleParam(searchParams.sample)
+ if (useSampleData !== null && useSampleData !== values.useSampleData) {
+ actions.setUseSampleData(useSampleData)
+ }
+ },
+ loadTopReportsSuccess: ({ topReports }) => {
+ if (values.useSampleData) {
+ return
+ }
+ // pinned: analytics event name and properties. Renaming them breaks dashboards.
+ posthog.capture('today home loaded', {
+ report_count: topReports.results.length,
+ more_report_count: values.moreReportCount,
+ })
+ },
+ reportOpened: ({ report, source }) => {
+ if (values.useSampleData) {
+ return
+ }
+ // pinned: analytics event name and properties. Renaming them breaks dashboards.
+ posthog.capture('today report opened', {
+ report_id: report.id,
+ priority: report.priority ?? null,
+ has_pr: !!report.implementation_pr_url,
+ source,
+ })
+ },
+ })),
+ afterMount(({ actions, values, cache }) => {
+ const useSampleData = parseSampleParam(router.values.searchParams.sample)
+ if (useSampleData !== null && useSampleData !== values.useSampleData) {
+ actions.setUseSampleData(useSampleData)
+ } else {
+ actions.loadTopReports()
+ }
+ cache.disposables.add(() => {
+ const clock = window.setInterval(() => actions.tick(), CLOCK_MS)
+ return () => clearInterval(clock)
+ }, 'clock')
+ }),
+])
diff --git a/frontend/src/scenes/project-homepage/today/todayReportLogic.ts b/frontend/src/scenes/project-homepage/today/todayReportLogic.ts
new file mode 100644
index 000000000000..9508affa1306
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/todayReportLogic.ts
@@ -0,0 +1,173 @@
+import { MakeLogicType, afterMount, connect, kea, key, path, props, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+
+import api from 'lib/api'
+import { addProjectIdIfMissing } from 'lib/utils/kea-router'
+import { teamLogic } from 'scenes/teamLogic'
+import { urls } from 'scenes/urls'
+
+import { signalsReportsSignalsRetrieve } from 'products/signals/frontend/generated/api'
+import { ReportChartApi, SignalNodeApi } from 'products/signals/frontend/generated/api.schemas'
+import { SignalReport } from 'products/signals/frontend/inbox/types'
+import { ChartPlacements, resolveChartPlacements } from 'products/signals/frontend/inbox/utils/chartPlacement'
+
+import { todayLogic } from './todayLogic'
+import { findSampleReport, isSampleReportId, sampleSignals } from './todaySampleReports'
+
+export interface TodayReportLogicProps {
+ reportId: string
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayReportLogicValues {
+ reports: SignalReport[] // todayLogic
+ chartPlacements: ChartPlacements
+ currentReport: SignalReport | null
+ fullReport: SignalReport | null
+ fullReportLoading: boolean
+ reportFailed: boolean
+ reportSignals: SignalNodeApi[] | null
+ reportSignalsLoading: boolean
+ reportUrl: string
+ signals: SignalNodeApi[]
+ trailingCharts: ReportChartApi[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayReportLogicActions {
+ loadFullReport: () => any
+ loadFullReportFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadFullReportSuccess: (
+ fullReport: SignalReport,
+ payload?: any
+ ) => {
+ fullReport: SignalReport
+ payload?: any
+ }
+ loadReportSignals: () => any
+ loadReportSignalsFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ }
+ loadReportSignalsSuccess: (
+ reportSignals: SignalNodeApi[],
+ payload?: any
+ ) => {
+ reportSignals: SignalNodeApi[]
+ payload?: any
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface todayReportLogicMeta {
+ key: string
+ __keaTypeGenInternalSelectorTypes: {
+ currentReport: (
+ fullReport: SignalReport | null,
+ reports: SignalReport[],
+ reportFailed: boolean
+ ) => SignalReport | null
+ chartPlacements: (currentReport: SignalReport | null) => ChartPlacements
+ trailingCharts: (currentReport: SignalReport | null, chartPlacements: ChartPlacements) => ReportChartApi[]
+ signals: (reportSignals: SignalNodeApi[] | null) => SignalNodeApi[]
+ }
+}
+
+export type todayReportLogicType = MakeLogicType<
+ todayReportLogicValues,
+ todayReportLogicActions,
+ TodayReportLogicProps,
+ todayReportLogicMeta
+>
+
+export const todayReportLogic = kea<todayReportLogicType>([
+ props({} as TodayReportLogicProps),
+ key((props) => props.reportId),
+ path((reportId) => ['scenes', 'project-homepage', 'today', 'todayReportLogic', reportId]),
+ connect(() => ({ values: [todayLogic, ['reports']] })),
+ loaders(({ props }) => ({
+ fullReport: [
+ null as SignalReport | null,
+ {
+ loadFullReport: async () => {
+ if (isSampleReportId(props.reportId)) {
+ const report = findSampleReport(props.reportId)
+ if (!report) {
+ throw new Error('Sample report not found')
+ }
+ return report
+ }
+ // nosemgrep: prefer-codegen-api-namespaced-signals -- Today passes reports to the Inbox's helpers, which take the handwritten SignalReport. The generated report type is wider (string status and priority, read-only arrays), so this call moves to generated types together with the Inbox.
+ return await api.signalReports.get(props.reportId)
+ },
+ },
+ ],
+ reportSignals: [
+ null as SignalNodeApi[] | null,
+ {
+ loadReportSignals: async (): Promise<SignalNodeApi[]> => {
+ if (isSampleReportId(props.reportId)) {
+ return sampleSignals(props.reportId)
+ }
+ const response = await signalsReportsSignalsRetrieve(
+ String(teamLogic.values.currentTeamId),
+ props.reportId
+ )
+ return response.signals
+ },
+ },
+ ],
+ })),
+ reducers({
+ reportFailed: [false, { loadFullReport: () => false, loadFullReportFailure: () => true }],
+ }),
+ selectors(({ props }) => ({
+ // The list row renders at once, and the full report replaces it when it arrives with its charts.
+ // A failed load shows its error instead, so the page never passes off the list row as the report.
+ currentReport: [
+ (s) => [s.fullReport, s.reports, s.reportFailed],
+ (fullReport: SignalReport | null, reports: SignalReport[], reportFailed: boolean): SignalReport | null =>
+ reportFailed ? null : (fullReport ?? reports.find((report) => report.id === props.reportId) ?? null),
+ ],
+ chartPlacements: [
+ (s) => [s.currentReport],
+ (currentReport: SignalReport | null): ChartPlacements =>
+ resolveChartPlacements(
+ currentReport?.summary,
+ (currentReport?.charts ?? []).map((chart) => chart.chart_id)
+ ),
+ ],
+ trailingCharts: [
+ (s) => [s.currentReport, s.chartPlacements],
+ (currentReport: SignalReport | null, chartPlacements: ChartPlacements): ReportChartApi[] =>
+ (currentReport?.charts ?? []).filter((chart) => !chartPlacements.inlineIds.has(chart.chart_id)),
+ ],
+ // The API returns signals oldest first, and the newest one is the most useful to read first.
+ signals: [
+ (s) => [s.reportSignals],
+ (reportSignals: SignalNodeApi[] | null): SignalNodeApi[] =>
+ [...(reportSignals ?? [])].sort(
+ (first, second) => new Date(second.timestamp).getTime() - new Date(first.timestamp).getTime()
+ ),
+ ],
+ // Absolute, because the session prompt gives it to the agent so the agent can read the report.
+ reportUrl: [
+ () => [],
+ (): string =>
+ `${window.location.origin}${addProjectIdIfMissing(urls.inboxReport('reports', props.reportId))}`,
+ ],
+ })),
+ afterMount(({ actions }) => {
+ actions.loadFullReport()
+ actions.loadReportSignals()
+ }),
+])
diff --git a/frontend/src/scenes/project-homepage/today/todaySampleReports.ts b/frontend/src/scenes/project-homepage/today/todaySampleReports.ts
new file mode 100644
index 000000000000..f1e490edfdaf
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/todaySampleReports.ts
@@ -0,0 +1,463 @@
+import type { SignalNode } from 'scenes/debug/signals/types'
+
+import { SignalReport, SignalReportStatus } from 'products/signals/frontend/inbox/types'
+
+import type { TodayReports } from './todayLogic'
+import { TodayBriefingSegment } from './todaySignalReports'
+
+// Sample ids carry this prefix, so a report page knows to read the fixture rather than the API.
+const SAMPLE_ID_PREFIX = 'sample-'
+const HOUR_MS = 60 * 60 * 1000
+
+export function isSampleReportId(reportId: string): boolean {
+ return reportId.startsWith(SAMPLE_ID_PREFIX)
+}
+
+/** `?sample=1` turns sample data on, `?sample=0` turns it off, and anything else leaves it as it is. */
+export function parseSampleParam(value: unknown): boolean | null {
+ const normalized = String(value ?? '').toLowerCase()
+ if (['1', 'true', 'on'].includes(normalized)) {
+ return true
+ }
+ if (['0', 'false', 'off'].includes(normalized)) {
+ return false
+ }
+ return null
+}
+
+interface SampleReportSpec {
+ id: string
+ title: string
+ summary: string
+ hoursAgo: number
+ priority: SignalReport['priority']
+ actionability: SignalReport['actionability']
+ status: SignalReportStatus
+ sourceProducts: string[]
+ pullRequestUrl?: string
+ suggestedPrompts?: string[]
+ signals: {
+ sourceProduct: SignalNode['source_product']
+ sourceType: SignalNode['source_type']
+ content: string
+ hoursAgo: number
+ }[]
+}
+
+// The Hedgebox demo scenarios from the Today mock, all invented. Signals leave `extra` empty so they render as
+// plain cards and fetch nothing. Evidence from a product that has no signal type keeps its name in the text.
+const SAMPLE_SPECS: SampleReportSpec[] = [
+ {
+ id: `${SAMPLE_ID_PREFIX}pr`,
+ title: 'Review PR #9123',
+ summary:
+ '**The Safari checkout fix is ready for review.**\n\nTuesday’s deploy stopped some Safari users before payment. The checkout sent an empty billing address to the payment service.\n\nPR #9123 restores the address before payment is submitted. The change is small, tested, and ready for you.',
+ hoursAgo: 2,
+ priority: 'P1',
+ actionability: 'immediately_actionable',
+ status: SignalReportStatus.READY,
+ sourceProducts: ['error_tracking', 'session_replay', 'analytics', 'github'],
+ pullRequestUrl: 'https://github.com/example/hedgebox/pull/9123',
+ signals: [
+ {
+ sourceProduct: 'error_tracking',
+ sourceType: 'issue',
+ content: '1,284 events. The same TypeError started after deploy #4821.',
+ hoursAgo: 2,
+ },
+ {
+ sourceProduct: 'session_replay',
+ sourceType: 'session_problem',
+ content: '38 recordings. Safari users stop after they submit payment.',
+ hoursAgo: 3,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: '−12 points. Safari completion fell while Chrome stayed flat.',
+ hoursAgo: 4,
+ },
+ {
+ sourceProduct: 'github',
+ sourceType: 'issue',
+ content: 'PR #9123. The fix restores the missing billing address.',
+ hoursAgo: 5,
+ },
+ ],
+ },
+ {
+ id: `${SAMPLE_ID_PREFIX}exp`,
+ title: 'Ship one-page checkout',
+ summary:
+ '**One-page checkout won. It is safe to ship.**\n\nThe shorter checkout completed more often than the current flow. It did not increase refunds, support requests, or payment errors.\n\nThe result passed the team’s decision threshold. You can send the winning flow to everyone today.',
+ hoursAgo: 3,
+ priority: 'P1',
+ actionability: 'immediately_actionable',
+ status: SignalReportStatus.READY,
+ sourceProducts: ['analytics', 'session_replay'],
+ signals: [
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Experiments · 95% likely. The one-page version is the likely winner.',
+ hoursAgo: 3,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: '+6.4%. Checkout completion rose from 54.1% to 57.6%.',
+ hoursAgo: 4,
+ },
+ {
+ sourceProduct: 'session_replay',
+ sourceType: 'session_problem',
+ content: 'Fewer exits. People no longer pause between address and payment.',
+ hoursAgo: 5,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Feature flags · Ready. The winning variant can reach everyone now.',
+ hoursAgo: 6,
+ },
+ ],
+ },
+ {
+ id: `${SAMPLE_ID_PREFIX}safari`,
+ title: 'Watch 38 Safari recordings',
+ summary:
+ '**Safari users reach payment, then get stuck.**\n\nThe recordings show the same sequence. A person enters a card, submits payment, and sees no progress.\n\nThe problem affects Safari 17 after Tuesday’s deploy. Chrome sessions continue through the same step.',
+ hoursAgo: 5,
+ priority: 'P1',
+ actionability: 'requires_human_input',
+ status: SignalReportStatus.PENDING_INPUT,
+ sourceProducts: ['session_replay', 'analytics', 'error_tracking'],
+ signals: [
+ {
+ sourceProduct: 'session_replay',
+ sourceType: 'session_problem',
+ content: '38 sessions. Every sampled session stalls after payment.',
+ hoursAgo: 5,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: '49% complete. Safari trails Chrome by 13 points.',
+ hoursAgo: 6,
+ },
+ {
+ sourceProduct: 'error_tracking',
+ sourceType: 'issue',
+ content: 'address.ts:42. The billing address is empty at submission.',
+ hoursAgo: 7,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Data warehouse · Safari 17. Older Safari versions stay near their baseline.',
+ hoursAgo: 8,
+ },
+ ],
+ },
+ {
+ id: `${SAMPLE_ID_PREFIX}error`,
+ title: 'Triage the formatAddress TypeError',
+ summary:
+ '**One new error is blocking checkout completion.**\n\nThe error begins when checkout formats an empty billing address. It started with deploy #4821 and appears only after payment submission.\n\nFour hundred and twelve people saw it. The same error also explains the Safari conversion drop.',
+ hoursAgo: 7,
+ priority: 'P2',
+ actionability: 'immediately_actionable',
+ status: SignalReportStatus.READY,
+ sourceProducts: ['error_tracking', 'analytics', 'session_replay'],
+ pullRequestUrl: 'https://github.com/example/hedgebox/pull/9131',
+ signals: [
+ {
+ sourceProduct: 'error_tracking',
+ sourceType: 'issue',
+ content: '1,284 events. TypeError in formatAddress at address.ts:42.',
+ hoursAgo: 7,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: '412 users. Most affected users arrived from Safari.',
+ hoursAgo: 8,
+ },
+ {
+ sourceProduct: 'session_replay',
+ sourceType: 'session_problem',
+ content: '19 sampled. The submit button stops after one click.',
+ hoursAgo: 9,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Data warehouse · Deploy #4821. The first event arrived six minutes after release.',
+ hoursAgo: 10,
+ },
+ ],
+ },
+ {
+ id: `${SAMPLE_ID_PREFIX}llm`,
+ title: 'Check which model summarize-doc uses',
+ summary:
+ '**Document summaries became more expensive overnight.**\n\nThe summarize-doc workflow now spends 31% more per active user. Usage stayed flat, so higher traffic does not explain the change.\n\nMost of the increase comes from a model change and longer prompts. The quality score did not improve.',
+ hoursAgo: 9,
+ priority: 'P2',
+ actionability: 'immediately_actionable',
+ status: SignalReportStatus.READY,
+ sourceProducts: ['llm_analytics', 'analytics'],
+ pullRequestUrl: 'https://github.com/example/hedgebox/pull/9140',
+ signals: [
+ {
+ sourceProduct: 'llm_analytics',
+ sourceType: 'evaluation',
+ content: '+31% cost. Cost rose while the number of summaries stayed flat.',
+ hoursAgo: 9,
+ },
+ {
+ sourceProduct: 'llm_analytics',
+ sourceType: 'evaluation',
+ content: 'Tracing · 2.4× tokens. The new prompt repeats the source document.',
+ hoursAgo: 10,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Usage flat. The same number of people used summaries.',
+ hoursAgo: 11,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Data warehouse · summarize-doc. One workflow accounts for 84% of the increase.',
+ hoursAgo: 12,
+ },
+ ],
+ },
+ {
+ id: `${SAMPLE_ID_PREFIX}nps`,
+ title: 'Read 23 pricing complaints',
+ summary:
+ '**Pricing is the main reason detractors hesitate.**\n\nTwenty-three detractors mention pricing in their survey response. Most of them visited the new pricing page before they replied.\n\nThey understand the product, but they cannot predict the bill. The confusion is strongest among small teams with growing data volume.',
+ hoursAgo: 20,
+ priority: 'P3',
+ actionability: 'requires_human_input',
+ status: SignalReportStatus.PENDING_INPUT,
+ sourceProducts: ['conversations', 'analytics', 'session_replay'],
+ signals: [
+ {
+ sourceProduct: 'conversations',
+ sourceType: 'feedback',
+ content: 'Surveys · NPS 32. Twenty-three of 61 detractors mention pricing.',
+ hoursAgo: 20,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Customer analytics · Small teams. Growing teams express the most uncertainty.',
+ hoursAgo: 21,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: '71% visited. Most detractors saw the new pricing page.',
+ hoursAgo: 22,
+ },
+ {
+ sourceProduct: 'session_replay',
+ sourceType: 'session_problem',
+ content: '3 comparisons. People revisit the usage table before leaving.',
+ hoursAgo: 23,
+ },
+ ],
+ },
+ {
+ id: `${SAMPLE_ID_PREFIX}browser`,
+ title: 'Compare checkout by browser',
+ summary:
+ '**Safari accounts for the checkout gap.**\n\nChrome and Firefox remain near their usual completion rates. Safari 17 falls sharply after payment submission.\n\nThe browser comparison isolates the problem to one checkout path. Mobile Safari shows the largest drop.',
+ hoursAgo: 26,
+ priority: 'P3',
+ actionability: 'requires_human_input',
+ status: SignalReportStatus.PENDING_INPUT,
+ sourceProducts: ['analytics', 'session_replay', 'error_tracking'],
+ pullRequestUrl: 'https://github.com/example/hedgebox/pull/9123',
+ signals: [
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: '−13 points. Safari trails the other browsers at checkout.',
+ hoursAgo: 26,
+ },
+ {
+ sourceProduct: 'session_replay',
+ sourceType: 'session_problem',
+ content: '38 sessions. The same payment stall appears across sampled sessions.',
+ hoursAgo: 27,
+ },
+ {
+ sourceProduct: 'error_tracking',
+ sourceType: 'issue',
+ content: '1,284 events. The error appears mainly in Safari 17.',
+ hoursAgo: 28,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Data warehouse · 3 browsers. Chrome and Firefox stay near their baseline.',
+ hoursAgo: 29,
+ },
+ ],
+ },
+ {
+ id: `${SAMPLE_ID_PREFIX}guardrails`,
+ title: 'Review experiment guardrails',
+ summary:
+ '**The winning checkout passed every guardrail.**\n\nThe shorter checkout increased completion without increasing refunds, support requests, or payment failures.\n\nEach guardrail stayed within its agreed range. The result is ready for a full rollout.',
+ hoursAgo: 30,
+ priority: 'P3',
+ actionability: 'immediately_actionable',
+ status: SignalReportStatus.READY,
+ sourceProducts: ['analytics', 'error_tracking', 'conversations'],
+ signals: [
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Experiments · 4 passed. Every release guardrail stayed within range.',
+ hoursAgo: 30,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: '+6.4%. Checkout completion improved for the winning variant.',
+ hoursAgo: 31,
+ },
+ {
+ sourceProduct: 'error_tracking',
+ sourceType: 'issue',
+ content: 'No increase. Payment and checkout errors stayed flat.',
+ hoursAgo: 32,
+ },
+ {
+ sourceProduct: 'conversations',
+ sourceType: 'feedback',
+ content: 'Surveys · Support flat. The new flow did not increase support requests.',
+ hoursAgo: 33,
+ },
+ ],
+ },
+ {
+ id: `${SAMPLE_ID_PREFIX}traces`,
+ title: 'Check summary-model traces',
+ summary:
+ '**The new summary model repeats the source document.**\n\nRecent traces show the source text twice in the prompt. This duplication explains most of the token increase.\n\nThe model change did not improve the quality score. The previous model remains the lower-cost option.',
+ hoursAgo: 40,
+ priority: 'P3',
+ actionability: 'immediately_actionable',
+ status: SignalReportStatus.READY,
+ sourceProducts: ['llm_analytics', 'analytics'],
+ pullRequestUrl: 'https://github.com/example/hedgebox/pull/9147',
+ signals: [
+ {
+ sourceProduct: 'llm_analytics',
+ sourceType: 'evaluation',
+ content: 'Tracing · 24 traces. Each sampled trace contains the source text twice.',
+ hoursAgo: 40,
+ },
+ {
+ sourceProduct: 'llm_analytics',
+ sourceType: 'evaluation',
+ content: '2.4× tokens. Input tokens rose after the model change.',
+ hoursAgo: 41,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Usage flat. Traffic did not cause the higher cost.',
+ hoursAgo: 42,
+ },
+ {
+ sourceProduct: 'analytics',
+ sourceType: 'anomaly_investigation',
+ content: 'Data warehouse · Quality flat. The quality score did not improve.',
+ hoursAgo: 43,
+ },
+ ],
+ },
+]
+
+const BRIEFING_LINK = (id: string, text: string, highlight?: boolean): TodayBriefingSegment => ({
+ text,
+ reportId: `${SAMPLE_ID_PREFIX}${id}`,
+ ...(highlight ? { highlight } : {}),
+})
+
+/** The hand-written briefing from the mock, which reads better than one built from report titles. */
+export const SAMPLE_BRIEFING: TodayBriefingSegment[][] = [
+ [
+ BRIEFING_LINK('safari', 'Safari users can’t pay'),
+ { text: ' since Tuesday’s deploy, and ' },
+ BRIEFING_LINK('pr', 'a fix is waiting', true),
+ { text: ' for your review.' },
+ ],
+ [BRIEFING_LINK('exp', 'One-page checkout won'), { text: ' its experiment, and signups beat the forecast by 18%.' }],
+ [
+ { text: 'Keep an eye on ' },
+ BRIEFING_LINK('error', 'one new error'),
+ { text: ', LLM cost per user ' },
+ BRIEFING_LINK('llm', 'up 31%'),
+ { text: ', and ' },
+ BRIEFING_LINK('nps', 'pricing that confuses people'),
+ { text: '.' },
+ ],
+]
+
+function buildSampleReport(spec: SampleReportSpec, now: number): SignalReport {
+ const updatedAt = new Date(now - spec.hoursAgo * HOUR_MS).toISOString()
+ return {
+ id: spec.id,
+ title: spec.title,
+ summary: spec.summary,
+ status: spec.status,
+ total_weight: spec.signals.length,
+ signal_count: spec.signals.length,
+ created_at: updatedAt,
+ updated_at: updatedAt,
+ artefact_count: 0,
+ is_suggested_reviewer: true,
+ priority: spec.priority,
+ actionability: spec.actionability,
+ already_addressed: false,
+ source_products: spec.sourceProducts,
+ implementation_pr_url: spec.pullRequestUrl ?? null,
+ suggested_prompts: spec.suggestedPrompts,
+ charts: [],
+ }
+}
+
+export function sampleTopReports(limit: number, now: number = Date.now()): TodayReports {
+ return {
+ results: SAMPLE_SPECS.slice(0, limit).map((spec) => buildSampleReport(spec, now)),
+ count: SAMPLE_SPECS.length,
+ }
+}
+
+export function findSampleReport(reportId: string, now: number = Date.now()): SignalReport | null {
+ const spec = SAMPLE_SPECS.find((candidate) => candidate.id === reportId)
+ return spec ? buildSampleReport(spec, now) : null
+}
+
+export function sampleSignals(reportId: string, now: number = Date.now()): SignalNode[] {
+ const spec = SAMPLE_SPECS.find((candidate) => candidate.id === reportId)
+ return (spec?.signals ?? []).map((signal, index) => ({
+ signal_id: `${reportId}-signal-${index}`,
+ content: signal.content,
+ source_product: signal.sourceProduct,
+ source_type: signal.sourceType,
+ source_id: `${reportId}-source-${index}`,
+ weight: 1,
+ timestamp: new Date(now - signal.hoursAgo * HOUR_MS).toISOString(),
+ extra: {} as SignalNode['extra'],
+ }))
+}
diff --git a/frontend/src/scenes/project-homepage/today/todaySignalReports.ts b/frontend/src/scenes/project-homepage/today/todaySignalReports.ts
new file mode 100644
index 000000000000..d3061466c8f0
--- /dev/null
+++ b/frontend/src/scenes/project-homepage/today/todaySignalReports.ts
@@ -0,0 +1,111 @@
+import { dayjs } from 'lib/dayjs'
+
+import { isActionCapableReport } from 'products/signals/frontend/inbox/inboxTaskKickoffLogic'
+import { SignalReport } from 'products/signals/frontend/inbox/types'
+
+export type TodayReportIcon = 'pr' | 'replay' | 'error' | 'llm' | 'survey' | 'analytics' | 'trace' | 'inbox'
+
+/** One run of text in the briefing. A run with `reportId` links to that report. */
+export interface TodayBriefingSegment {
+ text: string
+ reportId?: string
+ /** Marks the report that already has a pull request waiting for review. */
+ highlight?: boolean
+}
+
+export interface TodayReportSource {
+ label: string
+ color: string
+ icon: TodayReportIcon
+}
+
+const SOURCES: Record<string, TodayReportSource> = {
+ error_tracking: { label: 'Error tracking', color: 'var(--color-product-error-tracking-light)', icon: 'error' },
+ sentry: { label: 'Sentry', color: 'var(--color-product-error-tracking-light)', icon: 'error' },
+ session_replay: { label: 'Session replay', color: 'var(--color-product-session-replay-light)', icon: 'replay' },
+ replay_vision: { label: 'Replay vision', color: 'var(--color-product-session-replay-light)', icon: 'replay' },
+ llm_analytics: { label: 'LLM analytics', color: 'var(--color-product-llm-analytics-light)', icon: 'llm' },
+ analytics: { label: 'Product analytics', color: 'var(--color-product-product-analytics-light)', icon: 'analytics' },
+ conversations: { label: 'Support', color: 'var(--color-product-support-light)', icon: 'survey' },
+ zendesk: { label: 'Zendesk', color: 'var(--color-product-support-light)', icon: 'survey' },
+ surveys: { label: 'Surveys', color: 'var(--color-product-surveys-light)', icon: 'survey' },
+ logs: { label: 'Logs', color: 'var(--color-product-logs-light)', icon: 'trace' },
+ github: { label: 'GitHub', color: 'var(--color-text-secondary)', icon: 'pr' },
+ gitlab: { label: 'GitLab', color: 'var(--color-text-secondary)', icon: 'pr' },
+ linear: { label: 'Linear', color: 'var(--color-text-secondary)', icon: 'inbox' },
+ jira: { label: 'Jira', color: 'var(--color-text-secondary)', icon: 'inbox' },
+}
+
+const FALLBACK_SOURCE: TodayReportSource = {
+ label: 'Self-driving',
+ color: 'var(--color-text-secondary)',
+ icon: 'inbox',
+}
+
+/** Questions that only ask for an answer, so they are safe to offer on any report. */
+export const GENERAL_REPORT_PROMPTS = [
+ 'Why is this happening?',
+ 'Who is affected, and how badly?',
+ 'What would you look at first?',
+]
+
+export function reportTitle(report: Pick<SignalReport, 'title'>): string {
+ return report.title?.trim() || 'Untitled report'
+}
+
+export function sourceLabel(source: string): string {
+ return SOURCES[source]?.label ?? source.replace(/_/g, ' ').replace(/^./, (first) => first.toUpperCase())
+}
+
+/** The style of the product that contributed the report's first signal. */
+export function reportSource(report: Pick<SignalReport, 'source_products'>): TodayReportSource {
+ const source = report.source_products?.[0]
+ if (!source) {
+ return FALLBACK_SOURCE
+ }
+ return SOURCES[source] ?? { ...FALLBACK_SOURCE, label: sourceLabel(source) }
+}
+
+export function reportIcon(report: Pick<SignalReport, 'source_products' | 'implementation_pr_url'>): TodayReportIcon {
+ return report.implementation_pr_url ? 'pr' : reportSource(report).icon
+}
+
+export function reportMeta(report: Pick<SignalReport, 'source_products' | 'updated_at'>): string {
+ return `${reportSource(report).label} · ${dayjs(report.updated_at).fromNow()}`
+}
+
+/**
+ * The prompts offered under a report. The report's own suggestions can ask for action, so they are
+ * offered only where the Inbox offers them too. Every other report gets questions that only ask for
+ * an answer.
+ */
+export function reportPrompts(report: SignalReport): string[] {
+ const suggested = isActionCapableReport(report) ? (report.suggested_prompts ?? []) : []
+ return suggested.length ? suggested : GENERAL_REPORT_PROMPTS
+}
+
+function lowerFirst(text: string): string {
+ // Keep acronyms such as "API" or "LLM" as they are.
+ return /^[A-Z][a-z]/.test(text) ? text.charAt(0).toLowerCase() + text.slice(1) : text
+}
+
+/** One linked sentence per report, so every report in the briefing opens from the text. */
+export function briefingForReports(reports: SignalReport[]): TodayBriefingSegment[][] {
+ const [first, ...rest] = reports
+ if (!first) {
+ return []
+ }
+ const paragraphs: TodayBriefingSegment[][] = [
+ [{ text: reportTitle(first), reportId: first.id, highlight: !!first.implementation_pr_url }, { text: '.' }],
+ ]
+ if (rest.length) {
+ paragraphs.push([
+ { text: 'Also on your list: ' },
+ ...rest.flatMap((report, index): TodayBriefingSegment[] => [
+ { text: lowerFirst(reportTitle(report)), reportId: report.id },
+ { text: index === rest.length - 1 ? '.' : index === rest.length - 2 ? ', and ' : ', ' },
+ ]),
+ ])
+ }
+ return paragraphs
+}
diff --git a/frontend/src/scenes/sceneTypes.ts b/frontend/src/scenes/sceneTypes.ts
index 087710f3790f..425b76d80f6e 100644
--- a/frontend/src/scenes/sceneTypes.ts
+++ b/frontend/src/scenes/sceneTypes.ts
@@ -101,6 +101,7 @@ export enum Scene {
LegacyPlugin = 'LegacyPlugin',
LegalDocuments = 'LegalDocuments',
LegalDocumentNew = 'LegalDocumentNew',
+ Library = 'Library',
Link = 'Link',
Links = 'Links',
LiveDebugger = 'LiveDebugger',
diff --git a/frontend/src/scenes/scenes.ts b/frontend/src/scenes/scenes.ts
index baca32ae8aff..908627018d4c 100644
--- a/frontend/src/scenes/scenes.ts
+++ b/frontend/src/scenes/scenes.ts
@@ -332,6 +332,10 @@ export const sceneConfigurations: Record<Scene | string, SceneConfig> = {
name: 'Homepage',
layout: 'app-raw-no-header',
},
+ [Scene.Library]: {
+ projectBased: true,
+ name: 'Library',
+ },
[Scene.PropertyDefinitionEdit]: {
projectBased: true,
name: 'Data management',
@@ -825,6 +829,9 @@ export const routes: Record<string, [Scene | string, string]> = {
[urls.variables()]: [Scene.DataManagement, 'variables'],
[urls.variableEdit(':id')]: [Scene.SqlVariableEdit, 'sqlVariableEdit'],
[urls.projectHomepage()]: [Scene.ProjectHomepage, 'projectHomepage'],
+ [urls.todayReport(':reportId')]: [Scene.ProjectHomepage, 'todayReport'],
+ [urls.library()]: [Scene.Library, 'library'],
+ [urls.library(':objectType')]: [Scene.Library, 'libraryObjectType'],
[urls.aiHistory()]: [Scene.Max, 'maxHistory'],
[urls.ai()]: [Scene.Max, 'max'],
[urls.projectCreateFirst()]: [Scene.ProjectCreateFirst, 'projectCreateFirst'],
diff --git a/frontend/src/scenes/urls.ts b/frontend/src/scenes/urls.ts
index 88bd9b6dbec1..3c6f4b81a234 100644
--- a/frontend/src/scenes/urls.ts
+++ b/frontend/src/scenes/urls.ts
@@ -167,6 +167,8 @@ export const urls = {
projectCreateFirst: (): string => '/organization/create-project',
projectRoot: (): string => '/',
projectHomepage: (): string => '/home',
+ todayReport: (reportId: string): string => `/home/reports/${reportId}`,
+ library: (objectType?: string): string => (objectType ? `/library/${objectType}` : '/library'),
ai: (chat?: string, ask?: string): string => combineUrl('/ai', { ask, chat }).url,
aiTask: (taskId: string): string => combineUrl('/ai', { task: taskId }).url,
aiHistory: (): string => '/ai/history',
diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.ts
index b4d9643df553..2e0441599e21 100644
--- a/products/signals/frontend/inbox/inboxAnalytics.ts
+++ b/products/signals/frontend/inbox/inboxAnalytics.ts
@@ -71,7 +71,10 @@ export const INBOX_EVENTS = {
type InboxEvent = (typeof INBOX_EVENTS)[keyof typeof INBOX_EVENTS]
-/** Action surface an `Inbox report action` fired from. `context_menu` is the right-click menu on a list row. */
+/**
+ * Action surface an `Inbox report action` fired from. `context_menu` is the right-click menu on a list row.
+ * `today` is a report page on the Today homepage.
+ */
export type InboxReportActionSurface =
| 'detail_pane'
| 'detail_footer'
@@ -79,6 +82,7 @@ export type InboxReportActionSurface =
| 'bulk_bar'
| 'triage_mode'
| 'context_menu'
+ | 'today'
/**
* Affordance that put the first report into a multi-select. Tells us which ones people find, so