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.

feat(desktop): standardize session startup in the chat (#97625)

Shy Alter35b0e1df3cb5
diff --git a/products/desktop/apps/mobile/src/app/task/[id].tsx b/products/desktop/apps/mobile/src/app/task/[id].tsx
index 3ec20f3ac73f..b49876bc4386 100644
--- a/products/desktop/apps/mobile/src/app/task/[id].tsx
+++ b/products/desktop/apps/mobile/src/app/task/[id].tsx
@@ -743,25 +743,18 @@ export default function TaskDetailScreen() {
const prUrl = readPrUrls(task?.latest_run?.output)[0];
- const activityPhase = getSessionActivityPhase({ retrying, session });
- const isConnecting = activityPhase === "connecting";
- const isThinking = activityPhase === "working";
-
- // Show the loading overlay until the SSE snapshot has populated the
- // session's events. For tasks that already have a run (i.e. opening an
- // old task), `session.status` stays `"connecting"` until the first
- // snapshot arrives — that's when historical events become available.
- // For brand-new tasks (no `latest_run`), there's no history to wait
- // for, so we only gate on the initial metadata fetch.
const isHistoryLoading =
!!task?.latest_run &&
!!session &&
session.status === "connecting" &&
session.events.length === 0;
- // Suppress the full-screen overlay when we have an optimistic prompt to
- // show — the user just submitted and seeing their own text + a connecting
- // indicator is friendlier than a blank spinner.
- const showLoading = (loading || isHistoryLoading) && !optimisticPrompt;
+ const activityPhase = getSessionActivityPhase({
+ retrying: retrying || isHistoryLoading,
+ session,
+ });
+ const isConnecting = activityPhase === "connecting";
+ const isThinking = activityPhase === "working";
+ const showLoading = !task && loading && !optimisticPrompt;
// Haptic pulse when connecting/thinking indicators dismiss
const prevWaiting = useRef(false);
@@ -857,19 +850,10 @@ export default function TaskDetailScreen() {
}}
/>
- {/* Loading overlay — covers the list while initial task metadata
- is fetched AND while the SSE watcher is still loading the
- historical events snapshot for an existing run. */}
{showLoading && (
<View className="absolute inset-0 items-center justify-center bg-background">
<ActivityIndicator size="large" color={themeColors.accent[9]} />
- <Text className="mt-4 text-gray-11">
- {task?.latest_run
- ? loading
- ? "Connecting..."
- : "Loading history..."
- : "Loading task..."}
- </Text>
+ <Text className="mt-4 text-gray-11">Loading task...</Text>
</View>
)}
diff --git a/products/desktop/packages/core/src/canvas/threadTimeline.test.ts b/products/desktop/packages/core/src/canvas/threadTimeline.test.ts
index f14538e9208c..6465a78f29b6 100644
--- a/products/desktop/packages/core/src/canvas/threadTimeline.test.ts
+++ b/products/desktop/packages/core/src/canvas/threadTimeline.test.ts
@@ -212,7 +212,7 @@ describe("deriveThreadAgentStatus", () => {
isInitializing: true,
errorTitle: "Run failed",
},
- expected: { phase: "active", label: "Loading" },
+ expected: { phase: "active", label: "Connecting to agent..." },
},
{
name: "prioritizes pending permissions over active work",
@@ -226,7 +226,7 @@ describe("deriveThreadAgentStatus", () => {
{
name: "reports startup loading before other activity",
input: { isInitializing: true },
- expected: { phase: "active", label: "Loading" },
+ expected: { phase: "active", label: "Connecting to agent..." },
},
{
name: "keeps startup loading ahead of prompt work",
@@ -235,7 +235,7 @@ describe("deriveThreadAgentStatus", () => {
isInitializing: true,
isPromptPending: true,
},
- expected: { phase: "active", label: "Loading" },
+ expected: { phase: "active", label: "Connecting to agent..." },
},
{
name: "reports active work",
diff --git a/products/desktop/packages/core/src/canvas/threadTimeline.ts b/products/desktop/packages/core/src/canvas/threadTimeline.ts
index 0ac762f6495e..37d71c0c87e8 100644
--- a/products/desktop/packages/core/src/canvas/threadTimeline.ts
+++ b/products/desktop/packages/core/src/canvas/threadTimeline.ts
@@ -108,7 +108,7 @@ export function deriveThreadAgentStatus({
}): ThreadAgentStatus | null {
if (!hasActivity && !isInitializing) return null;
if (isInitializing) {
- return { phase: "active", label: "Loading" };
+ return { phase: "active", label: "Connecting to agent..." };
}
if (hasError || cloudStatus === "failed") {
return { phase: "error", label: errorTitle ?? "Failed" };
diff --git a/products/desktop/packages/core/src/sessions/sessionStartup.ts b/products/desktop/packages/core/src/sessions/sessionStartup.ts
index 9545c615901c..1f6bd8db36b2 100644
--- a/products/desktop/packages/core/src/sessions/sessionStartup.ts
+++ b/products/desktop/packages/core/src/sessions/sessionStartup.ts
@@ -1,18 +1,22 @@
import { z } from "zod";
import { isNotification, POSTHOG_NOTIFICATIONS } from "./acpNotifications";
+const startupPhaseSchema = z.enum(["sdk_initialization", "setup_hooks"]);
+
const startupEventSchema = z.object({
message: z.object({
method: z.string(),
- params: z.object({
- status: z.enum(["sdk_initialization", "setup_hooks"]),
- }),
+ params: z.object({ status: startupPhaseSchema }),
}),
});
-export type SessionStartupPhase = z.infer<
- typeof startupEventSchema
->["message"]["params"]["status"];
+export type SessionStartupPhase = z.infer<typeof startupPhaseSchema>;
+
+export function isSessionStartupPhase(
+ status: string,
+): status is SessionStartupPhase {
+ return startupPhaseSchema.safeParse(status).success;
+}
export function readSessionStartupPhase(
event: unknown,
diff --git a/products/desktop/packages/ui/src/assets/images/zen.png b/products/desktop/packages/ui/src/assets/images/zen.png
deleted file mode 100644
index babf0bc9e383..000000000000
Binary files a/products/desktop/packages/ui/src/assets/images/zen.png and /dev/null differ
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ThreadPanel.tsx b/products/desktop/packages/ui/src/features/canvas/components/ThreadPanel.tsx
index 69c779bfaf88..2b6e1e656f97 100644
--- a/products/desktop/packages/ui/src/features/canvas/components/ThreadPanel.tsx
+++ b/products/desktop/packages/ui/src/features/canvas/components/ThreadPanel.tsx
@@ -395,7 +395,7 @@ function ThreadPanelHeader({
function ThreadTimeline({
timeline,
- isReady,
+ hasLoadedThread,
currentUserUuid,
currentUserEmail,
isTaskAuthor,
@@ -404,7 +404,7 @@ function ThreadTimeline({
onDelete,
}: {
timeline: ThreadTimelineRow<TaskThreadMessage>[];
- isReady: boolean;
+ hasLoadedThread: boolean;
currentUserUuid?: string;
currentUserEmail?: string;
isTaskAuthor: boolean;
@@ -412,7 +412,7 @@ function ThreadTimeline({
onSendToAgent: (messageId: string) => void;
onDelete: (messageId: string) => void;
}) {
- if (!isReady) return <ThreadLoadingState />;
+ if (!hasLoadedThread) return <ThreadLoadingState />;
if (timeline.length === 0) {
return (
<Empty className="h-full border-0">
@@ -528,7 +528,7 @@ function ThreadConversation({
const {
timeline,
agentStatus,
- isReady,
+ hasLoadedThread,
members,
currentUser,
isTaskAuthor,
@@ -566,7 +566,7 @@ function ThreadConversation({
<div ref={contentRef}>
<ThreadTimeline
timeline={timeline}
- isReady={isReady}
+ hasLoadedThread={hasLoadedThread}
currentUserUuid={currentUser?.uuid}
currentUserEmail={currentUser?.email}
isTaskAuthor={isTaskAuthor}
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useTaskThread.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useTaskThread.ts
index f7aa8e40db90..c6ab61b8585d 100644
--- a/products/desktop/packages/ui/src/features/canvas/hooks/useTaskThread.ts
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useTaskThread.ts
@@ -25,8 +25,7 @@ export function useTaskThread(
},
): {
messages: TaskThreadMessage[];
- isLoading: boolean;
- /** The thread has come back at least once. Distinct from `!isLoading`, which flips back
+ /** The thread has come back at least once. Distinct from a loading flag, which flips back
* on a refetch and would blink a loader over content already on screen. */
hasLoaded: boolean;
} {
@@ -68,7 +67,6 @@ export function useTaskThread(
]);
return {
messages: query.data ?? [],
- isLoading: query.isLoading,
hasLoaded: query.isSuccess || query.isError,
};
}
diff --git a/products/desktop/packages/ui/src/features/canvas/hooks/useThreadConversation.ts b/products/desktop/packages/ui/src/features/canvas/hooks/useThreadConversation.ts
index e8291dc5de95..16f6b71660b7 100644
--- a/products/desktop/packages/ui/src/features/canvas/hooks/useThreadConversation.ts
+++ b/products/desktop/packages/ui/src/features/canvas/hooks/useThreadConversation.ts
@@ -42,9 +42,8 @@ export interface ThreadConversation {
agentStatus: ThreadAgentStatus | null;
events: SessionEvents;
isPromptPending: boolean;
- isReady: boolean;
- /** The thread's own durable content has arrived. The timeline draws on this rather than
- * on `isReady`, which also waits for the live session to connect. */
+ /** The thread's own durable content has arrived. Unlike the live session's
+ * connect state, this never goes back to false once true. */
hasLoadedThread: boolean;
members: UserBasic[];
currentUser: { id?: number; uuid?: string; email?: string } | undefined;
@@ -67,11 +66,7 @@ export function useThreadConversation(
const client = useOptionalAuthenticatedClient();
const { data: currentUser } = useCurrentUser({ client });
- const {
- messages,
- isLoading,
- hasLoaded: hasLoadedThread,
- } = useTaskThread(taskId);
+ const { messages, hasLoaded: hasLoadedThread } = useTaskThread(taskId);
const { postMessage, isPosting } = usePostTaskThreadMessage(taskId);
const { postMessageToAgent, isPostingToAgent } =
usePostTaskThreadMessageToAgent(taskId);
@@ -208,7 +203,6 @@ export function useThreadConversation(
agentStatus,
events,
isPromptPending,
- isReady: !isInitializing && !isLoading,
hasLoadedThread,
members,
currentUser,
diff --git a/products/desktop/packages/ui/src/features/inbox/components/ReportChatSidebar.tsx b/products/desktop/packages/ui/src/features/inbox/components/ReportChatSidebar.tsx
index 7d5d7d0801ea..d330c8df11b8 100644
--- a/products/desktop/packages/ui/src/features/inbox/components/ReportChatSidebar.tsx
+++ b/products/desktop/packages/ui/src/features/inbox/components/ReportChatSidebar.tsx
@@ -22,13 +22,20 @@ import {
import { useReportChatPanelStore } from "@posthog/ui/features/inbox/stores/reportChatPanelStore";
import { useDraftStore } from "@posthog/ui/features/message-editor/draftStore";
import { EmbeddedSessionView } from "@posthog/ui/features/sessions/components/EmbeddedSessionView";
+import { SessionStartupStatus } from "@posthog/ui/features/sessions/components/SessionStartupStatus";
import { taskDetailQuery } from "@posthog/ui/features/tasks/queries";
-import { LoadingState } from "@posthog/ui/primitives/LoadingState";
import { ResizableSidebar } from "@posthog/ui/primitives/ResizableSidebar";
import { useOpenTask } from "@posthog/ui/router/useOpenTask";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import { useCallback, useEffect, useState } from "react";
+const loadingConversation = (
+ <SessionStartupStatus
+ label="Loading conversation..."
+ className="h-full justify-center"
+ />
+);
+
const isMac =
typeof navigator !== "undefined" && /Mac/i.test(navigator.platform);
@@ -123,7 +130,7 @@ export function ReportChatSidebar({
) : tasksLoading ? (
// Offering the starter before the task lookup resolves invites a
// duplicate conversation on a report that already has one.
- <LoadingState />
+ loadingConversation
) : (
<ReportChatStarter
report={report}
@@ -180,7 +187,7 @@ function ReportChatConversation({
]);
if (!task) {
- return <LoadingState />;
+ return loadingConversation;
}
return <EmbeddedSessionView task={task} />;
diff --git a/products/desktop/packages/ui/src/features/provisioning/ProvisioningView.tsx b/products/desktop/packages/ui/src/features/provisioning/ProvisioningView.tsx
deleted file mode 100644
index 5f69f4d0c048..000000000000
--- a/products/desktop/packages/ui/src/features/provisioning/ProvisioningView.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-import { Spinner } from "@posthog/ui/primitives/Spinner";
-import { useEffect, useRef } from "react";
-import { useProvisioningStore } from "./store";
-
-interface ProvisioningViewProps {
- taskId: string;
-}
-
-export function ProvisioningView({ taskId }: ProvisioningViewProps) {
- const lines = useProvisioningStore((s) => s.output[taskId]);
- const scrollRef = useRef<HTMLPreElement>(null);
-
- const text = (lines ?? []).join("\n");
-
- useEffect(() => {
- const el = scrollRef.current;
- if (el) {
- el.scrollTop = el.scrollHeight;
- }
- }, []);
-
- return (
- <div className="h-full">
- <div className="flex h-full flex-col gap-2 p-3">
- <div className="flex items-center gap-2">
- <Spinner size="sm" />
- <span className="font-medium text-[13px]">Preparing worktree</span>
- </div>
- <p className="m-0 text-gray-11 text-sm">
- Creating a separate checkout for this task. Setup output appears
- below.
- </p>
- <div className="min-h-0 flex-1 rounded-(--radius-2) border border-(--gray-a5) bg-(--color-surface)">
- <pre
- ref={scrollRef}
- className="m-0 h-full overflow-auto whitespace-pre-wrap break-all p-2 font-[var(--code-font-family)] text-(--gray-12) text-[13px]"
- >
- {text}
- </pre>
- </div>
- </div>
- </div>
- );
-}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/CloudSessionLifecycle.tsx b/products/desktop/packages/ui/src/features/sessions/components/CloudSessionLifecycle.tsx
index 43088d67ee14..af98a4ddf086 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/CloudSessionLifecycle.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/CloudSessionLifecycle.tsx
@@ -1,5 +1,4 @@
import { Warning } from "@phosphor-icons/react";
-import { Spinner } from "@posthog/ui/primitives/Spinner";
import { Button, Flex, Text } from "@radix-ui/themes";
interface CloudStreamDisconnectedBannerProps {
@@ -52,14 +51,3 @@ export function CloudStreamDisconnectedBanner({
</Flex>
);
}
-
-export function ConnectingToAgent({ spinning = true }: { spinning?: boolean }) {
- return (
- <>
- <Spinner size="lg" spinning={spinning} className="text-gray-9" />
- <Text color="gray" className="text-base">
- Connecting to agent...
- </Text>
- </>
- );
-}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/PendingChatView.test.tsx b/products/desktop/packages/ui/src/features/sessions/components/PendingChatView.test.tsx
deleted file mode 100644
index d600cc73efca..000000000000
--- a/products/desktop/packages/ui/src/features/sessions/components/PendingChatView.test.tsx
+++ /dev/null
@@ -1,119 +0,0 @@
-import { fireEvent, render, screen, waitFor } from "@testing-library/react";
-import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-
-import { PendingChatView } from "./PendingChatView";
-
-class ResizeObserverCapture {
- static instances: ResizeObserverCallback[] = [];
-
- constructor(callback: ResizeObserverCallback) {
- ResizeObserverCapture.instances.push(callback);
- }
-
- observe() {}
- unobserve() {}
- disconnect() {}
-}
-
-function measure(element: HTMLElement, overflow: boolean): void {
- Object.defineProperty(element, "scrollHeight", {
- configurable: true,
- value: overflow ? 500 : 100,
- });
- Object.defineProperty(element, "clientHeight", {
- configurable: true,
- value: 100,
- });
- for (const callback of ResizeObserverCapture.instances) {
- callback([], {} as ResizeObserver);
- }
-}
-
-function renderPending(
- props: {
- content?: string;
- attachments?: { id: string; label: string }[];
- } = {},
-) {
- render(
- <PendingChatView
- executionTarget="local"
- content={props.content ?? "Ship the login fix"}
- attachments={props.attachments}
- />,
- );
-}
-
-describe("PendingChatView", () => {
- beforeEach(() => {
- ResizeObserverCapture.instances = [];
- vi.stubGlobal("ResizeObserver", ResizeObserverCapture);
- });
-
- afterEach(() => {
- vi.unstubAllGlobals();
- });
-
- it("renders the prompt with a loading state", () => {
- renderPending();
- expect(screen.getByText("Ship the login fix")).toBeInTheDocument();
- expect(screen.getByText("Starting local agent")).toBeInTheDocument();
- expect(
- screen.queryByText(/Your prompt is saved with this task/),
- ).not.toBeInTheDocument();
- });
-
- it("renders file mentions as chips so the bubble matches the live transcript", () => {
- renderPending({
- content: 'fix <file path="src/a.ts" />',
- });
- expect(screen.getByText("src/a.ts")).toBeInTheDocument();
- expect(screen.queryByText("fix @src/a.ts")).not.toBeInTheDocument();
- });
-
- it("hides attachment chips when the content already carries file mentions", () => {
- renderPending({
- content: 'run this <file path="src/a.ts" />',
- attachments: [{ id: "src/a.ts", label: "src/a.ts" }],
- });
- expect(screen.getByText("src/a.ts")).toBeInTheDocument();
- // The attachment would render the same label a second time.
- expect(screen.getAllByText("src/a.ts")).toHaveLength(1);
- });
-
- it("shows attachments for plain content without file mentions", () => {
- renderPending({
- content: "summarize this",
- attachments: [{ id: "notes.txt", label: "notes.txt" }],
- });
- expect(screen.getByText("notes.txt")).toBeInTheDocument();
- });
-
- it("clamps a long prompt to five lines and expands on Show more", async () => {
- renderPending({
- content: Array.from({ length: 20 }, (_, i) => `line ${i}`).join("\n\n"),
- });
-
- const clamped = document.querySelector(".max-h-\\[5lh\\]");
- expect(clamped).not.toBeNull();
- expect(screen.queryByText("Show more")).not.toBeInTheDocument();
-
- measure(clamped as HTMLElement, true);
- await waitFor(() =>
- expect(screen.getByText("Show more")).toBeInTheDocument(),
- );
-
- fireEvent.click(screen.getByText("Show more"));
- expect(screen.getByText("Show less")).toBeInTheDocument();
- expect(document.querySelector(".max-h-\\[5lh\\]")).toBeNull();
- });
-
- it("keeps a short prompt unclamped with no toggle", () => {
- renderPending({ content: "Ship the login fix" });
-
- const clamped = document.querySelector(".max-h-\\[5lh\\]");
- expect(clamped).not.toBeNull();
- measure(clamped as HTMLElement, false);
- expect(screen.queryByText("Show more")).not.toBeInTheDocument();
- });
-});
diff --git a/products/desktop/packages/ui/src/features/sessions/components/PendingChatView.tsx b/products/desktop/packages/ui/src/features/sessions/components/PendingChatView.tsx
deleted file mode 100644
index 3170918132de..000000000000
--- a/products/desktop/packages/ui/src/features/sessions/components/PendingChatView.tsx
+++ /dev/null
@@ -1,77 +0,0 @@
-import {
- ChatBubble,
- ChatBubbleContent,
- ChatMessage,
- ChatMessageContent,
- ChatMessageFooter,
-} from "@posthog/quill";
-import { ComposerWidth } from "@posthog/ui/features/sessions/components/ComposerWidth";
-import { UserMessageBody } from "@posthog/ui/features/sessions/components/chat-thread/UserMessageBody";
-import { PendingInputPlaceholder } from "@posthog/ui/features/sessions/components/PendingInputPlaceholder";
-import {
- CHAT_CONTENT_MAX_WIDTH,
- CHAT_CONTENT_PADDING_INLINE,
-} from "@posthog/ui/features/sessions/constants";
-import type { UserMessageAttachment } from "@posthog/ui/features/sessions/userMessageTypes";
-import {
- SessionStartupStatus,
- type SessionStartupStatusProps,
-} from "./SessionStartupStatus";
-
-interface PendingChatViewProps extends SessionStartupStatusProps {
- /**
- * The prompt as the live transcript will render it (serialized content with
- * chips), so the bubble looks the same when the transcript replaces it.
- */
- content: string;
- attachments?: UserMessageAttachment[];
-}
-
-export function PendingChatView({
- content,
- attachments,
- executionTarget,
- phase,
-}: PendingChatViewProps) {
- return (
- <div className="absolute inset-0 flex flex-col bg-background">
- <div className="min-h-0 flex-1 overflow-y-auto [scrollbar-gutter:stable]">
- <div
- className="flex w-full flex-col gap-4 py-4 pb-8"
- style={{ paddingInline: CHAT_CONTENT_PADDING_INLINE }}
- >
- <div
- className="mx-auto w-full py-1"
- style={{ maxWidth: CHAT_CONTENT_MAX_WIDTH }}
- >
- <ChatMessage align="end">
- <ChatMessageContent className="gap-1">
- <ChatBubble align="end" className="rounded-lg">
- <ChatBubbleContent>
- <UserMessageBody
- content={content}
- attachments={attachments}
- />
- </ChatBubbleContent>
- </ChatBubble>
- <ChatMessageFooter aria-hidden className="min-h-5" />
- </ChatMessageContent>
- </ChatMessage>
- </div>
- <div
- className="mx-auto w-full px-2.5"
- style={{ maxWidth: CHAT_CONTENT_MAX_WIDTH }}
- >
- <SessionStartupStatus
- executionTarget={executionTarget}
- phase={phase}
- />
- </div>
- </div>
- </div>
- <ComposerWidth compact={false}>
- <PendingInputPlaceholder />
- </ComposerWidth>
- </div>
- );
-}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/PendingInputPlaceholder.tsx b/products/desktop/packages/ui/src/features/sessions/components/PendingInputPlaceholder.tsx
deleted file mode 100644
index d33372a273bf..000000000000
--- a/products/desktop/packages/ui/src/features/sessions/components/PendingInputPlaceholder.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { Box, Flex } from "@radix-ui/themes";
-
-/**
- * Non-interactive skeleton sized to match {@link PromptInput} so the chat
- * shell does not jump when the real editor mounts after session init.
- */
-export function PendingInputPlaceholder() {
- return (
- <Flex direction="column" gap="1" aria-hidden className="w-full opacity-70">
- <Flex
- align="end"
- className="rounded-(--radius-2) border border-(--gray-5) bg-card"
- >
- <Box className="min-h-[37px] flex-1 px-2 py-2">
- <Box className="h-3 w-2/5 animate-pulse rounded bg-gray-4" />
- </Box>
- <Box className="m-1 h-7 w-7 shrink-0 animate-pulse rounded bg-gray-5" />
- </Flex>
- <Flex align="center" gap="1" className="px-1">
- <Box className="h-6 w-6 animate-pulse rounded bg-gray-4" />
- <Box className="h-6 w-16 animate-pulse rounded bg-gray-4" />
- <Box className="h-6 w-28 animate-pulse rounded bg-gray-4" />
- </Flex>
- </Flex>
- );
-}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.test.tsx b/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.test.tsx
deleted file mode 100644
index 7a4bda47fbe2..000000000000
--- a/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.test.tsx
+++ /dev/null
@@ -1,66 +0,0 @@
-import { act, render, screen } from "@testing-library/react";
-import { afterEach, describe, expect, it, vi } from "vitest";
-import { SessionInitializingView } from "./SessionInitializingView";
-
-afterEach(() => {
- vi.useRealTimers();
-});
-
-describe("SessionInitializingView", () => {
- it.each([
- {
- executionTarget: "local" as const,
- title: "Starting local agent",
- },
- {
- executionTarget: "cloud" as const,
- title: "Starting cloud agent",
- },
- ])(
- "shows the current step through $executionTarget startup",
- ({ executionTarget, title }) => {
- vi.useFakeTimers();
-
- render(<SessionInitializingView executionTarget={executionTarget} />);
-
- expect(screen.getByRole("status").textContent).toBe(title);
-
- act(() => {
- vi.advanceTimersByTime(2000);
- });
-
- expect(screen.getByRole("status").textContent).toBe(title);
- },
- );
-
- it("updates the visible phase when hooks start and finish", () => {
- vi.useFakeTimers();
- const { rerender } = render(
- <SessionInitializingView executionTarget="local" />,
- );
- rerender(
- <SessionInitializingView executionTarget="local" phase="setup_hooks" />,
- );
- expect(screen.getByRole("status")).toHaveTextContent(
- "Running repository setup",
- );
- act(() => {
- vi.advanceTimersByTime(2000);
- });
- expect(screen.getByRole("status").textContent).toBe(
- "Running repository setup",
- );
- rerender(
- <SessionInitializingView
- executionTarget="local"
- phase="sdk_initialization"
- />,
- );
- expect(screen.getByRole("status")).toHaveTextContent(
- "Starting local agent",
- );
- expect(
- screen.queryByText("Running repository setup"),
- ).not.toBeInTheDocument();
- });
-});
diff --git a/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.tsx b/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.tsx
deleted file mode 100644
index e8d82be83b2a..000000000000
--- a/products/desktop/packages/ui/src/features/sessions/components/SessionInitializingView.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import { useEffect, useState } from "react";
-import zenHedgehog from "../../../assets/images/zen.png";
-import {
- SessionStartupStatus,
- type SessionStartupStatusProps,
-} from "./SessionStartupStatus";
-
-const REVEAL_DELAY_MS = 2000;
-
-export function SessionInitializingView({
- executionTarget,
- phase,
-}: SessionStartupStatusProps) {
- const [revealed, setRevealed] = useState(false);
-
- useEffect(() => {
- const timer = setTimeout(() => setRevealed(true), REVEAL_DELAY_MS);
- return () => clearTimeout(timer);
- }, []);
-
- if (!revealed) {
- return (
- <div className="absolute inset-0 flex items-center justify-center gap-2 bg-background">
- <SessionStartupStatus executionTarget={executionTarget} phase={phase} />
- </div>
- );
- }
-
- return (
- <div className="absolute inset-0 flex flex-col items-center justify-center gap-5 bg-background">
- <div className="zen-float">
- <img src={zenHedgehog} alt="" className="block w-[160px]" />
- </div>
- <SessionStartupStatus executionTarget={executionTarget} phase={phase} />
- </div>
- );
-}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/SessionProvisioningStatus.tsx b/products/desktop/packages/ui/src/features/sessions/components/SessionProvisioningStatus.tsx
new file mode 100644
index 000000000000..2249ecaf94e1
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/sessions/components/SessionProvisioningStatus.tsx
@@ -0,0 +1,61 @@
+import { CaretDown } from "@phosphor-icons/react";
+import { Button, cn } from "@posthog/quill";
+import { useProvisioningStore } from "@posthog/ui/features/provisioning/store";
+import { useEffect, useRef, useState } from "react";
+import { SessionStartupStatus, startupLabel } from "./SessionStartupStatus";
+
+export function SessionProvisioningStatus({
+ taskId,
+ executionTarget,
+}: {
+ taskId: string;
+ executionTarget: "cloud" | "local";
+}) {
+ const lines = useProvisioningStore((s) => s.output[taskId]);
+ const [open, setOpen] = useState(false);
+ const logRef = useRef<HTMLPreElement>(null);
+ const detail = lines?.findLast((line) => line.trim())?.trim();
+ const hasLog = !!lines && lines.length > 0;
+
+ useEffect(() => {
+ const el = logRef.current;
+ if (!open || !lines || !el) return;
+ el.scrollTop = el.scrollHeight;
+ }, [open, lines]);
+
+ return (
+ <div className="w-full min-w-0">
+ <SessionStartupStatus
+ label={startupLabel(executionTarget, "setup_hooks")}
+ />
+ <div className="min-w-0 pl-[22px]">
+ {detail && (
+ <p className="mt-0.5 mb-0 truncate text-gray-10 text-sm">{detail}</p>
+ )}
+ {hasLog && (
+ <Button
+ aria-expanded={open}
+ className="mt-1"
+ onClick={() => setOpen(!open)}
+ size="xs"
+ variant="link-muted"
+ >
+ <CaretDown
+ className={cn("transition-transform", open && "rotate-180")}
+ size={12}
+ />
+ {open ? "Hide log" : "Show log"}
+ </Button>
+ )}
+ {open && hasLog && (
+ <pre
+ ref={logRef}
+ className="mt-1 mb-0 max-h-40 w-full overflow-auto whitespace-pre-wrap break-words rounded-(--radius-2) border border-(--gray-a5) bg-(--color-surface) p-2 text-left font-[var(--code-font-family)] text-(--gray-12) text-[13px]"
+ >
+ {lines.join("\n")}
+ </pre>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/SessionStartupRow.tsx b/products/desktop/packages/ui/src/features/sessions/components/SessionStartupRow.tsx
new file mode 100644
index 000000000000..0f22a6d86310
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/sessions/components/SessionStartupRow.tsx
@@ -0,0 +1,46 @@
+import type { Task } from "@posthog/shared/domain-types";
+import { useProvisioningStore } from "@posthog/ui/features/provisioning/store";
+import { SessionProvisioningStatus } from "@posthog/ui/features/sessions/components/SessionProvisioningStatus";
+import {
+ SessionStartupStatus,
+ startupLabel,
+} from "@posthog/ui/features/sessions/components/SessionStartupStatus";
+import { useSessionViewState } from "@posthog/ui/features/sessions/hooks/useSessionViewState";
+import { useSessionStore } from "@posthog/ui/features/sessions/sessionStore";
+
+export function SessionStartupRow({
+ taskId,
+ task,
+}: {
+ taskId: string;
+ task: Task;
+}) {
+ const isProvisioning = useProvisioningStore((s) => s.activeTasks.has(taskId));
+ const startupPhase = useSessionStore(
+ (state) => state.startingTaskIds[taskId]?.phase,
+ );
+ const { isCloud, isRunning, isInitializing, hasError } = useSessionViewState(
+ taskId,
+ task,
+ );
+ const executionTarget = isCloud ? "cloud" : "local";
+
+ if (isProvisioning) {
+ return (
+ <SessionProvisioningStatus
+ executionTarget={executionTarget}
+ taskId={taskId}
+ />
+ );
+ }
+ if (hasError || (isRunning && !isInitializing)) return null;
+ return (
+ <SessionStartupStatus
+ label={
+ isInitializing
+ ? startupLabel(executionTarget, startupPhase)
+ : "Connecting to agent..."
+ }
+ />
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/SessionStartupStatus.stories.tsx b/products/desktop/packages/ui/src/features/sessions/components/SessionStartupStatus.stories.tsx
index f434ecd92066..9f42e26b69f8 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/SessionStartupStatus.stories.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/SessionStartupStatus.stories.tsx
@@ -1,31 +1,57 @@
+import { useProvisioningStore } from "@posthog/ui/features/provisioning/store";
import type { Meta, StoryObj } from "@storybook/react-vite";
-import { PendingChatView } from "./PendingChatView";
-import { SessionStartupStatus } from "./SessionStartupStatus";
+import { SessionProvisioningStatus } from "./SessionProvisioningStatus";
+import { SessionStartupStatus, startupLabel } from "./SessionStartupStatus";
const meta = {
title: "Sessions/Startup status",
component: SessionStartupStatus,
parameters: { layout: "centered" },
- args: { executionTarget: "local" },
+ args: { label: startupLabel("local") },
} satisfies Meta<typeof SessionStartupStatus>;
export default meta;
type Story = StoryObj<typeof meta>;
-export const StartingAgent: Story = {};
-export const RunningSetup: Story = { args: { phase: "setup_hooks" } };
-export const Cloud: Story = { args: { executionTarget: "cloud" } };
+export const StartingLocalAgent: Story = {};
+export const RunningSetup: Story = {
+ args: { label: startupLabel("local", "setup_hooks") },
+};
+export const StartingCloudAgent: Story = {
+ args: { label: startupLabel("cloud") },
+};
+export const Reconnecting: Story = {
+ args: { label: "Connecting to agent..." },
+};
+
+const PROVISIONING_TASK_ID = "story-provisioning";
-export const PendingWorktree: Story = {
- args: { phase: "setup_hooks" },
+export const Provisioning: Story = {
parameters: { layout: "fullscreen" },
- render: (args) => (
- <div className="relative h-screen min-h-[420px] w-full bg-background">
- <PendingChatView
- content="Add keyboard navigation to the project list."
- executionTarget={args.executionTarget}
- phase={args.phase}
- />
+ decorators: [
+ (Story) => {
+ useProvisioningStore.setState({
+ output: {
+ [PROVISIONING_TASK_ID]: [
+ "Cloning into /tasks/story-provisioning...",
+ "Installing dependencies",
+ ],
+ },
+ });
+ return <Story />;
+ },
+ ],
+ render: () => (
+ <div className="min-h-[420px] w-full bg-background p-6">
+ <div className="mx-auto w-full max-w-[750px]">
+ <p className="mb-6 text-sm">
+ Sure. I will start by reading the setup script.
+ </p>
+ <SessionProvisioningStatus
+ executionTarget="local"
+ taskId={PROVISIONING_TASK_ID}
+ />
+ </div>
</div>
),
};
diff --git a/products/desktop/packages/ui/src/features/sessions/components/SessionStartupStatus.tsx b/products/desktop/packages/ui/src/features/sessions/components/SessionStartupStatus.tsx
index 7baadb6458a3..dbb1d8e6e7d4 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/SessionStartupStatus.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/SessionStartupStatus.tsx
@@ -1,25 +1,39 @@
import type { SessionStartupPhase } from "@posthog/core/sessions/sessionStartup";
+import { cn } from "@posthog/quill";
import { Spinner } from "@posthog/ui/primitives/Spinner";
-export interface SessionStartupStatusProps {
- executionTarget: "cloud" | "local";
- phase?: SessionStartupPhase;
+export type SessionStartupTarget = "cloud" | "local";
+
+const TITLE: Record<SessionStartupTarget, string> = {
+ local: "Starting local agent",
+ cloud: "Starting cloud agent",
+};
+
+export function startupLabel(
+ target: SessionStartupTarget,
+ phase?: SessionStartupPhase,
+): string {
+ return target === "local" && phase === "setup_hooks"
+ ? "Running repository setup"
+ : TITLE[target];
}
export function SessionStartupStatus({
- executionTarget,
- phase,
-}: SessionStartupStatusProps) {
- const isSetup = executionTarget === "local" && phase === "setup_hooks";
- const title = isSetup
- ? "Running repository setup"
- : executionTarget === "local"
- ? "Starting local agent"
- : "Starting cloud agent";
+ label,
+ className,
+}: {
+ label: string;
+ className?: string;
+}) {
return (
- <output className="flex items-center gap-2 text-gray-11 text-sm">
+ <output
+ className={cn(
+ "flex min-w-0 items-center gap-2 text-gray-11 text-sm",
+ className,
+ )}
+ >
<Spinner aria-hidden size="sm" className="shrink-0 text-accent-11" />
- <span>{title}</span>
+ <span className="shrink-0">{label}</span>
</output>
);
}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/SessionView.tsx b/products/desktop/packages/ui/src/features/sessions/components/SessionView.tsx
index 781b4cdcb63c..5f0655c6980c 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/SessionView.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/SessionView.tsx
@@ -29,10 +29,7 @@ import { useDraftStore } from "@posthog/ui/features/message-editor/draftStore";
import { useAutoFocusOnTyping } from "@posthog/ui/features/message-editor/useAutoFocusOnTyping";
import { resolveAndAttachDroppedFiles } from "@posthog/ui/features/message-editor/utils/persistFile";
import { PermissionSelector } from "@posthog/ui/features/permissions/PermissionSelector";
-import {
- CloudStreamDisconnectedBanner,
- ConnectingToAgent,
-} from "@posthog/ui/features/sessions/components/CloudSessionLifecycle";
+import { CloudStreamDisconnectedBanner } from "@posthog/ui/features/sessions/components/CloudSessionLifecycle";
import { ComposerWidth } from "@posthog/ui/features/sessions/components/ComposerWidth";
import { ContextUsageIndicator } from "@posthog/ui/features/sessions/components/ContextUsageIndicator";
import type { PromptRecallHandler } from "@posthog/ui/features/sessions/components/chat-thread/composerPromptRecall";
@@ -42,13 +39,11 @@ import {
} from "@posthog/ui/features/sessions/components/copyContextTarget";
import { DropZoneOverlay } from "@posthog/ui/features/sessions/components/DropZoneOverlay";
import { ModelSwitchCacheDialog } from "@posthog/ui/features/sessions/components/ModelSwitchCacheDialog";
-import { PendingChatView } from "@posthog/ui/features/sessions/components/PendingChatView";
import { PermissionDock } from "@posthog/ui/features/sessions/components/PermissionDock";
import { PlanStatusBar } from "@posthog/ui/features/sessions/components/PlanStatusBar";
import { QueuedMessagesDock } from "@posthog/ui/features/sessions/components/QueuedMessagesDock";
import { ReasoningLevelSelector } from "@posthog/ui/features/sessions/components/ReasoningLevelSelector";
import { RawLogsView } from "@posthog/ui/features/sessions/components/raw-logs/RawLogsView";
-import { SessionInitializingView } from "@posthog/ui/features/sessions/components/SessionInitializingView";
import { SessionSummaryPanel } from "@posthog/ui/features/sessions/components/SessionSummaryPanel";
import { SideQuestionCard } from "@posthog/ui/features/sessions/components/SideQuestionCard";
import { SteerQueueToggle } from "@posthog/ui/features/sessions/components/SteerQueueToggle";
@@ -72,7 +67,6 @@ import {
useModelConfigOptionForTask,
usePendingPermissionsForTask,
useSessionSelector,
- useSessionStore,
useThoughtLevelConfigOptionForTask,
} from "@posthog/ui/features/sessions/sessionStore";
import {
@@ -85,10 +79,7 @@ import { useIsWorkspaceCloudRun } from "@posthog/ui/features/workspace/useWorksp
import { useConnectivity } from "@posthog/ui/hooks/useConnectivity";
import { Spinner } from "@posthog/ui/primitives/Spinner";
import { toast } from "@posthog/ui/primitives/toast";
-import {
- pendingTaskPromptStoreApi,
- usePendingTaskPrompt,
-} from "@posthog/ui/shell/pendingTaskPromptStore";
+import { pendingTaskPromptStoreApi } from "@posthog/ui/shell/pendingTaskPromptStore";
import { Box, Button, ContextMenu, Flex, Text } from "@radix-ui/themes";
import {
type ReactNode,
@@ -176,7 +167,6 @@ export function SessionView({
useSessionEventsResidency(taskId);
const showRawLogs = useShowRawLogs();
const { setShowRawLogs } = useSessionViewActions();
- const pendingTaskPrompt = usePendingTaskPrompt(taskId);
const pendingPermissions = usePendingPermissionsForTask(taskId);
const modeOption = useModeConfigOptionForTask(taskId);
const thoughtOption = useThoughtLevelConfigOptionForTask(taskId);
@@ -201,9 +191,6 @@ export function SessionView({
const olderHistoryCursor = useSessionSelector(taskId, (session) =>
isCloud ? (session?.transcriptWindowStart ?? 0) : 0,
);
- const startupPhase = useSessionStore((state) =>
- taskId ? state.startingTaskIds[taskId]?.phase : undefined,
- );
const isLoadingOlderHistory = useSessionSelector(
taskId,
(session) => session?.isLoadingOlderTranscript ?? false,
@@ -681,22 +668,6 @@ export function SessionView({
</Box>
</Box>
</>
- ) : isInitializing ? (
- pendingTaskPrompt?.promptText ? (
- <PendingChatView
- executionTarget={isCloud ? "cloud" : "local"}
- phase={startupPhase}
- content={
- pendingTaskPrompt.contentXml ?? pendingTaskPrompt.promptText
- }
- attachments={pendingTaskPrompt.attachments}
- />
- ) : (
- <SessionInitializingView
- phase={startupPhase}
- executionTarget={isCloud ? "cloud" : "local"}
- />
- )
) : (
<>
<DropZoneOverlay isVisible={isDraggingFile} />
@@ -787,111 +758,96 @@ export function SessionView({
/>
</PermissionDock>
) : (
- <Box className="relative shrink-0">
- <Box
- className={`absolute inset-0 flex min-h-[66px] items-center justify-center gap-2 transition-opacity duration-200 ${
- isRunning
- ? "pointer-events-none opacity-0"
- : "opacity-100"
- }`}
- >
- <ConnectingToAgent spinning={!isRunning} />
- </Box>
- <Box
- className={`transition-all duration-300 ease-out ${
- isRunning
- ? "translate-y-0 opacity-100"
- : "pointer-events-none translate-y-4 opacity-0"
- }`}
- >
- <ComposerWidth compact={compact}>
- {taskId && (
- <SessionSummaryPanel
- taskId={taskId}
- taskRunId={activeTaskRunId}
- />
- )}
- {taskId && (
- <SideQuestionCard
- taskId={taskId}
- taskRunId={activeTaskRunId}
- />
- )}
- {taskId && <QueuedMessagesDock taskId={taskId} />}
- <PromptInput
- ref={editorRef}
- sessionId={sessionId}
- placeholder="Type a message... ! for bash mode, / for skills"
- disabled={!isRunning}
- submitDisabledExternal={
- !isOnline ||
- attachmentsUploading ||
- attachmentUploadFailed ||
- spendStop !== null
- }
- clearOnSubmit={false}
- submitTooltipOverride={
- !isOnline
- ? "No internet connection"
- : attachmentsUploading
- ? "Uploading attachments…"
- : attachmentUploadFailed
- ? "Attachment upload failed"
- : spendStop
- ? spendStopMessage(spendStop)
- : undefined
- }
- isLoading={!!isPromptPending}
- isActiveSession={isActiveSession}
+ <Box className="shrink-0">
+ <ComposerWidth compact={compact}>
+ {taskId && (
+ <SessionSummaryPanel
taskId={taskId}
- repoPath={repoPath}
- modeOption={modeOption}
- onModeChange={
- modeOption ? handleModeChange : undefined
- }
- allowBypassPermissions={allowBypassPermissions}
- enableBashMode={!isCloudRun}
- modelSelector={null}
- reasoningSelector={
- thoughtOption || sessionModelOption ? (
- <ReasoningLevelSelector
- thoughtOption={thoughtOption}
- modelOption={sessionModelOption}
- adapter={adapter}
- contextWindowOption={contextWindowOption}
- fastModeOption={fastModeOption}
- onChange={handleThoughtChange}
- onConfigOptionChange={handleConfigOptionChange}
- disabled={!isRunning}
- />
- ) : null
- }
- messagingModeToggle={
- taskId ? (
- <SteerQueueToggle taskId={taskId} />
- ) : undefined
- }
- toolbarEndSlot={
- <ContextUsageIndicator
- usage={contextUsage}
- taskId={taskId}
- originProduct={task?.origin_product}
- focused={isActiveSession !== false}
- />
- }
- onToggleMessagingMode={toggleMessagingMode}
- onAttachmentsChange={handleAttachmentsChange}
- attachmentUploadStatuses={attachmentUploadStatuses}
- onPromptRecall={handlePromptRecall}
- onBeforeSubmit={handleBeforeSubmit}
- onSubmit={handleSubmit}
- onBashCommand={onBashCommand}
- onCancel={onCancelPrompt}
- isEditingQueued={isEditingQueued}
- onCancelEdit={cancelQueuedEdit}
+ taskRunId={activeTaskRunId}
+ />
+ )}
+ {taskId && (
+ <SideQuestionCard
+ taskId={taskId}
+ taskRunId={activeTaskRunId}
/>
- </ComposerWidth>
- </Box>
+ )}
+ {taskId && <QueuedMessagesDock taskId={taskId} />}
+ <PromptInput
+ ref={editorRef}
+ sessionId={sessionId}
+ placeholder={
+ isRunning
+ ? "Type a message... ! for bash mode, / for skills"
+ : "Waiting for the agent..."
+ }
+ disabled={!isRunning}
+ submitDisabledExternal={
+ !isOnline ||
+ attachmentsUploading ||
+ attachmentUploadFailed ||
+ spendStop !== null
+ }
+ clearOnSubmit={false}
+ submitTooltipOverride={
+ !isOnline
+ ? "No internet connection"
+ : attachmentsUploading
+ ? "Uploading attachments…"
+ : attachmentUploadFailed
+ ? "Attachment upload failed"
+ : spendStop
+ ? spendStopMessage(spendStop)
+ : undefined
+ }
+ isLoading={!!isPromptPending}
+ isActiveSession={isActiveSession}
+ taskId={taskId}
+ repoPath={repoPath}
+ modeOption={modeOption}
+ onModeChange={modeOption ? handleModeChange : undefined}
+ allowBypassPermissions={allowBypassPermissions}
+ enableBashMode={!isCloudRun}
+ modelSelector={null}
+ reasoningSelector={
+ thoughtOption || sessionModelOption ? (
+ <ReasoningLevelSelector
+ thoughtOption={thoughtOption}
+ modelOption={sessionModelOption}
+ adapter={adapter}
+ contextWindowOption={contextWindowOption}
+ fastModeOption={fastModeOption}
+ onChange={handleThoughtChange}
+ onConfigOptionChange={handleConfigOptionChange}
+ disabled={!isRunning}
+ />
+ ) : null
+ }
+ messagingModeToggle={
+ taskId ? (
+ <SteerQueueToggle taskId={taskId} />
+ ) : undefined
+ }
+ toolbarEndSlot={
+ <ContextUsageIndicator
+ usage={contextUsage}
+ taskId={taskId}
+ originProduct={task?.origin_product}
+ focused={isActiveSession !== false}
+ />
+ }
+ onToggleMessagingMode={toggleMessagingMode}
+ onAttachmentsChange={handleAttachmentsChange}
+ attachmentUploadStatuses={attachmentUploadStatuses}
+ onPromptRecall={handlePromptRecall}
+ onBeforeSubmit={handleBeforeSubmit}
+ onSubmit={handleSubmit}
+ onBashCommand={onBashCommand}
+ onCancel={onCancelPrompt}
+ isEditingQueued={isEditingQueued}
+ onCancelEdit={cancelQueuedEdit}
+ />
+ </ComposerWidth>
</Box>
)}
</>
diff --git a/products/desktop/packages/ui/src/features/sessions/components/buildConversationItems.test.ts b/products/desktop/packages/ui/src/features/sessions/components/buildConversationItems.test.ts
index 3ba13f28d8cd..4caf9bc5ddba 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/buildConversationItems.test.ts
+++ b/products/desktop/packages/ui/src/features/sessions/components/buildConversationItems.test.ts
@@ -300,6 +300,54 @@ describe("buildConversationItems", () => {
expect(fullIds.slice(-tailIds.length)).toEqual(tailIds);
});
+ it.each([
+ {
+ name: "while the start is still the newest thing",
+ trailing: [],
+ expected: 0,
+ },
+ {
+ name: "once the agent speaks after it",
+ trailing: [agentMessageMsg(6, "Hi")],
+ expected: 1,
+ },
+ {
+ name: "once per burst when content separates them",
+ trailing: [
+ agentMessageMsg(6, "Hi"),
+ statusMsg(7, "setup_hooks"),
+ statusMsg(8, "sdk_initialization"),
+ agentMessageMsg(9, "Back"),
+ ],
+ expected: 2,
+ },
+ ])(
+ "collapses a startup burst into one agent_started row $name",
+ ({ trailing, expected }) => {
+ const result = buildConversationItems(
+ [
+ userPromptMsg(1, 1, "go"),
+ statusMsg(2, "setup_hooks"),
+ statusMsg(3, "sdk_initialization"),
+ statusMsg(4, "setup_hooks"),
+ statusMsg(5, "sdk_initialization"),
+ ...trailing,
+ ],
+ false,
+ );
+ const statuses = result.items.filter(
+ (i): i is Extract<ConversationItem, { type: "session_update" }> =>
+ i.type === "session_update" && i.update.sessionUpdate === "status",
+ );
+ expect(statuses).toHaveLength(expected);
+ for (const item of statuses) {
+ expect((item.update as { status: string }).status).toBe(
+ "agent_started",
+ );
+ }
+ },
+ );
+
it("clears the compacting spinner on a successful completion status, without duplicating the row", () => {
// A successful compaction sends a terminal `status: compacting, isComplete:
// true`. It must flip the existing status row, not append a second one.
diff --git a/products/desktop/packages/ui/src/features/sessions/components/buildConversationItems.ts b/products/desktop/packages/ui/src/features/sessions/components/buildConversationItems.ts
index 092b2f1683b8..442bc943ed95 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/buildConversationItems.ts
+++ b/products/desktop/packages/ui/src/features/sessions/components/buildConversationItems.ts
@@ -8,6 +8,7 @@ import {
} from "@posthog/agent/acp-extensions";
import { extractPromptDisplayContent } from "@posthog/core/sessions/promptContent";
import { isSteerPromptParams } from "@posthog/core/sessions/sessionEvents";
+import { isSessionStartupPhase } from "@posthog/core/sessions/sessionStartup";
import {
type AcpMessage,
type AgentConversationEvent,
@@ -167,6 +168,7 @@ export interface ItemBuilder {
* permission request — and the resolving tool_call_update replays the raw
* plan-less input, so the plan is re-applied after every merge. */
recoveredPlans: Map<string, string>;
+ pendingAgentStart: number | null;
}
export function createItemBuilder(): ItemBuilder {
@@ -186,6 +188,7 @@ export function createItemBuilder(): ItemBuilder {
isBackgroundTurnActive: false,
runStartedRunIds: new Set(),
recoveredPlans: new Map(),
+ pendingAgentStart: null,
};
}
@@ -276,9 +279,17 @@ function markThoughtCompletionInItems(
}
}
+function flushAgentStart(b: ItemBuilder) {
+ const ts = b.pendingAgentStart;
+ if (ts === null) return;
+ b.pendingAgentStart = null;
+ pushItem(b, { sessionUpdate: "status", status: "agent_started" }, ts);
+}
+
function pushItem(b: ItemBuilder, update: RenderItem, ts?: number) {
const turn = b.currentTurn;
if (!turn) return;
+ flushAgentStart(b);
turn.itemCount++;
b.items.push({
type: "session_update",
@@ -911,6 +922,11 @@ function handleRuntimeStatus(
): void {
ensureImplicitTurn(b, timestamp);
+ if (isSessionStartupPhase(status.status)) {
+ b.pendingAgentStart ??= timestamp;
+ return;
+ }
+
if (status.status === "refusal" || status.status === "refusal_fallback") {
pushItem(b, {
sessionUpdate: "status",
@@ -1342,6 +1358,7 @@ function appendTextChunk(
ts: number,
) {
if (update.content.type !== "text") return;
+ flushAgentStart(b);
const lastItem = b.items[b.items.length - 1];
if (
diff --git a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.tsx b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.tsx
index ef97ba0bf470..53c32dec8d29 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/chat-thread/ChatThreadFooter.tsx
@@ -2,6 +2,7 @@ import type { AcpMessage } from "@posthog/shared";
import type { Task } from "@posthog/shared/domain-types";
import type { BuildResult } from "@posthog/ui/features/sessions/components/buildConversationItems";
import { SessionFooter } from "@posthog/ui/features/sessions/components/SessionFooter";
+import { SessionStartupRow } from "@posthog/ui/features/sessions/components/SessionStartupRow";
import { useConversationItems } from "@posthog/ui/features/sessions/hooks/useConversationItems";
import {
usePendingPermissionsForTask,
@@ -69,6 +70,11 @@ export function ChatThreadFooter({
return (
<div className="pt-1">
+ {taskId && task && (
+ <div className="-mx-2.5 pb-1">
+ <SessionStartupRow taskId={taskId} task={task} />
+ </div>
+ )}
<SessionFooter
task={task}
isPromptPending={isPromptPending}
diff --git a/products/desktop/packages/ui/src/features/sessions/components/session-update/StatusNotificationView.tsx b/products/desktop/packages/ui/src/features/sessions/components/session-update/StatusNotificationView.tsx
index 294f4ecaf1bb..7e3ebb074197 100644
--- a/products/desktop/packages/ui/src/features/sessions/components/session-update/StatusNotificationView.tsx
+++ b/products/desktop/packages/ui/src/features/sessions/components/session-update/StatusNotificationView.tsx
@@ -186,6 +186,14 @@ export function StatusNotificationView({
);
}
+ if (status === "agent_started") {
+ return (
+ <ChatMarker variant="separator">
+ <ChatMarkerContent>Agent started</ChatMarkerContent>
+ </ChatMarker>
+ );
+ }
+
if (status === "clearing") {
if (isComplete) {
return null;
diff --git a/products/desktop/packages/ui/src/features/task-detail/components/TaskLogsPanel.tsx b/products/desktop/packages/ui/src/features/task-detail/components/TaskLogsPanel.tsx
index 259ed44b763c..2373781435ab 100644
--- a/products/desktop/packages/ui/src/features/task-detail/components/TaskLogsPanel.tsx
+++ b/products/desktop/packages/ui/src/features/task-detail/components/TaskLogsPanel.tsx
@@ -7,7 +7,6 @@ import { ErrorBoundary } from "../../../primitives/ErrorBoundary";
import { useHostCapabilities } from "../../../shell/useHostCapabilities";
import { useFolders } from "../../folders/useFolders";
import { useDraftStore } from "../../message-editor/draftStore";
-import { ProvisioningView } from "../../provisioning/ProvisioningView";
import { useProvisioningStore } from "../../provisioning/store";
import { SessionView } from "../../sessions/components/SessionView";
import { useSessionCallbacks } from "../../sessions/hooks/useSessionCallbacks";
@@ -47,7 +46,6 @@ export function TaskLogsPanel({ taskId, task, hideInput }: TaskLogsPanelProps) {
const isSuspended = suspendedTaskIds.has(taskId);
const { restoreTask, isRestoring } = useRestoreTask();
- const isProvisioning = useProvisioningStore((s) => s.activeTasks.has(taskId));
const provisioningError = useProvisioningStore((s) => s.errors[taskId]);
const clearProvisioning = useProvisioningStore((s) => s.clear);
@@ -113,10 +111,6 @@ export function TaskLogsPanel({ taskId, task, hideInput }: TaskLogsPanelProps) {
await restoreTask(taskId);
}, [taskId, restoreTask]);
- if (isProvisioning) {
- return <ProvisioningView taskId={taskId} />;
- }
-
// Worktree provisioning failed but the task was kept. Offer to retry setup
// (worktree mode) on the existing task. Takes priority over the folder-picker
// branch below, whose !hasDirectoryMapping gate wouldn't fire here since the
diff --git a/products/desktop/packages/ui/src/styles/globals.css b/products/desktop/packages/ui/src/styles/globals.css
index 2b153d2ff5a1..b196128415bd 100644
--- a/products/desktop/packages/ui/src/styles/globals.css
+++ b/products/desktop/packages/ui/src/styles/globals.css
@@ -395,21 +395,6 @@ body:has(.rt-DialogOverlay[data-state="open"]) {
--ph-yellow: #f8be2a;
}
-/* Zen hedgehog float animation for auth/onboarding screens */
-@keyframes zen-float {
- 0%,
- 100% {
- transform: translateY(0px);
- }
- 50% {
- transform: translateY(-14px);
- }
-}
-
-.zen-float {
- animation: zen-float 3.5s ease-in-out infinite;
-}
-
/* Animated logo: one 2.4s timeline. The spines hop in a wave (AnimatedLogo.tsx
staggers their delays), and the eyelid (a head-colored disc over the eye
hole) closes as the wave lands on the head, so the blink keyframes sit just