: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
feat(tasks): add a comments panel to the web artifacts tab (#110451)
Shy Alter3d69600a8a7a
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsxindex f5eb21e00ed0..0ce6087b1463 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/TaskRunArtifacts.stories.tsx@@ -461,15 +461,16 @@ function StoryPage({fileName,versionId,edit,+ commentsOpen = false,}: {tab?: TaskRunTabfileName?: stringversionId?: stringedit?: StoryEdit+ commentsOpen?: boolean}): JSX.Element {- const { setActiveTab, selectArtifact, selectVersion, startEditing, setEditDraft, saveEdit } = useActions(- taskRunArtifactsLogic({ taskId: TASK_ID })- )+ const { setActiveTab, selectArtifact, selectVersion, startEditing, setEditDraft, saveEdit, setCommentsOpen } =+ useActions(taskRunArtifactsLogic({ taskId: TASK_ID }))const { selectedText, isEditing } = useValues(taskRunArtifactsLogic({ taskId: TASK_ID }))useEffect(() => {if (fileName) {@@ -479,7 +480,8 @@ function StoryPage({selectVersion(versionId)}setActiveTab(tab)- }, [tab, fileName, versionId, setActiveTab, selectArtifact, selectVersion])+ setCommentsOpen(commentsOpen)+ }, [tab, fileName, versionId, commentsOpen, setActiveTab, selectArtifact, selectVersion, setCommentsOpen])const textLoaded = typeof selectedText?.text === 'string'useEffect(() => {if (!edit || !textLoaded || isEditing) {@@ -691,3 +693,156 @@ export const ResumedTask: Story = {parameters: { msw: { mocks: taskMocks(ARTIFACTS, { resumed: true }) } },render: () => <StoryPage fileName={REPORT_FILE_NAME} />,}++const REVIEWER = {+ id: 2,+ uuid: 'user-uuid-2',+ distinct_id: 'user-2',+ first_name: 'Jamie',+ last_name: 'Rivera',+ email: '[email protected]',+}+const ANALYST = {+ id: 3,+ uuid: 'user-uuid-3',+ distinct_id: 'user-3',+ first_name: 'Priya',+ last_name: 'Shah',+ email: '[email protected]',+}++function artifactComment(+ id: string,+ itemId: string,+ createdBy: typeof REVIEWER,+ content: string,+ createdAt: string,+ itemContext: Record<string, unknown>,+ sourceComment: string | null = null+): Record<string, unknown> {+ return {+ id,+ created_by: createdBy,+ completed_by: null,+ slack_thread: null,+ version: 0,+ scope: 'task_artifact',+ item_id: itemId,+ item_context: { taskId: TASK_ID, ...itemContext },+ content,+ created_at: createdAt,+ completed_at: null,+ source_comment: sourceComment,+ deleted: false,+ }+}++// The stored offsets are made up, so the highlight has to find its quote by text, as a Desktop comment does.+const QUOTE = 'The start trial button now sits below the fold'+const ARTIFACT_COMMENTS = [+ artifactComment(+ 'comment-quote',+ 'artifact-report',+ REVIEWER,+ 'Which screen sizes did you check?',+ '2026-09-28T18:22:00Z',+ {+ anchor: { kind: 'text', quote: QUOTE, prefix: '', suffix: '', start: 0, end: QUOTE.length },+ }+ ),+ artifactComment(+ 'comment-quote-reply',+ 'artifact-report',+ ANALYST,+ 'Every laptop size in the funnel. 1366 × 768 has the most people.',+ '2026-09-28T18:24:00Z',+ {},+ 'comment-quote'+ ),+ artifactComment(+ 'comment-document',+ 'artifact-report',+ ANALYST,+ 'Can we share this with the growth team on Monday?',+ '2026-09-28T18:25:00Z',+ {+ anchor: { kind: 'document' },+ }+ ),+ artifactComment(+ 'comment-resolved',+ 'artifact-report',+ REVIEWER,+ 'Add the week of Sep 7 to the table.',+ '2026-09-28T18:20:00Z',+ { anchor: { kind: 'document' } }+ ),+ artifactComment(+ 'comment-resolved-state',+ 'artifact-report',+ ANALYST,+ 'Resolved this thread',+ '2026-09-28T18:21:00Z',+ { anchor: { kind: 'document' }, threadState: 'resolved' },+ 'comment-resolved'+ ),+ artifactComment(+ 'comment-pin-1',+ 'artifact-chart',+ REVIEWER,+ 'This bar looks too tall next to the others.',+ '2026-09-28T18:23:00Z',+ {+ anchor: { kind: 'region', x: 0.21, y: 0.2, width: 0.035, height: 0.035 },+ }+ ),+ artifactComment(+ 'comment-pin-2',+ 'artifact-chart',+ ANALYST,+ 'Label the drop here so people see it at once.',+ '2026-09-28T18:26:00Z',+ {+ anchor: { kind: 'region', x: 0.44, y: 0.56, width: 0.035, height: 0.035 },+ }+ ),+]++function commentMocks(): ReturnType<typeof taskMocks> {+ const mocks = taskMocks(ARTIFACTS)+ // New comments are kept for the story's lifetime, so a comment made in the story shows in the list.+ const comments = [...ARTIFACT_COMMENTS]+ return {+ get: {+ ...mocks.get,+ '/api/projects/:team_id/comments/': ({ request }: { request: Request }) => {+ const itemId = new URL(request.url).searchParams.get('item_id')+ return [200, { results: comments.filter((comment) => comment.item_id === itemId), next: null }]+ },+ },+ post: {+ ...mocks.post,+ '/api/projects/:team_id/comments/': async ({ request }: { request: Request }) => {+ const body = (await request.json()) as Record<string, unknown>+ const saved = {+ ...artifactComment(+ `comment-new-${comments.length}`,+ String(body.item_id),+ REVIEWER,+ String(body.content),+ '2026-09-28T18:30:00Z',+ {}+ ),+ ...body,+ }+ comments.push(saved)+ return [201, saved]+ },+ },+ }+}++export const MarkdownComments: Story = {+ parameters: { msw: { mocks: commentMocks() } },+ render: () => <StoryPage fileName={REPORT_FILE_NAME} commentsOpen />,+}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentActions.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentActions.tsxnew file mode 100644index 000000000000..61a28e07fe5e--- /dev/null+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentActions.tsx@@ -0,0 +1,40 @@+import { useActions, useValues } from 'kea'++import { IconComment } from '@posthog/icons'+import { Button, Text, Tooltip, TooltipContent, TooltipTrigger, cn } from '@posthog/quill-primitives'++import { TaskArtifactCommentsLogicProps, taskArtifactCommentsLogic } from '../taskArtifactCommentsLogic'+import { taskRunArtifactsLogic } from '../taskRunArtifactsLogic'++/** The toolbar control for comments: show or hide the panel. */+export function ArtifactCommentActions({ logicProps }: { logicProps: TaskArtifactCommentsLogicProps }): JSX.Element {+ const { openCount } = useValues(taskArtifactCommentsLogic(logicProps))+ const { commentsOpen } = useValues(taskRunArtifactsLogic({ taskId: logicProps.taskId }))+ const { setCommentsOpen } = useActions(taskRunArtifactsLogic({ taskId: logicProps.taskId }))+ const commentsLabel = commentsOpen ? 'Hide comments' : 'Show comments'+ return (+ <Tooltip>+ <TooltipTrigger+ delay={0}+ render={+ // Toggle cannot hold a ref, and the tooltip needs one to anchor, so this is a pressed Button.+ <Button+ aria-label={openCount > 0 ? `${commentsLabel}, ${openCount} open` : commentsLabel}+ aria-pressed={commentsOpen}+ className={cn(commentsOpen && 'bg-fill-selected')}+ onClick={() => setCommentsOpen(!commentsOpen)}+ data-attr="task-artifact-comments-toggle"+ />+ }+ >+ <IconComment />+ {openCount > 0 && (+ <Text size="xs" render={<span />} className="tabular-nums">+ {openCount}+ </Text>+ )}+ </TooltipTrigger>+ <TooltipContent>{commentsLabel}</TooltipContent>+ </Tooltip>+ )+}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentComposer.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentComposer.tsxnew file mode 100644index 000000000000..d252fb6e3e32--- /dev/null+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentComposer.tsx@@ -0,0 +1,112 @@+import { ChangeEvent, KeyboardEvent } from 'react'++import { Button, Kbd, KbdGroup, Text, Textarea } from '@posthog/quill-primitives'++import { isMac } from 'lib/utils/dom'++/** A comment box with a send button. Cmd+Enter or Ctrl+Enter sends, and Escape cancels. */+export function ArtifactCommentComposer({+ value,+ onChange,+ onSubmit,+ onCancel,+ saving,+ busy = false,+ label,+ placeholder,+ submitLabel = 'Comment',+ quote,+ autoFocus = false,+ rows = 2,+ dataAttr,+}: {+ value: string+ onChange: (value: string) => void+ onSubmit: () => void+ onCancel?: () => void+ /** This box's write is in flight. */+ saving: boolean+ /** Another write is in flight, so this one waits. */+ busy?: boolean+ label: string+ placeholder: string+ submitLabel?: string+ /** The selected text the comment is about. */+ quote?: string+ autoFocus?: boolean+ rows?: number+ dataAttr: string+}): JSX.Element {+ const submit = (): void => {+ if (value.trim() && !saving && !busy) {+ onSubmit()+ }+ }+ return (+ <form+ className="flex flex-col gap-2"+ onSubmit={(event) => {+ event.preventDefault()+ submit()+ }}+ >+ {quote && (+ <Text+ size="xs"+ variant="muted"+ render={<blockquote />}+ className="m-0 line-clamp-3 border-l-2 border-border pl-2 break-words whitespace-pre-wrap"+ >+ {quote}+ </Text>+ )}+ <Textarea+ autoFocus={autoFocus}+ aria-label={label}+ placeholder={placeholder}+ rows={rows}+ value={value}+ disabled={saving}+ onChange={(event: ChangeEvent<HTMLTextAreaElement>) => onChange(event.target.value)}+ onKeyDown={(event: KeyboardEvent<HTMLTextAreaElement>) => {+ if (event.key === 'Enter' && (event.metaKey || event.ctrlKey)) {+ event.preventDefault()+ submit()+ } else if (event.key === 'Escape' && onCancel) {+ event.preventDefault()+ onCancel()+ }+ }}+ data-attr={`${dataAttr}-input`}+ />+ <div className="flex items-center justify-end gap-2">+ <KbdGroup className="mr-auto text-muted-foreground" aria-label="Keyboard shortcut to send">+ <Kbd>{isMac() ? '⌘' : 'Ctrl'}</Kbd>+ <Kbd>Enter</Kbd>+ </KbdGroup>+ {onCancel && (+ <Button+ type="button"+ size="sm"+ variant="outline"+ disabled={saving}+ onClick={onCancel}+ data-attr={`${dataAttr}-cancel`}+ >+ Cancel+ </Button>+ )}+ <Button+ type="submit"+ size="sm"+ variant="primary"+ loading={saving}+ disabled={!value.trim() || busy}+ data-attr={`${dataAttr}-submit`}+ >+ {submitLabel}+ </Button>+ </div>+ </form>+ )+}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentEntry.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentEntry.tsxnew file mode 100644index 000000000000..94a2ee9b14f5--- /dev/null+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentEntry.tsx@@ -0,0 +1,56 @@+import { ReactNode } from 'react'++import {+ Avatar,+ AvatarFallback,+ ThreadItem,+ ThreadItemActions,+ ThreadItemAuthor,+ ThreadItemBody,+ ThreadItemContent,+ ThreadItemGutter,+ ThreadItemHeader,+ ThreadItemTimestamp,+} from '@posthog/quill-primitives'++import { dayjs } from 'lib/dayjs'+import { fullNameOrEmail } from 'lib/utils/strings'++import type { CommentApi } from 'products/platform_features/frontend/generated/api.schemas'+import { TaskUserAvatar } from 'products/tasks/frontend/spaces/TaskUserAvatar'++/** One comment in a thread: who wrote it, when, and what it says. `actions` show on hover and focus. */+export function ArtifactCommentEntry({ comment, actions }: { comment: CommentApi; actions?: ReactNode }): JSX.Element {+ const name = comment.created_by ? fullNameOrEmail(comment.created_by) : 'Deleted user'+ return (+ <ThreadItem>+ {/* The narrow panel has no continuation timestamps, so the gutter only needs room for the avatar. */}+ <ThreadItemGutter className="w-5">+ {comment.created_by ? (+ <TaskUserAvatar+ user={{+ uuid: comment.created_by.uuid,+ email: comment.created_by.email,+ first_name: comment.created_by.first_name ?? '',+ last_name: comment.created_by.last_name ?? '',+ }}+ />+ ) : (+ <Avatar size="xs">+ <AvatarFallback>?</AvatarFallback>+ </Avatar>+ )}+ </ThreadItemGutter>+ <ThreadItemContent>+ <ThreadItemHeader>+ <ThreadItemAuthor className="truncate">{name}</ThreadItemAuthor>+ <ThreadItemTimestamp dateTime={comment.created_at} title={dayjs(comment.created_at).format('LLL')}>+ {dayjs(comment.created_at).fromNow()}+ </ThreadItemTimestamp>+ </ThreadItemHeader>+ <ThreadItemBody className="break-words whitespace-pre-wrap">{comment.content}</ThreadItemBody>+ </ThreadItemContent>+ {actions && <ThreadItemActions aria-label="Comment actions">{actions}</ThreadItemActions>}+ </ThreadItem>+ )+}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentThreadCard.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentThreadCard.tsxnew file mode 100644index 000000000000..5f25931448b3--- /dev/null+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentThreadCard.tsx@@ -0,0 +1,133 @@+import { useActions, useValues } from 'kea'+import { useEffect, useRef } from 'react'++import { IconCheck, IconPin, IconRefresh } from '@posthog/icons'+import { Badge, Button, Text, ThreadItemAction, ThreadItemGroup, cn } from '@posthog/quill-primitives'++import { ArtifactCommentThread } from '../artifactComments'+import { TaskArtifactCommentsLogicProps, taskArtifactCommentsLogic } from '../taskArtifactCommentsLogic'+import { ArtifactCommentComposer } from './ArtifactCommentComposer'+import { ArtifactCommentEntry } from './ArtifactCommentEntry'++/** One comment thread: what it is about, its comments, and a reply box. */+export function ArtifactCommentThreadCard({+ logicProps,+ thread,+}: {+ logicProps: TaskArtifactCommentsLogicProps+ thread: ArtifactCommentThread+}): JSX.Element {+ const { activeThreadId, writing, drafts } = useValues(taskArtifactCommentsLogic(logicProps))+ const { activateThread, setThreadResolved, replyToThread, setDraft } = useActions(+ taskArtifactCommentsLogic(logicProps)+ )+ const ref = useRef<HTMLElement>(null)+ const rootId = thread.root.id+ const active = activeThreadId === rootId+ const { anchor } = thread++ // A click on a highlight or a pin in the preview brings its thread into view.+ useEffect(() => {+ if (active) {+ ref.current?.scrollIntoView({ block: 'nearest', behavior: 'smooth' })+ }+ }, [active])++ const resolveAction = (+ <ThreadItemAction+ label={thread.resolved ? 'Reopen thread' : 'Resolve thread'}+ variant="default"+ loading={writing === rootId}+ disabled={!!writing && writing !== rootId}+ onClick={() => setThreadResolved(rootId, !thread.resolved)}+ data-attr={thread.resolved ? 'task-artifact-comment-reopen' : 'task-artifact-comment-resolve'}+ >+ {thread.resolved ? <IconRefresh /> : <IconCheck />}+ </ThreadItemAction>+ )+ const anchorLabel =+ anchor?.kind === 'text'+ ? `Comments on "${anchor.quote}"`+ : thread.pinNumber+ ? `Comments on pin ${thread.pinNumber}`+ : 'Comments on this file'++ return (+ <section+ ref={ref}+ aria-label={anchorLabel}+ data-selected={active || undefined}+ className={cn('flex flex-col gap-1 rounded-md py-2', active && 'bg-fill-selected')}+ data-attr="task-artifact-comment-thread"+ >+ {(anchor?.kind === 'text' || thread.pinNumber || thread.resolved) && (+ <div className="flex min-w-0 flex-wrap items-center gap-1 px-2">+ {anchor?.kind === 'text' && (+ <button+ type="button"+ className="w-full min-w-0 cursor-pointer border-l-2 border-warning py-0.5 pl-2 text-left"+ onClick={() => activateThread(active ? null : rootId)}+ aria-pressed={active}+ data-attr="task-artifact-comment-thread-quote"+ >+ <Text size="xs" variant="muted" render={<span />} className="line-clamp-2 italic">+ {anchor.quote}+ </Text>+ </button>+ )}+ {thread.pinNumber && (+ <button+ type="button"+ className="cursor-pointer rounded-sm"+ onClick={() => activateThread(active ? null : rootId)}+ aria-pressed={active}+ data-attr="task-artifact-comment-thread-pin"+ >+ <Badge variant="info">+ <IconPin />+ {`Pin ${thread.pinNumber}`}+ </Badge>+ </button>+ )}+ {thread.resolved && <Badge variant="completed">Resolved</Badge>}+ </div>+ )}+ <ThreadItemGroup>+ <ArtifactCommentEntry comment={thread.root} actions={resolveAction} />+ {thread.replies.map((reply) => (+ <ArtifactCommentEntry key={reply.id} comment={reply} />+ ))}+ </ThreadItemGroup>+ {/* Like Desktop, the reply box opens on the picked thread, so a long list stays short. */}+ {/* pl-9 lines the reply controls up with the comment text, past the avatar gutter. */}+ {!thread.resolved && !active && !drafts[rootId] && (+ <div className="pr-2 pl-9">+ <Button+ size="xs"+ variant="outline"+ onClick={() => activateThread(rootId)}+ data-attr="task-artifact-comment-reply-open"+ >+ Reply+ </Button>+ </div>+ )}+ {!thread.resolved && (active || !!drafts[rootId]) && (+ <div className="pr-2 pl-9">+ <ArtifactCommentComposer+ value={drafts[rootId] ?? ''}+ onChange={(value) => setDraft(rootId, value)}+ onSubmit={() => replyToThread(rootId)}+ saving={writing === rootId}+ busy={!!writing && writing !== rootId}+ label="Reply"+ placeholder="Reply"+ submitLabel="Reply"+ rows={1}+ dataAttr="task-artifact-comment-reply"+ />+ </div>+ )}+ </section>+ )+}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentsPanel.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentsPanel.tsxnew file mode 100644index 000000000000..c204110891a0--- /dev/null+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/ArtifactCommentsPanel.tsx@@ -0,0 +1,161 @@+import { useActions, useValues } from 'kea'+import { Fragment } from 'react'++import { IconComment, IconWarning, IconX } from '@posthog/icons'+import {+ Button,+ Empty,+ EmptyContent,+ EmptyDescription,+ EmptyHeader,+ EmptyMedia,+ EmptyTitle,+ Label,+ Separator,+ Skeleton,+ SkeletonText,+ Switch,+ Text,+ Tooltip,+ TooltipContent,+ TooltipTrigger,+} from '@posthog/quill-primitives'++import { TaskArtifactCommentsLogicProps, taskArtifactCommentsLogic } from '../taskArtifactCommentsLogic'+import { taskRunArtifactsLogic } from '../taskRunArtifactsLogic'+import { ArtifactCommentComposer } from './ArtifactCommentComposer'+import { ArtifactCommentThreadCard } from './ArtifactCommentThreadCard'++const EMPTY_HINT = 'Comment on the whole file above.'++function ThreadList({ logicProps }: { logicProps: TaskArtifactCommentsLogicProps }): JSX.Element {+ const { visibleThreads, threads, commentsLoadFailed, commentsLoading } = useValues(+ taskArtifactCommentsLogic(logicProps)+ )+ const { loadComments } = useActions(taskArtifactCommentsLogic(logicProps))+ if (!threads) {+ if (commentsLoadFailed) {+ return (+ <Empty className="min-h-0 flex-1 border-0">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ <IconWarning />+ </EmptyMedia>+ <EmptyTitle>Comments didn't load</EmptyTitle>+ <EmptyDescription>Check your connection and try again.</EmptyDescription>+ </EmptyHeader>+ <EmptyContent>+ <Button+ variant="outline"+ loading={commentsLoading}+ onClick={() => loadComments()}+ data-attr="task-artifact-comments-retry"+ >+ Try again+ </Button>+ </EmptyContent>+ </Empty>+ )+ }+ return (+ <div className="flex flex-col gap-4 p-3">+ {[0, 1].map((index) => (+ <div key={index} className="flex gap-2">+ <Skeleton className="size-6 shrink-0 rounded-full" />+ <SkeletonText lines={2} className="flex-1" />+ </div>+ ))}+ </div>+ )+ }+ if (!visibleThreads || visibleThreads.length === 0) {+ return (+ <Empty className="min-h-0 flex-1 border-0">+ <EmptyHeader>+ <EmptyMedia variant="icon">+ <IconComment />+ </EmptyMedia>+ <EmptyTitle>{threads.length > 0 ? 'No open comments' : 'No comments yet'}</EmptyTitle>+ <EmptyDescription>{EMPTY_HINT}</EmptyDescription>+ </EmptyHeader>+ </Empty>+ )+ }+ return (+ <div className="flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto p-1">+ {visibleThreads.map((thread, index) => (+ <Fragment key={thread.root.id}>+ {index > 0 && <Separator />}+ <ArtifactCommentThreadCard logicProps={logicProps} thread={thread} />+ </Fragment>+ ))}+ </div>+ )+}++/** The comment threads on the open artifact version, with a box to comment on the whole file. */+export function ArtifactCommentsPanel({ logicProps }: { logicProps: TaskArtifactCommentsLogicProps }): JSX.Element {+ const { resolvedCount, showResolved, drafts, writing } = useValues(taskArtifactCommentsLogic(logicProps))+ const { setShowResolved, setDraft, submitComment } = useActions(taskArtifactCommentsLogic(logicProps))+ const { setCommentsOpen } = useActions(taskRunArtifactsLogic({ taskId: logicProps.taskId }))+ const switchId = `task-artifact-comments-show-resolved-${logicProps.artifactId}`+ return (+ <aside+ aria-label="Comments"+ // Below this width the panel covers the preview, so the preview keeps a readable width.+ className="absolute inset-y-0 right-0 z-20 flex w-full max-w-80 flex-col border-l border-border bg-background shadow-md @[64rem]/main-content:static @[64rem]/main-content:w-80 @[64rem]/main-content:shrink-0 @[64rem]/main-content:shadow-none"+ data-attr="task-artifact-comments-panel"+ >+ <div className="flex h-10 shrink-0 items-center gap-2 border-b border-border px-3">+ <Text size="xs" weight="medium" variant="muted" render={<span />}>+ Comments+ </Text>+ <div className="ml-auto flex items-center gap-2">+ {resolvedCount > 0 && (+ <>+ <Switch+ id={switchId}+ size="sm"+ checked={showResolved}+ onCheckedChange={(checked: boolean) => setShowResolved(checked)}+ data-attr="task-artifact-comments-show-resolved"+ />+ <Label htmlFor={switchId} className="text-xs">+ {`Show resolved (${resolvedCount})`}+ </Label>+ </>+ )}+ <Tooltip>+ <TooltipTrigger+ delay={0}+ render={+ <Button+ size="icon-sm"+ aria-label="Close comments"+ onClick={() => setCommentsOpen(false)}+ data-attr="task-artifact-comments-close"+ />+ }+ >+ <IconX />+ </TooltipTrigger>+ <TooltipContent>Close comments</TooltipContent>+ </Tooltip>+ </div>+ </div>+ <div className="shrink-0 border-b border-border p-2">+ <ArtifactCommentComposer+ value={drafts.document ?? ''}+ onChange={(value) => setDraft('document', value)}+ onSubmit={() => submitComment('document')}+ saving={writing === 'document'}+ busy={!!writing && writing !== 'document'}+ label="Comment on this file"+ placeholder="Comment on this file"+ dataAttr="task-artifact-comment-document"+ />+ </div>+ <ThreadList logicProps={logicProps} />+ </aside>+ )+}diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsxindex 9992d8e744a3..4bb616dd1011 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx+++ b/products/posthog_ai/frontend/scenes/TaskTracker/components/TaskRunArtifacts.tsx@@ -72,9 +72,12 @@ import { useKeyboardHotkeys } from 'lib/hooks/useKeyboardHotkeys'import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'import { LinkPrimitive } from 'lib/lemon-ui/Link'+import { isCommentableArtifact } from '../artifactComments'import { withStrictCsp } from '../artifactHtml'+import { TaskArtifactCommentsLogicProps } from '../taskArtifactCommentsLogic'import {ArtifactFile,+ ArtifactPreviewKind,RunArtifact,TaskRunTab,artifactPreviewKind,@@ -89,6 +92,8 @@ import {postHogObjectRef,} from '../taskRunArtifacts'import { FullPageSource, artifactDownloadUrl, taskRunArtifactsLogic } from '../taskRunArtifactsLogic'+import { ArtifactCommentActions } from './ArtifactCommentActions'+import { ArtifactCommentsPanel } from './ArtifactCommentsPanel'import { ArtifactEditor } from './ArtifactEditor'import { ArtifactEditToolbar } from './ArtifactEditToolbar'import { ArtifactIcon } from './ArtifactIcon'@@ -109,6 +114,15 @@ function hasFullPageShortcut(artifact: RunArtifact): boolean {return postHogObjectRef(artifact)?.objectKind !== 'replay'}+/** The comments logic for an artifact version, or null when the artifact takes no comments. */+function commentLogicProps(+ taskId: string,+ artifact: RunArtifact | null,+ kind: ArtifactPreviewKind | null+): TaskArtifactCommentsLogicProps | null {+ return isCommentableArtifact(artifact) && kind ? { taskId, artifactId: artifact.id, kind } : null+}+/** Size for a file, the object kind for a cited PostHog object, where the agent sent a living document. */function artifactDetail(artifact: RunArtifact): string {if (artifact.living) {@@ -718,6 +732,7 @@ function ArtifactToolbar({taskRunArtifactsLogic({ taskId }))const kind = artifactPreviewKind(artifact)+ const comments = commentLogicProps(taskId, artifact, kind)const objectRef = postHogObjectRef(artifact)const objectLink =objectRef && currentProjectId !== null@@ -790,6 +805,7 @@ function ArtifactToolbar({<IconPencil className="size-4" /></IconAction>)}+ {comments && <ArtifactCommentActions logicProps={comments} />}{isTextPreview(kind) && <CopySourceAction text={selectedText?.text ?? null} />}{/* The file list replaces these once there is room for it. */}<div className="flex items-center gap-1 @[52rem]/main-content:hidden">@@ -881,6 +897,21 @@ function PreviewSurface({ taskId, mode }: { taskId: string; mode: PreviewMode }))}+/** The preview, with the comments panel beside it when it is open. */+function PreviewBody({ taskId, mode }: { taskId: string; mode: PreviewMode }): JSX.Element {+ const { selectedArtifact, selectedKind, commentsOpen } = useValues(taskRunArtifactsLogic({ taskId }))+ const comments = commentLogicProps(taskId, selectedArtifact, selectedKind)+ return (+ <div className="relative flex min-h-0 flex-1">+ <div className="flex min-w-0 flex-1 flex-col">+ <OlderVersionNotice taskId={taskId} />+ <PreviewSurface taskId={taskId} mode={mode} />+ </div>+ {comments && commentsOpen && <ArtifactCommentsPanel key={comments.artifactId} logicProps={comments} />}+ </div>+ )+}+function ArtifactsWorkspace({ taskId }: { taskId: string }): JSX.Element {const { files, selectedArtifact, isEditing } = useValues(taskRunArtifactsLogic({ taskId }))const { setActiveTab, reportFullPageOpened } = useActions(taskRunArtifactsLogic({ taskId }))@@ -959,12 +990,7 @@ function ArtifactsWorkspace({ taskId }: { taskId: string }): JSX.Element {<ArtifactNav taskId={taskId} /><section className="flex min-w-0 flex-1 flex-col">{toolbar}- {!expanded && (- <>- <OlderVersionNotice taskId={taskId} />- <PreviewSurface taskId={taskId} mode={mode} />- </>- )}+ {!expanded && <PreviewBody taskId={taskId} mode={mode} />}</section><Dialog open={expanded} onOpenChange={setExpanded}>{/* Full page covers the whole window, so the dialog drops its inset, corners and shadow. */}@@ -976,8 +1002,7 @@ function ArtifactsWorkspace({ taskId }: { taskId: string }): JSX.Element {{/* The toolbar hides parts by container width, so the dialog gets its own container. */}<div className="@container/main-content flex min-h-0 flex-1 flex-col">{toolbar}- <OlderVersionNotice taskId={taskId} />- <PreviewSurface taskId={taskId} mode={mode} />+ <PreviewBody taskId={taskId} mode={mode} /></div></DialogContent></Dialog>diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskArtifactCommentsLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskArtifactCommentsLogic.tsindex 1d303a39f94d..36b80c8753a7 100644--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskArtifactCommentsLogic.ts+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskArtifactCommentsLogic.ts@@ -273,11 +273,11 @@ export const taskArtifactCommentsLogic = kea<taskArtifactCommentsLogicType>([(comments: CommentApi[] | null): ArtifactCommentThread[] | null =>comments ? buildArtifactCommentThreads(comments) : null,],- /** Newest thread first. Resolved threads show only when asked for. */+ /** Oldest thread first, like PostHog Desktop, so pins list in number order. Resolved threads show only when asked for. */visibleThreads: [(s) => [s.threads, s.showResolved],(threads: ArtifactCommentThread[] | null, showResolved: boolean): ArtifactCommentThread[] | null =>- threads ? threads.filter((thread) => showResolved || !thread.resolved).reverse() : null,+ threads ? threads.filter((thread) => showResolved || !thread.resolved) : null,],openCount: [(s) => [s.threads],