mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-09 07:10:34 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work. > - People enter that work through the workspace, agent conversations, and tasks. > - Coordinator and Agent Chat still require experimental enrollment. > - Task link prefetches do not warm the compact queries used by the default task view. Chat also waits for a request when its navigation list already holds the conversation. > - This pull request makes Coordinator and Agent Chat standard and reuses the reads needed for navigation. > - People can choose Classic workspace in Experimental settings. Cached work can appear while fresh data loads. ## Linked Issues or Issue Description **What existing behavior does this improve?** Workspace selection, Agent Chat availability, and navigation between Chat, Tasks, and task details. **Subsystem affected** Cross-cutting: UI, workspace preferences, instance settings, and the database migration. **Current behavior** People must enable Coordinator and Agent Chat in Experimental settings. Opening a task can repeat requests because prefetch warms the full detail and comment queries, while the default view reads compact task data and a recent comment window. Opening Chat waits for a detail request even when the current person's conversation list contains it. **Proposed behavior** Coordinator is the standard workspace for everyone. Experimental settings offer Classic workspace, off by default. Old Coordinator experiment values do not select Classic. Agent Chat is available to everyone, including instances with an old saved or managed off value. Task link intent warms the queries used by the mounted view. Chat can use the current person's company-scoped conversation list during refresh. **Reason and benefit** People can use the standard workspace without setup. Repeat navigation can show cached content while the server refreshes it. **Breaking changes** Existing Coordinator experiment and Agent Chat off values no longer disable these surfaces. Classic requires an explicit new opt-in. The workspace API keeps its existing response shape and audit checks. The migration retains legacy values and adds a separate Classic preference. Execution permissions, company access, and chat privacy checks still apply. **Additional context** Roadmap check: this graduates existing surfaces and improves their navigation. It does not add a new agent execution capability. Duplicate searches found no open Coordinator workspace PR. Related server cache work, Refs: #17828, addresses compact issue-list invalidation; this PR addresses client navigation queries. ## What Changed - Add a default-off Classic workspace preference. Derive the existing workspace API response from that choice. Keep personal persistence, account isolation, and audited writes in the workspace preference service. - Replace the Coordinator experiment control with Classic workspace. Use Coordinator while preferences load. Update the existing settings examples and navigation recipe. - Retire the Agent Chat experiment control. Ignore old stored and managed off values. Retain the compatibility key and the existing execution and access checks. - Reuse account- and company-scoped chat list data with its original freshness timestamp. - Share compact task and recent-comment query options between prefetch and the task view. Keep full-history prefetch for Classic tasks and expanded history. - Add upgrade, replay, cache, account isolation, and browser switching regressions. Update product, database, development, and roadmap documentation. ## Verification - Targeted preference, settings, migration, cache, and UI regression tests passed during implementation. The cache tests hold refresh requests pending and check that content still renders. They also check account isolation and stale refresh behavior. - A real browser test verified fresh Coordinator defaults, Classic opt-in persistence, and return to Coordinator. It used an isolated source checkout with fresh data on macOS. - Token, migration numbering and safety, map, and Storybook catalog checks pass after the rebase. - Repository typecheck and build pass. Typecheck and token gates also pass after review repairs. The broad local run passed all six chat integration shards (1,931 tests). It then found the host-CLI-dependent recovery fixture described below. Its remaining duplicate work was stopped after the full current-head CI matrix passed; this is not a claim that the broad local command completed green. - Review repairs passed 419 UI/migration fixture tests, 19 Coordinator navigation tests, and all 214 tests in the five affected server suites. The 24 Chat/workspace browser tests pass, including standard Coordinator switching and explicit Classic persistence. - The broader browser repair run passed 85 tests. It retained two failed assertions and skipped five later serial cases. The affected files then passed all 11 tests after the fixes: reopen the desktop panel after reload and open More for Audit and Connectors. This includes the five serial cases that had not run. - The broad local suite exposed a recovery fixture that executed the host Codex CLI during a simulated remote probe. On a host with Codex 0.154.0, model fallback broke its fixed-model assertion. The fake sandbox now reports Codex 0.160.0. All 20 selected recovery/provider compatibility cases pass after the repair. - A CLI company import/export suite timed out during server startup in the second CI run. The port fallback is intentional in that fixture. No root cause was established. That suite passes on the final commit in CI. This records recovery, not a claimed product fix for the earlier timeout. - The first CI run exposed remaining assumptions about the retired flags and Classic UI. The repair commit updates those fixtures and navigation steps. It also restores the missing enabled Cases destination in Coordinator. Earlier local recovery attempts used the wrong fixture notification and advanced fake time during live execution; the corrected tests use the subscribed recovery queue and wall time during execution. - Greptile reviewed commit `98972b030d4505d838427a2fca6b196b8cad6d47` at **5/5** with no new comments. The original finding is resolved. - Current-head CI is green: **56 successful checks**, with three checks skipped by workflow filters. This includes typecheck, build, the complete Vitest matrix, all eight browser shards, Runner verification, release checks, and security checks. [Final CI run](https://github.com/paperclipai/paperclip/actions/runs/42132651414). - Typecheck caught missing `pid` and `startedAt` fields in the simulated command result. The fixture now returns the complete process contract, and the server test-layer typecheck passes. - Storybook catalog alignment was checked. Storybook play tests were not run. Hosted latency and cold bundle loading were not measured. ## Risks - The new default changes the workspace for people who previously left the Coordinator experiment off. They can opt into Classic in Experimental settings. - The additive migration must run before the new server code. It is safe to replay and preserves explicit Classic choices. - Cached content can be stale during background refresh. Existing query invalidation and source timestamps still control freshness. - These changes reduce avoidable loading waits. They do not establish a measured improvement in hosted request latency or initial bundle download time. ## Model Used OpenAI Codex, based on GPT-6, with reasoning, repository tools, code execution, and browser automation. The exact serving revision and context-window size are not exposed in this session. ## 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 --------- Co-authored-by: Scott Tong <scott@scottsmbpm5max.lan> Co-authored-by: Paperclip <noreply@paperclip.ing>
182 lines
12 KiB
TypeScript
182 lines
12 KiB
TypeScript
import { randomUUID } from "node:crypto";
|
|
import { readFile } from "node:fs/promises";
|
|
import { expect, test, type APIRequestContext, type APIResponse, type Locator, type Page } from "@playwright/test";
|
|
import { expectTaskPanelTab } from "./helpers/task-panel-tabs";
|
|
|
|
// Real task UI, document revisions, attachment storage and pause holds.
|
|
// Only the explicit failed-upload response in the recovery test is injected.
|
|
async function json(response: APIResponse) {
|
|
expect(response.ok(), `${response.status()}: ${await response.text()}`).toBe(true);
|
|
return response.json();
|
|
}
|
|
|
|
async function setup(page: Page, request: APIRequestContext, mobile = false) {
|
|
await page.setViewportSize(mobile ? { width: 390, height: 844 } : { width: 1440, height: 960 });
|
|
await page.addInitScript(() => localStorage.setItem("paperclip:panel-visible", "true"));
|
|
const companies = await json(await request.get("/api/companies"));
|
|
const company = companies.find((row: { name: string }) => row.name === "Artifact Upload Review") ?? await json(await request.post("/api/companies", { data: { name: `Artifact uploads ${randomUUID()}` } }));
|
|
const issue = await json(await request.post(`/api/companies/${company.id}/issues`, {
|
|
data: { title: `Upload handoff files ${randomUUID().slice(0, 8)}`, status: "backlog", assigneeAgentId: null, assigneeUserId: null },
|
|
}));
|
|
await json(await request.post(`/api/issues/${issue.id}/tree-holds`, { data: { mode: "pause" } }));
|
|
await page.goto(`/${company.issuePrefix}/issues/${issue.identifier}${mobile ? "?from=inbox&fromHref=%2Finbox%2Fmine" : ""}`);
|
|
await expect(page.getByRole("heading", { name: issue.title, exact: true })).toBeVisible();
|
|
if (mobile) {
|
|
await page.getByRole("button", { name: "More actions", exact: true }).click();
|
|
await page.getByRole("button", { name: "Properties", exact: true }).click();
|
|
} else {
|
|
await page.getByRole("button", { name: "Show properties", exact: true }).click();
|
|
}
|
|
const panel = mobile ? page.getByTestId("mobile-task-side-panel") : page.locator("aside").filter({ has: page.getByRole("button", { name: "Open a new tab", exact: true }) });
|
|
await panel.getByRole("option", { name: "Artifacts", exact: true }).click();
|
|
await expectTaskPanelTab(panel, mobile, "Artifacts");
|
|
await expect(panel.getByRole("button", { name: "Upload files", exact: true })).toBeVisible();
|
|
return { company, issue, panel };
|
|
}
|
|
|
|
async function chooseFiles(page: Page, panel: Locator, files: { name: string; mimeType: string; buffer: Buffer }[]) {
|
|
const chooser = page.waitForEvent("filechooser");
|
|
await panel.getByRole("button", { name: "Upload files", exact: true }).click();
|
|
await (await chooser).setFiles(files);
|
|
}
|
|
|
|
async function assertStillPaused(request: APIRequestContext, issueId: string) {
|
|
const issue = await json(await request.get(`/api/issues/${issueId}`));
|
|
expect(issue.status).toBe("backlog");
|
|
expect(issue.assigneeAgentId).toBeNull();
|
|
expect(issue.assigneeUserId).toBeNull();
|
|
const state = await json(await request.get(`/api/issues/${issueId}/tree-control/state`));
|
|
expect(state.activePauseHold).not.toBeNull();
|
|
expect(await json(await request.get(`/api/issues/${issueId}/comments`))).toEqual([]);
|
|
expect(await json(await request.get(`/api/issues/${issueId}/runs`))).toEqual([]);
|
|
}
|
|
|
|
for (const mobile of [false, true]) {
|
|
test(`upload documents and files while a task remains paused (mobile=${mobile})`, async ({ page, request }, testInfo) => {
|
|
const { issue, panel } = await setup(page, request, mobile);
|
|
const markdown = "# Engineering handoff\n\nStart with the loop inventory and preserve current task ownership.";
|
|
const csv = "path,pattern\ndelivery,event-driven\nroutines,clock-driven";
|
|
await chooseFiles(page, panel, [
|
|
{ name: "core-handoff.md", mimeType: "text/markdown", buffer: Buffer.from(markdown) },
|
|
{ name: "loop-inventory.csv", mimeType: "text/csv", buffer: Buffer.from(csv) },
|
|
]);
|
|
const document = panel.locator("#document-core-handoff");
|
|
await expect(document.getByRole("heading", { name: "Engineering handoff", exact: true })).toBeVisible();
|
|
await expect(document.getByText("Start with the loop inventory and preserve current task ownership.", { exact: true })).toBeVisible();
|
|
await expect(panel.getByRole("link", { name: "Download loop-inventory.csv", exact: true })).toBeVisible();
|
|
await expectTaskPanelTab(panel, mobile, "Artifacts");
|
|
const download = page.waitForEvent("download");
|
|
await panel.getByRole("link", { name: "Download loop-inventory.csv", exact: true }).click();
|
|
const downloaded = await download;
|
|
expect(downloaded.suggestedFilename()).toBe("loop-inventory.csv");
|
|
expect(await readFile((await downloaded.path())!, "utf8")).toBe(csv);
|
|
await document.getByRole("button", { name: "Collapse core-handoff document", exact: true }).click();
|
|
await expect(document.getByText("Start with the loop inventory and preserve current task ownership.", { exact: true })).toBeHidden();
|
|
await document.getByRole("button", { name: "Expand core-handoff document", exact: true }).click();
|
|
await expect(document.getByText("Start with the loop inventory and preserve current task ownership.", { exact: true })).toBeVisible();
|
|
await assertStillPaused(request, issue.id);
|
|
await page.reload();
|
|
await expect(page.getByRole("heading", { name: issue.title, exact: true })).toBeVisible();
|
|
const documents = await json(await request.get(`/api/issues/${issue.id}/documents`));
|
|
const attachments = await json(await request.get(`/api/issues/${issue.id}/attachments`));
|
|
expect(documents).toHaveLength(1);
|
|
expect(documents[0].key).toBe("core-handoff");
|
|
expect(documents[0].body).toBe(markdown);
|
|
expect(attachments).toHaveLength(1);
|
|
expect(attachments[0].originalFilename).toBe("loop-inventory.csv");
|
|
if (mobile) {
|
|
await page.getByRole("button", { name: "More actions", exact: true }).click();
|
|
await page.getByRole("button", { name: "Properties", exact: true }).click();
|
|
} else {
|
|
await page.getByRole("button", { name: "Show properties", exact: true }).click();
|
|
}
|
|
await expect(document.getByRole("heading", { name: "Engineering handoff", exact: true })).toBeVisible();
|
|
await expect(document.getByText("Start with the loop inventory and preserve current task ownership.", { exact: true })).toBeVisible();
|
|
await assertStillPaused(request, issue.id);
|
|
await page.screenshot({ path: testInfo.outputPath("uploaded-handoff-persisted.png"), fullPage: true });
|
|
});
|
|
}
|
|
|
|
test("the entire populated panel accepts a drop and preserves an existing document", async ({ page, request }, testInfo) => {
|
|
const { issue, panel } = await setup(page, request);
|
|
const original = "# Original handoff\n\nPreserve this version.";
|
|
await chooseFiles(page, panel, [{ name: "handoff.md", mimeType: "text/markdown", buffer: Buffer.from(original) }]);
|
|
const document = panel.locator("#document-handoff");
|
|
await expect(document.getByRole("heading", { name: "Original handoff", exact: true })).toBeVisible();
|
|
const originalDocument = await json(await request.get(`/api/issues/${issue.id}/documents/handoff`));
|
|
const transfer = await page.evaluateHandle(() => {
|
|
const data = new DataTransfer();
|
|
data.items.add(new File(["# Additional handoff\n\nNew reference, separate document."], "handoff.md", { type: "text/markdown" }));
|
|
data.items.add(new File(["Check saved deadlines before enabling instance sleep."], "verification.txt", { type: "text/plain" }));
|
|
return data;
|
|
});
|
|
const header = panel.locator("[data-presentation] > header");
|
|
await header.dispatchEvent("dragenter", { dataTransfer: transfer });
|
|
const overlay = panel.locator("[data-artifact-drop-overlay]");
|
|
await expect(overlay).toBeVisible();
|
|
const frameBounds = await panel.locator("[data-presentation]").boundingBox();
|
|
const overlayBounds = await overlay.boundingBox();
|
|
expect(overlayBounds).toEqual(frameBounds);
|
|
await page.screenshot({ path: testInfo.outputPath("entire-panel-dropzone.png"), fullPage: true });
|
|
await header.dispatchEvent("dragleave", { dataTransfer: transfer });
|
|
await expect(overlay).toBeHidden();
|
|
await header.dispatchEvent("dragenter", { dataTransfer: transfer });
|
|
await document.dispatchEvent("drop", { dataTransfer: transfer });
|
|
await expect(panel.locator("#document-handoff, #document-handoff-2")).toHaveCount(2);
|
|
await expect(document.getByText("Preserve this version.", { exact: true })).toBeVisible();
|
|
await expect(panel.locator("#document-handoff-2").getByText("New reference, separate document.", { exact: true })).toBeVisible();
|
|
await expect(panel.getByText("verification.txt", { exact: true }).first()).toBeVisible();
|
|
const documents = await json(await request.get(`/api/issues/${issue.id}/documents`));
|
|
expect(documents.map((row: { key: string }) => row.key).sort()).toEqual(["handoff", "handoff-2"]);
|
|
const preserved = documents.find((row: { key: string }) => row.key === "handoff");
|
|
expect(preserved.body).toBe(original);
|
|
expect(preserved.latestRevisionId).toBe(originalDocument.latestRevisionId);
|
|
expect(documents.find((row: { key: string }) => row.key === "handoff-2").body).toBe("# Additional handoff\n\nNew reference, separate document.");
|
|
await assertStillPaused(request, issue.id);
|
|
});
|
|
|
|
test("a failed upload stays local and retry preserves the successful files", async ({ page, request }) => {
|
|
const { issue, panel } = await setup(page, request);
|
|
let fail = true;
|
|
await page.route(`**/api/companies/*/issues/${issue.id}/attachments`, async route => {
|
|
if (fail) { fail = false; await route.fulfill({ status: 422, contentType: "application/json", body: JSON.stringify({ error: "Upload failed. Try again." }) }); }
|
|
else await route.continue();
|
|
});
|
|
await chooseFiles(page, panel, [
|
|
{ name: "failed-reference.txt", mimeType: "text/plain", buffer: Buffer.from("Reference restored after retry.") },
|
|
{ name: "saved-reference.txt", mimeType: "text/plain", buffer: Buffer.from("Keep this successful file.") },
|
|
]);
|
|
await expect(panel.getByRole("button", { name: "Retry", exact: true })).toBeVisible();
|
|
await expect.poll(async () => (await json(await request.get(`/api/issues/${issue.id}/attachments`))).length).toBe(1);
|
|
await panel.getByRole("button", { name: "Retry", exact: true }).click();
|
|
await expect(panel.getByRole("button", { name: "Retry", exact: true })).toBeHidden();
|
|
await expect.poll(async () => (await json(await request.get(`/api/issues/${issue.id}/attachments`))).map((row: { originalFilename: string }) => row.originalFilename).sort()).toEqual(["failed-reference.txt", "saved-reference.txt"]);
|
|
await assertStillPaused(request, issue.id);
|
|
});
|
|
|
|
test("reserved filenames create visible documents without replacing internal revisions", async ({ page, request }) => {
|
|
const { issue, panel } = await setup(page, request);
|
|
const reserved = ["artifact-review-notes", "continuation-summary", "pipeline-case-body"];
|
|
const originals = new Map<string, string>();
|
|
for (const key of reserved) {
|
|
const document = await json(await request.put(`/api/issues/${issue.id}/documents/${key}`, {
|
|
data: { title: "Internal context", format: "markdown", body: `Preserve the internal ${key} document.`, baseRevisionId: null },
|
|
}));
|
|
originals.set(key, document.latestRevisionId);
|
|
}
|
|
await chooseFiles(page, panel, reserved.map(key => ({ name: `${key}.md`, mimeType: "text/markdown", buffer: Buffer.from(`# Uploaded ${key}\n\nThis reference must stay visible.`) })));
|
|
await expect(panel.locator('[id^="document-upload-"]')).toHaveCount(3);
|
|
for (const key of reserved) {
|
|
const document = panel.locator(`#document-upload-${key}`);
|
|
await expect(document.getByRole("heading", { name: `Uploaded ${key}`, exact: true })).toBeVisible();
|
|
await expect(document.getByText("This reference must stay visible.", { exact: true })).toBeVisible();
|
|
}
|
|
const documents = await json(await request.get(`/api/issues/${issue.id}/documents`));
|
|
expect(documents.filter((row: { key: string }) => row.key.startsWith("upload-")).map((row: { key: string }) => row.key).sort()).toEqual(reserved.map(key => `upload-${key}`).sort());
|
|
for (const key of reserved) {
|
|
const document = await json(await request.get(`/api/issues/${issue.id}/documents/${key}`));
|
|
expect(document.latestRevisionId).toBe(originals.get(key));
|
|
}
|
|
await assertStillPaused(request, issue.id);
|
|
});
|