: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(spaces): draw the optimistic kickoff in the feed's row style (#104298)
Shy Alterd7e8a47a14f6
diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.stories.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.stories.tsxindex 646024aee4cf..ad5fecf0ae78 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.stories.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.stories.tsx@@ -187,6 +187,13 @@ export const PendingKickoff: Story = {},};+export const PendingKickoffList: Story = {+ args: {+ ...PendingKickoff.args,+ rowStyle: "list",+ },+};+export const Loading: Story = {args: {tasks: [],diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.test.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.test.tsxindex 0a8514acf037..f1b6f7cc6117 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.test.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.test.tsx@@ -239,6 +239,35 @@ describe("ChannelFeedView", () => {expect(screen.getByText(task.title)).toBeInTheDocument();});+ // The kickoff has to lead the feed in the shape of the view around it. It+ // used to render as a card above the rows, whichever view was active, so the+ // list view showed one card sitting on top of a list.+ it.each([+ ["cards" as const, true],+ ["list" as const, false],+ ])("shows a pending kickoff first, in the %s shape", (rowStyle, isCard) => {+ const prompt = "Add a dark-mode toggle";+ const { container } = render(+ <Theme>+ <ChannelFeedView+ channelId="channel-1"+ tasks={[task]}+ pending={[{ id: "pending-1", prompt }]}+ rowStyle={rowStyle}+ isLoading={false}+ onOpenTask={vi.fn()}+ onOpenThread={vi.fn()}+ />+ </Theme>,+ );++ const feed = container.textContent ?? "";+ expect(feed).toContain(prompt);+ expect(feed.indexOf(prompt)).toBeLessThan(feed.indexOf(task.title));+ // Only the card puts a "New task" heading above the prompt.+ expect(screen.queryByText("New task") !== null).toBe(isCard);+ });+it("shows the kind's empty note, not the channel welcome, when a filter empties the feed", () => {render(<Theme>diff --git a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsx b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsxindex 9c078d1d47a6..6c53616cd2f6 100644--- a/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsx+++ b/products/desktop/packages/ui/src/features/canvas/components/ChannelFeedView.tsx@@ -1420,11 +1420,34 @@ const FeedLogRow = memo(function FeedLogRow({);});-// The optimistic kickoff row: the user's prompt as a "Starting…" card, shown-// at the top of the feed the moment they submit. Deliberately dumb — no-// per-task data hooks or polls (there's no task id to query yet); it's-// replaced by a real FeedRow as soon as the task is created.-function PendingFeedRow({ pending }: { pending: PendingKickoff }) {+// The optimistic kickoff row: the user's prompt as a "Starting…" entry at the+// top of the feed, shown the moment they submit. It takes the shape of the view+// around it, and it stays deliberately dumb, with no per-task data hooks or+// polls, because there is no task id to query yet. A real row replaces it as+// soon as the task is created.+function PendingFeedRow({+ prompt,+ listRow,+}: {+ prompt: string;+ listRow: boolean;+}) {+ if (listRow) {+ return (+ <div className="flex h-8 w-full items-center gap-2 rounded-md px-2 text-[13px]">+ <span className="flex size-3.5 shrink-0 items-center justify-center">+ <Spinner size="sm" aria-hidden="true" />+ </span>+ <span className="min-w-0 flex-1 truncate font-medium">{prompt}</span>+ <Badge variant="info">Starting…</Badge>+ {/* The avatar and the time of a real row have nothing to show yet, so+ the row holds their two columns open. This keeps the badge in the+ badge column, and it keeps the row still when the real row arrives. */}+ <span className="size-5 shrink-0" />+ <span className="w-8 shrink-0" />+ </div>+ );+ }return (<Card size="sm" className="my-1.5 w-full rounded-xl bg-(--gray-2) py-0"><CardContent className="flex flex-col px-4 pt-3.5 pb-3">@@ -1438,7 +1461,7 @@ function PendingFeedRow({ pending }: { pending: PendingKickoff }) {</Badge></div><div className="mt-1.5 text-(--gray-9) text-xs leading-normal">- <ExpandablePrompt lines={2}>{pending.prompt}</ExpandablePrompt>+ <ExpandablePrompt lines={2}>{prompt}</ExpandablePrompt></div></CardContent></Card>@@ -1722,7 +1745,7 @@ export function ChannelFeedView({[spaceItems],);- const entries = useMemo<readonly FeedEntry[]>(() => {+ const orderedEntries = useMemo<readonly FeedEntry[]>(() => {const merged = mergeFeedEntries(visibleTasks,systemMessages ?? [],@@ -1745,7 +1768,9 @@ export function ChannelFeedView({? entry.report.title: entry.kind === "pr"? (entry.pullRequest.title ?? entry.pullRequest.task.title)- : entry.message.text;+ : entry.kind === "pending"+ ? entry.prompt+ : entry.message.text;return [...kept].sort((a, b) =>sort === "alpha"? (title(a) ?? "").localeCompare(title(b) ?? "")@@ -1764,6 +1789,26 @@ export function ChannelFeedView({itemByKey,]);+ // A kickoff the user just submitted leads the list until its real card+ // arrives. It is prepended instead of sorted in, because the client clock and+ // the server clock can disagree, and an optimistic row must stay first under+ // every sort the user can pick.+ const entries = useMemo<readonly FeedEntry[]>(() => {+ if (pending.length === 0) return orderedEntries;+ const createdAt = new Date().toISOString();+ const kickoffs = pending+ .map(+ (kickoff): FeedEntry => ({+ kind: "pending",+ id: kickoff.id,+ createdAt,+ prompt: kickoff.prompt,+ }),+ )+ .reverse();+ return [...kickoffs, ...orderedEntries];+ }, [pending, orderedEntries]);+// The channel's dominant repo: on a single-repo channel every card would// repeat the same chip, so the repo chip only renders on tasks that target a// different repo than most of the channel.@@ -1964,18 +2009,7 @@ export function ChannelFeedView({const now = new Date();const rows: ReactNode[] = [];const shownEntries = entries.slice(0, visibleCount);- // Pending kickoffs land at the top, newest first, under a "Today" separator.let lastDayLabel: string | null = null;- if (pending.length > 0) {- lastDayLabel = "Today";- rows.push(- <DaySeparator key="separator-pending" label="Today" compact={listRows} />,- );- for (let i = pending.length - 1; i >= 0; i--) {- const p = pending[i];- rows.push(<PendingFeedRow key={p.id} pending={p} />);- }- }const activityIso = (entry: FeedEntry): string => {if (sort === "created") return entry.createdAt;if (entry.kind === "canvas") {@@ -2058,6 +2092,12 @@ export function ChannelFeedView({report={entry.report}onOpenReport={onOpenReport ?? (() => {})}/>+ ) : entry.kind === "pending" ? (+ <PendingFeedRow+ key={entry.id}+ prompt={entry.prompt}+ listRow={listRows}+ />) : (<SystemFeedRow key={entry.id} message={entry.message} />);diff --git a/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.ts b/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.tsindex 459c9c8c4057..53ffae410413 100644--- a/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.ts+++ b/products/desktop/packages/ui/src/features/canvas/components/channelFeedDisplay.ts@@ -36,7 +36,8 @@ export type FeedEntry =id: string;createdAt: string;message: ChannelFeedSystemMessage;- };+ }+ | { kind: "pending"; id: string; createdAt: string; prompt: string };/** Which entry kinds the feed shows. Sessions cover tasks and their system rows. */export type FeedKindFilter = "all" | "sessions" | "reports";@@ -54,7 +55,9 @@ export function feedEntryMatchesTypes(entry: FeedEntry,types: readonly SpaceActivityType[],): boolean {- if (entry.kind === "system") return types.includes("task");+ if (entry.kind === "system" || entry.kind === "pending") {+ return types.includes("task");+ }return types.includes(entry.kind);}diff --git a/products/desktop/packages/ui/src/features/feedback/FeedbackModal.test.tsx b/products/desktop/packages/ui/src/features/feedback/FeedbackModal.test.tsxindex 891ccbeea874..8a8b79e038b4 100644--- a/products/desktop/packages/ui/src/features/feedback/FeedbackModal.test.tsx+++ b/products/desktop/packages/ui/src/features/feedback/FeedbackModal.test.tsx@@ -106,7 +106,10 @@ describe("FeedbackModal", () => {expect(screen.getByLabelText("Feedback type")).toBe(selector);expect(selector).toHaveTextContent("General");await user.click(selector);- await user.click(screen.getByRole("option", { name: label }));+ // The select mounts its popup in a portal, so the option arrives a frame+ // after the click. `getByRole` does not retry, and a loaded CI runner loses+ // that race.+ await user.click(await screen.findByRole("option", { name: label }));await user.type(screen.getByPlaceholderText("What happened, and what did you expect?"),"Example feedback",