mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-21 00:05:49 +02:00
## 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
193 lines
10 KiB
TypeScript
193 lines
10 KiB
TypeScript
import {
|
||
AlertTriangle,
|
||
BookOpen,
|
||
Bot,
|
||
Box,
|
||
Clock3,
|
||
Database,
|
||
FileCheck2,
|
||
FilePenLine,
|
||
FileText,
|
||
GitBranch,
|
||
ListChecks,
|
||
PackageCheck,
|
||
Search,
|
||
ShieldCheck,
|
||
TerminalSquare,
|
||
Users,
|
||
} from "lucide-react";
|
||
import type {
|
||
TaskChatMaterializedResourceItem,
|
||
TaskChatProtocolItem,
|
||
TaskChatProviderActivityItem,
|
||
TaskChatWorkspaceChangeItem,
|
||
TaskChatWorkspaceFileItem,
|
||
} from "./task-chat-model";
|
||
import {
|
||
humanizeToolName,
|
||
isGenericToolName,
|
||
mcpToolIdentity,
|
||
toolActivityPresentation,
|
||
type ToolIcon,
|
||
} from "./tool-taxonomy";
|
||
|
||
export interface TaskChatActivityPresentation {
|
||
icon: ToolIcon;
|
||
runningLabel: string;
|
||
completedLabel: string;
|
||
failedLabel?: string;
|
||
interruptedLabel?: string;
|
||
detail?: string;
|
||
}
|
||
|
||
function providerDetail(item: TaskChatProviderActivityItem, ...labels: string[]): string | undefined {
|
||
return item.details.find((entry) => labels.includes(entry.label))?.value;
|
||
}
|
||
|
||
function meaningfulToolDetail(value: string | undefined): string | undefined {
|
||
if (!value || isGenericToolName(value) || /^tool(?:\s+|_)call\b/i.test(value)) return undefined;
|
||
return value;
|
||
}
|
||
|
||
export function providerActivityPresentation(item: TaskChatProviderActivityItem): TaskChatActivityPresentation {
|
||
const detail = item.summary
|
||
?? providerDetail(item, "Query", "URL", "Target", "Name", "Reference", "Reason", "Summary");
|
||
switch (item.family) {
|
||
case "research": {
|
||
const action = providerDetail(item, "Action")?.toLowerCase();
|
||
if (action === "open_page") {
|
||
return { icon: Search, runningLabel: "Opening a web page", completedLabel: "Opened a web page", failedLabel: "Couldn’t open the web page", interruptedLabel: "Stopped opening the web page", detail };
|
||
}
|
||
if (action === "find_in_page") {
|
||
return { icon: Search, runningLabel: "Searching the page", completedLabel: "Searched the page", failedLabel: "Page search failed", interruptedLabel: "Page search stopped", detail };
|
||
}
|
||
return { icon: Search, runningLabel: "Searching the web", completedLabel: "Searched the web", failedLabel: "Web search failed", interruptedLabel: "Web search stopped", detail };
|
||
}
|
||
case "tool_execution": {
|
||
const name = providerDetail(item, "Name");
|
||
const target = providerDetail(item, "Target");
|
||
const progress = providerDetail(item, "Progress");
|
||
const tool = toolActivityPresentation({
|
||
name,
|
||
transport: providerDetail(item, "Transport"),
|
||
namespace: providerDetail(item, "Namespace"),
|
||
operation: providerDetail(item, "Operation"),
|
||
target,
|
||
progress,
|
||
});
|
||
const boundedActivity = meaningfulToolDetail(item.summary)
|
||
?? meaningfulToolDetail(progress)
|
||
?? meaningfulToolDetail(target);
|
||
const activityIsIdentity = Boolean(
|
||
boundedActivity && name && humanizeToolName(boundedActivity) === humanizeToolName(name),
|
||
);
|
||
const technicalName = name ? mcpToolIdentity(name)?.name ?? name : tool.displayName;
|
||
const source = tool.sourceLabel
|
||
? `${tool.sourceLabel} · ${technicalName}`
|
||
: name && !isGenericToolName(name) && humanizeToolName(name) !== tool.runningLabel.replace(/^Running /, "")
|
||
? name
|
||
: undefined;
|
||
return {
|
||
icon: tool.icon,
|
||
runningLabel: tool.runningLabel,
|
||
completedLabel: tool.completedLabel,
|
||
failedLabel: tool.failedLabel,
|
||
interruptedLabel: tool.interruptedLabel,
|
||
detail: [activityIsIdentity ? undefined : boundedActivity, source].filter(Boolean).join(" · ") || undefined,
|
||
};
|
||
}
|
||
case "plan":
|
||
return { icon: ListChecks, runningLabel: "Updating the plan", completedLabel: "Updated the plan", failedLabel: "Plan update failed", interruptedLabel: "Plan update stopped", detail };
|
||
case "delegation": {
|
||
const action = providerDetail(item, "Action")?.toLowerCase();
|
||
if (action === "message") return { icon: Users, runningLabel: "Messaging a subagent", completedLabel: "Messaged a subagent", failedLabel: "Subagent message failed", interruptedLabel: "Subagent message stopped", detail };
|
||
if (action === "resume") return { icon: Users, runningLabel: "Resuming a subagent", completedLabel: "Resumed a subagent", failedLabel: "Couldn’t resume the subagent", interruptedLabel: "Subagent resume stopped", detail };
|
||
if (action === "close") return { icon: Users, runningLabel: "Closing a subagent", completedLabel: "Closed a subagent", failedLabel: "Couldn’t close the subagent", interruptedLabel: "Subagent close stopped", detail };
|
||
if (action === "wait") return { icon: Users, runningLabel: "Waiting for subagents", completedLabel: "Finished waiting for subagents", failedLabel: "Subagent wait failed", interruptedLabel: "Stopped waiting for subagents", detail };
|
||
return { icon: Users, runningLabel: "Starting a subagent", completedLabel: "Started a subagent", failedLabel: "Subagent start failed", interruptedLabel: "Subagent start stopped", detail };
|
||
}
|
||
case "model_identity":
|
||
return item.eventType === "model.route.changed"
|
||
? { icon: Bot, runningLabel: "Switching models", completedLabel: "Switched models", failedLabel: "Model switch failed", interruptedLabel: "Model switch stopped", detail }
|
||
: { icon: Bot, runningLabel: "Verifying the model", completedLabel: "Verified the model", failedLabel: "Model verification failed", interruptedLabel: "Model verification stopped", detail };
|
||
case "context":
|
||
return { icon: Database, runningLabel: "Compacting context", completedLabel: "Compacted context", failedLabel: "Context compaction failed", interruptedLabel: "Context compaction stopped", detail };
|
||
case "artifact": {
|
||
const viewed = item.eventType === "artifact.viewed";
|
||
return viewed
|
||
? { icon: Box, runningLabel: "Viewing an artifact", completedLabel: "Viewed an artifact", failedLabel: "Couldn’t view the artifact", interruptedLabel: "Artifact view stopped", detail }
|
||
: { icon: Box, runningLabel: "Generating an artifact", completedLabel: "Generated an artifact", failedLabel: "Artifact generation failed", interruptedLabel: "Artifact generation stopped", detail };
|
||
}
|
||
case "review": {
|
||
const state = providerDetail(item, "State")?.toLowerCase();
|
||
return state === "exited"
|
||
? { icon: FileCheck2, runningLabel: "Leaving review mode", completedLabel: "Left review mode", failedLabel: "Couldn’t leave review mode", interruptedLabel: "Review-mode change stopped", detail }
|
||
: { icon: FileCheck2, runningLabel: "Entering review mode", completedLabel: "Entered review mode", failedLabel: "Couldn’t enter review mode", interruptedLabel: "Review-mode change stopped", detail };
|
||
}
|
||
case "hook":
|
||
return { icon: GitBranch, runningLabel: "Running a hook", completedLabel: "Ran a hook", failedLabel: "Hook failed", interruptedLabel: "Hook stopped", detail };
|
||
case "memory":
|
||
return { icon: BookOpen, runningLabel: "Checking memory", completedLabel: "Referenced memory", failedLabel: "Memory lookup failed", interruptedLabel: "Memory lookup stopped", detail };
|
||
case "safety":
|
||
return { icon: ShieldCheck, runningLabel: "Reviewing safety", completedLabel: "Reviewed safety", failedLabel: "Safety review failed", interruptedLabel: "Safety review stopped", detail };
|
||
case "terminal":
|
||
return { icon: TerminalSquare, runningLabel: "Sending terminal input", completedLabel: "Sent terminal input", failedLabel: "Terminal input failed", interruptedLabel: "Terminal input stopped", detail };
|
||
case "wait":
|
||
return { icon: Clock3, runningLabel: "Waiting", completedLabel: "Finished waiting", failedLabel: "Wait failed", interruptedLabel: "Wait stopped", detail };
|
||
case "provider_notice":
|
||
return { icon: AlertTriangle, runningLabel: "Provider notice", completedLabel: "Provider notice", failedLabel: "Provider error", interruptedLabel: "Provider notice", detail };
|
||
}
|
||
}
|
||
|
||
function workspaceChangePresentation(item: TaskChatWorkspaceChangeItem): TaskChatActivityPresentation {
|
||
const count = item.totals.files || item.files.length;
|
||
const detail = count > 0 ? `${count} ${count === 1 ? "file" : "files"}` : undefined;
|
||
return { icon: FilePenLine, runningLabel: "Editing files", completedLabel: "Edited files", detail };
|
||
}
|
||
|
||
function workspaceFilePresentation(item: TaskChatWorkspaceFileItem): TaskChatActivityPresentation {
|
||
return {
|
||
icon: FileText,
|
||
runningLabel: "Referencing a file",
|
||
completedLabel: "Referenced a file",
|
||
detail: item.line == null ? item.path : `${item.path}:${item.line}`,
|
||
};
|
||
}
|
||
|
||
function resourcePresentation(item: TaskChatMaterializedResourceItem): TaskChatActivityPresentation {
|
||
return {
|
||
icon: item.resourceKind === "document" ? FileText : PackageCheck,
|
||
runningLabel: "Saving a resource",
|
||
completedLabel: item.resourceKind === "document" ? "Added a document" : "Added a deliverable",
|
||
detail: item.title,
|
||
};
|
||
}
|
||
|
||
export function protocolActivityPresentation(item: TaskChatProtocolItem): TaskChatActivityPresentation | null {
|
||
switch (item.surface) {
|
||
case "provider_activity": return providerActivityPresentation(item);
|
||
case "workspace_change": return workspaceChangePresentation(item);
|
||
case "workspace_file": return workspaceFilePresentation(item);
|
||
case "resource": return resourcePresentation(item);
|
||
case "runtime_request":
|
||
case "run_result":
|
||
case "run_terminal":
|
||
return null;
|
||
}
|
||
}
|
||
|
||
export function protocolActivityIsRunning(item: TaskChatProtocolItem): boolean {
|
||
if (item.surface === "provider_activity") return item.status === "running";
|
||
if (item.surface === "workspace_change") return !item.complete;
|
||
return false;
|
||
}
|
||
|
||
export function protocolActivityLabel(item: TaskChatProtocolItem, presentation: TaskChatActivityPresentation): string {
|
||
if (item.surface !== "provider_activity") {
|
||
return protocolActivityIsRunning(item) ? presentation.runningLabel : presentation.completedLabel;
|
||
}
|
||
if (item.status === "failed") return presentation.failedLabel ?? `${presentation.completedLabel} · failed`;
|
||
if (item.status === "interrupted") return presentation.interruptedLabel ?? `${presentation.completedLabel} · interrupted`;
|
||
return item.status === "running" ? presentation.runningLabel : presentation.completedLabel;
|
||
}
|