Files
PaperClipAI/ui/src/components/task-chat/tool-row-task-reference.test.tsx
T
DottaandClaude Opus 5.5 7c673e695f fix(chat): name tasks by identifier, not UUID, in tool rows and agent text (#19635)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - New users meet Paperclip through the onboarding chat with their
first agent, and through task briefs that agents write
> - A browser walk of onboarding found internal handles and
control-plane jargon in those user-facing surfaces
> - A tool row showed `Read taskId: e3ecf9bc-…`, an agent-written brief
cited `task … (id 2b330993-…)`, and a Codex agent told a new user about
"receipts", "execution policy", and a "rejected policy patch"
> - Raw UUIDs and mechanism narration make the product look broken and
give the user nothing to act on
> - This pull request makes tool rows name a task by its identifier, and
tells agents to reference identifiers and to describe outcomes, not
mechanics
> - The benefit is that a new user sees "Read <task identifier>" and
plain progress updates

## Linked Issues or Issue Description

**What happened?**
In the task chat, a collapsed tool row rendered the raw call argument
`taskId: <uuid>`. An agent-written task description included a raw task
UUID next to the task identifier. A Codex chief of staff narrated
internal mechanics (receipts, execution policies, a rejected policy
patch) to a new user in chat.

**Expected behavior**
Tool rows name the task by its identifier. Agent-written text links
tasks and documents by identifier. Agents tell the user what happened,
what it means, and the next step.

**Steps to reproduce**
1. Run onboarding with the Codex API runner and accept a single-task
proposal.
2. Watch the handoff in the chief-of-staff chat.
3. See the task lookup tool row and the narration. With the Claude API
runner and the plan path, open a child task created from the plan and
read its description.

## What Changed

- `ui/src/components/task-chat/transcript-adapter.ts`: a tool row's
target never contains a UUID argument. A `taskId`/`issueId` UUID is kept
as `taskRefId` on the tool item.
- New `ui/src/components/task-chat/task-reference.ts`:
`useTaskReferenceLabel` reads the task from the shared issue detail
query cache and returns its identifier. It returns "task" until the task
resolves or when it cannot.
- `TaskChatRunnerActivityGroup` and `TaskChatToolCard` show that
identifier as the row subject. They load the task only for rows that
have a task reference.
- `skills/paperclip/SKILL.md` (Comment Style): two new required rules.
"No raw IDs in prose" and "Describe outcomes, not mechanics".
- First-task onboarding skill: a "Talk in outcomes" rule. Non-inline
handoff inputs use an identifier link, not a raw UUID.
- Chief-of-staff persona (`AGENTS.md` for the first agent): the same
plain-language rule, so it applies in every chat.
- `skills/paperclip-converting-plans-to-tasks/SKILL.md`: task
descriptions reference other tasks and documents by identifier link,
never by raw UUID.
- No change to `skills-releases/` snapshots. They are frozen releases.

## Verification

Red on master (fix files reverted, new tests kept):

```
ui  tool-row-task-reference.test.tsx
 FAIL  ... > falls back to a plain word while the task cannot be resolved
AssertionError: expected 'ReadtaskId: e3ecf9bc-099a-4b10-8169-9…' not to contain 'e3ecf9bc-099a-4b10-8169-9ce490a91e3d'
      Tests  3 failed (3)
server  user-facing-wording-guidance.test.ts
      Tests  6 failed (6)
```

Green with the fix:

```
ui  tool-row-task-reference.test.tsx        Tests  3 passed (3)
server  user-facing-wording-guidance.test.ts Tests  6 passed (6)
```

Neighbouring suites:

- `cd ui && npx vitest run src/components/task-chat
src/components/TaskChatThread src/components/transcript`: 70 files, 1448
passed, 1 skipped.
- From the repo root: `onboarding-first-task-assets`,
`paperclip-skill-utils`, `onboarding-first-task-admission`,
`hiring-operational-examples`, `cli-invocation-safety`, and the new
guidance test all pass.
- `pnpm check:token-gates`: all gates clean. The change adds no styles.
- `ui` typecheck: no errors in the changed files.
- Not run locally: `agent-skills-routes.test.ts` hit a 30 s `beforeAll`
import timeout on a cold cache. CI covers it.

## Risks

- Low risk. A row that names a task loads that task once through the
shared issue detail cache. The thread usually has it cached already. A
failed load shows "task" and does not retry.
- Rows now show other non-UUID arguments after the identifier (for
example `<identifier> · status: done`). Rows without a task reference do
not change.
- The skill text changes the guidance that agents read. They do not
change permissions, tools, or API behavior.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, run in Claude Code
with tool use (shell, file edits, test execution).

## 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
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:12:48 -06:00

107 lines
4.5 KiB
TypeScript

// @vitest-environment jsdom
import { act } from "react";
import { createRoot, type Root } from "react-dom/client";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import type { TranscriptEntry } from "@/adapters";
import { queryKeys } from "../../lib/queryKeys";
import { TaskChatRunnerActivityGroup } from "./TaskChatRunnerActivityGroup";
import { TaskChatToolCard } from "./TaskChatToolCard";
import { summarizeToolInput, transcriptToTaskChatItems } from "./transcript-adapter";
import type { TaskChatActivityPhaseItem, TaskChatToolItem } from "./task-chat-model";
const issuesApi = vi.hoisted(() => ({ get: vi.fn(), getCore: vi.fn() }));
vi.mock("../../api/issues", () => ({ issuesApi }));
(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
const TASK_UUID = "e3ecf9bc-099a-4b10-8169-9ce490a91e3d";
const TS = "2026-11-06T15:41:52.000Z";
/** The Codex walk's collapsed row: a task lookup whose only argument is the task UUID. */
function taskLookupRow(): TaskChatToolItem {
const entries: TranscriptEntry[] = [
{ kind: "tool_call", ts: TS, toolUseId: "call-1", name: "Read", input: { taskId: TASK_UUID } },
{ kind: "tool_result", ts: TS, toolUseId: "call-1", content: "{}", isError: false },
];
const items = transcriptToTaskChatItems(entries, { runId: "run-1", agentName: "Head baker", running: false });
const tool = items.find((item): item is TaskChatToolItem => item.kind === "tool");
if (!tool) throw new Error("expected a tool row");
return tool;
}
const phase = (items: TaskChatToolItem[]): TaskChatActivityPhaseItem => ({
id: "phase", kind: "activity_phase", items, active: false, summary: "",
});
describe("tool rows never show raw task UUIDs", () => {
let container: HTMLDivElement;
let root: Root;
let queryClient: QueryClient;
beforeEach(() => {
issuesApi.get.mockReset();
issuesApi.getCore.mockReset();
container = document.createElement("div");
document.body.appendChild(container);
root = createRoot(container);
queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } });
});
afterEach(() => {
act(() => root.unmount());
container.remove();
queryClient.clear();
});
function renderRow(tool: TaskChatToolItem) {
act(() => root.render(
<QueryClientProvider client={queryClient}>
<TaskChatRunnerActivityGroup defaultExpanded item={phase([tool])} />
</QueryClientProvider>,
));
return container.querySelector(`[data-activity-row="${tool.id}"]`);
}
it("keeps a UUID argument out of the summarized target", () => {
expect(summarizeToolInput({ taskId: TASK_UUID }) ?? "").not.toContain(TASK_UUID);
expect(summarizeToolInput({ issueId: TASK_UUID, includeComments: true }) ?? "").not.toContain(TASK_UUID);
});
it("shows the task identifier in place of its UUID", () => {
queryClient.setQueryData(queryKeys.issues.detail(TASK_UUID), {
id: TASK_UUID, identifier: "PIX-3", title: "Create printable cake menu and logo",
});
const row = renderRow(taskLookupRow());
expect(row?.textContent).not.toContain(TASK_UUID);
expect(row?.textContent).toContain("PIX-3");
});
it("reads only the core task view for an uncached task, on both tool-row surfaces", async () => {
issuesApi.getCore.mockResolvedValue({ id: TASK_UUID, identifier: "PIX-3", title: "Create printable cake menu and logo" });
const tool = taskLookupRow();
act(() => root.render(
<QueryClientProvider client={queryClient}>
<TaskChatToolCard item={tool} />
</QueryClientProvider>,
));
const card = container.querySelector('[data-testid="task-chat-tool-card"]');
await vi.waitFor(async () => {
await act(async () => { await Promise.resolve(); });
expect(card?.textContent).toContain("PIX-3");
});
expect(card?.textContent).not.toContain(TASK_UUID);
expect(issuesApi.getCore).toHaveBeenCalledTimes(1);
expect(issuesApi.get).not.toHaveBeenCalled();
});
it("falls back to a plain word while the task cannot be resolved", async () => {
issuesApi.getCore.mockRejectedValue(new Error("not found"));
const row = renderRow(taskLookupRow());
await vi.waitFor(async () => {
await act(async () => { await Promise.resolve(); });
expect(issuesApi.getCore).toHaveBeenCalled();
});
expect(row?.textContent).not.toContain(TASK_UUID);
expect(row?.textContent).toContain("task");
});
});