Files
PaperClipAI/ui/src/components/task-chat/tool-taxonomy.test.ts
T
Dotta 39206c0096 feat(ui): complete the task workspace (#12640)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The task page is the main place where people guide and review agent
work.
> - Native runner events already project into the existing task chat on
the lower stack.
> - The larger task workspace must support those events without breaking
direct adapters.
> - Legacy questions, final replies, empty transcripts, and classic
controls must keep their behavior.
> - This pull request completes the provider-neutral task workspace
experience.
> - The benefit is one coherent task surface for native and direct
execution paths.

## Linked Issues or Issue Description

Refs #12639.
Refs #12617.
Refs #12352.

**Subsystem affected**

Task chat, task detail, side panels, interaction forms, and transcript
presentation.

**Problem or motivation**

The task page does not provide one complete workspace for live activity,
plans, questions, queued guidance, files, and documents. Earlier native
UI work also exposed compatibility risks in legacy question and reply
paths.

**Proposed solution**

Add the task workspace components and provider-neutral protocol
presentation. Keep runner-only controls behind runtime facts. Preserve
all direct-adapter composer, transcript, interaction, and finalization
behavior.

**Alternatives considered**

A separate runner page would duplicate task behavior. Replacing legacy
transcript logic would create unnecessary adapter regressions.

**Roadmap alignment**

This work supports the unified task experience and the Cloud and Sandbox
agents milestone.

## Stack

- Base PR: #12639.
- Lower PR: #12638.
- This PR contains only its 119-file UI delta against
`runner/remote-wss-transport`.
- The next stack PR adds administrator and observability controls.

## What Changed

- Added a reusable task workspace side panel for files and documents.
- Added provider-neutral cards for tools, plans, questions, protocol
activity, and progress.
- Added queued guidance and richer composer state.
- Added compact and expanded interaction presentation.
- Added live activity, thinking, usage, recovery, and final reply
presentation.
- Added document annotations and task deep links.
- Added bounded question validation and response handling.
- Preserved native runner event projection from master.
- Preserved legacy channel-less replies and explicit final reply
precedence.
- Preserved direct-adapter and classic-interface controls.
- Did not change server execution selection, Rust code, migrations,
workflows, or `pnpm-lock.yaml`.

## Verification

- GitHub Actions will run UI tests, repository tests, typecheck, build,
browser tests, security, and policy gates.
- Tests cover active, settled, empty-transcript, interaction,
queued-message, plan, question, file, document, and classic-interface
states.
- Compatibility tests cover direct adapters and native runner projection
together.
- Local tests were not run. The requested verification policy uses
GitHub Actions for this series.
- `git diff --check runner/remote-wss-transport...HEAD` passes.
- The delta contains 119 UI-only files.

## Risks

- This is a large task-page change.
- Most files are new focused components and tests.
- Shared transcript code keeps the lower native projection and legacy
direct-adapter fallbacks.
- Runner-only controls use adapter and runtime facts.
- No execution path or rollout flag changes in this PR.

> 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

OpenAI Codex with GPT-5.6. The work used high-reasoning agent mode,
repository tools, GitHub tools, and parallel code-audit agents.

## 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 or instance-local Paperclip issues
or links
- [x] My branch name describes the change and contains no internal
Paperclip ticket id
- [ ] 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 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
2026-09-01 02:44:19 -05:00

156 lines
7.7 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
BookOpen,
Brain,
ChevronsLeftRightEllipsis,
CircleHelp,
FilePenLine,
MessageSquareReply,
Network,
Search,
SearchCode,
Terminal,
Wrench,
} from "lucide-react";
import { McpIcon } from "./McpIcon";
import {
humanizeToolName,
isGenericToolName,
mcpToolIdentity,
mcpToolSegment,
statusLabelIcon,
toolActivityPresentation,
toolTaxonomy,
} from "./tool-taxonomy";
describe("tool activity vocabulary", () => {
it("maps Claude, Codex, and Pi built-ins to action-specific copy and icons", () => {
expect(toolTaxonomy("Bash")).toEqual({ family: "terminal", icon: Terminal, verbLabel: "Running a command" });
expect(toolTaxonomy("exec_command")).toEqual({ family: "terminal", icon: Terminal, verbLabel: "Running a command" });
expect(toolTaxonomy("Grep")).toEqual({ family: "grep", icon: SearchCode, verbLabel: "Searching file contents" });
expect(toolTaxonomy("Glob")).toEqual({ family: "search", icon: Search, verbLabel: "Searching files" });
expect(toolTaxonomy("Read")).toEqual({ family: "read", icon: BookOpen, verbLabel: "Reading a file" });
expect(toolTaxonomy("NotebookEdit")).toEqual({ family: "edit", icon: FilePenLine, verbLabel: "Editing a notebook" });
expect(toolTaxonomy("WebFetch")).toEqual({ family: "web", icon: ChevronsLeftRightEllipsis, verbLabel: "Fetching a web page" });
expect(toolTaxonomy("Agent")).toEqual({ family: "agent", icon: Network, verbLabel: "Starting a subagent" });
expect(toolTaxonomy("AskUserQuestion")).toEqual({ family: "question", icon: CircleHelp, verbLabel: "Requesting input" });
});
it("normalizes camel, Pascal, snake, kebab, dotted, and both MCP formats", () => {
for (const name of ["searchIssues", "SearchIssues", "search_issues", "search-issues", "search.issues"]) {
expect(toolActivityPresentation({ name }).runningLabel).toBe("Searching issues");
}
expect(mcpToolIdentity("mcp__linear-server__search_issues")).toEqual({ namespace: "linear-server", name: "search_issues" });
expect(mcpToolIdentity("mcp.linear-server.search_issues")).toEqual({ namespace: "linear-server", name: "search_issues" });
expect(mcpToolSegment("mcp__linear-server__search_issues")).toBe("Search issues");
expect(mcpToolSegment("mcp.linear-server.search_issues")).toBe("Search issues");
const mcp = toolActivityPresentation({ name: "mcp.paperclip.search_tasks" });
expect(mcp).toMatchObject({
family: "mcp",
icon: McpIcon,
runningLabel: "Searching tasks",
completedLabel: "Searched tasks",
sourceLabel: "Paperclip",
confidence: "exact",
});
});
it("covers every ACP kind before falling back to a future extension name", () => {
const expected: Record<string, string> = {
read: "Reading data",
edit: "Updating data",
delete: "Deleting an item",
move: "Moving an item",
search: "Searching",
execute: "Running a command",
think: "Thinking",
fetch: "Fetching data",
switch_mode: "Switching mode",
other: "Running Custom extension",
};
for (const [operation, runningLabel] of Object.entries(expected)) {
expect(toolActivityPresentation({ name: "custom_extension", operation }).runningLabel).toBe(runningLabel);
}
expect(toolActivityPresentation({ name: "Read file '/tmp/private.json'", operation: "read" }).runningLabel).toBe("Reading data");
});
it("covers every normalized verb-prefix family", () => {
const cases: Array<[string, string]> = [
["get_record", "Reading record"], ["list_records", "Listing records"],
["lookup_record", "Searching record"], ["fetch_record", "Fetching record"],
["open_record", "Opening record"], ["patch_record", "Updating record"],
["register_record", "Creating record"], ["remove_record", "Deleting record"],
["rename_record", "Moving record"], ["execute_record", "Running a command"],
["prompt_user", "Requesting user"], ["comment_record", "Posting record"],
["delegate_record", "Starting record"], ["interrupt_record", "Stopping record"],
["poll_record", "Waiting"], ["complete_record", "Reporting completion"],
["block_record", "Reporting a blocker"],
];
for (const [name, runningLabel] of cases) {
expect(toolActivityPresentation({ name }).runningLabel).toBe(runningLabel);
}
});
it("gives anticipated provider tools and Paperclip operations purpose-specific labels", () => {
const anticipated = [
"ToolSearch", "NotebookRead", "NotebookEdit", "TaskOutput", "TaskStop", "SendMessage",
"EnterPlanMode", "ExitPlanMode", "LSP", "TodoWrite", "ReportFindings", "Skill",
"view_image", "Image generation", "Compact conversation", "Guardian Review",
"apply_patch", "multi_tool_use.parallel", "wait_agent", "interrupt_agent",
];
const paperclip = [
"get_task_context", "get_task_history", "list_documents", "read_document", "list_document_revisions",
"report_progress", "answer_status_question", "write_document", "request_human_input",
"register_deliverable", "finish_task", "paperclip_finish", "block_task", "paperclip_block",
"request_review", "list_agents", "get_agent", "search_tasks", "list_approvals", "get_approval",
"get_approval_context", "get_workspace_runtime", "control_workspace_service", "set_dependencies",
"create_task", "request_approval", "decide_approval", "comment_on_approval", "schedule_wake",
"generic_api_request",
];
for (const name of [...anticipated, ...paperclip]) {
const presentation = toolActivityPresentation({ name, namespace: paperclip.includes(name) ? "paperclip" : undefined });
expect(presentation.confidence, name).toBe("exact");
expect(presentation.runningLabel, name).not.toMatch(/running a tool|tool call/i);
expect(presentation.completedLabel, name).not.toMatch(/ran a tool|tool call/i);
}
expect(toolActivityPresentation({ name: "report_progress", namespace: "paperclip" }).runningLabel).toBe("Reporting progress");
expect(toolActivityPresentation({ name: "paperclip_block", namespace: "paperclip" }).completedLabel).toBe("Reported a blocker");
expect(toolActivityPresentation({ name: "schedule_wake", namespace: "paperclip" }).runningLabel).toBe("Scheduling a wake-up");
});
it("humanizes unknown named extensions and reserves the unnamed copy for missing identity", () => {
expect(toolActivityPresentation({ name: "CustomExtension" })).toMatchObject({
icon: Wrench,
runningLabel: "Running Custom extension",
completedLabel: "Ran Custom extension",
displayName: "Custom extension",
confidence: "fallback",
});
for (const name of ["", undefined, null, "tool call"]) {
expect(toolActivityPresentation({ name })).toMatchObject({
runningLabel: "Running an unnamed tool",
completedLabel: "Ran an unnamed tool",
confidence: "unnamed",
});
}
expect(humanizeToolName("someFuture-extension.v2")).toBe("Some future extension v2");
});
});
describe("status and placeholder helpers", () => {
it("gives tool-free informative statuses their glyphs", () => {
expect(statusLabelIcon("Thinking")).toBe(Brain);
expect(statusLabelIcon("Responding")).toBe(MessageSquareReply);
expect(statusLabelIcon("Responding (streaming)")).toBe(MessageSquareReply);
expect(statusLabelIcon("Working")).toBeNull();
});
it("recognizes ACPX placeholders but keeps real names", () => {
for (const name of ["tool call", "tool call (completed)", "Tool Call (failed)", "acp_tool", "tool", ""]) {
expect(isGenericToolName(name)).toBe(true);
}
expect(isGenericToolName("Terminal")).toBe(false);
expect(isGenericToolName("mcp__linear__search_issues")).toBe(false);
});
});