mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-28 04:02:18 +01: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
232 lines
8.8 KiB
TypeScript
232 lines
8.8 KiB
TypeScript
// @vitest-environment jsdom
|
||
|
||
import { flushSync } from "react-dom";
|
||
import { createRoot, type Root } from "react-dom/client";
|
||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||
import type { TranscriptEntry } from "@/adapters";
|
||
import { ThemeProvider } from "@/context/ThemeContext";
|
||
import { TaskChatLiveTail } from "./TaskChatLiveTail";
|
||
import { transcriptToTaskChatItems } from "./transcript-adapter";
|
||
import type { TaskChatItem } from "./task-chat-model";
|
||
|
||
const TS = "2026-08-08T12:00:00.000Z";
|
||
|
||
describe("TaskChatLiveTail", () => {
|
||
let container: HTMLDivElement;
|
||
let root: Root | null = null;
|
||
|
||
beforeEach(() => {
|
||
container = document.createElement("div");
|
||
document.body.appendChild(container);
|
||
root = createRoot(container);
|
||
});
|
||
|
||
afterEach(() => {
|
||
flushSync(() => root?.unmount());
|
||
root = null;
|
||
container.remove();
|
||
});
|
||
|
||
function render(items: TaskChatItem[], emptyMessage?: string) {
|
||
flushSync(() =>
|
||
root!.render(
|
||
<ThemeProvider>
|
||
<TaskChatLiveTail items={items} emptyMessage={emptyMessage} />
|
||
</ThemeProvider>,
|
||
),
|
||
);
|
||
}
|
||
|
||
function parse(entries: TranscriptEntry[], running = true) {
|
||
return transcriptToTaskChatItems(entries, { runId: "run-1", running });
|
||
}
|
||
|
||
it("renders streamed reply markdown and tool cards from a live transcript", () => {
|
||
const items = parse([
|
||
{ kind: "assistant", ts: TS, text: "Looking into the failing test." },
|
||
{ kind: "tool_call", ts: TS, name: "Read", toolUseId: "t1", input: { file_path: "src/app.ts" } },
|
||
{ kind: "tool_result", ts: TS, toolUseId: "t1", content: "ok", isError: false },
|
||
]);
|
||
render(items);
|
||
|
||
expect(container.querySelector('[data-testid="task-chat-phase-interstitial"]')?.textContent).toContain(
|
||
"Looking into the failing test.",
|
||
);
|
||
const phaseSummary = container.querySelector<HTMLButtonElement>('[data-testid="task-chat-phase-summary"]');
|
||
expect(phaseSummary?.getAttribute("aria-expanded")).toBe("true");
|
||
// Tool row renders with its name + mono target.
|
||
expect(container.textContent).toContain("Read");
|
||
expect(container.textContent).toContain("src/app.ts");
|
||
});
|
||
|
||
it("keeps tool diff bodies out of the activity feed", () => {
|
||
const items = parse([
|
||
{ kind: "tool_call", ts: TS, name: "Edit", toolUseId: "t1", input: { file_path: "a.ts" } },
|
||
{ kind: "diff", ts: TS, changeType: "add", text: "const x = 1;" },
|
||
{ kind: "diff", ts: TS, changeType: "remove", text: "const x = 0;" },
|
||
]);
|
||
render(items);
|
||
|
||
const phaseSummary = container.querySelector<HTMLButtonElement>('[data-testid="task-chat-phase-summary"]');
|
||
expect(phaseSummary?.getAttribute("aria-expanded")).toBe("true");
|
||
expect(container.textContent).not.toContain("const x = 1;");
|
||
expect(container.textContent).not.toContain("+1 −1");
|
||
|
||
const tool = container.querySelector<HTMLButtonElement>(".tc-enter-tool button");
|
||
expect(tool).not.toBeNull();
|
||
flushSync(() => tool?.click());
|
||
|
||
expect(container.textContent).toContain("+1 −1");
|
||
expect(container.textContent).not.toContain("const x = 1;");
|
||
expect(container.querySelector('[data-testid="task-chat-tool-change-summary"]')).not.toBeNull();
|
||
});
|
||
|
||
it("drops the debug plumbing kinds RunTranscriptView surfaced", () => {
|
||
// Feed the exact noise the board flagged: init row, stdout/stderr/system
|
||
// dumps, and a result line — interleaved with real content. None of the
|
||
// noise may reach the DOM; only the assistant text + tool row survive.
|
||
const items = parse([
|
||
{ kind: "init", ts: TS, model: "claude-opus", sessionId: "sess-INITMARKER" },
|
||
{ kind: "system", ts: TS, text: "SYSTEMNOISE hint about the environment" },
|
||
{ kind: "stdout", ts: TS, text: "STDOUTNOISE raw log line" },
|
||
{ kind: "stderr", ts: TS, text: "STDERRNOISE warning" },
|
||
{ kind: "assistant", ts: TS, text: "Here is the real reply." },
|
||
{ kind: "tool_call", ts: TS, name: "Bash", toolUseId: "t1", input: { command: "pnpm test" } },
|
||
{
|
||
kind: "result",
|
||
ts: TS,
|
||
text: "RESULTNOISE",
|
||
inputTokens: 10,
|
||
outputTokens: 5,
|
||
cachedTokens: 0,
|
||
costUsd: 0.01,
|
||
subtype: "success",
|
||
isError: false,
|
||
errors: [],
|
||
},
|
||
]);
|
||
render(items);
|
||
|
||
expect(container.querySelector('[data-testid="task-chat-phase-interstitial"]')?.textContent).toContain(
|
||
"Here is the real reply.",
|
||
);
|
||
const phaseSummary = container.querySelector<HTMLButtonElement>('[data-testid="task-chat-phase-summary"]');
|
||
expect(phaseSummary?.getAttribute("aria-expanded")).toBe("true");
|
||
const text = container.textContent ?? "";
|
||
expect(text).toContain("Here is the real reply.");
|
||
expect(text).toContain("pnpm test");
|
||
// No debug plumbing, no RunTranscriptView chrome.
|
||
for (const noise of [
|
||
"INITMARKER",
|
||
"SYSTEMNOISE",
|
||
"STDOUTNOISE",
|
||
"STDERRNOISE",
|
||
"RESULTNOISE",
|
||
"Streaming",
|
||
"LOG LINES",
|
||
"SYSTEM MESSAGES",
|
||
]) {
|
||
expect(text).not.toContain(noise);
|
||
}
|
||
});
|
||
|
||
it("renders provider-supplied reasoning in the live activity stream", () => {
|
||
const items = parse([
|
||
{ kind: "thinking", ts: TS, text: "Provider reasoning summary" },
|
||
{ kind: "assistant", ts: TS, text: "Visible answer." },
|
||
]);
|
||
expect(items[0]).toMatchObject({ kind: "thinking", streaming: false });
|
||
render(items);
|
||
|
||
expect(container.textContent).toContain("Visible answer.");
|
||
const reasoningPhase = container.querySelector<HTMLButtonElement>(
|
||
'[data-testid="task-chat-phase-summary"]',
|
||
);
|
||
expect(reasoningPhase?.textContent).toContain("Reasoning");
|
||
expect(reasoningPhase?.getAttribute("aria-expanded")).toBe("true");
|
||
|
||
expect(container.textContent).toContain("Provider reasoning summary");
|
||
const thinking = container.querySelector('[data-testid="task-chat-thinking"]');
|
||
expect(thinking?.getAttribute("data-state")).toBe("settled");
|
||
expect(
|
||
thinking?.querySelector('[data-testid="task-chat-thinking-text"]')
|
||
?.textContent,
|
||
).toContain("Provider reasoning summary");
|
||
const phaseChildren = thinking?.closest(
|
||
'[data-testid="task-chat-phase-children"]',
|
||
);
|
||
expect(phaseChildren?.classList.contains("ml-2.5")).toBe(true);
|
||
expect(phaseChildren?.classList.contains("pl-6")).toBe(true);
|
||
expect(
|
||
phaseChildren?.querySelector('[data-testid="task-chat-phase-child-rail"]'),
|
||
).not.toBeNull();
|
||
expect(thinking?.textContent).not.toContain("Reasoning");
|
||
expect(thinking?.querySelector(".shimmer-text")).toBeNull();
|
||
expect(
|
||
thinking
|
||
?.querySelector('[data-testid="task-chat-thinking-icon"]')
|
||
?.classList.contains("text-(--status-agent-running)"),
|
||
).toBe(false);
|
||
expect(
|
||
thinking
|
||
?.querySelector('[data-testid="task-chat-thinking-icon"]')
|
||
?.classList.contains("text-muted-foreground/50"),
|
||
).toBe(true);
|
||
expect(thinking?.querySelector(".task-chat-reasoning-markdown")).toBeNull();
|
||
});
|
||
|
||
it("bounds long tool targets and wraps the full value only when expanded", () => {
|
||
const longPath =
|
||
"/Users/dotta/paperclip/instances/default/companies/company-id/codex/home/skills/paperclip/references/API-reference.md";
|
||
const items = parse([
|
||
{
|
||
kind: "tool_call",
|
||
ts: TS,
|
||
name: "Read",
|
||
toolUseId: "long-read",
|
||
input: { file_path: longPath },
|
||
},
|
||
]);
|
||
const renderedTarget = items
|
||
.flatMap((item) =>
|
||
item.kind === "activity_phase" ? item.items : [item],
|
||
)
|
||
.find((item) => item.kind === "tool")?.target;
|
||
render(items);
|
||
|
||
const tool = container.querySelector<HTMLButtonElement>(
|
||
".tc-enter-tool button",
|
||
);
|
||
const collapsedTarget = tool?.querySelector(
|
||
".task-chat-collapsed-line-fade",
|
||
);
|
||
expect(tool?.classList.contains("overflow-hidden")).toBe(true);
|
||
expect(tool?.getAttribute("aria-expanded")).toBe("false");
|
||
expect(renderedTarget).toBeTruthy();
|
||
expect(collapsedTarget?.textContent).toBe(renderedTarget);
|
||
|
||
flushSync(() => tool?.click());
|
||
|
||
const expandedTarget = container.querySelector(
|
||
'[data-testid="task-chat-tool-target-detail"]',
|
||
);
|
||
expect(tool?.getAttribute("aria-expanded")).toBe("true");
|
||
expect(expandedTarget?.textContent).toBe(renderedTarget);
|
||
expect(
|
||
expandedTarget?.classList.contains("task-chat-expanded-line-wrap"),
|
||
).toBe(true);
|
||
});
|
||
|
||
it("shows the empty message when nothing renderable has streamed yet", () => {
|
||
render([], "Waiting to start...");
|
||
expect(container.textContent).toContain("Waiting to start...");
|
||
});
|
||
|
||
it("renders nothing (not even the empty message) once content exists", () => {
|
||
const items = parse([{ kind: "assistant", ts: TS, text: "streaming…" }]);
|
||
render(items, "Waiting to start...");
|
||
expect(container.textContent).not.toContain("Waiting to start...");
|
||
expect(container.textContent).toContain("streaming…");
|
||
});
|
||
});
|