From 17f9105a23010bc6ab9d5982b97e66705d14780d Mon Sep 17 00:00:00 2001 From: scotttong Date: Thu, 26 Nov 2026 00:23:21 +0000 Subject: [PATCH] fix(ui): open agent chat from the task transcript (#23004) ## Thinking Path > - People use Paperclip to manage AI agents and their work. > - A task shows the agent's name and avatar beside its run status. > - People can use that identity to follow up with the agent. > - The link opened the agent's settings. This added a second step to reach the conversation. > - This change opens the agent's existing one-on-one chat directly from the task. ## Linked Issues or Issue Description **What happened?** Clicking an agent's name beside its run status in a task opened the agent overview. **Expected behavior** The link should open that agent's chat in the same company. **Steps to reproduce** Open a task with an agent run. Click the avatar or name beside the run status. Check the destination and use browser Back to return to the task. **Paperclip version or commit** Reproduced on e18fe61c8f. Related work: #13283 introduced the shared task and agent chat surface. ## What Changed - Use the task's agent roster to build the company-scoped chat link. Use the agent ID for a missing or terminated roster member. - Keep the link to the agent overview inside direct chat. - Add a regression test for task and direct chat links. ## Verification - The Chromium end-to-end test passed against the built UI. It clicks the company-scoped agent link in the task, opens the saved conversation, and checks the overview link inside direct chat. - The focused task thread suite passed 434 tests and skipped one: `pnpm exec vitest run ui/src/components/TaskChatThread.test.tsx`. - In Chrome, clicked the named link beside a native run. Verified the company, agent, existing conversation, and Back navigation. Verified keyboard activation, the assignee menu, and the settings link from direct chat. - All 224 selected UI test files passed locally before adding the regression test. Three CLI worktree tests could not start their embedded PostgreSQL instances because the machine was out of shared-memory slots. ## Risks The task and direct chat share the identity component. The test checks both destinations to guard against a self-link inside direct chat. ## Model Used OpenAI GPT-6 via Codex, with local code execution and browser testing. ## Checklist - [x] I have included a thinking path that traces from project context to this change - [x] I have specified the model used (with version and capability details) - [x] I have checked ROADMAP.md and confirmed this PR does not duplicate planned core work - [x] I have searched GitHub for duplicate or related PRs and linked them above - [x] I have either (a) linked existing issues with `Fixes: #` / `Closes #` / `Refs #` OR (b) described the issue in-PR following the relevant issue template - [x] I have not referenced internal/instance-local Paperclip issues or links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip` URLs) - [x] My branch name describes the change (e.g. `docs/...`, `fix/...`) and contains no internal Paperclip ticket id or instance-derived details - [ ] I have run tests locally and they pass - [x] I have added or updated tests where applicable - [ ] I have updated relevant documentation to reflect my changes - [x] I have considered and documented any risks above - [ ] All Paperclip CI gates are green - [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups - [x] I will address all Greptile and reviewer comments before requesting merge --------- Co-authored-by: Scott Tong --- tests/e2e/agent-chat-messages.spec.ts | 10 ++++++++- ui/src/components/TaskChatThread.test.tsx | 16 ++++++++++++++ .../components/task-chat/TaskChatBubble.tsx | 22 +++++++++++-------- ui/src/pages/IssueDetail.tsx | 3 +++ 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/tests/e2e/agent-chat-messages.spec.ts b/tests/e2e/agent-chat-messages.spec.ts index 0a1e3714c45..210ea374aca 100644 --- a/tests/e2e/agent-chat-messages.spec.ts +++ b/tests/e2e/agent-chat-messages.spec.ts @@ -63,7 +63,15 @@ test("a routine delivers a first digest, unread state, source link and replyable await expect.poll(async () => (await json(await request.get(f.chatPath))).isUnreadForMe).toBe(false); await sourceLink.click(); await expect(page).toHaveURL(new RegExp(`/issues/${source.identifier}`)); - await page.goto(f.route); + await expect(page.getByText("Digest delivered.", { exact: true })).toBeVisible(); + const identity = page.getByTestId("task-chat-agent-identity").filter({ hasText: f.agent.name }).first(); + const chatPath = `/${f.company.issuePrefix}/chats/${f.agent.urlKey}`; + await expect(identity).toHaveAccessibleName(f.agent.name); + await expect(identity).toHaveAttribute("href", chatPath); + await identity.click(); + await expect(page).toHaveURL(chatPath); + await expect(page.getByText("Morning PR digest", { exact: true })).toBeVisible(); + await expect(identity).toHaveAttribute("href", `/${f.company.issuePrefix}/agents/${f.agent.id}/overview`); await send(page, { action: "digest-followup", text: "Which was the first PR?" }); await idle(request, f.chatPath, 2); await expect(page.getByText("The first PR in your morning digest is PR 123.", { exact: true })).toBeVisible({ timeout: 45_000 }); diff --git a/ui/src/components/TaskChatThread.test.tsx b/ui/src/components/TaskChatThread.test.tsx index c08e0a41417..9ef38051af0 100644 --- a/ui/src/components/TaskChatThread.test.tsx +++ b/ui/src/components/TaskChatThread.test.tsx @@ -15,6 +15,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; import { ConnectivityProvider, createConnectivityStore } from "@/lib/connectivity"; import { INITIAL_TRANSCRIPT_REVEAL_BUDGET_MS, TaskChatThread } from "./TaskChatThread"; import { IssueChatThread } from "./IssueChatThread"; +import { TaskChatAgentIdentity, TaskTranscriptAgents } from "./task-chat/TaskChatBubble"; import type { Agent, IssueDocument, @@ -184,6 +185,21 @@ async function settleThreadLayout() { }); } +it("opens the agent's chat from a task and settings from the direct chat", () => { + const agent = { id: "agent-id", name: "Mira Vale", urlKey: "mira-vale-2" } as Agent; + const identity = ; + const link = () => container.querySelector("a")?.getAttribute("href"); + + render({identity}); + expect(link()).toBe("/chats/mira-vale-2"); + + render({identity}); + expect(link()).toBe("/chats/agent-id"); + + render(identity); + expect(link()).toBe("/agents/agent-id/overview"); +}); + describe.each(["legacy", "native"] as const)("historical %s system status", (runtimeMode) => { const run = (id: string, status: string, minute: number) => ({ runId: id, status, runtimeMode, agentId: "agent", agentName: "Assistant", diff --git a/ui/src/components/task-chat/TaskChatBubble.tsx b/ui/src/components/task-chat/TaskChatBubble.tsx index 30a9765074b..780aad8f305 100644 --- a/ui/src/components/task-chat/TaskChatBubble.tsx +++ b/ui/src/components/task-chat/TaskChatBubble.tsx @@ -11,11 +11,11 @@ import { isVideoLikeOutput } from "@/lib/issue-output"; import { AgentAvatar, type AvatarAgent } from "../AgentAvatar"; import { Identity } from "../Identity"; import { paperclipHumanAvatarUrl } from "@/lib/issue-chat-human-author"; -import { useCallback, useContext, useState, type ReactNode } from "react"; +import { createContext, useCallback, useContext, useState, type ReactNode } from "react"; import { useEmailComment } from "@/components/EmailMessageCard"; -import type { IssueAttachment } from "@paperclipai/shared"; +import type { Agent, IssueAttachment } from "@paperclipai/shared"; import { IssueGalleryContext } from "@/context/IssueGalleryContext"; -import { cn } from "@/lib/utils"; +import { agentRouteRef, cn } from "@/lib/utils"; import { agentDetailHref } from "@/pages/agent-detail-navigation"; import { useStreamlinedTaskChatPresentation } from "./presentation-mode"; import { MarkdownBody } from "@/components/MarkdownBody"; @@ -87,6 +87,8 @@ function initialsForName(name: string) { return name.slice(0, 2).toUpperCase(); } +export const TaskTranscriptAgents = createContext | null>(null); + export function TaskChatAgentIdentity({ agentName, agentIcon, @@ -96,6 +98,7 @@ export function TaskChatAgentIdentity({ agentIcon?: string | null; agent?: AvatarAgent; }) { + const taskAgents = useContext(TaskTranscriptAgents); const identity = ( <> @@ -103,18 +106,19 @@ export function TaskChatAgentIdentity({ ); const className = "flex items-center gap-2 px-1"; - return agent?.id ? ( + if (!agent?.id) { + return {identity}; + } + const member = taskAgents?.get(agent.id); + const agentRef = member && member.status !== "terminated" ? agentRouteRef(member) : agent.id; + return ( {identity} - ) : ( - - {identity} - ); } diff --git a/ui/src/pages/IssueDetail.tsx b/ui/src/pages/IssueDetail.tsx index c727d0857be..156e436a985 100644 --- a/ui/src/pages/IssueDetail.tsx +++ b/ui/src/pages/IssueDetail.tsx @@ -38,6 +38,7 @@ import type { TaskComposerPause } from "../components/task-chat/TaskChatPausedTa import { TaskDetailTasksPanel } from "@/components/task-detail/TaskDetailTasksPanel"; import { IssueCreatedFromNote } from "@/components/task-detail/IssueCreatedFromNote"; import { EmailThreadProvider } from "../components/EmailMessageCard"; +import { TaskTranscriptAgents } from "../components/task-chat/TaskChatBubble"; import { EmailTaskActivity } from "../components/EmailTaskActivity"; import { TaskChatScrollNavigation, taskChatScrollEntry } from "@/components/task-chat/scroll-navigation"; import { @@ -2671,6 +2672,7 @@ const IssueDetailChatTab = memo(function IssueDetailChatTab({ }} > + + )}