Skip to content

Render agent thread updates: markdown links and agent-authored messages#3380

Merged
trunk-io[bot] merged 5 commits into
mainfrom
posthog-code/canvas-thread-auto-posts
Jul 17, 2026
Merged

Render agent thread updates: markdown links and agent-authored messages#3380
trunk-io[bot] merged 5 commits into
mainfrom
posthog-code/canvas-thread-auto-posts

Conversation

@k11kirky

@k11kirky k11kirky commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Problem

The backend now posts durable agent updates into task threads, including canvas creation links and turn-complete announcements. The client rendered markdown links as raw text and displayed agent-authored rows as "Unknown".

Why: Thread updates should remain readable and clearly attributed when they are delivered without a human author.

Changes

  • Parse markdown-style named links alongside bare URLs in thread messages.
  • Type structured agent thread fields and render agent announcements with the Agent identity and robot avatar.
  • Keep human-only message actions off agent-authored rows.

How did you test this?

  • pnpm exec biome check --write packages/shared/src/domain-types.ts packages/ui/src/features/canvas/components/ThreadPanel.tsx packages/ui/src/features/canvas/components/ThreadPanel.test.tsx packages/ui/src/features/canvas/utils/linkify.ts packages/ui/src/features/canvas/utils/linkify.test.ts
  • pnpm --filter @posthog/shared typecheck
  • pnpm --filter @posthog/ui typecheck
  • cd packages/ui && pnpm exec vitest run src/features/canvas/components/ThreadPanel.test.tsx src/features/canvas/utils/linkify.test.ts

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Created with PostHog Code

@trunk-io

trunk-io Bot commented Jul 13, 2026

Copy link
Copy Markdown

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 90c7a61.

@k11kirky k11kirky changed the title Auto-post canvas creation and turn-complete updates into the task thread Render agent thread updates: markdown links and agent-authored messages Jul 13, 2026
k11kirky added 3 commits July 17, 2026 16:02
When a canvas-mode generation finishes, the client that started it now posts into the task's thread: a one-time "[Canvas name](link) has been created" comment when the run built a new canvas, plus a turn-complete note @-mentioning the task creator. Thread rendering learns markdown-style [label](url) links so the created comment reads as a named link.

Generated-By: PostHog Code
Task-Id: ea09a661-1f6d-4bd8-a046-24be60909d28
The canvas-created and turn-complete thread posts now come from the PostHog backend (PostHog/posthog#70371) so they land even when no client is open. This PR keeps only the rendering side: markdown [label](url) links in thread messages, and authorless messages shown as "Agent" with a robot avatar.

Generated-By: PostHog Code
Task-Id: ea09a661-1f6d-4bd8-a046-24be60909d28
Types the new TaskThreadMessage fields from PostHog/posthog#70371 (stacked on #70320) and keys agent rendering on author_kind, keeping the authorless fallback for older backends. payload.run_id on turn_complete rows is the dedupe key for live session-derived agent turn views.

Generated-By: PostHog Code
Task-Id: ea09a661-1f6d-4bd8-a046-24be60909d28
@k11kirky
k11kirky force-pushed the posthog-code/canvas-thread-auto-posts branch from 79fb7e2 to 5ce84d0 Compare July 17, 2026 15:02
Render structured and legacy authorless agent announcements with the Agent identity in the Quill thread row, and keep message actions limited to human messages. Add regression coverage for the current component.

Generated-By: PostHog Code
Task-Id: 152cf34b-23c8-4e87-be9e-12d727e08edd
@k11kirky
k11kirky marked this pull request as ready for review July 17, 2026 15:10
@greptile-apps

greptile-apps Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "Adapt agent thread announcements to curr..." | Re-trigger Greptile

Comment thread packages/ui/src/features/canvas/components/ThreadPanel.tsx Outdated
Comment thread packages/ui/src/features/canvas/utils/linkify.ts
Treat structured author kinds as authoritative so system rows render as System and legacy authorless rows retain human behavior. Parse markdown links before mentions so labels containing @agent remain intact, with regression coverage for both review findings.

Generated-By: PostHog Code
Task-Id: 152cf34b-23c8-4e87-be9e-12d727e08edd
segments.push({
type: "link",
text: match[1] ?? "",
href: match[2] ?? "",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Deceptive external links

A collaborator can post [https://us.posthog.com](https://attacker.example) so the thread displays the trusted PostHog URL while clicking opens the attacker-controlled site. Restrict labeled-link rendering to server-authored announcements, or expose the destination host for human-authored messages.

@veria-ai

veria-ai Bot commented Jul 17, 2026

Copy link
Copy Markdown

PR overview

This pull request updates agent thread rendering to support markdown-style links and messages authored by agents in the canvas UI. The relevant changes are in the linkification logic used to display thread content.

There is one open security concern: human-authored thread content can render a trusted-looking link label while sending users to a different external destination. This creates a phishing/deception risk for collaborators viewing thread updates, though the impact is limited to users choosing to click the misleading link. No issues have been fixed or addressed yet.

Open issues (1)

Fixed/addressed: 0 · PR risk: 5/10

@k11kirky

Copy link
Copy Markdown
Contributor Author

/trunk merge

@trunk-io
trunk-io Bot merged commit 3d788e3 into main Jul 17, 2026
31 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/canvas-thread-auto-posts branch July 17, 2026 17:03
adboio added a commit that referenced this pull request Jul 20, 2026
#3380 landed on main after this branch was cut and already renders agent
thread rows (author_kind on TaskThreadMessage, robot avatar + "Agent" label,
no hover menu) inside ThreadMessageRow. Remove this branch's parallel copy:
the duplicated TaskThreadMessage fields the rebase glued in, the separate
AgentThreadRow component, and isAgentThreadMessage, whose only consumer was
that branch. Keep the TaskThreadMessageEvent union and point the existing
event field at it — the one piece #3380 didn't cover.

Generated-By: PostHog Code
Task-Id: a0f85df1-4a8f-4467-8051-e471b5e95009
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.

3 participants