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(signals): let the report composer reopen the last ask ai run (#115062)

posthog[bot]577908f65076
diff --git a/products/signals/frontend/inbox/components/detail/ReportDiscussionComposer.tsx b/products/signals/frontend/inbox/components/detail/ReportDiscussionComposer.tsx
index 38425aa00a99..d22558f0f93f 100644
--- a/products/signals/frontend/inbox/components/detail/ReportDiscussionComposer.tsx
+++ b/products/signals/frontend/inbox/components/detail/ReportDiscussionComposer.tsx
@@ -1,7 +1,8 @@
import { useActions, useValues } from 'kea'
import { useMemo, useRef, useState } from 'react'
-import { IconSparkles } from '@posthog/icons'
+import { IconChat, IconSparkles } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
import { cn } from 'lib/utils/css-classes'
@@ -30,8 +31,8 @@ export function ReportDiscussionComposer({
report: SignalReport
reportUrl: string
}): JSX.Element {
- const { isDiscussing, isCreatingPr, aiConsentDisabledReason } = useValues(inboxTaskKickoffLogic)
- const { discussReport } = useActions(inboxTaskKickoffLogic)
+ const { isDiscussing, isCreatingPr, aiConsentDisabledReason, lastReportRun } = useValues(inboxTaskKickoffLogic)
+ const { discussReport, openReportTask } = useActions(inboxTaskKickoffLogic)
const textAreaRef = useRef<HTMLTextAreaElement>(null)
const [draft, setDraft] = useState('')
const [activeSuggestionGroup, setActiveSuggestionGroup] = useState<SuggestionGroup | null>(null)
@@ -86,6 +87,15 @@ export function ReportDiscussionComposer({
submit(suggestion.content, 'suggested')
}
+ const lastRun = lastReportRun?.reportId === report.id ? lastReportRun : null
+ const resumeLastRun = (): void => {
+ if (!lastRun) {
+ return
+ }
+ captureInboxReportAction({ report, actionType: 'resume_discussion', surface: 'detail_pane' })
+ openReportTask(report, lastRun.taskId, lastRun.runId)
+ }
+
return (
<div className="flex flex-col h-full min-h-0 items-center justify-center overflow-y-auto p-4">
<div className="w-full max-w-2xl flex flex-col items-center gap-4">
@@ -139,6 +149,17 @@ export function ReportDiscussionComposer({
/>
)}
</Suggestions.Root>
+ {lastRun && (
+ <LemonButton
+ type="tertiary"
+ size="small"
+ icon={<IconChat />}
+ onClick={resumeLastRun}
+ data-attr="inbox-report-ask-ai-resume"
+ >
+ Go back to your last conversation
+ </LemonButton>
+ )}
</div>
</div>
)
diff --git a/products/signals/frontend/inbox/inboxAnalytics.ts b/products/signals/frontend/inbox/inboxAnalytics.ts
index 5f72428f9b25..358b12d8edbf 100644
--- a/products/signals/frontend/inbox/inboxAnalytics.ts
+++ b/products/signals/frontend/inbox/inboxAnalytics.ts
@@ -139,7 +139,8 @@ export type InboxReportFeedbackSentiment = 'positive' | 'negative'
/**
* Report actions cloud actually emits. Names match the desktop enum one-for-one (so the
* `action_type` breakdown reads the same across clients), plus cloud-only `restore` (Dismissed
- * section), `resolve` (marking a report done without an inbox PR), `view_diff`, `show_more` (a list
+ * section), `resolve` (marking a report done without an inbox PR), `resume_discussion` (reopening the
+ * last Ask AI run from the report composer), `view_diff`, `show_more` (a list
* section widening its window), and the section expand/collapse pair (desktop splits those per
* section instead).
* Desktop-only variants we don't fire yet are intentionally omitted.
@@ -149,6 +150,7 @@ export type InboxReportActionType =
| 'clear_feedback'
| 'resolve'
| 'discuss'
+ | 'resume_discussion'
| 'restore'
| 'create_pr'
| 'copy_implementation_prompt'
diff --git a/products/signals/frontend/inbox/inboxTaskKickoffLogic.test.ts b/products/signals/frontend/inbox/inboxTaskKickoffLogic.test.ts
index 5223db77cd0a..1d06d588bcd0 100644
--- a/products/signals/frontend/inbox/inboxTaskKickoffLogic.test.ts
+++ b/products/signals/frontend/inbox/inboxTaskKickoffLogic.test.ts
@@ -515,6 +515,13 @@ describe('inboxTaskKickoffLogic', () => {
expect(panel.values.historyExpanded).toBe(false)
expect(panel.values.activeCreation).toBeNull()
+ // The run keeps working after Back, so the composer must still be able to lead back to it.
+ logic.actions.openReportDiscussion(report, 'https://example.com/report')
+ expect(logic.values.lastReportRun).toEqual({
+ reportId: report.id,
+ taskId: 'report-task',
+ runId: 'report-run',
+ })
})
})
diff --git a/products/signals/frontend/inbox/inboxTaskKickoffLogic.ts b/products/signals/frontend/inbox/inboxTaskKickoffLogic.ts
index e46670c85b49..95b170241c0a 100644
--- a/products/signals/frontend/inbox/inboxTaskKickoffLogic.ts
+++ b/products/signals/frontend/inbox/inboxTaskKickoffLogic.ts
@@ -69,6 +69,12 @@ export interface ReportWarmLease {
runId: string
}
+export interface ReportRunRef {
+ reportId: string
+ taskId: string
+ runId: string
+}
+
export interface ReportChatContext {
report: SignalReport
reportUrl: string
@@ -401,6 +407,7 @@ export interface inboxTaskKickoffLogicValues {
freeTrialDisabledReason: string | null
isCreatingPr: boolean
isDiscussing: boolean
+ lastReportRun: ReportRunRef | null
metricCheckReplacementDisabledReason: string | null
reportChatContext: ReportChatContext | null
reportWarmLease: ReportWarmLease | null
@@ -595,6 +602,14 @@ export const inboxTaskKickoffLogic = kea<inboxTaskKickoffLogicType>([
}),
},
],
+ // The panel's Back button clears the open run, and a report composer offers no history list.
+ // This keeps the last run so the composer can lead back to it while the run keeps working.
+ lastReportRun: [
+ null as ReportRunRef | null,
+ {
+ openReportTask: (_, { report, taskId, runId }) => ({ reportId: report.id, taskId, runId }),
+ },
+ ],
reportWarmLease: [
null as ReportWarmLease | null,
{