Skip to content

Commit 79fb7e2

Browse files
authored
Adopt structured agent thread rows (author_kind/event/payload)
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
1 parent c2880a6 commit 79fb7e2

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

packages/shared/src/domain-types.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ export interface TaskChannel {
8686
export interface TaskThreadMessage {
8787
id: string;
8888
task: string;
89+
/** Who authored the row; agent rows are server-emitted announcements. Absent on older backends. */
90+
author_kind?: "human" | "system" | "agent";
91+
/** Stable event key for non-human rows (e.g. "canvas_created", "turn_complete"). */
92+
event?: string;
93+
/** Structured event payload; turn_complete carries `{ run_id }` so a client rendering a run's live agent turns can dedupe the durable row. */
94+
payload?: Record<string, unknown>;
8995
content: string;
9096
created_at: string;
9197
author?: UserBasic | null;

packages/ui/src/features/canvas/components/ThreadPanel.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ function ThreadMessageRow({
6565
}) {
6666
const forwarded = !!message.forwarded_to_agent_at;
6767
const showMenu = (isTaskAuthor && !forwarded) || isOwnMessage;
68-
// Authorless messages are posted by the backend on the agent's behalf
69-
// (canvas created, turn complete).
70-
const isAgent = !message.author;
68+
// Agent rows are server-emitted announcements (canvas created, turn complete).
69+
// author_kind is authoritative; authorless is the pre-author_kind fallback.
70+
const isAgent =
71+
message.author_kind === "agent" ||
72+
(!message.author_kind && !message.author);
7173

7274
return (
7375
<div className="group flex gap-2 rounded-md px-2 py-1.5 hover:bg-fill-secondary">

0 commit comments

Comments
 (0)