Files
PaperClipAI/ui/src/components/task-chat/task-chat-states.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

182 lines
4.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Canonical state inventory for the chat-style task thread (the default task
* view; the classic legacy view sits behind enableClassicTaskInterface).
*
* This list is the single source of truth for:
* - the dev harness state switcher (/dev/task-chat-lab), and
* - the finish-line test that asserts every state renders without error.
*
* Each id traces to a real agent-protocol state (plan Deliverable 1). `tier`
* marks whether the state already streams live ("live") or is emitted upstream
* but dropped by acpx today ("tier-b", driven by synthetic events in the
* harness, live wiring flagged). `surface` says where the state renders.
*/
export const TASK_CHAT_STATES = [
"session-start",
"human-message",
"agent-message",
"thinking",
"responding",
"responding-burst",
"tool-call",
"diff",
"working",
"running",
"completed",
"activity-phases",
"awaiting-approval",
"plan-todo",
"interrupted",
"refused",
"truncated",
"live-token-cost",
] as const;
export type TaskChatStateId = (typeof TASK_CHAT_STATES)[number];
export type TaskChatStateTier = "live" | "tier-b";
export type TaskChatStateSurface = "thread" | "plan";
export interface TaskChatStateMeta {
id: TaskChatStateId;
label: string;
tier: TaskChatStateTier;
surface: TaskChatStateSurface;
/** Real protocol source, quoted for the harness inspector. */
protocol: string;
}
export const TASK_CHAT_STATE_META: Record<TaskChatStateId, TaskChatStateMeta> = {
"session-start": {
id: "session-start",
label: "Session start",
tier: "live",
surface: "thread",
protocol: 'acpx.session → TranscriptEntry kind:"init"',
},
"human-message": {
id: "human-message",
label: "Human message",
tier: "live",
surface: "thread",
protocol: 'IssueComment authorType:"user"',
},
"agent-message": {
id: "agent-message",
label: "Final response",
tier: "live",
surface: "thread",
protocol: 'PRP item.delta kind:"agentMessage" channel:"final"',
},
thinking: {
id: "thinking",
label: "Thinking",
tier: "live",
surface: "thread",
protocol: "text_delta stream:thought (ACP agent_thought_chunk)",
},
responding: {
id: "responding",
label: "Progress update (streaming)",
tier: "live",
surface: "thread",
protocol: 'PRP item.delta kind:"agentMessage" channel:"progress"',
},
"responding-burst": {
id: "responding-burst",
label: "Progress update burst",
tier: "live",
surface: "thread",
protocol: "text_delta stream:output ×N, tool calls between (PAP-368 dwell)",
},
"tool-call": {
id: "tool-call",
label: "Tool call",
tier: "live",
surface: "thread",
protocol: "acpx.tool_call (ACP tool_call / tool_call_update)",
},
diff: {
id: "diff",
label: "Diff",
tier: "live",
surface: "thread",
protocol: 'ToolCallContent type:"diff" → TranscriptEntry kind:"diff"',
},
working: {
id: "working",
label: "Working",
tier: "live",
surface: "thread",
protocol: "heartbeat.run.progress + acpx.status",
},
running: {
id: "running",
label: "Running",
tier: "live",
surface: "thread",
protocol: 'message.status.type === "running"',
},
completed: {
id: "completed",
label: "Completed (collapsed)",
tier: "live",
surface: "thread",
protocol: "acpx.result (StopReason in subtype)",
},
"activity-phases": {
id: "activity-phases",
label: "Long-run activity phases",
tier: "live",
surface: "thread",
protocol: "assistant boundaries + chronological tool calls",
},
"awaiting-approval": {
id: "awaiting-approval",
label: "Awaiting approval",
tier: "tier-b",
surface: "thread",
protocol: "ACP RequestPermissionRequest + PermissionOptionKind",
},
"plan-todo": {
id: "plan-todo",
label: "Plan / todo",
tier: "tier-b",
surface: "plan",
protocol: "ACP Plan { entries: PlanEntry[] }, PlanEntryStatus",
},
interrupted: {
id: "interrupted",
label: "Interrupted",
tier: "tier-b",
surface: "thread",
protocol: 'AcpRuntimeTurnResult.status:"cancelled" / StopReason "cancelled"',
},
refused: {
id: "refused",
label: "Refused",
tier: "tier-b",
surface: "thread",
protocol: 'StopReason "refusal"',
},
truncated: {
id: "truncated",
label: "Truncated",
tier: "tier-b",
surface: "thread",
protocol: 'StopReason "max_tokens" | "max_turn_requests"',
},
"live-token-cost": {
id: "live-token-cost",
label: "Live token / cost",
tier: "tier-b",
surface: "thread",
protocol: "ACP UsageUpdate { used, size, cost }",
},
};
export const TASK_CHAT_STATE_LIST: TaskChatStateMeta[] = TASK_CHAT_STATES.map(
(id) => TASK_CHAT_STATE_META[id],
);