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(phai): unify TaskTracker loaders and error states (#66253)

Georgiy Tarasov57ffb71660ab
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 5486d58edff1..e44f9041c844 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5577,17 +5577,17 @@ snapshots:
scenes-app-inbox-detail--report-minimal--light:
hash: v1.k794b7964.0d41bcb80f75889f19bb97431a0ea86a2128d00eafd5a07c5f7ac5acc3e7d14e.7a4HLQtAa2T29HhTiXgo4hhzixjc70hJlL6tOGxN5IE
scenes-app-inbox-detail--run-failed--dark:
- hash: v1.k794b7964.2acef5200f1a224e4703a48e86d554af9ad74436c3b797101820c5b7c781136c.92CBgDspT8I31nE2c_EDoDdOdIv5KJo3A1GaPe1UT24
+ hash: v1.k794b7964.c0871658ef7f3c70991579392f170e561b7e02012f25b2fb91c037e12ef2b7e5.9BuPfkNlOUsXtPDxZw0SpzHuxsFpRk0zYr1qbUSfTUE
scenes-app-inbox-detail--run-failed--light:
- hash: v1.k794b7964.f7b87386c6992664f27ed406bd9914973d9942f359e88108b379956b6f56e893.Buu_XGONwE_XnQy0DzLM1VKPtXDNkCN56uThmsEj6c0
+ hash: v1.k794b7964.44ebf07a1f6f87a9da89aaa2fb74e1fb3eab77b551fef3c53940e5241946381b.fVc4j0b_baLCed5kkBPuSCwJbUGz7yXi_G3pkWHca-8
scenes-app-inbox-detail--run-in-progress--dark:
- hash: v1.k794b7964.f79b25a6fca808926518901392571ca5e16d453cd99a97dc0b7174d18087648f.Zp_xspMLdCzJWxP7B4_TiwwPvLJK5JFlrwANlnves1w
+ hash: v1.k794b7964.ab9f9752bb67cc0ad39a4ff7d1efd848ecf14f6f71f343634283d7cc4a790ed7.hhAXCqbj1_PfpZOKUlNZASh7EdvcfqxHft4QMMIgvBo
scenes-app-inbox-detail--run-in-progress--light:
- hash: v1.k794b7964.975335749852a054dc196e070a8b91c5eb40a563560fcc7741b6f8e44d11066e.yFm7WNmicK8eHzxdDb-ORXXjv3PHIpzoPbFo8W5c2cc
+ hash: v1.k794b7964.afd17a4f6ab6b7c2da21b3516168e9dc46e16ee95f7b15f4b464f8a6079d990e.IO1ku-tgJBFhGQ0AtZWiMzK7Kljtv0R2zPLSx3u8L4c
scenes-app-inbox-detail--run-ready--dark:
- hash: v1.k794b7964.f4d5851d8282a06f95f7cee962402b997bae19978b5c19d19e3c8932a1c47ccd.4wqc2vZ7Tjk9Mgf1MveZOwePBnMdm24VJ3qHgo-ikdM
+ hash: v1.k794b7964.9455e0021fee635cd2dc67ef2dd6f5ea0e1acb15fbe396235b7c577589cfc9cc.DIumkcqd3LeJxymXRgoiGqMXSRRQsrlSgVRozhIwWcY
scenes-app-inbox-detail--run-ready--light:
- hash: v1.k794b7964.2fbb263dadddfb78130f7ce6666d5ef10151ebec9143e7f00ab0285bd3b9a21f.wRvvBPNYIVLvm3HJy8POg4TxUHmaOjEp_67VyRIArWM
+ hash: v1.k794b7964.1275e53ffe43ab03b0662bdce1c71ff390aca055f822bbe9ef0d1da32b3ad6ac.DwdNm96SH0AWVIw4gKzdTglfVjjs0n7WNjsvPptuMko
scenes-app-inbox-scene--empty--dark:
hash: v1.k794b7964.0730c341122d1d593f4e6acf7a176e05bdd79e9ca6bf5f785a909fd57ad274f1.V4Hgc6xF9-5hiq75aqzZWcbiemdqMe3fdbcMqVHbg7U
scenes-app-inbox-scene--empty--light:
@@ -6752,6 +6752,10 @@ snapshots:
hash: v1.k794b7964.a4d6867ee7ae54ba44c7f6f4002d6e33fa830d206ac6afa05f2b89e0ca95e346.PDSiDJLaSvGtlHV3OjGJ6kswEGvkiWvnCzctD2gAQ5g
scenes-app-tasks--empty--light:
hash: v1.k794b7964.29c0f8bc2017536737772598446346d98313568315f72ededbf1d039607547e0.OU_OMY38iwmrrhLdUcM_p-SzDyhjQdoWZzMPV68MXL4
+ scenes-app-tasks--list-load-error--dark:
+ hash: v1.k794b7964.a60a5d6cd5201b8e3f6621a7282d1b87a916e7d3da33702fa37e4ea04cfe3e0b.JjeTJaTZTYuFHMtutyvlUxleGBRoHAXfwBh9uAZO36I
+ scenes-app-tasks--list-load-error--light:
+ hash: v1.k794b7964.083e8fe00fe541815b5c7252bf2ebe087ac6742ccb968f789f0f24869fb97d91.pXzJliBz214_88INCoXcrF8TKRrqEKezPr2pOsrOm2c
scenes-app-tasks--list-with-composer--dark:
hash: v1.k794b7964.5435b6f664c848c8e1724754d4e7226c8c29408bc8aa28a760ec383ddd9164aa.nyXHi9_h37_s0KjS06fJ8LjfegSLs-eaCz947neTM38
scenes-app-tasks--list-with-composer--light:
@@ -6769,17 +6773,17 @@ snapshots:
scenes-app-tasks--mobile-new-task--light:
hash: v1.k794b7964.c28ab66e9201b84fb893ff6d661d5af159afb5dc69d646dcf12e55c80ee5f6fd.FB3N3ZfQFFAz8Z5g6aUXzHSx47UrNWDuNrz41kFBns0
scenes-app-tasks--mobile-task-selected--dark:
- hash: v1.k794b7964.7e4cde9ac22735bb8bee5b7aca4a4bf400701138d2bee6bdb89c5da650a0bc81.qulE70DQ-8xxLRME6Cm5KDoPrEXIxkaaHjJLnE5dMkM
+ hash: v1.k794b7964.45c56cdba57d4cdfcca851cc2ad88c08831fe0cbab19863b86a028705d7b52a8.BwQ4BP5IbXOFCimc4-sLUVE54-zEA9naxwb7q7EWR58
scenes-app-tasks--mobile-task-selected--light:
- hash: v1.k794b7964.094371966357cba5e2f30b552a4cc02fdf6ea46934368b8f9868c4d070eb8ddb._NbMzS6nW8ctbuOszrsuzpqW01MYXxi3MA0YQ7d82nA
+ hash: v1.k794b7964.fcba0f8e9e7360da3c671debfff263fc22467c9820e5706207523add08e29d99.Nr7dbzdN-8LSM4JvLEOty1cjbb4zz4XFhGfJp9pH8iQ
scenes-app-tasks--new-task--dark:
hash: v1.k794b7964.5435b6f664c848c8e1724754d4e7226c8c29408bc8aa28a760ec383ddd9164aa.DtHTFuTejBqpfhCO8FgLuAhKadOx0aeFUMTb7gKTXWU
scenes-app-tasks--new-task--light:
hash: v1.k794b7964.0873123f13ccdc83104f94c89d562a43c89b7c2c788e1264f499d38f7a78ad79.Zi2QsmppKkEO3piOxpmRAC-s1BFLahgR9MqWLhWuih0
scenes-app-tasks--task-detail-loading--dark:
- hash: v1.k794b7964.4e7464d60099a8450a3bbdce6cd6f55eefab279b3711f96d30bb19d0699460d1.nyXVcroEmfj0PXfsRp6Cx7WDkqF_ViQW3IJgtYBQC6w
+ hash: v1.k794b7964.036059c7da17026e0b6bcefd1424e247f6704e22e0ea2224c7923fa158a893cd.mCbM-Nn0alpVZeNCLn0Rtm7H0tdQGjxNfw2VwvQWbzk
scenes-app-tasks--task-detail-loading--light:
- hash: v1.k794b7964.fff3b9c0672f7b587207e47277a0bf4ea31f3ce5f4e627516d40792d56ceb5b7.19yIVqbDBDJK6bz837XIzMwMGDhfLNAqEjI6HlvISFc
+ hash: v1.k794b7964.a57d30a1035c87baa14e1968c697c7a8fec37125ac89432c87a9d08a325c6755.uf5e5AuhnUeCjIkXs4beBgD0ZJzUfhh-e3gSkTmxkLM
scenes-app-tasks--task-load-error--dark:
hash: v1.k794b7964.b945c04a5f6ce7dce2c1b38e46cf57df2c5f18eb8ba2f7ee8973c78035125465.kggPLzQhG1IhgnDvoy6odZpMs16As580yZ-09bNNr2o
scenes-app-tasks--task-load-error--light:
@@ -6789,17 +6793,17 @@ snapshots:
scenes-app-tasks--task-not-found--light:
hash: v1.k794b7964.4984e3b1be757bea26eb62183f1ff0f8d765654e57e88119164140d08eb86a22.PzkPd5Gio2FjQVIClJaRykwCa5WtEdFzlCPW7UazGnk
scenes-app-tasks--task-run-not-found--dark:
- hash: v1.k794b7964.ba9d36f73cacdfb6e2ee628d42081e2a7d7b7b5e6ea3916a3ed7e8e2b8dfe1f9.xk8nfrLdGjzbZuhzqB5ikjyrEKvzgLaA2tGIibzyY1Y
+ hash: v1.k794b7964.948ed15dc2cacf0c1ae3511803830c1aadbc6f1ae2a0bd271db71ddfba928338.sWKmNqmJfo11A77GadBwwJSCIJbCU2sYMPFWojdnr1k
scenes-app-tasks--task-run-not-found--light:
- hash: v1.k794b7964.088701b3cbe295c509ae6e93a131de71a0c5ea79d4be69f2871f70413ad3e647.HkMeU9Qzi_5eIMJPic_O_civBrTH0mio2i72r7LleJ0
+ hash: v1.k794b7964.2b03d9bda67392d193e5ccc1793b4c2d38e5774fece2a95d0ffe72b1bc51d972.vqP6OdDP9_HMGGsodTSmbMlOi9xdl0Xw5ELBoXF4TkQ
scenes-app-tasks--task-runs-load-error--dark:
- hash: v1.k794b7964.6bfebabbe8485d60c4c34c81051447ee59b6818aace944f6700cbe843f6ba512.8nVH4g9HF_BbdLyXQ2krZnlZBMA2G8Q2wlb157afLcc
+ hash: v1.k794b7964.476ad4a74ebba7c06613b27f169471dcb9221a852eae3265ad4618b3141bb43c.TeXVuyo4ziRfDOfHg6lllLZ16ppKxvi7TAN-w2Aae3U
scenes-app-tasks--task-runs-load-error--light:
- hash: v1.k794b7964.0845d49663ac4d4693894ba2515dd40c6225f5964eed1cc9953f407a489787c7.H7imQdr7JpKmBVA8KHpVSs1WvdQ2yZm4txgOhZKeBl0
+ hash: v1.k794b7964.dd3089cd902fc9598e5850a1c5693766c861df7e3c448f947860dcf90252df60.AXhOq0KvByljMk7iWLipy8o4ny2fhhsn6-3MYBW-Z6g
scenes-app-tasks--task-selected--dark:
- hash: v1.k794b7964.0b0f1a819fe5f147cff7a7b54e5bf568a06ee44033e5e27eac3832dee39c04d0.PO70htE6tUnmkqQhoK9eLKUtaHXyQAZuFHfb9Q9mHmI
+ hash: v1.k794b7964.43141d26e6c595c08b802fc27b45f0b789b9a30e6adb9f89cc7cf6f84589af0c.igILN389iz6FTrt2YEcIXOkKbmvVa0O4V3dGEt67IyI
scenes-app-tasks--task-selected--light:
- hash: v1.k794b7964.53c8bcaaea10f801ee1f0abf1c9f80bd8c10947360da77ce965a0f9d6264569a.EoEhPvY7PpvPpgLwelqa_MwdllPT0Po8JV6ZgIRw0Ps
+ hash: v1.k794b7964.e4fe2d6614fb9c055af9651beb6f0c419b1103ecea61b67f5cdcd5071429e3c9.LPqOfl6yK7UKwgvALvn7RmWj3OeOo36NAlMLcsf84iQ
scenes-app-user-interviews-invite-preview-modal--emailable--dark:
hash: v1.k794b7964.0cd3e50dcd442e57712b0ebe06d6952c589a4c88c49fca26771c9e17bc07e6dc.iNYX9Up5MvnGHGT7ku7yMuFIJ0NnbSspOz6Ce0Kb2cU
scenes-app-user-interviews-invite-preview-modal--emailable--light:
diff --git a/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx b/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
index fe1003723619..07f5ebbcdf71 100644
--- a/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
+++ b/frontend/src/scenes/inbox/components/detail/AgentRunDetail.tsx
@@ -193,7 +193,13 @@ function TaskLogBody({
return (
<div className="h-[calc(100dvh-22rem)] min-h-[420px] w-full overflow-hidden rounded border border-primary bg-surface-primary">
{/* In-progress runs stream live; terminal runs show the static replay. */}
- <RunViewer taskId={task.id} runId={runId} interaction={replayOnly ? 'read-only' : 'live'} />
+ <RunViewer
+ taskId={task.id}
+ runId={runId}
+ interaction={replayOnly ? 'read-only' : 'live'}
+ threadRowClassName="px-3"
+ threadListClassName="py-3"
+ />
</div>
)
}
diff --git a/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx b/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx
index 498db38c341a..c77409890d33 100644
--- a/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ArtefactTaskRun.tsx
@@ -107,7 +107,13 @@ export function ArtefactTaskRun({
{expanded && task && runId ? (
<div className="mt-2 h-[420px] overflow-hidden rounded border border-primary bg-surface-primary">
- <RunViewer taskId={task.id} runId={runId} interaction={replayOnly ? 'read-only' : 'live'} />
+ <RunViewer
+ taskId={task.id}
+ runId={runId}
+ interaction={replayOnly ? 'read-only' : 'live'}
+ threadRowClassName="px-3"
+ threadListClassName="py-3"
+ />
</div>
) : null}
</div>
diff --git a/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx b/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx
index b2fff5e2b061..669b2a7f4abf 100644
--- a/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx
+++ b/frontend/src/scenes/inbox/components/detail/ReportTasksSection.tsx
@@ -85,12 +85,16 @@ function TaskRow({
{expanded ? (
<div className="mt-1.5 mb-1 ml-1.5">
{runId ? (
- <div className="h-[420px] overflow-y-auto rounded border border-primary bg-surface-primary">
+ // The viewer's virtualized thread owns scroll, so this box only bounds the height and
+ // clips — an `overflow-y-auto` here would nest a second scrollbar. Content is kept off
+ // the border via `threadRowClassName`/`threadListClassName`, not padding on this box.
+ <div className="h-[420px] overflow-hidden rounded border border-primary bg-surface-primary">
<RunViewer
taskId={task.id}
runId={runId}
interaction={replayOnly ? 'read-only' : 'live'}
- className="px-3 py-2"
+ threadRowClassName="px-3"
+ threadListClassName="py-3"
/>
</div>
) : (
diff --git a/products/posthog_ai/frontend/AGENTS.md b/products/posthog_ai/frontend/AGENTS.md
index 0e83fb031140..b7c2a7f6fa68 100644
--- a/products/posthog_ai/frontend/AGENTS.md
+++ b/products/posthog_ai/frontend/AGENTS.md
@@ -41,8 +41,12 @@ The headline exports per module:
- **`api/run`** — **`RunViewer`**, the lazy, code-split embeddable: calling `<RunViewer .../>` binds the
stream logic and renders the default layout behind a `RunLogSkeleton` Suspense fallback (the heavy chunk —
- stream logic, virtualized thread, tool/diff renderers — loads on demand). It is the only form any consumer
- uses; the compound (`Root` + `.Thread/.Prompt/.Composer/.Resources/.ContextUsage` slots) stays internal to
+ stream logic, virtualized thread, tool/diff renderers — loads on demand). This is the form every **embed**
+ uses (the inbox detail views), where the viewer is a secondary panel worth splitting out. The one exception
+ is the **runner scene** (`scenes/TaskTracker`), which renders `components/RunViewerImpl` **directly (eager,
+ relative import)**: the `/tasks` route is already a code-split scene chunk and the viewer is its primary
+ content, so a second `lazy()` would only add a redundant chunk fetch + Suspense flash. The compound
+ (`Root` plus the `.Thread/.Prompt/.Composer/.Resources/.ContextUsage` slots) stays internal to
`components/RunViewerImpl` backing the default layout, not surfaced (no consumer composes the slots, and
lazy-wrapping each would only add Suspense boundaries that never fire). For a custom layout, bind
`runStreamLogic` and compose the Tier 2 primitives. Also **`RunComposer`**.
diff --git a/products/posthog_ai/frontend/README.md b/products/posthog_ai/frontend/README.md
index 17068603cd6f..0d1e24d7931d 100644
--- a/products/posthog_ai/frontend/README.md
+++ b/products/posthog_ai/frontend/README.md
@@ -40,6 +40,12 @@ Pick the **lowest tier** that does the job.
`api/run` (Tier 1) is built on `api/primitives` (Tier 2); `api/primitives` consumes the headless
`api/logics`/`api/types` (Tier 3). Going down a tier trades convenience for control and a smaller chunk.
+`RunViewer` is **lazy by default** — code-split behind a `RunLogSkeleton` Suspense fallback — because the
+embeds that use it (the inbox detail views) show it as a secondary panel. A surface where the run viewer is
+the _primary_ content of an already-code-split route (the `/tasks` runner scene) is the exception: it renders
+the eager implementation directly so it doesn't pay a second chunk fetch + Suspense flash for the one thing
+the route exists to show.
+
## 3. Recipes
Each recipe shows the granular import to copy.
diff --git a/products/posthog_ai/frontend/components/RunLogSkeleton.tsx b/products/posthog_ai/frontend/components/RunLogSkeleton.tsx
index 24f427a72326..e3c419189e6f 100644
--- a/products/posthog_ai/frontend/components/RunLogSkeleton.tsx
+++ b/products/posthog_ai/frontend/components/RunLogSkeleton.tsx
@@ -2,23 +2,33 @@ import { memo } from 'react'
import { LemonSkeleton } from '@posthog/lemon-ui'
+import { cn } from 'lib/utils/css-classes'
+
/**
* Loading state for "a run/task log is loading" — shared by the runner scene, the lazy `RunViewer` chunk's
* Suspense fallback, and `RunViewer`'s in-stream bootstrap. Mirrors `ThreadView`'s centered `max-w-180`
* column and `MessageTemplate`'s rounded left/right bubbles so the surface keeps its shape when content
* mounts. A `LemonSkeleton`-only leaf, so it stays out of the heavy chunk and is safe as a fallback.
*/
-export const RunLogSkeleton = memo(function RunLogSkeleton(): JSX.Element {
+export const RunLogSkeleton = memo(function RunLogSkeleton({
+ className,
+ listClassName,
+ rowClassName,
+}: {
+ className?: string
+ listClassName?: string
+ rowClassName?: string
+}): JSX.Element {
return (
- <div className="flex flex-col h-full min-h-0 w-full" data-attr="run-log-skeleton">
- <div className="flex flex-col gap-1.5 w-full max-w-180 mx-auto pt-4">
- <div className="flex justify-start w-full">
+ <div className={cn('flex flex-col h-full min-h-0 w-full', className)} data-attr="run-log-skeleton">
+ <div className={cn('flex flex-col gap-1.5 w-full max-w-180 mx-auto pt-4', listClassName)}>
+ <div className={cn('flex justify-end w-full', rowClassName)}>
<LemonSkeleton className="h-16 w-3/4 rounded-lg" />
</div>
- <div className="flex justify-end w-full">
+ <div className={cn('flex justify-start w-full', rowClassName)}>
<LemonSkeleton className="h-10 w-1/2 rounded-lg" />
</div>
- <div className="flex justify-start w-full">
+ <div className={cn('flex justify-end w-full', rowClassName)}>
<LemonSkeleton className="h-24 w-4/5 rounded-lg" />
</div>
</div>
diff --git a/products/posthog_ai/frontend/components/RunViewerImpl.tsx b/products/posthog_ai/frontend/components/RunViewerImpl.tsx
index f9e9e5c0e6ea..ef21a6332e0a 100644
--- a/products/posthog_ai/frontend/components/RunViewerImpl.tsx
+++ b/products/posthog_ai/frontend/components/RunViewerImpl.tsx
@@ -29,6 +29,10 @@ export interface RunViewerProps {
*/
interaction?: 'live' | 'read-only'
className?: string
+ /** Applied to the thread's list wrapper (`VirtualizedThread.Root`), not the react-window scroll viewport. */
+ threadListClassName?: string
+ /** Applied to each thread item row's centered content (`VirtualizedThread.Row`); header/footer rows excluded. */
+ threadRowClassName?: string
/**
* Composer wiring — live mode only. Provide all of `composerValue`/`onComposerChange`/`onComposerSubmit`
* to render the follow-up composer; the consumer owns the draft and the send (this module never POSTs
@@ -101,6 +105,8 @@ function RunViewerRoot({
conversationId,
interaction = 'read-only',
className,
+ threadListClassName,
+ threadRowClassName,
composerValue,
onComposerChange,
onComposerSubmit,
@@ -133,7 +139,13 @@ function RunViewerRoot({
}}
>
<RunViewerBootstrap taskId={taskId} />
- {children ?? <DefaultRunViewerLayout className={className} />}
+ {children ?? (
+ <DefaultRunViewerLayout
+ className={className}
+ threadListClassName={threadListClassName}
+ threadRowClassName={threadRowClassName}
+ />
+ )}
</RunViewerContext.Provider>
</BindLogic>
)
@@ -157,14 +169,18 @@ function RunViewerBootstrap({ taskId }: { taskId: string }): null {
}
/** Thread slot: the streamed run thread, with the shared run-log skeleton during the first bootstrap. */
-function RunViewerThread(): JSX.Element {
+function RunViewerThread({
+ className,
+ listClassName,
+ rowClassName,
+}: { className?: string; listClassName?: string; rowClassName?: string } = {}): JSX.Element {
const { bootstrapLoading, threadItems } = useValues(runStreamLogic)
const showSkeleton = bootstrapLoading && threadItems.length === 0
if (showSkeleton) {
- return <RunLogSkeleton />
+ return <RunLogSkeleton className={className} listClassName={listClassName} rowClassName={rowClassName} />
}
// An error surfaces as a `handleStreamError` item folded into the thread, so it renders here too.
- return <ThreadView />
+ return <ThreadView className={className} listClassName={listClassName} rowClassName={rowClassName} />
}
/**
@@ -241,19 +257,37 @@ function RunViewerComposer(): JSX.Element | null {
}
/** Default prepackaged layout: thread, then (live only) resources, prompt, composer, and context usage. */
-function DefaultRunViewerLayout({ className }: { className?: string }): JSX.Element {
+function DefaultRunViewerLayout({
+ className,
+ threadClassName,
+ threadListClassName,
+ threadRowClassName,
+}: {
+ className?: string
+ threadClassName?: string
+ threadListClassName?: string
+ threadRowClassName?: string
+}): JSX.Element {
const { interaction } = useRunViewerContext()
if (interaction !== 'live') {
return (
<div className={cn('flex flex-col h-full min-h-0 w-full', className)}>
- <RunViewerThread />
+ <RunViewerThread
+ className={threadClassName}
+ listClassName={threadListClassName}
+ rowClassName={threadRowClassName}
+ />
</div>
)
}
return (
<div className={cn('@container/thread flex flex-col h-full overflow-hidden', className)}>
<div className="flex-1 min-h-0">
- <RunViewerThread />
+ <RunViewerThread
+ className={threadClassName}
+ listClassName={threadListClassName}
+ rowClassName={threadRowClassName}
+ />
</div>
<ResourcesBar />
<RunViewerPrompt />
diff --git a/products/posthog_ai/frontend/components/ThreadView.tsx b/products/posthog_ai/frontend/components/ThreadView.tsx
index 667ec8497430..b3e0392c94bf 100644
--- a/products/posthog_ai/frontend/components/ThreadView.tsx
+++ b/products/posthog_ai/frontend/components/ThreadView.tsx
@@ -27,7 +27,12 @@ function getThreadItemKey(item: ThreadItem): string {
* `virtualized={false}` when an ancestor already owns scroll (the live Max column + auto-scroller) — rows
* then render in document flow, unchanged from the pre-virtualized layout.
*/
-export function ThreadView({ virtualized = true }: { virtualized?: boolean } = {}): JSX.Element {
+export function ThreadView({
+ virtualized = true,
+ className,
+ listClassName,
+ rowClassName,
+}: { virtualized?: boolean; className?: string; listClassName?: string; rowClassName?: string } = {}): JSX.Element {
const { threadItems, toolInvocations, isThinking, streamPhase, runArtifacts, turnComplete, currentRunStatus } =
useValues(runStreamLogic)
const turnCancelled = currentRunStatus === 'cancelled'
@@ -64,7 +69,7 @@ export function ThreadView({ virtualized = true }: { virtualized?: boolean } = {
const renderItem = useCallback(
(item: ThreadItem, index: number): JSX.Element => (
- <VirtualizedThread.Row>
+ <VirtualizedThread.Row className={rowClassName}>
<ThreadRow
item={item}
isLast={index === threadItems.length - 1}
@@ -75,7 +80,7 @@ export function ThreadView({ virtualized = true }: { virtualized?: boolean } = {
/>
</VirtualizedThread.Row>
),
- [threadItems.length, isThinking, toolInvocations, turnComplete, turnCancelled]
+ [threadItems.length, isThinking, toolInvocations, turnComplete, turnCancelled, rowClassName]
)
return (
@@ -86,6 +91,8 @@ export function ThreadView({ virtualized = true }: { virtualized?: boolean } = {
footer={footer}
stickToBottom
virtualized={virtualized}
+ className={className}
+ listClassName={listClassName}
>
{renderItem}
</VirtualizedThread.Root>
diff --git a/products/posthog_ai/frontend/components/VirtualizedThread.tsx b/products/posthog_ai/frontend/components/VirtualizedThread.tsx
index d17205e508bd..21def85d84a0 100644
--- a/products/posthog_ai/frontend/components/VirtualizedThread.tsx
+++ b/products/posthog_ai/frontend/components/VirtualizedThread.tsx
@@ -72,6 +72,7 @@ export interface VirtualizedThreadRootProps<T> {
* adds no chrome in this mode, so the parent supplies layout (gap, centering, container query).
*/
virtualized?: boolean
+ listClassName?: string
children: (item: T, index: number) => ReactNode
}
@@ -92,6 +93,7 @@ function Root<T>({
stickToBottom = true,
maxWidthClassName = 'max-w-180',
className,
+ listClassName,
virtualized = true,
children,
}: VirtualizedThreadRootProps<T>): JSX.Element {
@@ -236,7 +238,7 @@ function Root<T>({
return (
<List<InternalRowProps>
style={{ height, width, overflowX: 'hidden' }}
- className="overscroll-contain"
+ className={cn('overscroll-contain', listClassName)}
overscanCount={overscanCount}
rowCount={rowCount}
rowHeight={dynamicRowHeight}
diff --git a/products/posthog_ai/frontend/lib/load-error.ts b/products/posthog_ai/frontend/lib/load-error.ts
new file mode 100644
index 000000000000..c8d2cd44a065
--- /dev/null
+++ b/products/posthog_ai/frontend/lib/load-error.ts
@@ -0,0 +1,21 @@
+import { ApiError } from 'lib/api'
+
+/** A 404 from the tasks API — surfaced as a `NotFound` scene, not a generic error banner. */
+export function isApiNotFound(errorObject: unknown): boolean {
+ return errorObject instanceof ApiError && errorObject.status === 404
+}
+
+/** Best-effort human message for a failed load: explicit `error` string first, then the
+ * `ApiError` detail/statusText, then a plain `Error.message`, else a generic fallback. */
+export function loadErrorMessage(error: string, errorObject: unknown): string {
+ if (error) {
+ return error
+ }
+ if (errorObject instanceof ApiError && (errorObject.detail || errorObject.statusText)) {
+ return errorObject.detail || errorObject.statusText || 'Something went wrong.'
+ }
+ if (errorObject instanceof Error && errorObject.message) {
+ return errorObject.message
+ }
+ return 'Something went wrong.'
+}
diff --git a/products/posthog_ai/frontend/logics/taskLogic.ts b/products/posthog_ai/frontend/logics/taskLogic.ts
index 12f836f78f09..4948b36cbba6 100644
--- a/products/posthog_ai/frontend/logics/taskLogic.ts
+++ b/products/posthog_ai/frontend/logics/taskLogic.ts
@@ -4,8 +4,9 @@ import { router } from 'kea-router'
import { lemonToast } from '@posthog/lemon-ui'
-import api, { ApiError } from 'lib/api'
+import api from 'lib/api'
+import { isApiNotFound, loadErrorMessage } from '../lib/load-error'
import { phDebugQueryParams } from '../lib/ph-debug'
import { Task, type TaskUpsertProps } from '../types/taskTypes'
import type { taskLogicType } from './taskLogicType'
@@ -15,23 +16,6 @@ export interface TaskLogicProps {
taskId: string
}
-function isApiNotFound(errorObject: unknown): boolean {
- return errorObject instanceof ApiError && errorObject.status === 404
-}
-
-function loadErrorMessage(error: string, errorObject: unknown): string {
- if (error) {
- return error
- }
- if (errorObject instanceof ApiError && (errorObject.detail || errorObject.statusText)) {
- return errorObject.detail || errorObject.statusText || 'Something went wrong.'
- }
- if (errorObject instanceof Error && errorObject.message) {
- return errorObject.message
- }
- return 'Something went wrong.'
-}
-
export const taskLogic = kea<taskLogicType>([
path(['products', 'posthog_ai', 'frontend', 'logics', 'taskLogic']),
props({} as TaskLogicProps),
diff --git a/products/posthog_ai/frontend/logics/tasksLogic.ts b/products/posthog_ai/frontend/logics/tasksLogic.ts
index b03d00f86d5f..cb89d4230bb8 100644
--- a/products/posthog_ai/frontend/logics/tasksLogic.ts
+++ b/products/posthog_ai/frontend/logics/tasksLogic.ts
@@ -9,6 +9,7 @@ import { addProductIntent } from 'lib/utils/product-intents'
import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'
+import { loadErrorMessage } from '../lib/load-error'
import { Task, TaskListParams, TaskUpsertProps } from '../types/taskTypes'
import type { tasksLogicType } from './tasksLogicType'
@@ -65,6 +66,13 @@ export const tasksLogic = kea<tasksLogicType>([
tasks: {
updateTask: (state, { task }) => state.map((t) => (t.id === task.id ? task : t)),
},
+ tasksError: [
+ null as string | null,
+ {
+ loadTasks: () => null,
+ loadTasksFailure: (_, { error, errorObject }) => loadErrorMessage(error, errorObject),
+ },
+ ],
}),
listeners(() => ({
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/TaskTracker.stories.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/TaskTracker.stories.tsx
index b7412b20d1e0..2f4ebe5e3822 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/TaskTracker.stories.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/TaskTracker.stories.tsx
@@ -161,6 +161,20 @@ export const Loading: Story = {
],
}
+// The tasks list endpoint fails with no cached tasks — the column shows an error + retry, not "No tasks yet".
+export const ListLoadError: Story = {
+ decorators: [
+ mswDecorator({
+ get: {
+ '/api/projects/:team_id/tasks/': () =>
+ HttpResponse.json({ detail: 'Could not load tasks.' }, { status: 500 }),
+ '/api/projects/:team_id/tasks/repositories/': { repositories: [] },
+ '/api/environments/:team_id/integrations/': { results: [] },
+ },
+ }),
+ ],
+}
+
// Detail route before either the task payload or run list has resolved.
export const TaskDetailLoading: Story = {
parameters: {
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/TaskTracker.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/TaskTracker.tsx
index 331ca221514b..05bdd669d105 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/TaskTracker.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/TaskTracker.tsx
@@ -85,7 +85,7 @@ export function TaskTracker({ taskId }: TaskTrackerProps): JSX.Element {
<div className="w-72 shrink-0 pl-0 flex flex-col min-h-0 border-r border-primary">
<TasksListColumn selectedTaskId={selectedTaskId} />
</div>
- <div className="flex-1 min-w-0 flex flex-col min-h-0 overflow-hidden">{rightPane}</div>
+ <div className="flex-1 min-w-0 flex flex-col min-h-0">{rightPane}</div>
</div>
</SceneContent>
)
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDetailPage.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDetailPage.tsx
index 0c045ff790d6..b8fb70baa2c6 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDetailPage.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskDetailPage.tsx
@@ -1,16 +1,14 @@
import { useActions, useValues } from 'kea'
import { IconArchive, IconExternal, IconGithub, IconPlay } from '@posthog/icons'
-import { LemonBanner, LemonButton, LemonDivider, LemonSkeleton } from '@posthog/lemon-ui'
+import { LemonButton, LemonDivider } from '@posthog/lemon-ui'
import { NotFound } from 'lib/components/NotFound'
import { SceneMenuBarFileItems } from 'lib/components/Scenes/SceneMenuBarFileItems'
-import { TZLabel } from 'lib/components/TZLabel'
import { FEATURE_FLAGS } from 'lib/constants'
import { dayjs } from 'lib/dayjs'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
-import { humanFriendlyDuration } from 'lib/utils/durations'
import { urls } from 'scenes/urls'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
@@ -28,11 +26,11 @@ import {
ScenePanelInfoSection,
} from '~/layout/scenes/SceneLayout'
-import { RunLogSkeleton } from 'products/posthog_ai/frontend/api/primitives'
-
-import { TaskRun } from '../../../types/taskTypes'
import { taskDetailSceneLogic } from '../taskDetailSceneLogic'
-import { TaskRunChat } from './TaskRunChat'
+import { TaskHeaderActionsSkeleton, TaskPanelSkeleton, TaskRunMetadataSkeleton } from './taskDetailSkeletons'
+import { TaskErrorBanner } from './TaskErrorBanner'
+import { TaskRunLog } from './TaskRunLog'
+import { TaskRunMetadata } from './TaskRunMetadata'
export interface TaskDetailPageProps {
taskId: string
@@ -42,21 +40,8 @@ export interface TaskDetailPageProps {
export function TaskDetailPage({ taskId, isMobile }: TaskDetailPageProps): JSX.Element {
const sceneLogic = taskDetailSceneLogic({ taskId })
- const {
- task,
- taskLoading,
- taskNotFound,
- taskError,
- runs,
- selectedRun,
- selectedRunId,
- runsLoading,
- runsError,
- selectedRunDataLoading,
- selectedRunNotFound,
- selectedRunError,
- } = useValues(sceneLogic)
- const { runTask, deleteTask, loadTask, loadTaskRuns, loadSelectedTaskRun } = useActions(sceneLogic)
+ const { task, taskNotFound, taskError, runs, selectedRun, isTaskPending, isHeaderLoading } = useValues(sceneLogic)
+ const { runTask, deleteTask, loadTask } = useActions(sceneLogic)
const { featureFlags } = useValues(featureFlagLogic)
const sceneMenuBarEnabled = !!featureFlags[FEATURE_FLAGS.SCENE_MENU_BAR]
@@ -64,22 +49,19 @@ export function TaskDetailPage({ taskId, isMobile }: TaskDetailPageProps): JSX.E
return <NotFound object="task" />
}
- const isTaskPending = taskLoading && !task
-
if (!isTaskPending && !task && !taskError) {
return <NotFound object="task" />
}
- const hasBeenRun = runs.length > 0
const latestRun = runs.length > 0 ? runs[0] : null
const isLatestRunInProgress = latestRun?.status === 'in_progress' || latestRun?.status === 'queued'
const isLatestRunCompleted = latestRun?.status === 'completed'
- const runButtonText = !hasBeenRun ? 'Run task' : 'Retry task'
+ const runButtonText = runs.length === 0 ? 'Run task' : 'Retry task'
const prUrl = selectedRun?.output?.pr_url as string | undefined
const titleActions =
- isTaskPending || !task ? (
- <TaskActionsSkeleton />
+ isHeaderLoading || !task ? (
+ <TaskHeaderActionsSkeleton />
) : (
<div className="flex items-center gap-2">
<LemonButton
@@ -109,7 +91,7 @@ export function TaskDetailPage({ taskId, isMobile }: TaskDetailPageProps): JSX.E
)
return (
- <SceneContent className="h-full min-h-0">
+ <SceneContent className="h-full min-h-0 gap-y-0">
{sceneMenuBarEnabled && task && (
<SceneMenuBar>
<SceneMenuBarMenu label="File" dataAttr="task-menubar-file">
@@ -123,7 +105,7 @@ export function TaskDetailPage({ taskId, isMobile }: TaskDetailPageProps): JSX.E
</SceneMenuBar>
)}
<ScenePanel>
- {isTaskPending || !task ? (
+ {isHeaderLoading || !task ? (
<TaskPanelSkeleton />
) : (
<>
@@ -163,201 +145,56 @@ export function TaskDetailPage({ taskId, isMobile }: TaskDetailPageProps): JSX.E
</ScenePanel>
{taskError && !task ? (
- <TaskLoadErrorBanner message={taskError} onRetry={loadTask} />
+ <TaskErrorBanner
+ title="We couldn't load this task."
+ message={taskError}
+ onRetry={loadTask}
+ dataAttr="task-load-error"
+ className="max-w-200"
+ />
) : (
<>
- {taskError && <TaskLoadErrorBanner message={taskError} onRetry={loadTask} />}
-
- <SceneTitleSection
- name={task?.title || 'Task'}
- description={null}
- resourceType={{ type: 'task' }}
- isLoading={isTaskPending}
- canEdit={false}
- forceBackTo={
- isMobile
- ? {
- key: 'tasks',
- name: 'Tasks',
- path: urls.taskTracker(),
- }
- : undefined
- }
- actions={titleActions}
- />
-
- {selectedRun && <TaskRunMetadata selectedRun={selectedRun} />}
-
- <LemonDivider />
-
- <TaskRunLogState
- taskId={taskId}
- selectedRun={selectedRun}
- selectedRunId={selectedRunId}
- runsLength={runs.length}
- runsLoading={runsLoading}
- runsError={runsError}
- selectedRunDataLoading={selectedRunDataLoading}
- selectedRunNotFound={selectedRunNotFound}
- selectedRunError={selectedRunError}
- onRetryRuns={loadTaskRuns}
- onRetrySelectedRun={loadSelectedTaskRun}
- />
+ {taskError && (
+ <TaskErrorBanner
+ title="We couldn't load this task."
+ message={taskError}
+ onRetry={loadTask}
+ dataAttr="task-load-error"
+ className="max-w-200"
+ />
+ )}
+
+ <header className="flex flex-col gap-y-2 mt-4">
+ <SceneTitleSection
+ name={task?.title || 'Task'}
+ description={null}
+ resourceType={{ type: 'task' }}
+ isLoading={isHeaderLoading}
+ canEdit={false}
+ forceBackTo={
+ isMobile
+ ? {
+ key: 'tasks',
+ name: 'Tasks',
+ path: urls.taskTracker(),
+ }
+ : undefined
+ }
+ actions={titleActions}
+ />
+
+ {isHeaderLoading ? (
+ <TaskRunMetadataSkeleton />
+ ) : (
+ selectedRun && <TaskRunMetadata selectedRun={selectedRun} />
+ )}
+
+ <LemonDivider className="mb-0 mt-0 lg:mt-4" />
+ </header>
+
+ <TaskRunLog taskId={taskId} />
</>
)}
</SceneContent>
)
}
-
-function TaskPanelSkeleton(): JSX.Element {
- return (
- <ScenePanelInfoSection>
- <div className="flex flex-col gap-3">
- <div>
- <div className="text-xs text-muted mb-1">Task ID</div>
- <LemonSkeleton className="h-5 w-24" />
- </div>
- <div>
- <div className="text-xs text-muted mb-1">Repository</div>
- <LemonSkeleton className="h-5 w-36" />
- </div>
- <div>
- <div className="text-xs text-muted mb-1">Created by</div>
- <LemonSkeleton className="h-5 w-32" />
- </div>
- <div>
- <div className="text-xs text-muted mb-1">Created</div>
- <LemonSkeleton className="h-5 w-40" />
- </div>
- </div>
- </ScenePanelInfoSection>
- )
-}
-
-function TaskActionsSkeleton(): JSX.Element {
- return (
- <div className="flex items-center gap-2">
- <LemonSkeleton className="h-7 w-40" />
- <LemonSkeleton className="h-7 w-24" />
- </div>
- )
-}
-
-function TaskLoadErrorBanner({ message, onRetry }: { message: string; onRetry: () => void }): JSX.Element {
- return (
- <LemonBanner
- type="error"
- className="max-w-200"
- action={{
- children: 'Retry',
- onClick: onRetry,
- }}
- data-attr="task-load-error"
- >
- <p>We couldn't load this task.</p>
- <p className="text-muted mb-0">{message}</p>
- </LemonBanner>
- )
-}
-
-function TaskRunsErrorBanner({ message, onRetry }: { message: string; onRetry: () => void }): JSX.Element {
- return (
- <LemonBanner
- type="error"
- action={{
- children: 'Retry',
- onClick: onRetry,
- }}
- data-attr="task-runs-load-error"
- >
- <p>We couldn't load this task's runs.</p>
- <p className="text-muted mb-0">{message}</p>
- </LemonBanner>
- )
-}
-
-function TaskRunMetadata({ selectedRun }: { selectedRun: TaskRun }): JSX.Element {
- return (
- <div className="flex items-center gap-4 text-xs text-muted">
- <dl className="inline-flex gap-1 items-center">
- <dt className="m-0">Created:</dt>
- <dd className="m-0 inline-flex items-center">
- <TZLabel time={selectedRun.created_at} showSeconds />
- </dd>
- </dl>
- {selectedRun.completed_at && (
- <dl className="inline-flex gap-1 items-center">
- <dt className="m-0">Completed:</dt>
- <dd className="m-0 inline-flex items-center">
- <TZLabel time={selectedRun.completed_at} showSeconds />
- </dd>
- </dl>
- )}
- {selectedRun.completed_at && (
- <dl className="inline-flex gap-1 items-center">
- <dt className="m-0">Duration:</dt>
- <dd className="m-0 inline-flex items-center">
- {humanFriendlyDuration(dayjs(selectedRun.completed_at).diff(selectedRun.created_at, 'second'))}
- </dd>
- </dl>
- )}
- </div>
- )
-}
-
-function TaskRunLogState({
- taskId,
- selectedRun,
- selectedRunId,
- runsLength,
- runsLoading,
- runsError,
- selectedRunDataLoading,
- selectedRunNotFound,
- selectedRunError,
- onRetryRuns,
- onRetrySelectedRun,
-}: {
- taskId?: string
- selectedRun: TaskRun | null
- selectedRunId: string | null
- runsLength: number
- runsLoading: boolean
- runsError: string | null
- selectedRunDataLoading: boolean
- selectedRunNotFound: boolean
- selectedRunError: string | null
- onRetryRuns: () => void
- onRetrySelectedRun: () => void
-}): JSX.Element | null {
- if (runsError) {
- return <TaskRunsErrorBanner message={runsError} onRetry={onRetryRuns} />
- }
- if (runsLoading && runsLength === 0) {
- return <RunLogSkeleton />
- }
- if (selectedRunNotFound) {
- return <NotFound object="task run" className="m-0 py-8" />
- }
- if (selectedRunError) {
- return <TaskRunsErrorBanner message={selectedRunError} onRetry={onRetrySelectedRun} />
- }
- if (selectedRunDataLoading && !selectedRun) {
- return <RunLogSkeleton />
- }
- if (runsLength === 0 && !selectedRunId) {
- return (
- <div className="text-center py-16">
- <p className="text-muted">This task hasn't been run yet</p>
- </div>
- )
- }
- if (taskId && selectedRun) {
- return (
- <div className="flex-1 min-h-0 overflow-hidden -mr-4 pr-4">
- <TaskRunChat taskId={taskId} runId={selectedRun.id} />
- </div>
- )
- }
- return selectedRunId ? <RunLogSkeleton /> : null
-}
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskErrorBanner.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskErrorBanner.tsx
new file mode 100644
index 000000000000..cebebffa0c9b
--- /dev/null
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskErrorBanner.tsx
@@ -0,0 +1,26 @@
+import { LemonBanner } from '@posthog/lemon-ui'
+
+export interface TaskErrorBannerProps {
+ /** Headline line, e.g. "We couldn't load this task." */
+ title: string
+ /** Detail line — the resolved API error message. */
+ message: string
+ onRetry: () => void
+ dataAttr: string
+ className?: string
+}
+
+/** Reusable error + retry banner for the task scene's failed loads (task, runs, selected run). */
+export function TaskErrorBanner({ title, message, onRetry, dataAttr, className }: TaskErrorBannerProps): JSX.Element {
+ return (
+ <LemonBanner
+ type="error"
+ className={className}
+ action={{ children: 'Retry', onClick: onRetry }}
+ data-attr={dataAttr}
+ >
+ <p>{title}</p>
+ <p className="text-muted mb-0">{message}</p>
+ </LemonBanner>
+ )
+}
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunChat.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunChat.tsx
index 47fcf5ea37a2..035b1fabe8f4 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunChat.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunChat.tsx
@@ -1,8 +1,11 @@
import { BindLogic, useActions, useValues } from 'kea'
import { runInteractionLogic, type RunInteractionLogicProps } from 'products/posthog_ai/frontend/api/logics'
-import { RunViewer } from 'products/posthog_ai/frontend/api/run'
+// Eager, NOT the lazy `api/run` facade: the runner scene is already a route-split chunk and the run viewer is
+// its primary content, so a second `lazy()` would only add a redundant chunk fetch + Suspense flash. The inbox
+// embeds keep the lazy `RunViewer`. `RunViewerImpl` is an internal sibling, so this is a relative import.
+import { RunViewer } from '../../../components/RunViewerImpl'
import { taskDetailSceneLogic } from '../taskDetailSceneLogic'
export interface TaskRunChatProps {
@@ -45,6 +48,8 @@ function TaskRunChatContent({ logicProps }: { logicProps: RunInteractionLogicPro
taskId={logicProps.taskId}
runId={logicProps.runId}
interaction="live"
+ threadListClassName="pt-4"
+ threadRowClassName="pr-4"
composerValue={draft}
onComposerChange={setDraft}
onComposerSubmit={submit}
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLog.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLog.tsx
new file mode 100644
index 000000000000..8625f775284e
--- /dev/null
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLog.tsx
@@ -0,0 +1,66 @@
+import { useActions, useValues } from 'kea'
+
+import { NotFound } from 'lib/components/NotFound'
+
+import { RunLogSkeleton } from 'products/posthog_ai/frontend/api/primitives'
+
+import { taskDetailSceneLogic } from '../taskDetailSceneLogic'
+import { TaskErrorBanner } from './TaskErrorBanner'
+import { TaskRunChat } from './TaskRunChat'
+
+/**
+ * Run-log slot state machine. Reads `taskDetailSceneLogic` directly (no prop drilling) and resolves to
+ * exactly one of: an error banner, a `NotFound`, the shared `RunLogSkeleton`, an empty state, or the live
+ * `TaskRunChat`. The skeleton is the only loading affordance here — once it hands off to `TaskRunChat`, the
+ * eager `RunViewer` shows the same `RunLogSkeleton` during its own bootstrap, so the transition is seamless.
+ */
+export function TaskRunLog({ taskId }: { taskId: string }): JSX.Element | null {
+ const logic = taskDetailSceneLogic({ taskId })
+ const { runs, selectedRun, selectedRunId, runsError, selectedRunError, selectedRunNotFound, isRunPending } =
+ useValues(logic)
+ const { loadTaskRuns, loadSelectedTaskRun } = useActions(logic)
+
+ if (runsError) {
+ return (
+ <TaskErrorBanner
+ title="We couldn't load this task's runs."
+ message={runsError}
+ onRetry={loadTaskRuns}
+ dataAttr="task-runs-load-error"
+ />
+ )
+ }
+ if (selectedRunError) {
+ return (
+ <TaskErrorBanner
+ title="We couldn't load this task's runs."
+ message={selectedRunError}
+ onRetry={loadSelectedTaskRun}
+ dataAttr="task-runs-load-error"
+ />
+ )
+ }
+ if (selectedRunNotFound) {
+ return <NotFound object="task run" className="m-0 py-8" />
+ }
+ if (isRunPending) {
+ return <RunLogSkeleton />
+ }
+ if (runs.length === 0 && !selectedRunId) {
+ return (
+ <div className="text-center py-16">
+ <p className="text-muted">This task hasn't been run yet</p>
+ </div>
+ )
+ }
+ if (selectedRun) {
+ // The viewer owns scroll edge-to-edge; this box just bounds the height. No `overflow-hidden`/negative
+ // margins — content is kept off the scrollbar via the viewer's `threadRowClassName`, not by clipping here.
+ return (
+ <div className="flex-1 min-h-0">
+ <TaskRunChat taskId={taskId} runId={selectedRun.id} />
+ </div>
+ )
+ }
+ return selectedRunId ? <RunLogSkeleton /> : null
+}
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunMetadata.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunMetadata.tsx
new file mode 100644
index 000000000000..28c3fd8d10a0
--- /dev/null
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunMetadata.tsx
@@ -0,0 +1,35 @@
+import { TZLabel } from 'lib/components/TZLabel'
+import { dayjs } from 'lib/dayjs'
+import { humanFriendlyDuration } from 'lib/utils/durations'
+
+import { TaskRun } from '../../../types/taskTypes'
+
+/** Created / completed / duration row shown above the run log for the selected run. */
+export function TaskRunMetadata({ selectedRun }: { selectedRun: TaskRun }): JSX.Element {
+ return (
+ <div className="items-center gap-4 text-xs text-muted hidden lg:flex">
+ <dl className="inline-flex gap-1 items-center">
+ <dt className="m-0">Created:</dt>
+ <dd className="m-0 inline-flex items-center">
+ <TZLabel time={selectedRun.created_at} showSeconds />
+ </dd>
+ </dl>
+ {selectedRun.completed_at && (
+ <dl className="inline-flex gap-1 items-center">
+ <dt className="m-0">Completed:</dt>
+ <dd className="m-0 inline-flex items-center">
+ <TZLabel time={selectedRun.completed_at} showSeconds />
+ </dd>
+ </dl>
+ )}
+ {selectedRun.completed_at && (
+ <dl className="inline-flex gap-1 items-center">
+ <dt className="m-0">Duration:</dt>
+ <dd className="m-0 inline-flex items-center">
+ {humanFriendlyDuration(dayjs(selectedRun.completed_at).diff(selectedRun.created_at, 'second'))}
+ </dd>
+ </dl>
+ )}
+ </div>
+ )
+}
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunStatusBadge.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunStatusBadge.tsx
deleted file mode 100644
index bac7d10e4e83..000000000000
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunStatusBadge.tsx
+++ /dev/null
@@ -1,19 +0,0 @@
-import { LemonTag } from '@posthog/lemon-ui'
-
-import { TASK_STATUS_CONFIG } from '../../../lib/task-status'
-import { TaskRun } from '../../../types/taskTypes'
-
-const STATUS_TO_TAG_TYPE: Record<string, 'primary' | 'success' | 'danger' | 'warning' | 'default'> = {
- primary: 'primary',
- success: 'success',
- danger: 'danger',
- warning: 'warning',
- muted: 'default',
-}
-
-export function TaskRunStatusBadge({ run }: { run: TaskRun }): JSX.Element {
- const config = TASK_STATUS_CONFIG[run.status]
- const tagType = STATUS_TO_TAG_TYPE[config.status || 'muted'] || 'default'
-
- return <LemonTag type={tagType}>{config.label}</LemonTag>
-}
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TasksListColumn.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TasksListColumn.tsx
index 3a520a84f4a3..ce073207882e 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TasksListColumn.tsx
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TasksListColumn.tsx
@@ -1,7 +1,7 @@
-import { useValues } from 'kea'
+import { useActions, useValues } from 'kea'
import { IconPlus, IconPlusSmall } from '@posthog/icons'
-import { LemonButton, LemonDivider, LemonSkeleton } from '@posthog/lemon-ui'
+import { LemonBanner, LemonButton, LemonDivider, LemonSkeleton } from '@posthog/lemon-ui'
import { ScrollableShadows } from 'lib/components/ScrollableShadows/ScrollableShadows'
import { Link } from 'lib/lemon-ui/Link'
@@ -18,7 +18,8 @@ interface TasksListColumnProps {
}
export function TasksListColumn({ selectedTaskId, isMobile = false }: TasksListColumnProps): JSX.Element {
- const { tasks, tasksLoading } = useValues(tasksLogic)
+ const { tasks, tasksLoading, tasksError } = useValues(tasksLogic)
+ const { loadTasks } = useActions(tasksLogic)
const rows =
tasksLoading && tasks.length === 0 ? (
@@ -27,6 +28,18 @@ export function TasksListColumn({ selectedTaskId, isMobile = false }: TasksListC
<LemonSkeleton className="h-8 opacity-60" />
<LemonSkeleton className="h-8 opacity-30" />
</div>
+ ) : // A failed load with no cached tasks must not look like "No tasks yet" — show the error + a retry.
+ // A refresh that fails while tasks already exist keeps the stale list rather than wiping good data.
+ tasksError && tasks.length === 0 ? (
+ <LemonBanner
+ type="error"
+ className="mx-1"
+ action={{ children: 'Retry', onClick: () => loadTasks() }}
+ data-attr="tasks-load-error"
+ >
+ <p className="mb-0">We couldn't load your tasks.</p>
+ <p className="text-muted mb-0">{tasksError}</p>
+ </LemonBanner>
) : tasks.length === 0 ? (
<div className="flex flex-col items-center justify-center text-center py-8 text-muted">
<p className="text-sm mb-0">No tasks yet</p>
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/taskDetailSkeletons.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/taskDetailSkeletons.tsx
new file mode 100644
index 000000000000..ebcd6426217f
--- /dev/null
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/taskDetailSkeletons.tsx
@@ -0,0 +1,49 @@
+import { LemonSkeleton } from '@posthog/lemon-ui'
+
+import { ScenePanelInfoSection } from '~/layout/scenes/SceneLayout'
+
+/** Skeleton for the scene side panel's task-info block — mirrors the four labelled rows. */
+export function TaskPanelSkeleton(): JSX.Element {
+ return (
+ <ScenePanelInfoSection>
+ <div className="flex flex-col gap-3">
+ <div>
+ <div className="text-xs text-muted mb-1">Task ID</div>
+ <LemonSkeleton className="h-5 w-24" />
+ </div>
+ <div>
+ <div className="text-xs text-muted mb-1">Repository</div>
+ <LemonSkeleton className="h-5 w-36" />
+ </div>
+ <div>
+ <div className="text-xs text-muted mb-1">Created by</div>
+ <LemonSkeleton className="h-5 w-32" />
+ </div>
+ <div>
+ <div className="text-xs text-muted mb-1">Created</div>
+ <LemonSkeleton className="h-5 w-40" />
+ </div>
+ </div>
+ </ScenePanelInfoSection>
+ )
+}
+
+/** Skeleton for the title-bar action buttons (Open in PostHog Code / View PR / Run). */
+export function TaskHeaderActionsSkeleton(): JSX.Element {
+ return (
+ <div className="flex items-center gap-2">
+ <LemonSkeleton className="h-7 w-40" />
+ <LemonSkeleton className="h-7 w-24" />
+ </div>
+ )
+}
+
+/** Skeleton for the run created/completed/duration metadata row. */
+export function TaskRunMetadataSkeleton(): JSX.Element {
+ return (
+ <div className="items-center gap-4 hidden lg:flex">
+ <LemonSkeleton className="h-4 w-32" />
+ <LemonSkeleton className="h-4 w-32" />
+ </div>
+ )
+}
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.test.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.test.ts
index 6c21e0cb4c96..9e64cb0b44c7 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.test.ts
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.test.ts
@@ -265,6 +265,42 @@ describe('taskDetailSceneLogic', () => {
})
})
+ describe('unified loading selectors', () => {
+ it('reports the header + run log as pending while task and runs are still loading', () => {
+ const logic = taskDetailSceneLogic({ taskId: 'task-123' })
+ logic.mount()
+
+ // afterMount fires loadTask + loadTaskRuns synchronously; nothing has resolved yet.
+ expect(logic.values.isTaskPending).toBe(true)
+ expect(logic.values.isRunPending).toBe(true)
+ expect(logic.values.isHeaderLoading).toBe(true)
+ logic.unmount()
+ })
+
+ it('clears pending once the task and its runs resolve', async () => {
+ global.fetch = createFetchMock({ runsList: [createMockRun('run-1', TaskRunStatus.COMPLETED)] })
+ const logic = taskDetailSceneLogic({ taskId: 'task-123' })
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.isTaskPending).toBe(false)
+ expect(logic.values.isRunPending).toBe(false)
+ expect(logic.values.isHeaderLoading).toBe(false)
+ logic.unmount()
+ })
+
+ it('resolves immediately for a task that has never run (no perpetual skeleton)', async () => {
+ const logic = taskDetailSceneLogic({ taskId: 'task-123' })
+ logic.mount()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.runs).toEqual([])
+ expect(logic.values.isRunPending).toBe(false)
+ expect(logic.values.isHeaderLoading).toBe(false)
+ logic.unmount()
+ })
+ })
+
describe('loadTaskSuccess updates tasksLogic', () => {
it('updates sidebar tasks list when task loads', async () => {
const tasksLogicInstance = tasksLogic()
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.ts
index 48f92bee2475..fb30f9c4e407 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.ts
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskDetailSceneLogic.ts
@@ -2,9 +2,10 @@ import { actions, afterMount, connect, kea, key, listeners, path, props, propsCh
import { loaders } from 'kea-loaders'
import { router } from 'kea-router'
-import api, { ApiError } from 'lib/api'
+import api from 'lib/api'
import { isUUIDLike } from 'lib/utils/guards'
+import { isApiNotFound, loadErrorMessage } from '../../lib/load-error'
import { phDebugQueryParams } from '../../lib/ph-debug'
import { TaskLogicProps, taskLogic } from '../../logics/taskLogic'
import { tasksLogic } from '../../logics/tasksLogic'
@@ -13,23 +14,6 @@ import type { taskDetailSceneLogicType } from './taskDetailSceneLogicType'
export type TaskDetailSceneLogicProps = TaskLogicProps
-function isApiNotFound(errorObject: unknown): boolean {
- return errorObject instanceof ApiError && errorObject.status === 404
-}
-
-function loadErrorMessage(error: string, errorObject: unknown): string {
- if (error) {
- return error
- }
- if (errorObject instanceof ApiError && (errorObject.detail || errorObject.statusText)) {
- return errorObject.detail || errorObject.statusText || 'Something went wrong.'
- }
- if (errorObject instanceof Error && errorObject.message) {
- return errorObject.message
- }
- return 'Something went wrong.'
-}
-
export const taskDetailSceneLogic = kea<taskDetailSceneLogicType>([
path(['products', 'posthog_ai', 'frontend', 'scenes', 'TaskTracker', 'taskDetailSceneLogic']),
props({} as TaskDetailSceneLogicProps),
@@ -144,6 +128,18 @@ export const taskDetailSceneLogic = kea<taskDetailSceneLogicType>([
return runs.length === 0
},
],
+ isTaskPending: [(s) => [s.taskLoading, s.task], (taskLoading, task): boolean => taskLoading && !task],
+ isRunPending: [
+ (s) => [s.runsLoading, s.runs, s.selectedRunDataLoading, s.selectedRun],
+ (runsLoading, runs, selectedRunDataLoading, selectedRun): boolean =>
+ (runsLoading && runs.length === 0) || (selectedRunDataLoading && !selectedRun),
+ ],
+ // The header (task panel + title + run metadata) and the run log share the runs-loading phase, so
+ // both resolve together: one skeleton-only loading state, no piecemeal pop-in.
+ isHeaderLoading: [
+ (s) => [s.isTaskPending, s.isRunPending],
+ (isTaskPending, isRunPending): boolean => isTaskPending || isRunPending,
+ ],
title: [
(s) => [s.task],
(task): string => {