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(inbox): close the two dead ends in the scout kickoff flow (#75829)

posthog[bot]f5f5816d1f65
diff --git a/frontend/src/scenes/inbox/components/cards/SignalRunCard.tsx b/frontend/src/scenes/inbox/components/cards/SignalRunCard.tsx
index 9b0228a915f0..d58686aabe19 100644
--- a/frontend/src/scenes/inbox/components/cards/SignalRunCard.tsx
+++ b/frontend/src/scenes/inbox/components/cards/SignalRunCard.tsx
@@ -6,6 +6,7 @@ import { LemonTag, Link } from '@posthog/lemon-ui'
import { TZLabel } from 'lib/components/TZLabel'
import { urls } from 'scenes/urls'
+import { captureInboxRunOpened } from '../../inboxAnalytics'
import { SignalRun } from '../../types'
import { stripScoutPrefix } from '../../utils/scoutRunsWindow'
import { resolveRunVariant, VARIANT_META } from './runStatusVariant'
@@ -24,6 +25,9 @@ export function SignalRunCard({ run }: { run: SignalRun }): JSX.Element {
column so it isn't nested inside this link. */}
<Link
to={urls.taskDetail(run.task_id)}
+ onClick={() =>
+ captureInboxRunOpened({ kind: run.kind, status: run.status, hasReport: !!run.report_id })
+ }
className="flex min-w-0 flex-1 items-start gap-2.5 text-left text-inherit no-underline"
>
{/* One small color-coded dot carries the status — no separate orb or status tag. */}
diff --git a/frontend/src/scenes/inbox/inboxAnalytics.ts b/frontend/src/scenes/inbox/inboxAnalytics.ts
index 994dabac120c..92a52f9227d0 100644
--- a/frontend/src/scenes/inbox/inboxAnalytics.ts
+++ b/frontend/src/scenes/inbox/inboxAnalytics.ts
@@ -2,7 +2,7 @@ import posthog from 'posthog-js'
import { dayjs } from 'lib/dayjs'
-import { SignalReport, SignalReportActionability, SignalReportPriority } from './types'
+import { SignalReport, SignalReportActionability, SignalReportPriority, SignalRunKind } from './types'
/**
* Inbox telemetry. Mirrors the desktop "Code" app's inbox analytics (event names + property
@@ -34,6 +34,7 @@ export const INBOX_EVENTS = {
SCOUT_CONFIG_CHANGED: 'Scout config changed',
SCOUT_ACTION: 'Scout action',
SCOUT_CHAT_STARTED: 'Scout chat started',
+ RUN_OPENED: 'Inbox run opened',
} as const
type InboxEvent = (typeof INBOX_EVENTS)[keyof typeof INBOX_EVENTS]
@@ -543,6 +544,22 @@ export function captureScoutAction(params: {
})
}
+/**
+ * A Runs tab row was opened. Nothing was captured here before, so a run that lands on a dead or
+ * unrelated task page left no trace outside a session recording.
+ */
+export function captureInboxRunOpened(params: {
+ kind: SignalRunKind
+ status: string | null
+ hasReport: boolean
+}): void {
+ captureInboxEvent(INBOX_EVENTS.RUN_OPENED, {
+ run_kind: params.kind,
+ run_status: params.status,
+ has_report: params.hasReport,
+ })
+}
+
/** A scout CTA kicked off a cloud task ("Suggest a scout", the fleet-overview chips). */
export function captureScoutChatStarted(params: {
chatType: ScoutChatType
diff --git a/frontend/src/scenes/inbox/inboxSceneLogic.test.ts b/frontend/src/scenes/inbox/inboxSceneLogic.test.ts
index 9c3f5d8d47ae..912395df1528 100644
--- a/frontend/src/scenes/inbox/inboxSceneLogic.test.ts
+++ b/frontend/src/scenes/inbox/inboxSceneLogic.test.ts
@@ -52,6 +52,14 @@ describe('mergeSignalRuns', () => {
expect(merged.map((r) => r.task_id)).toEqual(['task-ok'])
})
+ it('drops signal tasks with no report link (the scout-authoring CTA threads share the origin)', () => {
+ const merged = mergeSignalRuns(
+ [],
+ [signalTask({ id: 'scout-authoring-chat', title: 'Suggest a scout', signal_report: null })]
+ )
+ expect(merged).toEqual([])
+ })
+
it('interleaves scout and signal rows newest-first by created_at', () => {
const merged = mergeSignalRuns(
[scoutRun({ task_id: 'scout-old', created_at: '2026-06-10T00:00:00Z' })],
diff --git a/frontend/src/scenes/inbox/inboxSceneLogic.ts b/frontend/src/scenes/inbox/inboxSceneLogic.ts
index 2c4466bf72b4..988d162b7db4 100644
--- a/frontend/src/scenes/inbox/inboxSceneLogic.ts
+++ b/frontend/src/scenes/inbox/inboxSceneLogic.ts
@@ -63,6 +63,11 @@ const TASK_RUN_STATUS_TO_SCOUT_STATUS: Record<TaskRunStatus, SignalScoutRunStatu
* `SignalRun[]`. Pure (no I/O) so the merge/sort/normalize contract is unit-testable directly.
* Scout runs without a backing `task_id` are dropped (they can't deep-link to a task); signal rows
* fall back to the task's own timestamp / a null status when no run exists yet.
+ *
+ * A signal task only counts as a run once it's linked to a report. `origin_product=signal_report`
+ * alone is too broad: the scout-authoring CTAs create chat threads under the same origin, and those
+ * are a "let's write a scout" conversation, not a pipeline run — listing them here drops the user
+ * into a thread with no report to go back to.
*/
export function mergeSignalRuns(scoutRuns: SignalScoutRunSummary[], signalTasks: Task[]): SignalRun[] {
const scoutRows = scoutRuns
@@ -77,17 +82,19 @@ export function mergeSignalRuns(scoutRuns: SignalScoutRunSummary[], signalTasks:
created_at: run.created_at,
})
)
- const signalRows = signalTasks.map((task): SignalRun => {
- const latestStatus = task.latest_run?.status
- return {
- task_id: task.id,
- kind: 'signal',
- title: task.title,
- status: latestStatus ? TASK_RUN_STATUS_TO_SCOUT_STATUS[latestStatus] : null,
- report_id: task.signal_report,
- created_at: task.latest_run?.created_at ?? task.created_at,
- }
- })
+ const signalRows = signalTasks
+ .filter((task): task is Task & { signal_report: string } => !!task.signal_report)
+ .map((task): SignalRun => {
+ const latestStatus = task.latest_run?.status
+ return {
+ task_id: task.id,
+ kind: 'signal',
+ title: task.title,
+ status: latestStatus ? TASK_RUN_STATUS_TO_SCOUT_STATUS[latestStatus] : null,
+ report_id: task.signal_report,
+ created_at: task.latest_run?.created_at ?? task.created_at,
+ }
+ })
return [...scoutRows, ...signalRows].sort(
(a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()
)
diff --git a/products/posthog_ai/frontend/logics/taskLogic.test.ts b/products/posthog_ai/frontend/logics/taskLogic.test.ts
index 477533acb02f..df0bdeacc2b1 100644
--- a/products/posthog_ai/frontend/logics/taskLogic.test.ts
+++ b/products/posthog_ai/frontend/logics/taskLogic.test.ts
@@ -1,5 +1,7 @@
import { expectLogic } from 'kea-test-utils'
+import { lemonToast } from '@posthog/lemon-ui'
+
import { ApiError } from 'lib/api'
import { initKeaTests } from '~/test/init'
@@ -29,6 +31,11 @@ const createMockTask = (id: string): Task => ({
created_by: null,
})
+jest.mock('@posthog/lemon-ui', () => ({
+ ...jest.requireActual('@posthog/lemon-ui'),
+ lemonToast: { error: jest.fn(), success: jest.fn() },
+}))
+
describe('taskLogic', () => {
let logic: ReturnType<typeof taskLogic.build>
@@ -81,6 +88,22 @@ describe('taskLogic', () => {
})
})
+ describe('runTaskFailure', () => {
+ it('surfaces the error and clears the in-flight state so the button is clickable again', async () => {
+ logic = taskLogic({ taskId: 'task-123' })
+ logic.mount()
+
+ logic.actions.runTask()
+ expect(logic.values.runTaskInFlight).toBe(true)
+
+ logic.actions.runTaskFailure('Sandbox unavailable', new ApiError('Sandbox unavailable', 503))
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.runTaskInFlight).toBe(false)
+ expect(lemonToast.error).toHaveBeenCalledWith('Sandbox unavailable')
+ })
+ })
+
describe('runTaskSuccess', () => {
it('updates tasksLogic with task including new run', async () => {
const tasksLogicInstance = tasksLogic()
diff --git a/products/posthog_ai/frontend/logics/taskLogic.ts b/products/posthog_ai/frontend/logics/taskLogic.ts
index 6603fc992894..e503c99509fa 100644
--- a/products/posthog_ai/frontend/logics/taskLogic.ts
+++ b/products/posthog_ai/frontend/logics/taskLogic.ts
@@ -1,6 +1,9 @@
import { MakeLogicType, kea, key, listeners, path, props, reducers } from 'kea'
import { loaders } from 'kea-loaders'
import { router } from 'kea-router'
+import posthog from 'posthog-js'
+
+import { lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
@@ -17,6 +20,7 @@ export interface TaskLogicProps {
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface taskLogicValues {
+ runTaskInFlight: boolean
task: Task | null
taskError: string | null
taskLoading: boolean
@@ -120,7 +124,13 @@ export const taskLogic = kea<taskLogicType>([
// Interactive, not the default background: this run starts from the detail page the user
// is watching, and the agent-server only relays AskUserQuestion (and other approval
// prompts) to the client on non-background runs.
- return await api.tasks.run(props.taskId, { mode: TaskExecutionModeEnumApi.Interactive })
+ return await api.tasks.run(props.taskId, {
+ mode: TaskExecutionModeEnumApi.Interactive,
+ // The agent-server self-delivers `pending_user_message` from run state on boot, and
+ // interactive runs skip the workflow's forwarding path — nothing falls back to the
+ // task description. Without it the sandbox boots with no first turn and just idles.
+ ...(values.task?.description ? { pending_user_message: values.task.description } : {}),
+ })
},
deleteTask: async () => {
await api.tasks.delete(props.taskId)
@@ -144,6 +154,16 @@ export const taskLogic = kea<taskLogicType>([
loadTaskFailure: (_, { errorObject }) => isApiNotFound(errorObject),
},
],
+ // The run loader shares the `task` loader's `taskLoading`, which is also true for plain
+ // reloads — the Run button needs its own in-flight flag so it can't be clicked into the void.
+ runTaskInFlight: [
+ false,
+ {
+ runTask: () => true,
+ runTaskSuccess: () => false,
+ runTaskFailure: () => false,
+ },
+ ],
taskError: [
null as string | null,
{
@@ -153,7 +173,7 @@ export const taskLogic = kea<taskLogicType>([
},
],
}),
- listeners(({ values }) => ({
+ listeners(({ props, values }) => ({
loadTaskSuccess: () => {
if (values.task) {
tasksLogic.findMounted()?.actions.updateTask(values.task)
@@ -164,6 +184,13 @@ export const taskLogic = kea<taskLogicType>([
tasksLogic.findMounted()?.actions.updateTask(values.task)
}
},
+ runTaskFailure: ({ error, errorObject }) => {
+ const message = loadErrorMessage(error, errorObject)
+ lemonToast.error(message || 'Failed to start the run')
+ // Previously a rejected run changed nothing on screen, so the failure rate was
+ // unmeasurable — capture it rather than leaving it to session recordings.
+ posthog.capture('task_run_start_failed', { task_id: props.taskId, error: message })
+ },
updateTaskSuccess: () => {
if (values.task) {
tasksLogic.findMounted()?.actions.updateTask(values.task)
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDetailPage.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDetailPage.tsx
index 6971001b8ee6..48345baf7d75 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDetailPage.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDetailPage.tsx
@@ -22,7 +22,8 @@ export interface TaskDetailPageProps {
export function TaskDetailPage({ taskId, isMobile }: TaskDetailPageProps): JSX.Element {
const sceneLogic = taskDetailSceneLogic({ taskId })
- const { task, taskNotFound, taskError, runs, selectedRun, isTaskPending, isHeaderLoading } = useValues(sceneLogic)
+ const { task, taskNotFound, taskError, runs, selectedRun, isTaskPending, isHeaderLoading, runTaskInFlight } =
+ useValues(sceneLogic)
const { runTask, deleteTask, loadTask } = useActions(sceneLogic)
const { featureFlags } = useValues(featureFlagLogic)
const { activeCreation } = useValues(taskTrackerSceneLogic)
@@ -67,7 +68,14 @@ export function TaskDetailPage({ taskId, isMobile }: TaskDetailPageProps): JSX.E
</LemonButton>
)}
{!isPiTaskRuntime(task.runtime) && !isLatestRunInProgress && !isLatestRunCompleted && (
- <LemonButton type="primary" size="small" icon={<IconPlay />} onClick={runTask}>
+ <LemonButton
+ type="primary"
+ size="small"
+ icon={<IconPlay />}
+ onClick={runTask}
+ loading={runTaskInFlight}
+ disabledReason={runTaskInFlight ? 'Starting the run' : undefined}
+ >
{runButtonText}
</LemonButton>
)}
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.ts
index 973a2f566633..f0859143351f 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.ts
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.ts
@@ -29,6 +29,7 @@ export type TaskDetailSceneLogicProps = TaskLogicProps
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface taskDetailSceneLogicValues {
+ runTaskInFlight: boolean // taskLogic
task: Task | null // taskLogic
taskError: string | null // taskLogic
taskLoading: boolean // taskLogic
@@ -146,7 +147,7 @@ export const taskDetailSceneLogic = kea<taskDetailSceneLogicType>([
key((props) => props.taskId),
connect((props: TaskDetailSceneLogicProps) => ({
- values: [taskLogic(props), ['task', 'taskLoading', 'taskNotFound', 'taskError']],
+ values: [taskLogic(props), ['task', 'taskLoading', 'taskNotFound', 'taskError', 'runTaskInFlight']],
actions: [
taskLogic(props),
['loadTask', 'loadTaskSuccess', 'runTask', 'runTaskSuccess', 'deleteTask', 'updateTask'],