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(posthog-ai): keep the skeleton until a reopened task chat loads (#120523)

Shy Alter744b7b5ce482
diff --git a/products/posthog_ai/frontend/components/RunSurfaceImpl.test.tsx b/products/posthog_ai/frontend/components/RunSurfaceImpl.test.tsx
index 78980b1bc7b7..b330ae30afe5 100644
--- a/products/posthog_ai/frontend/components/RunSurfaceImpl.test.tsx
+++ b/products/posthog_ai/frontend/components/RunSurfaceImpl.test.tsx
@@ -42,6 +42,8 @@ function setValues(
pendingPermissionRequest: PermissionRequestRecord | null
respondingToPermission: boolean
bootstrapLoading: boolean
+ logBootstrapLoading: boolean
+ runConnectionState: { status: string } | null
runOpening: boolean
threadItems: unknown[]
task: { origin_product: string; runtime?: TaskRuntimeEnumApi } | null
@@ -337,6 +339,20 @@ describe('RunSurface', () => {
}
)
+ it.each([
+ { name: 'history still loading after the stream opened', runConnectionState: null, skeleton: true },
+ { name: 'a reconnecting stream', runConnectionState: { status: 'reconnecting' }, skeleton: false },
+ ])('with an empty thread and $name', ({ runConnectionState, skeleton }) => {
+ setValues({ bootstrapLoading: false, logBootstrapLoading: true, runConnectionState, threadItems: [] })
+ render(
+ <RunSurface.Root taskId="task-1" runId="run-1" interaction="live">
+ <RunSurface.Thread />
+ </RunSurface.Root>
+ )
+ expect(screen.queryByTestId('run-log-skeleton') !== null).toBe(skeleton)
+ expect(screen.queryByTestId('thread') !== null).toBe(!skeleton)
+ })
+
it.each([null, { origin_product: 'user_created' }])(
'keeps a populated thread visible while bootstrapping with task=%j',
(task) => {
diff --git a/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx b/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx
index 0a43d7918f18..4407aea0b418 100644
--- a/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx
+++ b/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx
@@ -241,7 +241,7 @@ function RunSurfaceThread({
} = {}): JSX.Element {
const { interaction, isScout, taskId, streamKey, runId, floatingInputsHeight } = useRunSurfaceContext()
const skin = useThreadSkin()
- const { bootstrapLoading, hasThreadItems } = useValues(runStreamLogic)
+ const { bootstrapLoading, logBootstrapLoading, runConnectionState, hasThreadItems } = useValues(runStreamLogic)
// Feedback identity: always the task, matching `$ai_session_id` on other surfaces.
const feedbackSessionId = taskId
const collectsFeedback = interaction === 'live' && !isScout && !!feedbackSessionId
@@ -262,7 +262,8 @@ function RunSurfaceThread({
) : null,
[feedbackSessionId, feedbackRun]
)
- const showSkeleton = bootstrapLoading && !hasThreadItems && streamKey === runId
+ const showSkeleton =
+ (bootstrapLoading || (logBootstrapLoading && !runConnectionState)) && !hasThreadItems && streamKey === runId
if (showSkeleton) {
return <RunLogSkeleton className={className} listClassName={listClassName} rowClassName={rowClassName} />
}