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): use quill skeleton for run log loading state (#123250)

Shy Alter0176586250ce
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index ea087fe4d97f..2bc8efad02fc 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -12057,13 +12057,13 @@ snapshots:
scenes-app-inbox-first-report--no-data-narrow--light:
hash: v1.k794b7964.8a760fde0be568a914e4453aac2c128a6ec065c0a6c01ef91eb016cbf11cf5ae.f8H0eCk6dHfGuY7f9eWdK5mjitwkzbGGrjg2ANeiNMM
scenes-app-inbox-first-report--running--dark:
- hash: v1.k794b7964.2bb4016dfbab0d8c8f1378706ab67bb51e84955b08685645596828789bb856d9.TZHjE1omnp-7XaQgd50zWuWvXUPdKlr-5ycTO7gJGJE
+ hash: v1.k794b7964.8873c63918500c67c125bf1810cfcbe0ebca8cb6326c7474a6d32760ce3108fc.cdTBqbm_zunougoPEEbKrq5YoNTbEhvWOoEZpP4w9cw
scenes-app-inbox-first-report--running--light:
- hash: v1.k794b7964.4d6369a69c7adb8a3edeadc4acc9cacc45bb2cbe753a68b1e8d336fbf9404053.JH83D4JcoC0XR8h7FgHmPxWiV5CAP6ZUqPzVkBYM5qU
+ hash: v1.k794b7964.6cad8925cb5f4e92a40d869f7bd5fec9080d4b0d810c6911f7a7935ddb912ebb.p7cBdOTLZxGPaazscXGseUZdlDMYNEOT3B-NFZCbxAQ
scenes-app-inbox-first-report--running-narrow--dark:
- hash: v1.k794b7964.1489893faeb3232bcd9ae74915614d155359ce14793fdcc57962a757d646e078.p5QygOekc_jO7LrBCAySkt7BCZpUi8TMtoCeVntqh90
+ hash: v1.k794b7964.83e568a89db9806e44fa63bb21de51c0611974fd86f5e78818c83d13cd981962.uHejFGwT0d13MiZd9dYf3wh0zj-GRRsKNKBUbj4YkRE
scenes-app-inbox-first-report--running-narrow--light:
- hash: v1.k794b7964.d994a9d5e1c127959958aa3e468fce4945cea47afe00e61fd1d7df37ec27c4b9.Isj5PvJ7ELE3a--ZB3q2pv1l6D3-vjIV0-J7X8pcR94
+ hash: v1.k794b7964.6247637182b919d676f1f745366b1f66417a72e61e3d69326931e3d71e763284.5vftvvyKgzlcrWlVtUR4EgW4S4aI_7ShVqifNBqYJH8
scenes-app-inbox-focused-setup--built-in-scouts--dark:
hash: v1.k794b7964.9c362d9b9c26bb883910cfbdd1836a4527c166f4c96a2f5360e69023c79d5f0e.DuYijIxQuSoZCwSuCLHfE5vpQ9S7-wEi7vbYSPvUoQY
scenes-app-inbox-focused-setup--built-in-scouts--light:
@@ -15789,9 +15789,9 @@ snapshots:
scenes-app-tasks--pi-task-selected--light:
hash: v1.k794b7964.dc94140b8460e76c6e8b81adb9c46997c89a5634f20fac20ddada1f1ffd12223.4KOsU0tDj1zB26GFLV3daFR9ypOtXtETf08ZsGEMZt4
scenes-app-tasks--task-detail-loading--dark:
- hash: v1.k794b7964.cf68a26a8d95ea04f3a13aa312f1ef15587ae7c533366fe679299a19f0e37dcc.6TZiaw-L4PN6eRjj342Xu9Zg9hSM2oqOFcM4l7GhyTs
+ hash: v1.k794b7964.a34fe05f1131d0368d2d803f27320c93f7a9bd5bcebc31d2459be0ed16e059c5.uSNsO42bTdJ1tYa-Bmz4uTocYRX1SIbo2vaa9IKq1AM
scenes-app-tasks--task-detail-loading--light:
- hash: v1.k794b7964.c8fb0a7ee9be9b7e43c86e1ef0ab08afa36fc1ee73e37c7db3f295cacd7f428e.LTBA5SJdNLyUSgSShns_HEJxKkHVYFN0T0lGWEKMTPs
+ hash: v1.k794b7964.f896d7c2b7cff888483338a1fededcca9f993a0b1dc1ec1bfcca6820b654c641.BHwh8AdR4NFJJrLw-CM4YYGlfVSb9XksqPOw2DeyKvg
scenes-app-tasks--task-load-error--dark:
hash: v1.k794b7964.8c160753039593f051efc147d69f447a861f14a8281d97f8f612b1b2279bb241.wB8WL7fVnS3sNEHJtbST0gUGVoyv2V2TwcnemxoSeBw
scenes-app-tasks--task-load-error--light:
diff --git a/products/posthog_ai/frontend/components/ReadonlyRunSurface.tsx b/products/posthog_ai/frontend/components/ReadonlyRunSurface.tsx
index 322a7f8b75d1..5caa6f0a252e 100644
--- a/products/posthog_ai/frontend/components/ReadonlyRunSurface.tsx
+++ b/products/posthog_ai/frontend/components/ReadonlyRunSurface.tsx
@@ -22,7 +22,11 @@ const Lazy = lazyWithRetry(() => import('./ReadonlyRunSurfaceImpl'))
*/
export function ReadonlyRunSurface(props: ReadonlyRunSurfaceProps): JSX.Element {
return (
- <Suspense fallback={<RunLogSkeleton />}>
+ <Suspense
+ fallback={
+ <RunLogSkeleton listClassName={props.threadListClassName} rowClassName={props.threadRowClassName} />
+ }
+ >
<Lazy {...props} />
</Suspense>
)
diff --git a/products/posthog_ai/frontend/components/RunLogSkeleton.scss b/products/posthog_ai/frontend/components/RunLogSkeleton.scss
new file mode 100644
index 000000000000..c559883b26be
--- /dev/null
+++ b/products/posthog_ai/frontend/components/RunLogSkeleton.scss
@@ -0,0 +1,29 @@
+// Waits before it shows, so a fast load never flashes a skeleton. The component sets the delay.
+.RunLogSkeleton {
+ animation: RunLogSkeleton__fadeIn 200ms ease-out both;
+}
+
+.RunLogReveal {
+ animation: RunLogSkeleton__reveal 150ms ease-out both;
+}
+
+@keyframes RunLogSkeleton__fadeIn {
+ from {
+ opacity: 0;
+ }
+}
+
+// Starts part-way in, so the swap from the skeleton never shows an empty frame.
+@keyframes RunLogSkeleton__reveal {
+ from {
+ opacity: 0.4;
+ }
+}
+
+@media (prefers-reduced-motion: reduce) {
+ .RunLogSkeleton,
+ .RunLogReveal,
+ .RunLogSkeleton .quill-skeleton {
+ animation: none;
+ }
+}
diff --git a/products/posthog_ai/frontend/components/RunLogSkeleton.tsx b/products/posthog_ai/frontend/components/RunLogSkeleton.tsx
index 53a4afe9cd94..260dafa4f46d 100644
--- a/products/posthog_ai/frontend/components/RunLogSkeleton.tsx
+++ b/products/posthog_ai/frontend/components/RunLogSkeleton.tsx
@@ -1,14 +1,56 @@
-import { memo } from 'react'
+import './RunLogSkeleton.scss'
-import { LemonSkeleton } from '@posthog/lemon-ui'
+import { memo, useEffect, useState } from 'react'
+
+import {
+ ChatBubble,
+ ChatBubbleContent,
+ ChatMessage,
+ ChatMessageContent,
+ ChatMessageFooter,
+ Skeleton,
+ SkeletonText,
+} from '@posthog/quill-primitives'
import { cn } from 'lib/utils/css-classes'
+import { footerRevealProps } from './quill/footerReveal'
+import { ThreadMarker } from './quill/ThreadMarker'
+
+interface SkeletonTurn {
+ question: string
+ tools: string[]
+ paragraphs: number[]
+}
+
+const TURNS: SkeletonTurn[] = [{ question: 'w-56', tools: ['w-28'], paragraphs: [3, 2] }]
+
+/** Fades a thread in after a skeleton was on screen, so the swap reads as one change and not as a jump. */
+export const RUN_LOG_REVEAL_CLASS = 'RunLogReveal'
+
+// One load can show several skeletons in turn (task, then run log). They share one fade-in clock, so the
+// chain waits once and a later skeleton never blinks or restarts the fade.
+const FADE_IN_DELAY_MS = 150
+let mountedSkeletons = 0
+let lastSkeletonHiddenAt = Number.NEGATIVE_INFINITY
+let chainStartedAt = 0
+
+function fadeInDelayMs(): number {
+ const now = performance.now()
+ if (mountedSkeletons === 0 && now - lastSkeletonHiddenAt > 250) {
+ chainStartedAt = now
+ }
+ return FADE_IN_DELAY_MS - (now - chainStartedAt)
+}
+
/**
* Loading state for "a run/task log is loading" — shared by the runner scene, the lazy `ReadonlyRunSurface`
- * chunk's Suspense fallback, and the `RunSurface` 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.
+ * chunk's Suspense fallback, and the `RunSurface` in-stream bootstrap. Built from the quill thread's own
+ * parts (`ChatBubble`, `ThreadMarker`, the reserved message footer, `ThreadView`'s 16px row gap), so each turn
+ * takes the same space as the turn that replaces it. It shows one turn at the top: a reopened thread lands
+ * with its last question at the top (`ThreadView`'s `anchorItemKey`), and a thread shorter than the screen
+ * starts at the top too. More guessed turns only add noise. Kept free of the markdown and virtualization
+ * chunk, so it is safe as a fallback.
*/
export const RunLogSkeleton = memo(function RunLogSkeleton({
className,
@@ -19,18 +61,77 @@ export const RunLogSkeleton = memo(function RunLogSkeleton({
listClassName?: string
rowClassName?: string
}): JSX.Element {
+ const [animationDelay] = useState(() => `${fadeInDelayMs()}ms`)
+ useEffect(() => {
+ mountedSkeletons++
+ return () => {
+ mountedSkeletons--
+ lastSkeletonHiddenAt = performance.now()
+ }
+ }, [])
return (
- <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={cn('flex justify-start w-full', rowClassName)}>
- <LemonSkeleton className="h-10 w-1/2 rounded-lg" />
- </div>
- <div className={cn('flex justify-end w-full', rowClassName)}>
- <LemonSkeleton className="h-24 w-4/5 rounded-lg" />
- </div>
+ <div
+ className={cn('RunLogSkeleton flex flex-col h-full min-h-0 w-full overflow-hidden', className)}
+ data-attr="run-log-skeleton"
+ style={{ animationDelay }}
+ role="status"
+ aria-busy="true"
+ >
+ <span className="sr-only">Loading conversation</span>
+ <div
+ data-quill
+ className={cn(
+ 'flex flex-col gap-4 w-full max-w-180 mx-auto pt-4 text-[var(--foreground)]',
+ listClassName
+ )}
+ >
+ {TURNS.map((turn, index) => (
+ <div key={index} className="flex flex-col gap-4">
+ <div className={rowClassName}>
+ <ChatMessage align="end">
+ <ChatMessageContent className="gap-1">
+ <ChatBubble align="end" className="rounded-lg">
+ <ChatBubbleContent>
+ <span className="flex items-center h-[1lh] text-sm leading-[1.625]">
+ <Skeleton className={cn('h-[0.7em] max-w-full', turn.question)} />
+ </span>
+ </ChatBubbleContent>
+ </ChatBubble>
+ <ChatMessageFooter
+ {...footerRevealProps(false, undefined, { reserveSpace: true })}
+ />
+ </ChatMessageContent>
+ </ChatMessage>
+ </div>
+ {turn.tools.map((width, toolIndex) => (
+ <div key={toolIndex} className={rowClassName}>
+ <ThreadMarker icon={<Skeleton className="size-3 rounded-sm" />}>
+ <span className="flex h-[1lh] items-center">
+ <Skeleton className={cn('h-2.5', width)} />
+ </span>
+ </ThreadMarker>
+ </div>
+ ))}
+ <div className={rowClassName}>
+ <ChatMessage align="start" className="w-full">
+ <ChatMessageContent className="w-full gap-1">
+ <ChatBubble variant="ghost" className="w-full">
+ <ChatBubbleContent className="flex w-full flex-col gap-3">
+ {turn.paragraphs.map((lines, paragraphIndex) => (
+ <SkeletonText
+ key={paragraphIndex}
+ lines={lines}
+ className="text-sm leading-[1.625]"
+ maxWidth={paragraphIndex === 0 ? 100 : 90}
+ />
+ ))}
+ </ChatBubbleContent>
+ </ChatBubble>
+ </ChatMessageContent>
+ </ChatMessage>
+ </div>
+ </div>
+ ))}
</div>
</div>
)
diff --git a/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx b/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx
index 8234860d8a5f..57f85009a39f 100644
--- a/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx
+++ b/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx
@@ -1,9 +1,10 @@
import { BindLogic, useActions, useValues } from 'kea'
-import { createContext, type ReactNode, useCallback, useContext, useEffect, useMemo, useState } from 'react'
+import { createContext, type ReactNode, useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react'
import { LemonBanner, LemonButton, LemonDivider } from '@posthog/lemon-ui'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
+import { cn } from 'lib/utils/css-classes'
import { useThreadSkin } from '../hooks/useThreadSkin'
import { isLogicRetained, RETAINED_RUN_STREAMS, retainMountedLogic } from '../logics/retainedLogics'
@@ -16,7 +17,7 @@ import { FeedbackPromptTrailer } from './FeedbackPromptTrailer'
import { PermissionInput } from './PermissionInput'
import { QuestionInput } from './QuestionInput'
import { QuillRunSurfaceInputs } from './quill/QuillRunSurfaceInputs'
-import { RunLogSkeleton } from './RunLogSkeleton'
+import { RUN_LOG_REVEAL_CLASS, RunLogSkeleton } from './RunLogSkeleton'
import { ThreadView } from './ThreadView'
import { TurnTrailerActions } from './TurnTrailerActions'
@@ -148,7 +149,7 @@ function RunSurfaceRoot({
)
}
if (!hasThreadItems && !hasOptimisticClientStream) {
- return <RunLogSkeleton />
+ return <RunLogSkeleton listClassName="py-4" rowClassName="px-4" />
}
}
@@ -269,9 +270,11 @@ function RunSurfaceThread({
) : null,
[feedbackSessionId, feedbackRun]
)
+ const showedSkeletonRef = useRef(false)
const showSkeleton =
(bootstrapLoading || (logBootstrapLoading && !runConnectionState)) && !hasThreadItems && streamKey === runId
if (showSkeleton) {
+ showedSkeletonRef.current = true
return <RunLogSkeleton className={className} listClassName={listClassName} rowClassName={rowClassName} />
}
// The runner shows context usage in its composer footer (`ContextUsageChip`); a surface with no
@@ -281,7 +284,7 @@ function RunSurfaceThread({
return (
<ThreadView
scrollRestorationKey={restoreReadPosition ? taskId : undefined}
- className={className}
+ className={cn(className, showedSkeletonRef.current && RUN_LOG_REVEAL_CLASS)}
listClassName={listClassName}
endInset={floatingInputsHeight > 0 ? floatingInputsHeight + FLOATING_INPUTS_GAP : undefined}
rowClassName={rowClassName}