Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions frontend/src/scenes/max/Thread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import {
isMultiVisualizationMessage,
isNotebookArtifactContent,
isVisualizationArtifactContent,
POSTHOG_AI_PREVIEW_EMPTY_STATE,
visualizationTypeToQuery,
} from './utils'

Expand Down Expand Up @@ -1079,7 +1080,7 @@ const Visualization = React.memo(function Visualization({

return (
<>
{!isCollapsed && <Query query={query} readOnly embedded />}
{!isCollapsed && <Query query={query} readOnly embedded context={POSTHOG_AI_PREVIEW_EMPTY_STATE} />}
<div className={clsx('flex items-center justify-between', !isCollapsed && 'mt-2')}>
<div className="flex items-center gap-1.5">
<LemonButton
Expand Down Expand Up @@ -1182,7 +1183,7 @@ export function MultiVisualizationAnswer({ message, className }: MultiVisualizat
<div className={`grid ${gridCols} gap-2`}>
{insightsToShow.map((insight, index) => (
<div key={index} className="relative min-h-[200px]">
<Query query={insight.query} readOnly embedded />
<Query query={insight.query} readOnly embedded context={POSTHOG_AI_PREVIEW_EMPTY_STATE} />
</div>
))}
</div>
Expand Down Expand Up @@ -1263,7 +1264,12 @@ function MultiVisualizationModal({ insights: messages }: MultiVisualizationModal
<TopHeading query={messages[selectedIndex].query} />
</h4>
<div className="min-h-80">
<Query query={messages[selectedIndex].query} readOnly embedded />
<Query
query={messages[selectedIndex].query}
readOnly
embedded
context={POSTHOG_AI_PREVIEW_EMPTY_STATE}
/>
</div>
</>
)}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/scenes/max/messages/NotebookArtifactAnswer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { isFunnelsQuery, isHogQLQuery, isInsightVizNode } from '~/queries/utils'
import { MarkdownMessage, MessageTemplate } from 'products/posthog_ai/frontend/api/primitives'

import { MessageStatus } from '../maxLogic'
import { castAssistantQuery, visualizationTypeToQuery } from '../utils'
import { castAssistantQuery, POSTHOG_AI_PREVIEW_EMPTY_STATE, visualizationTypeToQuery } from '../utils'
import { markdownToTiptap } from '../utils/markdownToTiptap'

interface NotebookArtifactAnswerProps {
Expand Down Expand Up @@ -208,7 +208,7 @@ function VisualizationBlockPreview({ block }: { block: VisualizationBlock }): JS
return (
<div className="border rounded overflow-hidden">
<div className={clsx('flex flex-col overflow-auto', isFunnelsQuery(block.query) ? 'h-[580px]' : 'h-96')}>
<Query query={query} readOnly embedded />
<Query query={query} readOnly embedded context={POSTHOG_AI_PREVIEW_EMPTY_STATE} />
</div>
<div className="flex items-center justify-between px-2 py-1 bg-surface-secondary border-t">
<LemonButton
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/scenes/max/messages/VisualizationWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ import { InsightShortId } from '~/types'

import { MessageTemplate } from 'products/posthog_ai/frontend/api/primitives'

import { visualizationTypeToQuery } from '../utils'
import { POSTHOG_AI_PREVIEW_EMPTY_STATE, visualizationTypeToQuery } from '../utils'

const QUERY_CONTEXT_POSTHOG_AI: QueryContext = { limitContext: 'posthog_ai' } as const
const QUERY_CONTEXT_POSTHOG_AI: QueryContext = {
limitContext: 'posthog_ai',
...POSTHOG_AI_PREVIEW_EMPTY_STATE,
} as const

export interface VisualizationWidgetProps {
content: VisualizationArtifactContent
Expand Down
14 changes: 14 additions & 0 deletions frontend/src/scenes/max/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
QuerySchema,
QuerySchemaRoot,
} from '~/queries/schema/schema-general'
import { QueryContext } from '~/queries/types'
import { isHogQLQuery, isInsightQueryNode } from '~/queries/utils'
import { ActionType, DashboardType, EventDefinition, QueryBasedInsightModel } from '~/types'

Expand Down Expand Up @@ -361,6 +362,19 @@ export function getAgentModeForScene(
return null
}

/**
* Empty-state copy for PostHog AI query previews. These previews re-run the assistant's generated
* query live, so they can come back with no rows even when the assistant already found an answer
* (e.g. via the query it executed). The generic "There are no matching events for this query" copy
* reads as a dead-end and points at filters the user can't edit here, which erodes trust in the
* assistant's output. Shared across every Max render path so the message stays consistent.
*/
export const POSTHOG_AI_PREVIEW_EMPTY_STATE: Pick<QueryContext, 'emptyStateHeading' | 'emptyStateDetail'> = {
emptyStateHeading: 'This preview returned no results',
emptyStateDetail:
"PostHog AI re-runs this query live, so it can come back empty even when the assistant already found the answer. Check the assistant's steps above for the full results.",
}

export const visualizationTypeToQuery = (
visualization: VisualizationItem | VisualizationArtifactContent | VisualizationBlock
): QuerySchema | null => {
Expand Down
Loading