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(today): let the rail chats use legacy posthog ai without the sandbox flag (#121963)

Peter Kirkham797ae4110d3c
diff --git a/frontend/src/layout/today/TodayChatRow.tsx b/frontend/src/layout/today/TodayChatRow.tsx
index a8f4a0b10574..b989a852ad6d 100644
--- a/frontend/src/layout/today/TodayChatRow.tsx
+++ b/frontend/src/layout/today/TodayChatRow.tsx
@@ -7,6 +7,7 @@ import { ContextMenu, ContextMenuContent, ContextMenuTrigger } from '@posthog/qu
import { urls } from 'scenes/urls'
import { TodayChatActionItems } from './TodayChatActionItems'
+import { todayListAppearanceLogic } from './todayListAppearanceLogic'
import { CONTEXT_PARTS, SHEET_PARTS } from './todayMenuParts'
import { useTodayPreviewMenuReport } from './todayPreviewCardContext'
import { chatPreview } from './todayPreviewCards'
@@ -16,7 +17,7 @@ import { TodaySheetMenu } from './TodaySheetMenu'
import { todayShellLogic } from './todayShellLogic'
import { todaySpacesLogic } from './todaySpacesLogic'
import { TodaySpacesRow } from './TodaySpacesRow'
-import { TodayWorkItem } from './todayWorkItems'
+import { TodayWorkItem, sessionDetails } from './todayWorkItems'
interface TodayChatRowProps {
item: TodayWorkItem
@@ -29,6 +30,9 @@ export function TodayChatRow({ item, dataAttr, optionValue }: TodayChatRowProps)
const reportMenuOpen = useTodayPreviewMenuReport()
const preview = useMemo(() => chatPreview(item), [item])
const { phoneLayout } = useValues(todayShellLogic)
+ const { spaceNames } = useValues(todaySpacesLogic)
+ const { fields } = useValues(todayListAppearanceLogic)
+ const details = useMemo(() => sessionDetails(item, fields, spaceNames), [item, fields, spaceNames])
const { touchMenuOpened } = useActions(todaySpacesLogic)
const [sheetOpen, setSheetOpen] = useState(false)
@@ -40,6 +44,7 @@ export function TodayChatRow({ item, dataAttr, optionValue }: TodayChatRowProps)
to={urls.ai(item.id)}
active={location.pathname.endsWith('/ai') && searchParams.chat === item.id}
dataAttr={dataAttr}
+ details={details}
optionValue={optionValue}
/>
</TodayPreviewTrigger>
diff --git a/frontend/src/layout/today/TodayNewChatButton.tsx b/frontend/src/layout/today/TodayNewChatButton.tsx
index 8f1d2488167f..7c08d213565b 100644
--- a/frontend/src/layout/today/TodayNewChatButton.tsx
+++ b/frontend/src/layout/today/TodayNewChatButton.tsx
@@ -5,11 +5,16 @@ import { IconPlus } from '@posthog/icons'
import { Button, Tooltip, TooltipContent, TooltipTrigger, cn } from '@posthog/quill'
import { LinkPrimitive } from 'lib/lemon-ui/Link'
-import { urls } from 'scenes/urls'
+import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
+
+import { todayNewChatUrl } from './todayRailItems'
export function TodayNewChatButton(): JSX.Element {
- const { location } = useValues(router)
- const starting = location.pathname.endsWith(urls.taskNewSession())
+ const { location, searchParams } = useValues(router)
+ const { effectivePhaiView } = useValues(maxGlobalLogic)
+ const newChatUrl = todayNewChatUrl(effectivePhaiView)
+ // A legacy chat in progress also sits on `/ai`, with its id in `chat`.
+ const starting = location.pathname.endsWith(newChatUrl) && !searchParams.chat && !searchParams.task
return (
<Tooltip>
@@ -18,7 +23,7 @@ export function TodayNewChatButton(): JSX.Element {
render={
<Button
size="icon"
- render={<LinkPrimitive to={urls.taskNewSession()} />}
+ render={<LinkPrimitive to={newChatUrl} />}
aria-current={starting ? 'page' : undefined}
className={cn('-me-2 text-muted-foreground', starting && 'bg-fill-selected text-foreground')}
aria-label="New chat"
diff --git a/frontend/src/layout/today/TodayRail.tsx b/frontend/src/layout/today/TodayRail.tsx
index 271d3bf330ca..aded6ae9c210 100644
--- a/frontend/src/layout/today/TodayRail.tsx
+++ b/frontend/src/layout/today/TodayRail.tsx
@@ -10,7 +10,7 @@ import { TODAY_RAIL_WIDTH, TodayRailPane, railPaneHref, todayShellLogic } from '
const RAIL_DATA_ATTRS: Partial<Record<TodayRailPane, string>> = { settings: 'today-settings' }
export function TodayRail(): JSX.Element {
- const { activePane } = useValues(todayShellLogic)
+ const { activePane, effectivePhaiView } = useValues(todayShellLogic)
const { clickRailPane } = useActions(todayShellLogic)
const renderTile = (pane: TodayRailPane): JSX.Element => (
@@ -19,7 +19,7 @@ export function TodayRail(): JSX.Element {
label={TODAY_PANES[pane].label}
icon={TODAY_PANES[pane].icon}
active={activePane === pane}
- to={railPaneHref(pane)}
+ to={railPaneHref(pane, effectivePhaiView)}
onClick={() => clickRailPane(pane)}
dataAttr={RAIL_DATA_ATTRS[pane] ?? `today-rail-${pane}`}
/>
diff --git a/frontend/src/layout/today/todayRailItems.tsx b/frontend/src/layout/today/todayRailItems.tsx
index 752ab8871623..3eb609e09002 100644
--- a/frontend/src/layout/today/todayRailItems.tsx
+++ b/frontend/src/layout/today/todayRailItems.tsx
@@ -2,6 +2,7 @@ import { IconApps, IconChat, IconGear, IconHome, IconSidebarClose, IconSidebarOp
import { IconAnalyticsBars } from 'lib/lemon-ui/icons'
import { isMac } from 'lib/utils/dom'
+import type { PhaiViewMode } from 'scenes/max/maxGlobalLogic'
import { urls } from 'scenes/urls'
import { TodayNewAnalyticsButton } from './TodayNewAnalyticsButton'
@@ -14,17 +15,22 @@ export interface TodayPane {
title: string
icon: JSX.Element
/** The page a rail pick opens. Without one, a pick only opens the sidebar and the open page stays. */
- home?: () => string
+ home?: (effectivePhaiView: PhaiViewMode) => string
action?: () => JSX.Element
}
+/** The task composer runs on the sandbox, so the legacy view starts a chat on `/ai` instead. */
+export function todayNewChatUrl(effectivePhaiView: PhaiViewMode): string {
+ return effectivePhaiView === 'new' ? urls.taskNewSession() : urls.ai()
+}
+
export const TODAY_PANES: Record<TodayRailPane, TodayPane> = {
home: { label: 'Home', title: 'Today', icon: <IconHome />, home: () => urls.projectHomepage() },
spaces: {
label: 'Chats',
title: 'Chats',
icon: <IconChat />,
- home: () => urls.taskNewSession(),
+ home: todayNewChatUrl,
action: TodayNewChatButton,
},
// No home: like Products, a pick only opens the sidebar and the open page stays.
diff --git a/frontend/src/layout/today/todayShellLogic.test.ts b/frontend/src/layout/today/todayShellLogic.test.ts
index 8d007d5d2bfc..78f9ce8a50e3 100644
--- a/frontend/src/layout/today/todayShellLogic.test.ts
+++ b/frontend/src/layout/today/todayShellLogic.test.ts
@@ -83,11 +83,13 @@ describe('todayShellLogic', () => {
})
test.each([
- ['home', '/home'],
- ['spaces', '/spaces/new'],
- ['analytics', '/airplane'],
- ['products', '/airplane'],
- ] as const)('opens the %s section when its rail item is picked', (pane, pathname) => {
+ ['home', false, '/home'],
+ ['spaces', true, '/spaces/new'],
+ ['spaces', false, '/ai'],
+ ['analytics', false, '/airplane'],
+ ['products', false, '/airplane'],
+ ] as const)('opens the %s section when its rail item is picked, sandbox %s', (pane, sandbox, pathname) => {
+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.PHAI_SANDBOX_MODE]: sandbox })
const logic = todayShellLogic()
logic.mount()
diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.ts
index 4d6f7bdf3fb9..a9634b98c14c 100644
--- a/frontend/src/layout/today/todayShellLogic.ts
+++ b/frontend/src/layout/today/todayShellLogic.ts
@@ -10,6 +10,7 @@ import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { isUnderPath, removeProjectIdIfPresent } from 'lib/utils/kea-router'
import { fromPostHogProducts } from 'scenes/analytics/analyticsUtils'
import { libraryTypeForPath } from 'scenes/library/libraryUtils'
+import { PhaiViewMode, maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
import { settingsSectionSceneForPath } from 'scenes/settings/settingsSectionScenes'
import { urls } from 'scenes/urls'
@@ -46,8 +47,8 @@ export function clampSidebarWidth(width: number | null): number {
}
/** The page a rail pane opens, or undefined when the pane only opens the sidebar. */
-export function railPaneHref(pane: TodayRailPane): string | undefined {
- return TODAY_PANES[pane].home?.()
+export function railPaneHref(pane: TodayRailPane, effectivePhaiView: PhaiViewMode): string | undefined {
+ return TODAY_PANES[pane].home?.(effectivePhaiView)
}
const PHONE_PAGE_LIMIT = 50
@@ -127,6 +128,7 @@ function paneAfterNavigation(openPane: TodayRailPane | null, pathname: string):
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface todayShellLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
+ effectivePhaiView: PhaiViewMode // maxGlobalLogic
mobileLayout: boolean // navigationLogic
activePane: TodayRailPane
lastSceneUrl: string | null
@@ -268,7 +270,14 @@ function sceneUrlOutsideAi(
export const todayShellLogic = kea<todayShellLogicType>([
path(['layout', 'today', 'todayShellLogic']),
connect(() => ({
- values: [featureFlagLogic, ['featureFlags'], navigationLogic, ['mobileLayout']],
+ values: [
+ featureFlagLogic,
+ ['featureFlags'],
+ maxGlobalLogic,
+ ['effectivePhaiView'],
+ navigationLogic,
+ ['mobileLayout'],
+ ],
actions: [router, ['locationChanged']],
})),
actions({
@@ -477,7 +486,7 @@ export const todayShellLogic = kea<todayShellLogicType>([
pickPane: ({ pane }) => {
// pinned: analytics event name and property. Renaming them breaks dashboards.
posthog.capture('today rail pane picked', { pane, phone_layout: values.phoneLayout })
- const href = railPaneHref(pane)
+ const href = railPaneHref(pane, values.effectivePhaiView)
if (href) {
cache.pickingPane = true
router.actions.push(href)
diff --git a/frontend/src/layout/today/todayWorkItems.test.ts b/frontend/src/layout/today/todayWorkItems.test.ts
index b499fb89338d..d02a563a61d3 100644
--- a/frontend/src/layout/today/todayWorkItems.test.ts
+++ b/frontend/src/layout/today/todayWorkItems.test.ts
@@ -339,4 +339,22 @@ describe('todayWorkItems', () => {
)
).toEqual(expected)
})
+
+ it('shows the creator and activity under a chat row, like a session row', () => {
+ const item = chatItem({
+ id: 'chat',
+ title: 'Login funnel',
+ updated_at: '2026-03-10T10:00:00',
+ user: { id: 1, first_name: 'Ada', last_name: 'Lovelace', email: '[email protected]' },
+ } as ConversationDetail)
+
+ expect(
+ sessionDetails(
+ item,
+ ['space', 'repository', 'branch', 'creator', 'activity'],
+ {},
+ dayjs('2026-03-10T12:00:59')
+ ).map((detail) => detail.text)
+ ).toEqual(['Ada Lovelace', '2h ago'])
+ })
})
diff --git a/frontend/src/layout/today/todayWorkItems.ts b/frontend/src/layout/today/todayWorkItems.ts
index 16f094eed674..ad3b1dbf2b0c 100644
--- a/frontend/src/layout/today/todayWorkItems.ts
+++ b/frontend/src/layout/today/todayWorkItems.ts
@@ -179,7 +179,16 @@ export function chatItem(conversation: ConversationDetail): TodayWorkItem {
status: null,
channel: null,
createdById: conversation.user?.id ?? null,
- author: null,
+ author: conversation.user
+ ? {
+ id: conversation.user.id,
+ uuid: conversation.user.uuid,
+ distinct_id: conversation.user.distinct_id,
+ first_name: conversation.user.first_name,
+ last_name: conversation.user.last_name ?? '',
+ email: conversation.user.email,
+ }
+ : null,
latestRunId: null,
runEnvironment: null,
originProduct: null,
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 96bd40516008..d8ab8d571d1e 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -444,7 +444,7 @@ export const FEATURE_FLAGS = {
PAYMENT_ENTRY_CONTACT_SUPPORT: 'payment-entry-contact-support', // owner: #team-billing, see `PaymentEntryModal.tsx`
PHAI_PLAN_MODE: 'phai-plan-mode', // owner: #team-posthog-ai
PHAI_QUILL: 'phai-quill', // owner: #team-posthog-ai, renders the PostHog AI chat thread in quill like PostHog Desktop; on with today-rail-nav too
- PHAI_SANDBOX_MODE: 'phai-sandbox-mode', // owner: #team-posthog-ai
+ PHAI_SANDBOX_MODE: 'phai-sandbox-mode', // owner: #team-posthog-ai, PostHog AI 2.0: the sandbox runtime and the task composer; without it the today-rail-nav chats use the legacy chat
PHAI_SCENE_AUTO_OPEN: 'phai-scene-auto-open', // owner: #team-posthog-ai
PHAI_TASKS: 'phai-tasks', // owner: #team-array
PI_ACP: 'pi-acp', // owner: #team-agent-infrastructure, Pi runs write ACP and show on the web run surface
diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
index 191aa1720364..ff5d5440c504 100644
--- a/frontend/src/scenes/project-homepage/today/Today.stories.tsx
+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx
@@ -87,6 +87,7 @@ const CONVERSATIONS = [
status: 'idle',
type: 'assistant',
updated_at: '2026-09-28T16:10:00Z',
+ user: ADA,
},
{
id: 'chat-2',
@@ -94,6 +95,7 @@ const CONVERSATIONS = [
status: 'idle',
type: 'assistant',
updated_at: '2026-09-25T09:00:00Z',
+ user: ADA,
},
]
@@ -860,6 +862,8 @@ const meta: Meta = {
'/api/users/@me/integrations/codex/': { status: 'not_connected' },
'/api/code/invites/check-access/': { has_access: true, has_loops_access: false },
'/api/projects/:team_id/tasks/repositories/': { repositories: [] },
+ '/api/projects/:team_id/sandbox_environments/': { results: [], next: null },
+ '/api/projects/:team_id/sandbox_custom_images/': { results: [], next: null },
'/api/projects/:team_id/tasks/': ({ request }) => {
const params = new URL(request.url).searchParams
const results = params.get('pinned')
@@ -1060,6 +1064,20 @@ export const ReportInANarrowWindow: Story = {
}
export const ChatsPane: Story = {
+ parameters: {
+ featureFlags: [
+ FEATURE_FLAGS.TODAY_RAIL_NAV,
+ FEATURE_FLAGS.POSTHOG_CODE_TASK_ANALYSIS,
+ FEATURE_FLAGS.PHAI_SANDBOX_MODE,
+ ],
+ },
+ play: async ({ canvasElement }) => {
+ await userEvent.click(await within(canvasElement).findByLabelText('Chats'))
+ },
+}
+
+// Without the sandbox flag, the Chats pane starts a legacy chat instead of a task.
+export const ChatsPaneOnLegacyPostHogAi: Story = {
play: async ({ canvasElement }) => {
await userEvent.click(await within(canvasElement).findByLabelText('Chats'))
},
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskMenu.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskMenu.tsx
index 6430f219fb49..20370c1bc4dc 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskMenu.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskMenu.tsx
@@ -4,6 +4,8 @@ import { useState } from 'react'
import { IconEllipsis } from '@posthog/icons'
import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuTrigger } from '@posthog/quill-primitives'
+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
+
import { DROPDOWN_PARTS, SHEET_PARTS, TodayMenuParts } from '~/layout/today/todayMenuParts'
import { panelChatTaskFor } from '~/layout/today/todayPanelChat'
import { TodayPanelMoveMenuItems } from '~/layout/today/TodayPanelMoveMenuItems'
@@ -23,9 +25,11 @@ export interface QuillTaskMenuProps {
export function QuillTaskMenu({ task, selectedRun, onArchive }: QuillTaskMenuProps): JSX.Element {
const { todayRailEnabled, phoneLayout } = useValues(todayShellLogic)
+ const sandboxModeEnabled = useFeatureFlag('PHAI_SANDBOX_MODE')
const [sheetOpen, setSheetOpen] = useState(false)
- // The phone layout has no floating or docked panel to move the chat into.
- const chat = todayRailEnabled && !phoneLayout ? panelChatTaskFor(task, selectedRun) : null
+ // The phone layout has no floating or docked panel to move the chat into. Without the sandbox, the panel
+ // shows the legacy chat and cannot show the task.
+ const chat = todayRailEnabled && !phoneLayout && sandboxModeEnabled ? panelChatTaskFor(task, selectedRun) : null
const items = (parts: TodayMenuParts): JSX.Element => (
<TaskMenuItems