Skip to content

Commit ef4444b

Browse files
authored
refactor(channels): drop agent-row rendering superseded by #3380
#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
1 parent 03b212e commit ef4444b

4 files changed

Lines changed: 14 additions & 97 deletions

File tree

packages/core/src/canvas/threadTimeline.test.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import {
33
buildThreadTimeline,
44
deriveThreadAgentStatus,
55
hasAgentMention,
6-
isAgentThreadMessage,
76
normalizeAgentPromptText,
87
shouldSuspendThreadSession,
98
visibleThreadMessages,
@@ -170,18 +169,6 @@ describe("shouldSuspendThreadSession", () => {
170169
});
171170
});
172171

173-
describe("isAgentThreadMessage", () => {
174-
it.each([
175-
{ author_kind: "agent", expected: true },
176-
{ author_kind: "human", expected: false },
177-
{ author_kind: "system", expected: false },
178-
// Older payloads predate agent rows; absent means human.
179-
{ author_kind: undefined, expected: false },
180-
])("author_kind $author_kind → $expected", ({ author_kind, expected }) => {
181-
expect(isAgentThreadMessage({ author_kind })).toBe(expected);
182-
});
183-
});
184-
185172
describe("visibleThreadMessages", () => {
186173
const human = { id: "h", author_kind: "human" as const };
187174
const turn = (runId: string, id = `turn-${runId}`) => ({

packages/core/src/canvas/threadTimeline.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,6 @@ export function shouldSuspendThreadSession({
143143
return !isCloud && !hasRun && !hasSession;
144144
}
145145

146-
/**
147-
* Agent rows are authorless by design, so anything reading `author` alone sees
148-
* nobody and calls them "Unknown". `author_kind` is the only thing that says
149-
* the agent wrote it.
150-
*/
151-
export function isAgentThreadMessage(message: {
152-
author_kind?: string;
153-
}): boolean {
154-
return message.author_kind === "agent";
155-
}
156-
157146
/**
158147
* The durable thread messages worth rendering, given the run whose turns the
159148
* viewer is already watching stream.

packages/shared/src/domain-types.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,16 +126,12 @@ export interface TaskThreadMessage {
126126
/** Who authored the row; agent rows are server-emitted announcements. Absent on older backends. */
127127
author_kind?: "human" | "system" | "agent";
128128
/** Stable event key for non-human rows (e.g. "canvas_created", "turn_complete"). */
129-
event?: string;
129+
event?: TaskThreadMessageEvent | string;
130130
/** Structured event payload; turn_complete carries `{ run_id }` so a client rendering a run's live agent turns can dedupe the durable row. */
131131
payload?: Record<string, unknown>;
132132
content: string;
133133
created_at: string;
134134
author?: UserBasic | null;
135-
author_kind?: "human" | "system" | "agent";
136-
/** Empty for human messages. */
137-
event?: TaskThreadMessageEvent | string;
138-
payload?: Record<string, unknown>;
139135
forwarded_to_agent_at?: string | null;
140136
forwarded_by?: UserBasic | null;
141137
}

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

Lines changed: 13 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
buildThreadTimeline,
1212
deriveThreadAgentStatus,
1313
hasAgentMention,
14-
isAgentThreadMessage,
1514
normalizeAgentPromptText,
1615
shouldSuspendThreadSession,
1716
type ThreadAgentMessage,
@@ -187,50 +186,6 @@ export function ThreadMessageRow({
187186
);
188187
}
189188

190-
/**
191-
* A durable row the agent posted — its final turn, or a question it needs
192-
* answered. Authorless by design, so it names itself rather than resolving an
193-
* author (which would read as "Unknown").
194-
*
195-
* Renders `content` through MentionText, not markdown: the server writes the
196-
* body with a real mention token for the task creator, and markdown would spell
197-
* that token out instead of chipping it.
198-
*
199-
* No hover menu — there's nothing to forward to the agent (it *is* the agent),
200-
* and its rows aren't the reader's to delete.
201-
*/
202-
function AgentThreadRow({
203-
message,
204-
currentUserEmail,
205-
}: {
206-
message: TaskThreadMessage;
207-
currentUserEmail?: string | null;
208-
}) {
209-
return (
210-
<ThreadItem>
211-
<ThreadItemGutter>
212-
<Avatar size="lg" className="sticky top-2">
213-
<AvatarFallback>
214-
<RobotIcon size={14} />
215-
</AvatarFallback>
216-
</Avatar>
217-
</ThreadItemGutter>
218-
<ThreadItemContent>
219-
<ThreadItemHeader>
220-
<ThreadItemAuthor>Agent</ThreadItemAuthor>
221-
<ThreadTimestamp dateTime={message.created_at} />
222-
</ThreadItemHeader>
223-
<ThreadItemBody>
224-
<MentionText
225-
content={message.content}
226-
currentUserEmail={currentUserEmail}
227-
/>
228-
</ThreadItemBody>
229-
</ThreadItemContent>
230-
</ThreadItem>
231-
);
232-
}
233-
234189
function agentPrompts(items: ConversationItem[]): ThreadAgentMessage[] {
235190
const prompts: ThreadAgentMessage[] = [];
236191
for (const item of items) {
@@ -454,29 +409,19 @@ function ThreadTimeline({
454409
author={taskAuthor}
455410
/>
456411
) : row.kind === "human" ? (
457-
// A durable row the agent wrote — authorless, so the human row would
458-
// credit it to "Unknown".
459-
isAgentThreadMessage(row.message.value ?? {}) ? (
460-
<AgentThreadRow
461-
key={row.message.id}
462-
message={row.message.value as TaskThreadMessage}
463-
currentUserEmail={currentUserEmail}
464-
/>
465-
) : (
466-
<ThreadMessageRow
467-
key={row.message.id}
468-
message={row.message.value as TaskThreadMessage}
469-
isTaskAuthor={isTaskAuthor}
470-
isOwnMessage={
471-
!!currentUserUuid &&
472-
currentUserUuid === row.message.value?.author?.uuid
473-
}
474-
currentUserEmail={currentUserEmail}
475-
canForward={canForward}
476-
onSendToAgent={() => onSendToAgent(row.message.id)}
477-
onDelete={() => onDelete(row.message.id)}
478-
/>
479-
)
412+
<ThreadMessageRow
413+
key={row.message.id}
414+
message={row.message.value as TaskThreadMessage}
415+
isTaskAuthor={isTaskAuthor}
416+
isOwnMessage={
417+
!!currentUserUuid &&
418+
currentUserUuid === row.message.value?.author?.uuid
419+
}
420+
currentUserEmail={currentUserEmail}
421+
canForward={canForward}
422+
onSendToAgent={() => onSendToAgent(row.message.id)}
423+
onDelete={() => onDelete(row.message.id)}
424+
/>
480425
) : (
481426
<AgentTurnRow
482427
key={row.message.id}

0 commit comments

Comments
 (0)