: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(tasks): stabilize loading layout when switching tasks (#110503)
Shy Alter6bf3e47fa185
diff --git a/docs/published/handbook/engineering/ai/sandboxed-agents.md b/docs/published/handbook/engineering/ai/sandboxed-agents.mdindex 4a6d5faf71d9..d509be37c073 100644--- a/docs/published/handbook/engineering/ai/sandboxed-agents.md+++ b/docs/published/handbook/engineering/ai/sandboxed-agents.md@@ -171,6 +171,7 @@ Task links in shared AI history open `/ai?task=<task-id>` and render the task ruThe task stays selected on reload and when navigating back or forward.Existing `/tasks/<task-id>` links still open the standalone runner.Task headers keep horizontal padding around the title and run metadata.+With `today-rail-nav` enabled, task loading placeholders preserve the header height, conversation column, and composer area while task metadata and run history load.In the AI chat view, the staff options menu sits beside the task actions, including **Open in PostHog Desktop**.## Fine-grained access tokensdiff --git a/products/posthog_ai/frontend/components/RunSurfaceImpl.test.tsx b/products/posthog_ai/frontend/components/RunSurfaceImpl.test.tsxindex 9dd89a3ed909..d1df99c6b14d 100644--- a/products/posthog_ai/frontend/components/RunSurfaceImpl.test.tsx+++ b/products/posthog_ai/frontend/components/RunSurfaceImpl.test.tsx@@ -137,6 +137,31 @@ describe('RunSurface', () => {})describe('Composer slot', () => {+ it('replaces the loading fallback with the composer after the run status resolves', () => {+ setValues({ currentRunStatus: null })+ const surface = (+ <RunSurface.Root taskId="task-1" runId="run-1" interaction="live">+ <RunSurface.Composer loadingFallback={<div data-attr="composer-loading" />}>+ <div data-attr="composer-child" />+ </RunSurface.Composer>+ </RunSurface.Root>+ )+ const { rerender } = render(surface)+ expect(screen.getByTestId('composer-loading')).toBeInTheDocument()+ expect(screen.queryByTestId('composer-child')).not.toBeInTheDocument()++ setValues({ currentRunStatus: 'completed' })+ rerender(+ <RunSurface.Root taskId="task-1" runId="run-1" interaction="live">+ <RunSurface.Composer loadingFallback={<div data-attr="composer-loading" />}>+ <div data-attr="composer-child" />+ </RunSurface.Composer>+ </RunSurface.Root>+ )+ expect(screen.queryByTestId('composer-loading')).not.toBeInTheDocument()+ expect(screen.getByTestId('composer-child')).toBeInTheDocument()+ })+it('clears a draft sent before its debounce commits', () => {jest.useFakeTimers()try {diff --git a/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx b/products/posthog_ai/frontend/components/RunSurfaceImpl.tsxindex dc75a638129d..3ce0bba75cf5 100644--- a/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx+++ b/products/posthog_ai/frontend/components/RunSurfaceImpl.tsx@@ -273,9 +273,11 @@ function RunSurfaceThread({function RunSurfaceComposer({children,isStopping = false,+ loadingFallback,}: {children?: ReactNodeisStopping?: boolean+ loadingFallback?: ReactNode}): JSX.Element | null {const { interaction, streamKey, floatingInputsHeight, setFloatingInputsHeight } = useRunSurfaceContext()const { pendingPermissionRequest, respondingToPermission, currentRunStatus, runOpening } = useValues(runStreamLogic)@@ -302,7 +304,7 @@ function RunSurfaceComposer({disabled={isStopping}/>))- const composer = children && (currentRunStatus !== null || runOpening) ? children : null+ const composer = children && (currentRunStatus !== null || runOpening) ? children : loadingFallback// Both inputs keep their local state through delivery and restoration, including uncommitted draft keystrokes.if (skin === 'quill') {diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskComposerSkeleton.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskComposerSkeleton.tsxnew file mode 100644index 000000000000..53720f3ea2a0--- /dev/null+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskComposerSkeleton.tsx@@ -0,0 +1,16 @@+import { Skeleton } from '@posthog/quill-primitives'++export function QuillTaskComposerSkeleton(): JSX.Element {+ return (+ <div data-quill aria-hidden className="flex flex-col gap-1">+ <div className="rounded-sm border border-border">+ <Skeleton className="h-16 w-full" />+ </div>+ <div className="flex h-6 items-center gap-1 px-1">+ <Skeleton className="size-6" />+ <Skeleton className="h-4 w-24" />+ <Skeleton className="h-4 w-32" />+ </div>+ </div>+ )+}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskTitle.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskTitle.tsxindex 6e8ce03e217f..71a77896720d 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskTitle.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/QuillTaskTitle.tsx@@ -41,9 +41,9 @@ export function QuillTaskTitle({ name, icon, isLoading, onRename, backTo, action<span className="flex size-5 shrink-0 items-center justify-center text-sm" aria-hidden>{icon}</span>- <div className="flex min-w-0 flex-1 items-center gap-1">+ <div className="flex h-6 min-w-0 flex-1 items-center gap-1">{isLoading ? (- <SkeletonText lines={1} className="w-60" />+ <SkeletonText lines={1} className="w-60 max-w-full" />) : draft !== null ? (<Inputaria-label="Task title"diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunChat.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunChat.tsxindex 819e835be73c..9cc295052bc9 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunChat.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunChat.tsx@@ -11,10 +11,12 @@ import { RunSurface } from 'products/posthog_ai/frontend/api/runSurface'import { RunEscapeBoundary, type RunEscapeBoundaryProps } from '../../../components/RunEscapeBoundary'import { useForegroundStream } from '../../../hooks/useForegroundStream'+import { useThreadSkin } from '../../../hooks/useThreadSkin'import { runCancellationLogic } from '../../../logics/runCancellationLogic'import type { RunContinuationHandoff } from '../../../logics/runInteractionLogic'import type { AttachedContextItem } from '../../../types/contextTypes'import { taskDetailSceneLogic } from '../taskDetailSceneLogic'+import { QuillTaskComposerSkeleton } from './QuillTaskComposerSkeleton'import { TaskRunComposer } from './TaskRunComposer'export interface TaskRunChatProps {@@ -136,6 +138,7 @@ function TaskRunChatContent({flushDraftRef: MutableRefObject<() => void>}): JSX.Element {const textAreaRef = useRef<HTMLTextAreaElement>(null)+ const skin = useThreadSkin()const { handleEscape } = useActions(runInteractionLogic(logicProps))const { cancellationState } = useValues(runInteractionLogic(logicProps))const { clearCancellation } = useActions(@@ -172,7 +175,10 @@ function TaskRunChatContent({/>{/* Stay live (stream keeps flowing) but omit the composer entirely for a read-only viewer. */}{!readOnly && (- <RunSurface.Composer isStopping={!!cancellationState}>+ <RunSurface.Composer+ isStopping={!!cancellationState}+ loadingFallback={skin === 'quill' ? <QuillTaskComposerSkeleton /> : undefined}+ >{/* The composer owns the per-keystroke draft in an isolated child so typing never re-rendersthe thread/virtualizer rendered as its sibling above — that cascade is what made the input lag. */}<TaskRunComposerdiff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLoadingSkeleton.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLoadingSkeleton.tsxnew file mode 100644index 000000000000..433c6339c283--- /dev/null+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLoadingSkeleton.tsx@@ -0,0 +1,26 @@+import { useState } from 'react'++import { QuillRunSurfaceInputs } from '../../../components/quill/QuillRunSurfaceInputs'+import { RunLogSkeleton } from '../../../components/RunLogSkeleton'+import { useThreadSkin } from '../../../hooks/useThreadSkin'+import { QuillTaskComposerSkeleton } from './QuillTaskComposerSkeleton'++export function TaskRunLoadingSkeleton(): JSX.Element {+ const skin = useThreadSkin()+ const [inputsHeight, setInputsHeight] = useState(0)+ if (skin === 'lemon') {+ return <RunLogSkeleton />+ }+ return (+ <div className="@container/thread flex h-full min-h-0 flex-col -mx-4">+ <RunLogSkeleton className="flex-1" listClassName="py-4" rowClassName="px-4" />+ <QuillRunSurfaceInputs+ approval={null}+ showApproval={false}+ composer={<QuillTaskComposerSkeleton />}+ height={inputsHeight}+ onHeightChange={setInputsHeight}+ />+ </div>+ )+}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLog.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLog.tsxindex 9185139c6982..c7bf832fa201 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLog.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunLog.tsx@@ -2,11 +2,10 @@ 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'+import { TaskRunLoadingSkeleton } from './TaskRunLoadingSkeleton'/*** Run-log slot state machine. Reads `taskDetailSceneLogic` directly (no prop drilling) and resolves to@@ -38,6 +37,7 @@ export function TaskRunLog({selectedRunError,selectedRunNotFound,isRunPending,+ isTaskPending,runContinuation,} = useValues(logic)const { loadTaskRuns, loadSelectedTaskRun, clearContinuationDraft } = useActions(logic)@@ -97,8 +97,8 @@ export function TaskRunLog({if (selectedRunNotFound) {return <NotFound object="task run" className="m-0 py-8" />}- if (isRunPending) {- return <RunLogSkeleton />+ if (isRunPending || isTaskPending) {+ return <TaskRunLoadingSkeleton />}if (runs.length === 0 && !selectedRunId) {return (@@ -116,5 +116,5 @@ export function TaskRunLog({</div>)}- return selectedRunId ? <RunLogSkeleton /> : null+ return selectedRunId ? <TaskRunLoadingSkeleton /> : null}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/taskDetailSkeletons.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/taskDetailSkeletons.tsxindex c4950e72dec3..bef3d763a215 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/taskDetailSkeletons.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/taskDetailSkeletons.tsx@@ -1,7 +1,10 @@import { LemonSkeleton } from '@posthog/lemon-ui'+import { Skeleton } from '@posthog/quill-primitives'import { ScenePanelInfoSection } from '~/layout/scenes/SceneLayout'+import { useThreadSkin } from '../../../hooks/useThreadSkin'+/** Skeleton for the scene side panel's task-info block — mirrors the four labelled rows. */export function TaskPanelSkeleton(): JSX.Element {return (@@ -30,6 +33,15 @@ export function TaskPanelSkeleton(): JSX.Element {/** Skeleton for the title-bar action buttons (Open in PostHog Desktop / View PR / Run). */export function TaskHeaderActionsSkeleton(): JSX.Element {+ const skin = useThreadSkin()+ if (skin === 'quill') {+ return (+ <div data-quill className="flex items-center gap-1">+ <Skeleton className="hidden h-6 w-44 lg:block" />+ <Skeleton className="size-6" />+ </div>+ )+ }return (<div className="flex items-center gap-2"><LemonSkeleton className="h-7 w-40" />