Skip to content

feat: add comments to task artifacts - #4067

Draft
puemos wants to merge 2 commits into
mainfrom
posthog-code/artifact-comments
Draft

feat: add comments to task artifacts#4067
puemos wants to merge 2 commits into
mainfrom
posthog-code/artifact-comments

Conversation

@puemos

@puemos puemos commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Migrated from #3970 — this is the artifact-comments work recreated on a posthog-code/ branch and squashed into one signed commit for the PostHog Code workflow. The original branch was 46 commits behind main; this is rebased onto current main. Original PR: #3970.

Summary

Adds Google Docs/Figma-style commenting to task artifact tabs:

  • inline text comments on Markdown and HTML
  • yellow circular comment pins on images
  • document-level comments for every artifact
  • sidebar threads with replies, mentions, Open/Resolved filtering, resolve/reopen, and anchor navigation
  • comment counts in artifact rows

Resolved threads remain available under the Resolved filter but are not rendered on the artifact: no text highlight, click target, or image pin.

Architecture

  • Reuses PostHog's generic Django Comment API with scope=task_artifact; no new persistence model.
  • Reuses the generated OpenAPI client for paginated reads and writes.
  • Reuses Thread's MentionComposer/MentionText and the API's existing mentions field.
  • Reuses Quill for cards, controls, filters, badges, empty states, avatars, and comment inputs.
  • Uses one small Zod-validated anchor union: text quote+position, normalized image region, or document.
  • Stores only { anchor, threadState? } in item_context; artifact identity remains the existing item_id.
  • Groups roots/replies and calculates resolved state once, shared by the sidebar and renderers.
  • Uses PAT-compatible thread-state replies for resolve/reopen because the generic /complete action rejects PAT access.

HTML artifacts

Inspired by Peek's open-source annotation bridge:

  • render original authored HTML in an opaque-origin iframe
  • inject a small selection/highlight bridge
  • exchange validated anchors over postMessage
  • preserve authored CSS/resources while keeping allow-same-origin disabled

Images

The existing ZoomableImage primitive now accepts an optional overlay. Pins and placement transform with the image automatically, without geometry polling or format-specific zoom logic.

Validation

  • API, core, and UI typechecks
  • 36 focused tests
  • Biome
  • host-boundary check
  • React Doctor: zero errors

Created with PostHog Code

Google Docs/Figma-style commenting on task artifact tabs: inline text
comments on Markdown/HTML, circular comment pins on images,
document-level comments, and a sidebar of threads with replies,
mentions, Open/Resolved filtering, resolve/reopen, and anchor
navigation, plus comment counts in artifact rows.

Reuses the generic Django Comment API (scope=task_artifact), the
generated OpenAPI client, Thread's mention composer, and Quill
primitives; anchors are a small Zod-validated union stored in
item_context. HTML artifacts render in an opaque-origin iframe with a
selection/highlight bridge exchanged over postMessage; images gain an
optional overlay on the existing ZoomableImage primitive.

Migrated from #3970 (feat/artifact-comments) onto current main and
squashed for the signed-commit workflow.

Generated-By: PostHog Code
Task-Id: 0331ac58-0a1c-4b4e-b884-2ff7d8e71986
@trunk-io

trunk-io Bot commented Aug 1, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

React Doctor found 9 issues in 2 files · 9 warnings.

9 warnings

src/features/canvas/components/TaskCommentsList.tsx

src/features/sessions/components/ArtifactPreview.tsx

Reviewed by React Doctor for commit cfdf89b.

Three blocking react-doctor findings in the PR's own files:

- ActivityPanel and TaskCommentsList adjusted state inside an effect on a
  prop/store change (no-adjust-state-on-prop-change); moved both to
  render-time adjustment with the existing prev-value refs, so no stale
  tab/filter commits before the switch.
- The comment-focus pulse created a setTimeout in an effect without
  returning cleanup (effect-needs-cleanup); the timer now lives in its
  own effect keyed on pulseThreadId and is cleared on the next pulse or
  unmount, dropping the stray ref.

Behavior unchanged; ActivityPanel and TaskCommentsList suites pass.

Generated-By: PostHog Code
Task-Id: 0331ac58-0a1c-4b4e-b884-2ff7d8e71986
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant