:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(tasks): add starter suggestions to the new web new session page (#115526)
Shy Alterf0c0cb4e24d3
diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsxindex d9dfd54d4d12..eae1a06d44db 100644--- a/frontend/src/scenes/project-homepage/today/Today.stories.tsx+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx@@ -1003,6 +1003,10 @@ export const PhoneWidth: Story = {parameters: { testOptions: { viewport: { width: 390, height: 844 } } },}+export const PhoneWidthNewSessionPage: Story = {+ parameters: { pageUrl: urls.taskNewSession(), testOptions: { viewport: { width: 390, height: 844 } } },+}+export const PhoneWidthMorePane: Story = {parameters: { testOptions: { viewport: { width: 390, height: 844 } } },play: async ({ canvasElement }) => {diff --git a/products/posthog_ai/frontend/api/runner.ts b/products/posthog_ai/frontend/api/runner.tsindex 65ec9ba735f3..3f68b6998041 100644--- a/products/posthog_ai/frontend/api/runner.ts+++ b/products/posthog_ai/frontend/api/runner.ts@@ -24,3 +24,4 @@ export { SidePanelRunner, type SidePanelRunnerProps } from '../components/SidePa// `SidePanelRunner`. `channelId` files the created task in a tasks channel, `initialRepositoryConfig` sets the// starting repo, and `onTaskCreated` gives the new task id back, so the host decides what to open.export { EmbeddedTaskComposer, type EmbeddedTaskComposerProps } from '../components/EmbeddedTaskComposer'+export type { ComposerPrefillRequest } from '../scenes/TaskTracker/components/TaskComposer'diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/EmbeddedTaskComposerImpl.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/EmbeddedTaskComposerImpl.tsxindex 96b388eb8b41..40c83bcf66c0 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/EmbeddedTaskComposerImpl.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/EmbeddedTaskComposerImpl.tsx@@ -5,7 +5,7 @@ import { TaskComposer, TaskComposerProps } from './TaskComposer'export type EmbeddedTaskComposerImplProps = Required<Pick<TaskTrackerSceneLogicProps, 'panelId'>> &Pick<TaskTrackerSceneLogicProps, 'channelId' | 'initialRepositoryConfig' | 'composerOverride' | 'onTaskCreated'> &- Pick<TaskComposerProps, 'focusRequest' | 'autoFocus'>+ Pick<TaskComposerProps, 'focusRequest' | 'autoFocus' | 'prefillRequest'>/*** The new-task composer alone, for a host page that lists tasks itself. It binds an embedded@@ -15,11 +15,17 @@ export type EmbeddedTaskComposerImplProps = Required<Pick<TaskTrackerSceneLogicPexport function EmbeddedTaskComposerImpl({focusRequest,autoFocus,+ prefillRequest,...props}: EmbeddedTaskComposerImplProps): JSX.Element {return (<BindLogic logic={taskTrackerSceneLogic} props={props}>- <TaskComposer variant="inline" focusRequest={focusRequest} autoFocus={autoFocus} />+ <TaskComposer+ variant="inline"+ focusRequest={focusRequest}+ autoFocus={autoFocus}+ prefillRequest={prefillRequest}+ /></BindLogic>)}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsxindex 7103907b27f0..6e7ceb473176 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskComposer.tsx@@ -24,6 +24,7 @@ import {import {cycleMode,getModesForRuntimeAdapter,+ type PermissionMode,resolveModeForRuntimeAdapter,} from 'products/posthog_ai/frontend/utils/composerModes'@@ -55,9 +56,20 @@ export interface TaskComposerProps {focusRequest?: number/** Focus the input on mount. A host page that is not mainly a composer turns it off and uses `focusRequest`. */autoFocus?: boolean+ prefillRequest?: ComposerPrefillRequest | null}-export function TaskComposer({ variant = 'page', focusRequest = 0, autoFocus = true }: TaskComposerProps): JSX.Element {+export interface ComposerPrefillRequest {+ prompt: string+ mode?: PermissionMode+}++export function TaskComposer({+ variant = 'page',+ focusRequest = 0,+ autoFocus = true,+ prefillRequest,+}: TaskComposerProps): JSX.Element {const inline = variant === 'inline'const {submitNewTask,@@ -65,6 +77,7 @@ export function TaskComposer({ variant = 'page', focusRequest = 0, autoFocus = tpickPermissionMode,setActiveSuggestionGroup,applySuggestion,+ applyPrefill,clearConsentBlock,} = useActions(taskTrackerSceneLogic)const {@@ -119,6 +132,16 @@ export function TaskComposer({ variant = 'page', focusRequest = 0, autoFocus = t}}+ const appliedPrefill = useRef<ComposerPrefillRequest | null>(null)+ useEffect(() => {+ if (!prefillRequest || prefillRequest === appliedPrefill.current) {+ return+ }+ appliedPrefill.current = prefillRequest+ applyPrefill(prefillRequest.prompt, prefillRequest.mode)+ textAreaRef.current?.focus()+ }, [prefillRequest, applyPrefill])+const field = (<Composer.Field><Composer.Placeholder>@@ -274,8 +297,7 @@ export function TaskComposer({ variant = 'page', focusRequest = 0, autoFocus = t{skin === 'lemon' && withConsent(<Composer.Submit data-attr="task-composer-send" />)}</Composer.Root></div>-- {showSuggestions && <Suggestions.Buttons data={DEFAULT_SUGGESTIONS_DATA} />}+ {showSuggestions && <Suggestions.Buttons data={DEFAULT_SUGGESTIONS_DATA} />}{' '}</Suggestions.Root></div></div>diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.tsindex 15fe72c511ad..cb0c61e3c39d 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts@@ -73,7 +73,7 @@ import {getRuntimeAdapterForModel,resolveEffortForModel,} from '../../utils/composerModels'-import { DEFAULT_COMPOSER_MODE, type PermissionMode } from '../../utils/composerModes'+import { DEFAULT_COMPOSER_MODE, getModesForRuntimeAdapter, type PermissionMode } from '../../utils/composerModes'import { wrapWithPosthogContext } from '../../utils/posthogContextBlock'import { submitWithWarmRunRetry } from '../../utils/warmRunSubmission'@@ -321,6 +321,13 @@ export interface taskTrackerSceneLogicActions {applyDefaultPermissionMode: () => {value: true}+ applyPrefill: (+ prompt: string,+ mode?: PermissionMode+ ) => {+ mode: PermissionMode | undefined+ prompt: string+ }applySuggestion: (item: SuggestionItem) => {item: SuggestionItem}@@ -507,6 +514,7 @@ export const taskTrackerSceneLogic = kea<taskTrackerSceneLogicType>([maybeAutoSelectIntegration: true,setActiveSuggestionGroup: (group: SuggestionGroup | null) => ({ group }),applySuggestion: (item: SuggestionItem) => ({ item }),+ applyPrefill: (prompt: string, mode?: PermissionMode) => ({ prompt, mode }),setHeadlineSeed: (seed: number) => ({ seed }),setPersistedRepositoryConfig: (config: PersistedRepositoryConfig) => ({ config }),openExistingTask: (task: Task) => ({ task }),@@ -771,6 +779,12 @@ export const taskTrackerSceneLogic = kea<taskTrackerSceneLogicType>([},// Fill the composer with the suggestion; submit straight away unless it needs the user to finish// typing (the component focuses the textarea in that case).+ applyPrefill: ({ prompt, mode }) => {+ if (mode && getModesForRuntimeAdapter(values.composerAdapter).includes(mode)) {+ actions.pickPermissionMode(mode)+ }+ actions.applySuggestion({ content: prompt, requiresUserInput: true })+ },applySuggestion: ({ item }) => {actions.setNewTaskData({ description: item.content, seedContextItems: undefined })if (!item.requiresUserInput) {diff --git a/products/tasks/frontend/spaces/NewSessionScene.tsx b/products/tasks/frontend/spaces/NewSessionScene.tsxindex a6ba61e11195..55709b2f4f33 100644--- a/products/tasks/frontend/spaces/NewSessionScene.tsx+++ b/products/tasks/frontend/spaces/NewSessionScene.tsx@@ -9,6 +9,8 @@ import { SceneExport } from 'scenes/sceneTypes'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { newSessionSceneLogic } from './newSessionSceneLogic'+import { NewSessionSuggestions } from './NewSessionSuggestions'+import { newSessionSuggestionsLogic } from './newSessionSuggestionsLogic'import { SpaceTaskComposer } from './SpaceTaskComposer'import { SpaceTaskComposerSkeleton } from './SpaceTaskComposerSkeleton'@@ -21,6 +23,8 @@ export function NewSessionScene(): JSX.Element {const enabled = useFeatureFlag('TODAY_RAIL_NAV')const { space, spacesLoading, spacesUnavailable, composerRepositoryConfig } = useValues(newSessionSceneLogic)const { sessionStarted, loadSpaces } = useActions(newSessionSceneLogic)+ const { suggestions, prefillRequest } = useValues(newSessionSuggestionsLogic)+ const { selectSuggestion } = useActions(newSessionSuggestionsLogic)if (!enabled) {return <NotFound object="page" />@@ -66,6 +70,7 @@ export function NewSessionScene(): JSX.Element {panelId={`new-session-${space.id}`}repositoryConfig={composerRepositoryConfig}onTaskCreated={sessionStarted}+ prefillRequest={prefillRequest}/></div>)@@ -73,7 +78,13 @@ export function NewSessionScene(): JSX.Element {</>)}</div>- <div aria-hidden className="shrink-[34] basis-[66%]" />+ <div className="mx-auto w-full max-w-150 shrink-[34] basis-[66%]">+ {space && suggestions.length > 0 && (+ <div className="pt-6 pb-4">+ <NewSessionSuggestions suggestions={suggestions} onSelect={selectSuggestion} />+ </div>+ )}+ </div></div></SceneContent>)diff --git a/products/tasks/frontend/spaces/NewSessionSuggestions.tsx b/products/tasks/frontend/spaces/NewSessionSuggestions.tsxnew file mode 100644index 000000000000..e153b58c0076--- /dev/null+++ b/products/tasks/frontend/spaces/NewSessionSuggestions.tsx@@ -0,0 +1,83 @@+import { useState } from 'react'++import { IconBug, IconCode, IconMessage, IconPalette, IconPiggyBank, IconTrending } from '@posthog/icons'+import {+ IconStack,+ IconStackItem,+ Item,+ ItemContent,+ ItemDescription,+ ItemMedia,+ ItemTitle,+ Text,+} from '@posthog/quill'++import type { NewSessionSuggestion, NewSessionSuggestionIcon } from './newSessionSuggestionDefaults'++const SUGGESTION_ICONS: Record<NewSessionSuggestionIcon, { Icon: typeof IconBug; color: string }> = {+ trends: { Icon: IconTrending, color: 'var(--color-product-customer-analytics-light)' },+ bug: { Icon: IconBug, color: 'var(--color-product-error-tracking-light)' },+ canvas: { Icon: IconPalette, color: 'var(--color-product-product-analytics-light)' },+ code: { Icon: IconCode, color: 'var(--color-product-tasks-light)' },+ revenue: { Icon: IconPiggyBank, color: 'var(--color-product-revenue-analytics-light)' },+ feedback: { Icon: IconMessage, color: 'var(--color-product-llm-analytics-light)' },+}++export interface NewSessionSuggestionsProps {+ suggestions: NewSessionSuggestion[]+ onSelect: (suggestion: NewSessionSuggestion, index: number) => void+}++export function NewSessionSuggestions({ suggestions, onSelect }: NewSessionSuggestionsProps): JSX.Element {+ const [activeId, setActiveId] = useState<string | null>(null)++ return (+ <div className="@container/new-session-suggestions flex flex-col gap-2">+ <Text size="xs" variant="muted" weight="medium" className="px-1">+ Suggestions+ </Text>+ <div className="grid grid-cols-1 gap-2 @lg/new-session-suggestions:grid-cols-2">+ {suggestions.map((suggestion, index) => {+ const { Icon, color } = SUGGESTION_ICONS[suggestion.icon]+ const activate = (): void => setActiveId(suggestion.id)+ const deactivate = (): void => setActiveId(null)+ return (+ <Item+ key={suggestion.id}+ variant="outline"+ size="sm"+ className="cursor-pointer items-start bg-card text-left text-card-foreground hover:bg-fill-hover"+ render={+ <button+ type="button"+ onClick={() => onSelect(suggestion, index)}+ onMouseEnter={activate}+ onMouseLeave={deactivate}+ onFocus={activate}+ onBlur={deactivate}+ data-attr="today-new-session-suggestion"+ />+ }+ >+ <ItemMedia>+ <IconStack className="[--quill-icon-stack-ring:transparent]">+ <IconStackItem+ color={color}+ active={activeId === suggestion.id}+ className="bg-clip-padding"+ >+ <Icon />+ </IconStackItem>+ </IconStack>+ </ItemMedia>+ <ItemContent className="min-w-0">+ <ItemTitle className="w-full truncate">{suggestion.label}</ItemTitle>+ <ItemDescription>{suggestion.description}</ItemDescription>+ </ItemContent>+ </Item>+ )+ })}+ </div>+ </div>+ )+}diff --git a/products/tasks/frontend/spaces/SpaceTaskComposer.tsx b/products/tasks/frontend/spaces/SpaceTaskComposer.tsxindex 1a8db0b01df2..ae76ab04f533 100644--- a/products/tasks/frontend/spaces/SpaceTaskComposer.tsx+++ b/products/tasks/frontend/spaces/SpaceTaskComposer.tsx@@ -1,4 +1,4 @@-import { EmbeddedTaskComposer } from 'products/posthog_ai/frontend/api/runner'+import { type ComposerPrefillRequest, EmbeddedTaskComposer } from 'products/posthog_ai/frontend/api/runner'import { ChannelDTOApi } from '../generated/api.schemas'import { SpaceComposerRepositoryConfig } from './spaceSceneLogic'@@ -17,6 +17,7 @@ export interface SpaceTaskComposerProps {repositoryConfig: SpaceComposerRepositoryConfigonTaskCreated: (sessionId: string) => voidfocusRequest?: number+ prefillRequest?: ComposerPrefillRequest | null}/** The new-session composer that files into a space, on the space's activity tab and on the new session page. */@@ -26,6 +27,7 @@ export function SpaceTaskComposer({repositoryConfig,onTaskCreated,focusRequest,+ prefillRequest,}: SpaceTaskComposerProps): JSX.Element {return (<EmbeddedTaskComposer@@ -37,6 +39,7 @@ export function SpaceTaskComposer({onTaskCreated={onTaskCreated}focusRequest={focusRequest}autoFocus={false}+ prefillRequest={prefillRequest}fallback={<SpaceTaskComposerSkeleton />}/>)diff --git a/products/tasks/frontend/spaces/newSessionSuggestionDefaults.ts b/products/tasks/frontend/spaces/newSessionSuggestionDefaults.tsnew file mode 100644index 000000000000..cd4bd5f68497--- /dev/null+++ b/products/tasks/frontend/spaces/newSessionSuggestionDefaults.ts@@ -0,0 +1,63 @@+import type { ComposerPrefillRequest } from 'products/posthog_ai/frontend/api/runner'++export type NewSessionSuggestionIcon = 'trends' | 'bug' | 'canvas' | 'code' | 'revenue' | 'feedback'++export interface NewSessionSuggestion {+ id: string+ label: string+ description: string+ prompt: string+ icon: NewSessionSuggestionIcon+ mode?: ComposerPrefillRequest['mode']+}++export const DEFAULT_NEW_SESSION_SUGGESTIONS: NewSessionSuggestion[] = [+ {+ id: 'feature-analysis',+ label: 'Run a feature analysis',+ description: 'Adoption, engagement, and retention',+ icon: 'trends',+ mode: 'auto',+ prompt: "Analyze how a feature is performing: adoption, engagement, and retention of users who use it compared with users who don't. Build a canvas that explains what you found, with the charts behind it.\n\n\nUser input:\n- Feature to analyze:\n- Time period (optional):",+ },+ {+ id: 'debug-user-issue',+ label: 'Debug a user issue',+ description: "Trace a user's events, replays, and errors",+ icon: 'bug',+ mode: 'auto',+ prompt: 'Help me debug an issue a specific user is hitting. Pull their recent events, session replays, and errors, then figure out what went wrong. Build a canvas that explains what you found and the evidence behind it.\n\n\nUser input:\n- Describe the user issue:\n- User identifier (distinct ID, email address, etc):',+ },+ {+ id: 'build-canvas',+ label: 'Build a canvas',+ description: 'Research and explain a question',+ icon: 'canvas',+ mode: 'auto',+ prompt: 'Research a question about our product, then build a canvas that explains the answer. Include the charts that show it and short written context for what they mean.\n\n\nUser input:\n- What should the canvas explain:\n- Time period (optional):',+ },+ {+ id: 'build-feature',+ label: 'Build a new feature',+ description: 'Design and implement something new',+ icon: 'code',+ mode: 'plan',+ prompt: 'Help me build a new feature. Propose an approach, then implement it. Open a PR if appropriate.\n\n\nUser input:\n- Describe the feature you want:\n- Any constraints or requirements (optional):',+ },+ {+ id: 'revenue-patterns',+ label: 'Understand revenue patterns',+ description: 'Trends over time, by plan, and by cohort',+ icon: 'revenue',+ mode: 'auto',+ prompt: 'Analyze our revenue trends. Break them down over time, by plan, and by cohort, and call out notable changes and likely drivers. Build a canvas that explains what you found, with the charts behind it.\n\n\nUser input:\n- What revenue question are you trying to answer:\n- Time period (optional):',+ },+ {+ id: 'summarize-feedback',+ label: 'Summarize user & agent feedback',+ description: 'Common themes across recent feedback',+ icon: 'feedback',+ mode: 'auto',+ prompt: 'Summarize recent user and support agent feedback. Surface the common themes, complaints, and requests. Build a canvas that explains the themes, with examples behind each one.\n\n\nUser input:\n- Feedback source or topic to focus on:\n- Time period (optional):',+ },+]diff --git a/products/tasks/frontend/spaces/newSessionSuggestionsLogic.ts b/products/tasks/frontend/spaces/newSessionSuggestionsLogic.tsnew file mode 100644index 000000000000..77333a131f3f--- /dev/null+++ b/products/tasks/frontend/spaces/newSessionSuggestionsLogic.ts@@ -0,0 +1,69 @@+import { MakeLogicType, actions, kea, listeners, path, reducers } from 'kea'+import posthog from 'posthog-js'++import type { ComposerPrefillRequest } from 'products/posthog_ai/frontend/api/runner'++import { DEFAULT_NEW_SESSION_SUGGESTIONS, NewSessionSuggestion } from './newSessionSuggestionDefaults'++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface newSessionSuggestionsLogicValues {+ prefillRequest: ComposerPrefillRequest | null+ source: string+ suggestions: NewSessionSuggestion[]+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface newSessionSuggestionsLogicActions {+ selectSuggestion: (+ suggestion: NewSessionSuggestion,+ position: number+ ) => {+ position: number+ suggestion: NewSessionSuggestion+ }+ setSuggestions: (+ suggestions: NewSessionSuggestion[],+ source: string+ ) => {+ source: string+ suggestions: NewSessionSuggestion[]+ }+}++export type newSessionSuggestionsLogicType = MakeLogicType<+ newSessionSuggestionsLogicValues,+ newSessionSuggestionsLogicActions+>++export const newSessionSuggestionsLogic = kea<newSessionSuggestionsLogicType>([+ path(['products', 'tasks', 'spaces', 'newSessionSuggestionsLogic']),+ actions({+ setSuggestions: (suggestions: NewSessionSuggestion[], source: string) => ({ suggestions, source }),+ selectSuggestion: (suggestion: NewSessionSuggestion, position: number) => ({ suggestion, position }),+ }),+ reducers({+ suggestions: [+ DEFAULT_NEW_SESSION_SUGGESTIONS as NewSessionSuggestion[],+ { setSuggestions: (_, { suggestions }) => suggestions },+ ],+ source: ['default' as string, { setSuggestions: (_, { source }) => source }],+ prefillRequest: [+ null as ComposerPrefillRequest | null,+ {+ selectSuggestion: (_, { suggestion }) => ({+ prompt: suggestion.prompt,+ mode: suggestion.mode,+ }),+ },+ ],+ }),+ listeners(({ values }) => ({+ selectSuggestion: ({ suggestion, position }) => {+ posthog.capture('today new session suggestion clicked', {+ suggestion_id: suggestion.id,+ position,+ source: values.source,+ })+ },+ })),+])