Files
PaperClipAI/tests/e2e/task-loading-frame.spec.ts
T
DottaandPaperclip 27d35314be feat: connect experimental Cursor Cloud to native Runner (#18069)
## Thinking Path

> - Paperclip helps people manage AI agents at work.
> - Native Runner owns execution and task authority.
> - Operators need an explicit native Cursor Cloud choice.
> - Tools/files need company, task, session and run scope.
> - This connects setup and lifecycle to Runner Core.
> - Legacy agents retain their selected runtime/history.

## Linked Issues or Issue Description

Depends on #18068. Managed-only API placement and API-owned Stop
containment are in #18310. Refs #5664, #11803, #17299, and #17471. No
duplicate native integration was found.

## What Changed

- Add explicit native setup, Test, saved settings and dispatch with
no-prompt account/catalog/callback checks.
- Scope MCP to company, agent, task, session and run through
authenticated HTTPS. Register verified artifacts/work products; preserve
unpriced accounting, completion and budgets.
- Connect Question/Plan continuation, cold handoff and admitted fresh
sessions; recheck waiting admission under the task lock.
- Present audited Stop intent while preserving physical containment
proof; bound typed Stop metadata. Preserve title edits through
preference/navigation readiness.
- Select one live/history representation per run to prevent duplicate
settled cards. Integrate upstream task/read-state/retry/schema contracts
and repair two test fixtures.

## Verification

Core #18068 merged normally as `3910352c923a`. Product head
`5a60f541c982` has passing repository CI/build/browser checks, including
required `ci / verify` and `ci / e2e`, plus a fresh exact-head Greptile
5/5 review with zero unresolved threads. Two non-required external app
checks remain pending: Paperclip Review is queued waiting for its
assigned agent; Superagent Security Scan is reviewing the diff. These
are not claimed completed. The normal merge endpoint enforces the
repository rules; no policy or status override is used. The dependent
Top PR is addressing its fresh deferred-Stop review finding.

Product `5a60f541c982` passed 270 UI and 20 selected
Cloud/native/disk-full tests, UI/server typechecks, tokens and maps.
Top’s clean normal merge passed tokens/maps/diff checks; its matrix is
pending. Earlier receipts retain Core’s 47 Rust, 4 compiled-native
retirement and 19 settlement controls, normal Runner build, and runtime
9af build/recursive typecheck. Reproduced loading/shutdown CI fixture
failures passed 7/7 browser and 121/121 unit tests, including a
broken-unsubscribe negative control. No timeout/oracle was relaxed.

The actual-parent restack adopts 75 mainline paths, including
schema/permission and generic runtime changes, beyond the prior two
fixture repairs and client projection fix. The full difference from
hosted `9af1a5de42a2` is therefore larger than four files; backend
source also differs. The merged config-read checks match Core391, and
the Cursor placement/runtime/relay/selection modules match frozen9af;
selected affected regressions pass. Paid proof keeps its actual 9af
source/image identity. The separately tested live/history card fix is
not claimed deployed on that host.

On 9af, original saved settings survived reopening and fresh no-prompt
Test authenticated catalog/model/binding; no new Save is claimed. Fresh
Linux admission passed. With `claude-sonnet-4-5`, Artifact downloaded
exact 27 bytes and matched 121 canonical identities in complete
S3-served history. First Stop’s strict quiet FAILED on a 10.373-second
gap despite independent cancellation/no late artifact. One targeted
unchanged-sampler retry retained all 24 samples: 35.076 seconds quiet /
maximum gap 4.584 seconds, 67 ordered canonical identities, and separate
CANCELLED/artifact-absent status after the original 180-second deadline.
The pre-reload duplicate settled card is disclosed. Exact-ID cleanup for
the three new provider agents is awaiting authorization, so full grades
and the fresh Artifact’s post-cleanup download remain blocked. A
historical deleted-provider artifact was newly downloaded on 9af;
original F226 Question/Plan/reconnect and cleanup proof keep their
identities.

Retained failures: stale fixture 132/133; E8 48/135 with 87 reset-hook
failures; Mac 17 SQL failures/skips; earlier
title/startup/custody/Stop/deletion failures with unknown causes/bounded
recoveries; `dea023` Stop’s warning/50 duplicate identities; pre-repair
ACK and original Core CI failures. WSP’s 251-assertion, 7/8-suite
attempt failed physical PostgreSQL teardown; the unchanged wrapper rerun
passed 128. Retry alone establishes no cause or full local-suite pass.
All paid attempts remain recorded; vendor dollar cost is UNKNOWN.

## Risks

Experimental: Cursor independently acknowledges neither the effective
model nor instruction digest before the first prompt. Explicit values
are submitted and checked through behavior; unpriced provider dollar
cost stays UNKNOWN.

Callbacks need authenticated reachable HTTPS. Scope, revocation,
budgets, completion and cleanup remain authoritative. Operator Stop
intent is separate from physical containment. Saved legacy agents retain
their selected runtime. Prior shared title-save/deletion failures remain
disclosed.

## Model Used

OpenAI Codex, GPT-6 family, assisted with reasoning, repository tools,
code execution, browser verification, and delegated code review. The
serving model’s exact API ID and context window are not exposed. No
value is inferred from the model catalog.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used and the limits of available model
metadata
- [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 linked public issues or described the issue in this PR
- [x] I have not referenced internal or instance-local Paperclip issues
or links
- [x] My branch describes the change and contains no internal ticket ID
- [x] I have run the scoped local tests reported above; pending gates
are stated separately
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation
- [x] I have considered and documented the risks
- [x] All required CI gates pass on the current head
- [x] Fresh Greptile is 5/5 with no unresolved findings on the current
head
- [x] I will address all reviewer comments before requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-03 09:01:39 -06:00

232 lines
14 KiB
TypeScript

import { expect, test, type APIRequestContext, type APIResponse } from "@playwright/test";
async function json(response: APIResponse) {
expect(response.ok(), `${response.status()} ${await response.text()}`).toBe(true);
return response.json();
}
async function createTask(request: APIRequestContext) {
const company = await json(await request.post("/api/companies", { data: { name: "Loading frame verification" } }));
const title = "Investigate a long-running workspace and preserve its saved findings, document cards, and pending review without moving the initial reading position";
const issue = await json(await request.post(`/api/companies/${company.id}/issues`, { data: {
title, status: "backlog", description: "## Saved investigation\n\n" + "Preserve the original report and all saved evidence. ".repeat(20),
} }));
return { company, issue, title, route: `/${company.issuePrefix}/issues/${issue.identifier}` };
}
for (const mobile of [false, true]) test(`a rich task uses one stable loading frame (${mobile ? "mobile" : "desktop"})`, async ({ page, request }, info) => {
test.setTimeout(60_000);
await page.setViewportSize(mobile ? { width: 390, height: 844 } : { width: 1280, height: 720 });
const fixture = await createTask(request);
try {
for (let index = 0; index < 20; index++) await json(await request.post(`/api/issues/${fixture.issue.id}/comments`, { data: {
body: `## Saved findings ${index}\n\n` + "Checked the recorded evidence and retained the result for review. ".repeat(12),
} }));
await json(await request.put(`/api/issues/${fixture.issue.id}/documents/plan`, { data: {
title: "Investigation plan", format: "markdown", body: "# Plan\n\nKeep the findings with the original task.",
} }));
await json(await request.post(`/api/issues/${fixture.issue.id}/work-products`, { data: {
type: "pull_request", provider: "github", title: "Saved investigation patch", status: "active",
url: "https://github.com/example/layout-fixture/pull/42", metadata: { repository: "example/layout-fixture", number: 42 },
} }));
await json(await request.post(`/api/issues/${fixture.issue.id}/interactions`, { data: {
kind: "request_confirmation", title: "Review the saved patch", continuationPolicy: "none",
payload: { version: 1, prompt: "Approve the saved findings?", acceptLabel: "Approve patch", rejectLabel: "Request changes" },
} }));
await page.route("**/api/workspace-preferences/me", async route => {
const response = await route.fetch();
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: true } });
});
await page.addInitScript(() => {
const frames: Array<{ ready: boolean; headerVisible: boolean; loading: number[] | null; loadingComposer: number[] | null; composer: number[] | null; latestY?: number; scrollHeight?: number; loadingFont?: string; titleFont?: string }> = [];
Object.assign(window, { taskLoadingFrames: frames });
const sample = () => {
const box = (selector: string) => {
const element = document.querySelector(selector);
if (!element || getComputedStyle(element).visibility !== "visible") return null;
const rect = element.getBoundingClientRect();
if (rect.width === 0 || rect.height === 0) return null;
return [rect.x, rect.y, rect.width, rect.height];
};
const font = (selector: string) => {
const element = document.querySelector(selector);
return element ? getComputedStyle(element).font : undefined;
};
const header = document.querySelector('[data-testid="issue-detail-header"]');
const bounds = header?.getBoundingClientRect();
frames.push({
ready: !!document.querySelector('[data-testid="task-chat-thread"] > [aria-busy="false"]'),
headerVisible: !!header && getComputedStyle(header).visibility === "visible" && bounds!.bottom > 60 && bounds!.top < innerHeight,
loading: box('[data-testid="task-chat-loading-frame"]'),
loadingComposer: box('[data-testid="task-chat-loading-composer"] .paperclip-task-chat-composer'),
composer: box('[data-testid="task-chat-composer-stack"] .paperclip-task-chat-composer'),
latestY: [...document.querySelectorAll('[id^="comment-"]')].at(-1)?.getBoundingClientRect().y,
scrollHeight: document.querySelector('[data-testid="task-chat-scroller"]')?.scrollHeight,
loadingFont: font('[data-slot="task-loading-title"]'),
titleFont: font('[data-testid="task-chat-history-content"] [data-testid="issue-detail-header"] h2'),
});
requestAnimationFrame(sample);
};
requestAnimationFrame(sample);
});
await page.goto(fixture.route);
await expect(page.getByTestId("task-chat-thread").locator(':scope > [aria-busy="false"]')).toBeVisible();
await expect(page.getByRole("button", { name: "Approve patch", exact: true })).toBeVisible();
await page.waitForTimeout(500);
const frames = await page.evaluate(() => (window as unknown as { taskLoadingFrames: Array<{ ready: boolean; headerVisible: boolean; loading: number[] | null; loadingComposer: number[] | null; composer: number[] | null; latestY?: number; scrollHeight?: number; loadingFont?: string; titleFont?: string }> }).taskLoadingFrames);
await info.attach("loading-frames", { body: JSON.stringify(frames), contentType: "application/json" });
expect(frames.filter(frame => !frame.ready && frame.headerVisible)).toEqual([]);
const loading = frames.filter(frame => frame.loading);
const ready = frames.filter(frame => frame.ready && frame.latestY !== undefined);
expect(loading.length).toBeGreaterThan(1);
expect(ready.length).toBeGreaterThan(5);
for (let dimension = 0; dimension < 4; dimension++) {
const values = loading.map(frame => frame.loading![dimension]);
expect(Math.max(...values) - Math.min(...values)).toBeLessThanOrEqual(2);
expect(Math.abs(loading.at(-1)!.loadingComposer![dimension] - ready[0].composer![dimension])).toBeLessThanOrEqual(2);
}
expect(loading.at(-1)!.loadingFont).toBe(ready[0].titleFont);
expect(Math.max(...ready.map(frame => frame.latestY!)) - Math.min(...ready.map(frame => frame.latestY!))).toBeLessThanOrEqual(2);
expect(new Set(ready.map(frame => frame.scrollHeight)).size).toBe(1);
} finally {
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
}
});
test("Classic startup does not guess a chat layout while personal preferences are pending", async ({ page, request }) => {
const fixture = await createTask(request);
let release!: () => void;
const preferenceReady = new Promise<void>(resolve => { release = resolve; });
try {
await page.route("**/api/instance/settings/experimental", async route => {
const response = await route.fetch();
await route.fulfill({ json: { ...await response.json(), enableClassicTaskInterface: true, enableStreamlinedUi: false } });
});
await page.route("**/api/workspace-preferences/me", async route => {
await preferenceReady;
const response = await route.fetch();
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: false } });
});
await page.goto(fixture.route);
await expect(page.getByTestId("shell-configuration-loading")).toBeVisible();
await expect(page.locator("[data-task-chat-shell]")).toHaveCount(0);
const preparedOutlet = page.getByTestId("shell-prepared-outlet");
await expect(preparedOutlet).toHaveAttribute("hidden", "");
await expect(preparedOutlet).toHaveAttribute("inert", "");
await expect(preparedOutlet).toHaveAttribute("aria-hidden", "true");
await expect(page.getByTestId("issue-detail-header")).toBeHidden();
await expect(page.getByRole("heading", { name: fixture.title, exact: true })).toHaveCount(0);
release();
await expect(page.getByTestId("issue-detail-header").getByRole("heading", { name: fixture.title, exact: true })).toBeVisible();
await expect(preparedOutlet).not.toHaveAttribute("hidden", "");
await expect(preparedOutlet).not.toHaveAttribute("inert", "");
await expect(preparedOutlet).not.toHaveAttribute("aria-hidden", "true");
await expect(page.locator("[data-task-chat-shell]")).toHaveCount(0);
} finally {
release();
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
}
});
test("a stalled web font does not hide an otherwise prepared conversation indefinitely", async ({ page, request }) => {
const fixture = await createTask(request);
let release!: () => void;
const fontReady = new Promise<void>(resolve => { release = resolve; });
try {
await page.route("**/api/workspace-preferences/me", async route => {
const response = await route.fetch();
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: true } });
});
await page.route("**/*.woff2", async route => { await fontReady; await route.abort(); });
await page.goto(fixture.route, { waitUntil: "domcontentloaded" });
await expect(page.getByTestId("task-chat-loading-frame")).toBeVisible();
await expect(page.getByTestId("task-chat-thread").locator(':scope > [aria-busy="false"]')).toBeVisible({ timeout: 5000 });
await expect(page.getByTestId("task-chat-composer-stack").locator('[contenteditable="true"]')).toBeEditable();
} finally {
release();
await page.unrouteAll({ behavior: "wait" });
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
}
});
for (const coordinator of [false, true]) test(`mobile chrome stays fixed when personal preferences resolve (Coordinator=${coordinator})`, async ({ page, request }, info) => {
await page.setViewportSize({ width: 390, height: 844 });
const fixture = await createTask(request);
let release!: () => void;
const preferenceReady = new Promise<void>(resolve => { release = resolve; });
await page.addInitScript(() => {
const frames: number[][] = [];
Object.assign(window, { mobileShellFrames: frames });
const sample = () => {
const shell = document.querySelector(".paperclip-app-shell");
if (shell && shell.getBoundingClientRect().width > 0) {
const rects = [".app-breadcrumb", ".mobile-bottom-nav", "#main-content"].map(selector => document.querySelector(selector)!.getBoundingClientRect());
frames.push([innerWidth, innerHeight, scrollX, scrollY, ...rects.flatMap((rect, index) => index === 2 ? [rect.x, rect.y, rect.width] : [rect.x, rect.y, rect.width, rect.height])]);
}
requestAnimationFrame(sample);
};
requestAnimationFrame(sample);
});
try {
await page.route("**/api/instance/settings/experimental", async route => {
const response = await route.fetch();
await route.fulfill({ json: { ...await response.json(), enableClassicTaskInterface: true, enableStreamlinedUi: false } });
});
await page.route("**/api/workspace-preferences/me", async route => {
await preferenceReady;
const response = await route.fetch();
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: coordinator } });
});
await page.goto(fixture.route);
await expect(page.getByTestId("shell-configuration-loading")).toBeVisible();
await expect(page.locator(".paperclip-app-shell")).toBeHidden();
expect(await page.evaluate(() => (window as unknown as { mobileShellFrames: number[][] }).mobileShellFrames)).toEqual([]);
release();
if (coordinator) await expect(page.getByTestId("task-chat-thread").locator(':scope > [aria-busy="false"]')).toBeVisible();
else await expect(page.getByTestId("issue-detail-header").getByRole("heading", { name: fixture.title, exact: true })).toBeVisible();
await page.waitForTimeout(300);
const frames = await page.evaluate(() => (window as unknown as { mobileShellFrames: number[][] }).mobileShellFrames);
await info.attach("mobile-preference-chrome", { body: JSON.stringify(frames), contentType: "application/json" });
expect(frames.length).toBeGreaterThan(5);
for (let dimension = 0; dimension < frames[0].length; dimension++) {
const values = frames.map(frame => frame[dimension]);
expect(Math.max(...values) - Math.min(...values)).toBeLessThanOrEqual(2);
}
} finally {
release();
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
}
});
test("a seeded Classic loading title uses the resolved title typography", async ({ page, request }) => {
const fixture = await createTask(request);
let release!: () => void;
const coreReady = new Promise<void>(resolve => { release = resolve; });
try {
await page.route("**/api/instance/settings/experimental", async route => {
const response = await route.fetch();
await route.fulfill({ json: { ...await response.json(), enableClassicTaskInterface: true, enableStreamlinedUi: false } });
});
await page.route("**/api/workspace-preferences/me", async route => {
const response = await route.fetch();
await route.fulfill({ json: { ...await response.json(), coordinatorWorkspaceEnabled: false } });
});
await page.goto(`/${fixture.company.issuePrefix}/issues`);
await page.getByRole("link").filter({ hasText: fixture.title }).first().click();
await expect(page.getByTestId("issue-detail-header").getByRole("heading", { name: fixture.title, exact: true })).toBeVisible();
await page.route("**/api/issues/*", async route => { await coreReady; await route.continue(); });
await page.reload({ waitUntil: "domcontentloaded" });
const loadingTitle = page.getByRole("heading", { name: fixture.title, exact: true });
await expect(loadingTitle).toBeVisible();
await expect(page.getByTestId("issue-detail-header")).toHaveCount(0);
const font = await loadingTitle.evaluate(element => getComputedStyle(element).font);
release();
const title = page.getByTestId("issue-detail-header").getByRole("heading", { name: fixture.title, exact: true });
await expect(title).toBeVisible();
expect(await title.evaluate(element => getComputedStyle(element).font)).toBe(font);
} finally {
release();
await request.patch(`/api/companies/${fixture.company.id}`, { data: { status: "archived" } });
}
});