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.

fix(today): keep ai in the tab, match rail items, hide ask ai buttons (#108963)

Peter Kirkhamd94279367095
diff --git a/frontend/src/layout/navigation-3000/Navigation.tsx b/frontend/src/layout/navigation-3000/Navigation.tsx
index cda04ceee39a..887d03d83963 100644
--- a/frontend/src/layout/navigation-3000/Navigation.tsx
+++ b/frontend/src/layout/navigation-3000/Navigation.tsx
@@ -50,13 +50,11 @@ export function Navigation({
const { scenePanelIsPresent, scenePanelOpenManual, sceneTakeoverActive } = useValues(sceneLayoutLogic)
const { sidePanelOpen } = useValues(sidePanelStateLogic)
const { sidePanelWidth } = useValues(panelLayoutLogic)
- const { leftNavWidth: todayLeftNavWidth } = useValues(todayShellLogic)
+ const { leftNavWidth: todayLeftNavWidth, todayRailEnabled: todayRail } = 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) => {
diff --git a/frontend/src/layout/scenes/components/SceneMenuBar.tsx b/frontend/src/layout/scenes/components/SceneMenuBar.tsx
index 196d25b07148..a587c989747d 100644
--- a/frontend/src/layout/scenes/components/SceneMenuBar.tsx
+++ b/frontend/src/layout/scenes/components/SceneMenuBar.tsx
@@ -34,6 +34,7 @@ import { urls } from 'scenes/urls'
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
import { sceneLayoutLogic } from '~/layout/scenes/sceneLayoutLogic'
+import { todayShellLogic } from '~/layout/today/todayShellLogic'
import { ProductKey } from '~/queries/schema/schema-general'
import { SidePanelTab } from '~/types'
@@ -134,6 +135,7 @@ const RIGHT_TRIGGER_LABEL_CLASSES = 'hidden @min-[36rem]/main-content:inline'
function SceneMenuBarRightLinks(): JSX.Element {
const { openSidePanel } = useActions(sidePanelStateLogic)
+ const { todayRailEnabled } = useValues(todayShellLogic)
const { productKey } = useContext(SceneContentContext)
const settingsUrl = getSettingsUrl(productKey)
@@ -174,20 +176,22 @@ function SceneMenuBarRightLinks(): JSX.Element {
<span className={RIGHT_TRIGGER_LABEL_CLASSES}>Support</span>
<IconSidePanel />
</Button>
- <Button
- type="button"
- onClick={() => {
- captureSceneMenuBar('scene menu bar right link clicked', { link: 'ai' })
- openSidePanel(SidePanelTab.Max)
- }}
- data-attr="scene-menu-bar-ai"
- aria-label="PostHog AI"
- className={RIGHT_TRIGGER_CLASSES}
- variant="outline"
- >
- <IconSparkles className="text-ai group-hover/button-primitive:animate-hue-rotate" />
- <span className={RIGHT_TRIGGER_LABEL_CLASSES}>PostHog AI</span>
- </Button>
+ {!todayRailEnabled && (
+ <Button
+ type="button"
+ onClick={() => {
+ captureSceneMenuBar('scene menu bar right link clicked', { link: 'ai' })
+ openSidePanel(SidePanelTab.Max)
+ }}
+ data-attr="scene-menu-bar-ai"
+ aria-label="PostHog AI"
+ className={RIGHT_TRIGGER_CLASSES}
+ variant="outline"
+ >
+ <IconSparkles className="text-ai group-hover/button-primitive:animate-hue-rotate" />
+ <span className={RIGHT_TRIGGER_LABEL_CLASSES}>PostHog AI</span>
+ </Button>
+ )}
</div>
)
}
diff --git a/frontend/src/layout/scenes/components/SceneTitleSection.tsx b/frontend/src/layout/scenes/components/SceneTitleSection.tsx
index 84ea31f216c3..6652264d0c73 100644
--- a/frontend/src/layout/scenes/components/SceneTitleSection.tsx
+++ b/frontend/src/layout/scenes/components/SceneTitleSection.tsx
@@ -33,6 +33,7 @@ import { sceneLogic } from 'scenes/sceneLogic'
import { navigation3000Logic } from '~/layout/navigation-3000/navigationLogic'
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
import { breadcrumbsLogic } from '~/layout/navigation/Breadcrumbs/breadcrumbsLogic'
+import { todayShellLogic } from '~/layout/today/todayShellLogic'
import { FileSystemIconType } from '~/queries/schema/schema-general'
import { Breadcrumb, FileSystemIconColor, SidePanelTab } from '~/types'
@@ -71,6 +72,7 @@ export function SceneTitlePanelButton({
const { featureFlags } = useValues(featureFlagLogic)
const sceneMenuBarEnabled = !!featureFlags[FEATURE_FLAGS.SCENE_MENU_BAR]
+ const { todayRailEnabled } = useValues(todayShellLogic)
// Open Info tab if scene has panel content, otherwise default to PostHog AI
const defaultTab = scenePanelIsPresent ? SidePanelTab.Info : SidePanelTab.Max
@@ -81,7 +83,7 @@ export function SceneTitlePanelButton({
return (
<>
- {!sceneMenuBarEnabled && (
+ {!sceneMenuBarEnabled && !todayRailEnabled && (
<ButtonPrimitive
className={cn(buttonClassName, maxButtonLabel && 'w-auto px-2')}
onClick={(e) => {
diff --git a/frontend/src/layout/today/TodayLibrarySidebar.tsx b/frontend/src/layout/today/TodayLibrarySidebar.tsx
index 0088b9f48a7c..4becd0295c8e 100644
--- a/frontend/src/layout/today/TodayLibrarySidebar.tsx
+++ b/frontend/src/layout/today/TodayLibrarySidebar.tsx
@@ -6,6 +6,7 @@ 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 { libraryTypeForPath } from 'scenes/library/libraryUtils'
import { urls } from 'scenes/urls'
import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
@@ -18,6 +19,7 @@ export function TodayLibrarySidebar(): JSX.Element {
const { objectTypes } = useValues(libraryLogic)
const { location } = useValues(router)
const path = removeProjectIdIfPresent(location.pathname)
+ const objectPageType = libraryTypeForPath(path)
return (
<div className="TodayPane">
@@ -36,7 +38,7 @@ export function TodayLibrarySidebar(): JSX.Element {
label={type.pluralLabel}
icon={iconForType(type.value as FileSystemIconType)}
to={urls.library(type.value)}
- active={path === urls.library(type.value)}
+ active={path === urls.library(type.value) || objectPageType === type.value}
action={<LibraryCreateButton objectType={type.value} />}
dataAttr="today-library-type"
/>
diff --git a/frontend/src/layout/today/TodayToolsSidebar.tsx b/frontend/src/layout/today/TodayToolsSidebar.tsx
index 450270e89a61..86282082e66f 100644
--- a/frontend/src/layout/today/TodayToolsSidebar.tsx
+++ b/frontend/src/layout/today/TodayToolsSidebar.tsx
@@ -3,16 +3,19 @@ import { router } from 'kea-router'
import { LemonInput } from '@posthog/lemon-ui'
+import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
+
import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'
import { FileSystemIconType } from '~/queries/schema/schema-general'
import { TodayPaneRow } from './TodayPaneRow'
-import { todayToolsLogic, toolLabel } from './todayToolsLogic'
+import { todayToolsLogic, toolHrefForPath, toolLabel } from './todayToolsLogic'
export function TodayToolsSidebar(): JSX.Element {
- const { toolGroups, search } = useValues(todayToolsLogic)
+ const { tools, toolGroups, search } = useValues(todayToolsLogic)
const { setSearch } = useActions(todayToolsLogic)
const { location } = useValues(router)
+ const activeHref = toolHrefForPath(removeProjectIdIfPresent(location.pathname), tools)
return (
<div className="TodayPane">
@@ -45,7 +48,7 @@ export function TodayToolsSidebar(): JSX.Element {
tool.iconColor
)}
to={href}
- active={!!href && location.pathname.endsWith(href.split('?')[0])}
+ active={!!href && href === activeHref}
dataAttr="today-tool"
/>
)
diff --git a/frontend/src/layout/today/todayShellLogic.test.ts b/frontend/src/layout/today/todayShellLogic.test.ts
index 5c44b3412ab3..8ad33ecd1c6b 100644
--- a/frontend/src/layout/today/todayShellLogic.test.ts
+++ b/frontend/src/layout/today/todayShellLogic.test.ts
@@ -3,6 +3,7 @@ import { router } from 'kea-router'
import { initKeaTests } from '~/test/init'
import { TODAY_RAIL_WIDTH, TODAY_SIDEBAR_MAX_WIDTH, railPaneForPath, todayShellLogic } from './todayShellLogic'
+import { toolHrefForPath } from './todayToolsLogic'
describe('todayShellLogic', () => {
beforeEach(() => {
@@ -17,19 +18,33 @@ describe('todayShellLogic', () => {
['/project/1/ai', 'spaces'],
['/project/1/ai/history', 'spaces'],
['/project/1/spaces/abc', 'spaces'],
- ['/project/1/insights/abc', null],
+ ['/project/1/feature_flags/920847', 'library'],
+ ['/project/1/insights/abc', 'library'],
+ ['/project/1/feature_flags', 'library'],
+ ['/project/1/data-management/destinations', 'tools'],
+ ['/project/1/sql', 'tools'],
['/project/1/airplane', null],
['/project/1/homework', null],
])('puts %s under %s', (pathname, pane) => {
expect(railPaneForPath(pathname)).toBe(pane)
})
+ test.each([
+ ['/data-management/destinations', '/data-management/destinations?tab=all'],
+ ['/data-management/destinations/abc', '/data-management/destinations?tab=all'],
+ ['/data-management/events', '/data-management'],
+ ['/data-management-old', null],
+ ])('selects the tool for %s', (path, href) => {
+ const tools = [{ href: '/data-management' }, { href: '/data-management/destinations?tab=all' }]
+ expect(toolHrefForPath(path, tools)).toBe(href)
+ })
+
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')
+ router.actions.push('/project/1/airplane')
expect(logic.values.activePane).toBe('tools')
router.actions.push('/project/1/ai')
diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.ts
index 237ad00d0563..6520e2a93760 100644
--- a/frontend/src/layout/today/todayShellLogic.ts
+++ b/frontend/src/layout/today/todayShellLogic.ts
@@ -3,9 +3,16 @@ import { router } from 'kea-router'
import type { LocationChangedPayload } from 'kea-router/lib/types'
import posthog from 'posthog-js'
+import { FEATURE_FLAGS } from 'lib/constants'
+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { removeProjectIdIfPresent } from 'lib/utils/kea-router'
+import { libraryTypeForPath } from 'scenes/library/libraryUtils'
import { urls } from 'scenes/urls'
+import { navigationLogic } from '~/layout/navigation/navigationLogic'
+
+import { toolHrefForPath } from './todayToolsLogic'
+
export type TodayRailPane = 'home' | 'spaces' | 'library' | 'tools'
export const TODAY_RAIL_WIDTH = 56
@@ -35,20 +42,26 @@ export function railPaneForPath(pathname: string): TodayRailPane | null {
if (isUnder(path, '/ai') || isUnder(path, '/spaces')) {
return 'spaces'
}
- if (isUnder(path, urls.library())) {
+ if (isUnder(path, urls.library()) || libraryTypeForPath(path)) {
return 'library'
}
+ if (toolHrefForPath(path)) {
+ return 'tools'
+ }
return null
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface todayShellLogicValues {
+ featureFlags: FeatureFlagsSet // featureFlagLogic
+ mobileLayout: boolean // navigationLogic
activePane: TodayRailPane
leftNavWidth: number
pickedPane: TodayRailPane | null
routePane: TodayRailPane | null
sidebarOpen: boolean
sidebarWidth: number
+ todayRailEnabled: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -94,6 +107,7 @@ export interface todayShellLogicMeta {
routePane: (location: { hash: string; pathname: string; search: string }) => TodayRailPane | null
activePane: (pickedPane: TodayRailPane | null, routePane: TodayRailPane | null) => TodayRailPane
leftNavWidth: (sidebarOpen: boolean, sidebarWidth: number) => number
+ todayRailEnabled: (featureFlags: FeatureFlagsSet, mobileLayout: boolean) => boolean
}
}
@@ -106,7 +120,10 @@ export type todayShellLogicType = MakeLogicType<
export const todayShellLogic = kea<todayShellLogicType>([
path(['layout', 'today', 'todayShellLogic']),
- connect(() => ({ actions: [router, ['locationChanged']] })),
+ connect(() => ({
+ values: [featureFlagLogic, ['featureFlags'], navigationLogic, ['mobileLayout']],
+ actions: [router, ['locationChanged']],
+ })),
actions({
pickPane: (pane: TodayRailPane) => ({ pane }),
setSidebarOpen: (open: boolean) => ({ open }),
@@ -148,6 +165,12 @@ export const todayShellLogic = kea<todayShellLogicType>([
(s) => [s.sidebarOpen, s.sidebarWidth],
(sidebarOpen: boolean, sidebarWidth: number): number => TODAY_RAIL_WIDTH + (sidebarOpen ? sidebarWidth : 0),
],
+ // The rail has no overlay mode, so narrow windows keep the regular navigation.
+ todayRailEnabled: [
+ (s) => [s.featureFlags, s.mobileLayout],
+ (featureFlags: FeatureFlagsSet, mobileLayout: boolean): boolean =>
+ !!featureFlags[FEATURE_FLAGS.TODAY_RAIL_NAV] && !mobileLayout,
+ ],
}),
listeners(({ values }) => ({
pickPane: ({ pane }) => {
diff --git a/frontend/src/layout/today/todayToolsLogic.ts b/frontend/src/layout/today/todayToolsLogic.ts
index 1c50a663cca6..fcb30b06bf39 100644
--- a/frontend/src/layout/today/todayToolsLogic.ts
+++ b/frontend/src/layout/today/todayToolsLogic.ts
@@ -20,6 +20,31 @@ export function toolLabel(tool: FileSystemImport): string {
return tool.displayLabel || tool.path
}
+// Saved object types live in Library, except the ones that are working pages.
+function isToolItem(item: FileSystemImport): boolean {
+ const type = item.type?.split('/')[0] || item.iconType || ''
+ return !!item.href && !(type in fileSystemTypes && !TOOL_FILE_SYSTEM_TYPES.has(type))
+}
+
+export function toolHrefForPath(
+ path: string,
+ tools: Pick<FileSystemImport, 'href'>[] = [...getTreeItemsProducts(), ...getTreeItemsMetadata()].filter(isToolItem)
+): string | null {
+ let match: { href: string; toolPath: string } | null = null
+ for (const { href } of tools) {
+ const toolPath = href?.split(/[?#]/)[0]
+ if (
+ href &&
+ toolPath &&
+ (path === toolPath || path.startsWith(`${toolPath}/`)) &&
+ (!match || toolPath.length > match.toolPath.length)
+ ) {
+ match = { href, toolPath }
+ }
+ }
+ return match?.href ?? null
+}
+
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface todayToolsLogicValues {
featureFlags: FeatureFlagsSet // featureFlagLogic
@@ -62,12 +87,10 @@ export const todayToolsLogic = kea<todayToolsLogicType>([
const seen = new Set<string>()
return [...getTreeItemsProducts(), ...getTreeItemsMetadata()]
.filter((item) => {
- const type = item.type?.split('/')[0] || item.iconType || ''
if (
!item.href ||
+ !isToolItem(item) ||
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)
) {
diff --git a/frontend/src/lib/components/AgentPromptButton/AgentPromptButton.tsx b/frontend/src/lib/components/AgentPromptButton/AgentPromptButton.tsx
index 54e3ef18426c..3f933d5b0efe 100644
--- a/frontend/src/lib/components/AgentPromptButton/AgentPromptButton.tsx
+++ b/frontend/src/lib/components/AgentPromptButton/AgentPromptButton.tsx
@@ -1,4 +1,4 @@
-import { useActions } from 'kea'
+import { useActions, useValues } from 'kea'
import { useState } from 'react'
import { IconChevronDown, IconCopy, IconLogomark, IconSparkles } from '@posthog/icons'
@@ -26,6 +26,8 @@ import {
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
+import { todayShellLogic } from '~/layout/today/todayShellLogic'
+
import { AgentLogo, claudeLogo, cursorLogo, openaiLogo } from './AgentLogo'
export interface AgentPromptAction {
@@ -202,7 +204,10 @@ export function AgentPromptButton({
const [remembered, setRemembered] = useLocalStorage<RememberedCombo | null>(`${resolvedStorageKey}:combo`, null)
const [open, setOpen] = useState(defaultOpen)
const { askSidePanelMax } = useActions(maxGlobalLogic)
- const availableAgents = agentKeys ? AGENTS.filter((agent) => agentKeys.includes(agent.key)) : AGENTS
+ const { todayRailEnabled } = useValues(todayShellLogic)
+ const availableAgents = AGENTS.filter(
+ (agent) => (!agentKeys || agentKeys.includes(agent.key)) && !(todayRailEnabled && agent.key === 'posthog-ai')
+ )
if (actions.length === 0 || availableAgents.length === 0) {
return null
diff --git a/frontend/src/scenes/library/libraryUtils.test.ts b/frontend/src/scenes/library/libraryUtils.test.ts
index e79979dadca8..81e3583e7965 100644
--- a/frontend/src/scenes/library/libraryUtils.test.ts
+++ b/frontend/src/scenes/library/libraryUtils.test.ts
@@ -1,4 +1,4 @@
-import { libraryObjectHref, libraryObjectName } from './libraryUtils'
+import { libraryObjectHref, libraryObjectName, libraryTypeForPath } from './libraryUtils'
describe('libraryUtils', () => {
test.each([
@@ -17,4 +17,18 @@ describe('libraryUtils', () => {
])('links an object to %s', (_, entry, href) => {
expect(libraryObjectHref(entry)).toBe(href)
})
+
+ test.each([
+ ['/feature_flags/920847', 'feature_flag'],
+ ['/workflows/abc/workflow', 'workflows'],
+ ['/replay/playlists/abc', 'session_recording_playlist'],
+ ['/feature_flags', 'feature_flag'],
+ ['/dashboard', 'dashboard'],
+ ['/data-management/actions', 'action'],
+ ['/feature_flags/templates', null],
+ ['/workflows/library/templates/new', null],
+ ['/notebooks/abc', null],
+ ])('finds the object type of %s', (path, type) => {
+ expect(libraryTypeForPath(path)).toBe(type)
+ })
})
diff --git a/frontend/src/scenes/library/libraryUtils.ts b/frontend/src/scenes/library/libraryUtils.ts
index 9da21afb93f3..cd4214b0da99 100644
--- a/frontend/src/scenes/library/libraryUtils.ts
+++ b/frontend/src/scenes/library/libraryUtils.ts
@@ -1,4 +1,6 @@
-import { fileSystemTypes } from '~/products'
+import { routes } from 'scenes/scenes'
+
+import { fileSystemTypes, getTreeItemsMetadata, getTreeItemsProducts } 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.
@@ -35,6 +37,61 @@ export function libraryObjectHref(entry: Pick<FileSystemEntry, 'href' | 'type' |
return entry.ref && definition ? definition.href(entry.ref) : null
}
+const REF_PLACEHOLDER = 'LIBRARY_REF'
+
+function routeSegments(route: string): string[] {
+ return route.split(/[?#]/)[0].split('/').filter(Boolean)
+}
+
+let parsedRoutes: { scene: string; parts: string[] }[] | null = null
+let objectTypeByScene: Map<string, string> | null = null
+
+// The router prefers a fixed segment to a parameter, so `/feature_flags/templates` opens its own scene.
+function sceneForPath(path: string): string | null {
+ parsedRoutes ??= Object.entries(routes).map(([route, [scene]]) => ({ scene, parts: routeSegments(route) }))
+ const segments = routeSegments(path)
+ let best: { scene: string; params: number } | null = null
+ for (const { scene, parts } of parsedRoutes) {
+ const wildcard = parts[parts.length - 1] === '*'
+ const fixedLength = wildcard ? parts.length - 1 : parts.length
+ if (wildcard ? segments.length <= fixedLength : segments.length !== fixedLength) {
+ continue
+ }
+ if (!parts.slice(0, fixedLength).every((part, index) => part.startsWith(':') || part === segments[index])) {
+ continue
+ }
+ const params = parts.filter((part) => part.startsWith(':') || part === '*').length
+ if (!best || params < best.params) {
+ best = { scene, params }
+ }
+ }
+ return best?.scene ?? null
+}
+
+export function libraryTypeForPath(path: string): string | null {
+ if (!objectTypeByScene) {
+ const scenes = new Map<string, string>()
+ const addPage = (type: string, href: string | undefined): void => {
+ const scene = href && !TOOL_FILE_SYSTEM_TYPES.has(type) ? sceneForPath(href) : null
+ if (scene && !scenes.has(scene)) {
+ scenes.set(scene, type)
+ }
+ }
+ for (const [type, definition] of Object.entries(fileSystemTypes)) {
+ addPage(type, definition.href(REF_PLACEHOLDER))
+ }
+ for (const item of [...getTreeItemsProducts(), ...getTreeItemsMetadata()]) {
+ const type = baseObjectType(item.type) || item.iconType || ''
+ if (Object.hasOwn(fileSystemTypes, type)) {
+ addPage(type, item.href)
+ }
+ }
+ objectTypeByScene = scenes
+ }
+ const scene = sceneForPath(path)
+ return (scene && objectTypeByScene.get(scene)) || 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(/(?<!\\)\//)
diff --git a/frontend/src/scenes/project-homepage/today/Today.scss b/frontend/src/scenes/project-homepage/today/Today.scss
index 3576dd6742c2..208a5295c008 100644
--- a/frontend/src/scenes/project-homepage/today/Today.scss
+++ b/frontend/src/scenes/project-homepage/today/Today.scss
@@ -568,16 +568,6 @@
}
}
-.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 {
diff --git a/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx b/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx
index d3bb54e98114..3d4069347997 100644
--- a/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx
+++ b/frontend/src/scenes/project-homepage/today/TodayAskBox.tsx
@@ -3,46 +3,41 @@ import { useState } from 'react'
import { IconArrowRight } from '@posthog/icons'
-import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
+import { todayLogic } from './todayLogic'
-/** Sends the question to PostHog AI, which answers in a new tab. */
+/** Sends the question to PostHog AI, which answers in a new chat under Spaces. */
export function TodayAskBox(): JSX.Element {
- const { askSidePanelMax } = useActions(maxGlobalLogic)
+ const { askAi } = useActions(todayLogic)
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('')
- }
- }}
+ <form
+ className="TodayAsk"
+ onSubmit={(event) => {
+ event.preventDefault()
+ const trimmed = question.trim()
+ if (trimmed) {
+ askAi(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"
>
- <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>}
- </>
+ <IconArrowRight />
+ </button>
+ </form>
)
}
diff --git a/frontend/src/scenes/project-homepage/today/TodayBriefing.tsx b/frontend/src/scenes/project-homepage/today/TodayBriefing.tsx
index 10bcffe4744c..6a0808cdd2ce 100644
--- a/frontend/src/scenes/project-homepage/today/TodayBriefing.tsx
+++ b/frontend/src/scenes/project-homepage/today/TodayBriefing.tsx
@@ -3,7 +3,6 @@ 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'
@@ -54,8 +53,7 @@ function BriefingSegment({ segment }: { segment: TodayBriefingSegment }): JSX.El
function TodayBriefingReports(): JSX.Element {
const { reportSummary, reports, briefing, hoveredReportId, moreReportCount } = useValues(todayLogic)
- const { openReport, setHoveredReportId } = useActions(todayLogic)
- const { askSidePanelMax } = useActions(maxGlobalLogic)
+ const { askAi, openReport, setHoveredReportId } = useActions(todayLogic)
return (
<>
@@ -107,7 +105,7 @@ function TodayBriefingReports(): JSX.Element {
<button
type="button"
data-attr="today-ask-about-edition"
- onClick={() => askSidePanelMax('Walk me through what changed in my product today.')}
+ onClick={() => askAi('Walk me through what changed in my product today.')}
>
ask PostHog AI to walk you through it
</button>
diff --git a/frontend/src/scenes/project-homepage/today/todayLogic.ts b/frontend/src/scenes/project-homepage/today/todayLogic.ts
index 4bb48fe298a0..b3e50203fb0a 100644
--- a/frontend/src/scenes/project-homepage/today/todayLogic.ts
+++ b/frontend/src/scenes/project-homepage/today/todayLogic.ts
@@ -116,6 +116,9 @@ export interface todayLogicActions {
searchParams: Record<string, any>
url: string
} // router
+ askAi: (prompt: string) => {
+ prompt: string
+ }
loadTopReports: () => any
loadTopReportsFailure: (
error: string,
@@ -178,6 +181,7 @@ export const todayLogic = kea<todayLogicType>([
actions: [router, ['locationChanged']],
})),
actions({
+ askAi: (prompt: string) => ({ prompt }),
setHoveredReportId: (reportId: string | null) => ({ reportId }),
openReport: (report: SignalReport, source: TodayReportOpenSource) => ({ report, source }),
reportOpened: (report: SignalReport, source: TodayReportOpenSource) => ({ report, source }),
@@ -255,6 +259,9 @@ export const todayLogic = kea<todayLogicType>([
],
}),
listeners(({ actions, values }) => ({
+ askAi: ({ prompt }) => {
+ router.actions.push(urls.ai(undefined, prompt))
+ },
openReport: ({ report, source }) => {
router.actions.push(urls.todayReport(report.id))
actions.reportOpened(report, source)
diff --git a/frontend/src/scenes/session-recordings/components/InternalSurvey/InternalMultipleChoiceSurvey.tsx b/frontend/src/scenes/session-recordings/components/InternalSurvey/InternalMultipleChoiceSurvey.tsx
index 946eb8b79a82..74862c70d9a0 100644
--- a/frontend/src/scenes/session-recordings/components/InternalSurvey/InternalMultipleChoiceSurvey.tsx
+++ b/frontend/src/scenes/session-recordings/components/InternalSurvey/InternalMultipleChoiceSurvey.tsx
@@ -9,6 +9,7 @@ import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
+import { todayShellLogic } from '~/layout/today/todayShellLogic'
import { SurveyQuestion, SurveyQuestionType } from '~/types'
import { internalMultipleChoiceSurveyLogic } from './internalMultipleChoiceSurveyLogic'
@@ -169,6 +170,7 @@ export function InternalMultipleChoiceSurvey({ surveyId }: InternalSurveyProps):
const { handleChoiceChange, handleSurveyResponse, setOpenChoice } = useActions(logic)
const { askSidePanelMax } = useActions(maxGlobalLogic)
+ const { todayRailEnabled } = useValues(todayShellLogic)
const { featureFlags } = useValues(featureFlagLogic)
//Because we want to run A/B test to see does it help users or not
@@ -232,7 +234,7 @@ export function InternalMultipleChoiceSurvey({ surveyId }: InternalSurveyProps):
>
{question.buttonText ?? 'Submit'}
</LemonButton>
- {isHelpEnabled && (
+ {isHelpEnabled && !todayRailEnabled && (
<LemonButton
disabledReason={
!openChoice || openChoice.length < 5
diff --git a/products/ai_observability/frontend/evaluations/components/EvaluationCodeEditor.tsx b/products/ai_observability/frontend/evaluations/components/EvaluationCodeEditor.tsx
index 870ed9bc0cd2..166e1b28b60e 100644
--- a/products/ai_observability/frontend/evaluations/components/EvaluationCodeEditor.tsx
+++ b/products/ai_observability/frontend/evaluations/components/EvaluationCodeEditor.tsx
@@ -6,6 +6,7 @@ import { LemonButton, LemonTable, LemonTag, Link, Tooltip } from '@posthog/lemon
import { CodeEditorResizeable } from 'lib/monaco/CodeEditorResizable'
+import { todayShellLogic } from '~/layout/today/todayShellLogic'
import { useOpenAi } from '~/scenes/max/useOpenAi'
import { urls } from '~/scenes/urls'
@@ -372,6 +373,7 @@ export function EvaluationCodeEditor(): JSX.Element {
const { evaluation, hogTestResultsLoading } = useValues(llmEvaluationLogic)
const { setHogSource, setAllowsNA, testHogOnSample } = useActions(llmEvaluationLogic)
const { openAi } = useOpenAi()
+ const { todayRailEnabled } = useValues(todayShellLogic)
if (!evaluation || evaluation.evaluation_type !== 'hog') {
return <div>Loading...</div>
@@ -430,25 +432,27 @@ export function EvaluationCodeEditor(): JSX.Element {
Test on sample
</LemonButton>
</Tooltip>
- <LemonButton
- type="secondary"
- size="xsmall"
- icon={<IconSparkles />}
- onClick={() =>
- openAi('Help me write Hog evaluation code for this evaluation', {
- evaluation: {
- id: evaluation.id,
- name: evaluation.name,
- description: evaluation.description,
- evaluation_type: evaluation.evaluation_type,
- hog_source: evaluation.evaluation_config.source,
- },
- })
- }
- data-attr="llma-evaluation-generate-with-ai"
- >
- Generate with AI
- </LemonButton>
+ {!todayRailEnabled && (
+ <LemonButton
+ type="secondary"
+ size="xsmall"
+ icon={<IconSparkles />}
+ onClick={() =>
+ openAi('Help me write Hog evaluation code for this evaluation', {
+ evaluation: {
+ id: evaluation.id,
+ name: evaluation.name,
+ description: evaluation.description,
+ evaluation_type: evaluation.evaluation_type,
+ hog_source: evaluation.evaluation_config.source,
+ },
+ })
+ }
+ data-attr="llma-evaluation-generate-with-ai"
+ >
+ Generate with AI
+ </LemonButton>
+ )}
</div>
<div className="flex items-center gap-2">
<span>Expected output:</span>
diff --git a/products/customer_analytics/frontend/components/ConfigureWithAIButton.tsx b/products/customer_analytics/frontend/components/ConfigureWithAIButton.tsx
index 3bbf8e4f6e30..abec04dbd718 100644
--- a/products/customer_analytics/frontend/components/ConfigureWithAIButton.tsx
+++ b/products/customer_analytics/frontend/components/ConfigureWithAIButton.tsx
@@ -1,4 +1,4 @@
-import { useActions } from 'kea'
+import { useActions, useValues } from 'kea'
import { IconSparkles } from '@posthog/icons'
import { LemonButton, LemonButtonProps } from '@posthog/lemon-ui'
@@ -6,6 +6,8 @@ import { LemonButton, LemonButtonProps } from '@posthog/lemon-ui'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { useOpenAi } from 'scenes/max/useOpenAi'
+import { todayShellLogic } from '~/layout/today/todayShellLogic'
+
import { customerAnalyticsDashboardEventsLogic } from '../scenes/CustomerAnalyticsConfigurationScene/events/customerAnalyticsDashboardEventsLogic'
type ConfigureWithAIButtonProps = LemonButtonProps & {
@@ -21,8 +23,9 @@ export function ConfigureWithAIButton({
eventToHighlight,
children,
...props
-}: ConfigureWithAIButtonProps): JSX.Element {
+}: ConfigureWithAIButtonProps): JSX.Element | null {
const { openAi } = useOpenAi()
+ const { todayRailEnabled } = useValues(todayShellLogic)
const { addEventToHighlight } = useActions(customerAnalyticsDashboardEventsLogic)
const { reportCustomerAnalyticsDashboardConfigureEventWithAIClicked } = useActions(eventUsageLogic)
@@ -34,6 +37,10 @@ export function ConfigureWithAIButton({
reportCustomerAnalyticsDashboardConfigureEventWithAIClicked({ event: event || eventToHighlight })
}
+ if (todayRailEnabled) {
+ return null
+ }
+
return (
<LemonButton
size="small"