Files
PaperClipAI/tests/runner-e2e/current-ui-controls.spec.ts
T
DottaandPaperclip 62033b9994 fix(qa): schedule recovered cleanup promptly and wait for task panels (#21660)
## Thinking Path

> - Paperclip lets people manage AI agents and their saved work.
> - QA journeys check browser controls and the cleanup of owned agent
resources.
> - A recovered workspace queues sandbox destruction after its files are
saved.
> - The cleanup queue treated that first attempt as a retry and waited
five minutes.
> - Agent termination correctly waited for destruction, so QA cleanup
failed first.
> - This PR runs that first cleanup attempt promptly and keeps the
existing safety gates.
> - It also waits for task-panel transitions before the browser acts
again.

## Linked Issues or Issue Description

**What happened?**

The full scheduled QA smoke completed with 23 passed and 1 failed.
Stop/redirect passed all eleven behavior checks but failed cleanup. The
cancelled run had a saved workspace and a bound stop receipt before
agent termination. Its sandbox was destroyed about five minutes later.
The shared cleanup schedule applied the retry delay before the first
destruction attempt.

The browser regressions also found that the current panel helper can
consume all four actions while an opener remains visible during panel
mounting.

**Expected behavior**

A recovered workspace's first cleanup attempt runs on the next eligible
worker pass. A failed attempt retains normal backoff. Agent termination
still waits for completed resource cleanup. Task-panel navigation waits
for the next controls before it acts again.

**Steps to reproduce**

1. Queue recovered-workspace destruction after the cleanup worker has
become idle.
2. Read the next cleanup deadline and advance one normal worker pass.
Before this fix, the deadline is five minutes late and no teardown runs.
3. Open task document controls with a delayed side-panel transition.
Before the panel fix, both collapsed-panel controls fail.

Refs #19224 and #19292 for retaining stop proof during workspace
recovery. This change keeps the full cleanup requirement for agent
termination. Current master supplies the shared task-panel helper; this
branch uses it and retains additional browser regressions.

## What Changed

- Use one shared first-attempt predicate for the cleanup deadline, sweep
selection and ownership report. It now includes recovered workspace
cleanup bound to the same run.
- Preserve worker spacing, in-flight claims, ownership and saved-file
checks, retry delays and attempt limits.
- Wait for panel controls after opening the panel. Wait for the selected
tab or menu action to finish.
- Add real PostgreSQL cleanup regressions, keep the Chromium controls,
and document the cleanup timing.

## Verification

Tested on Linux x86_64, Node v25.9.0. Local commit
`7c8e0f12aa4b19aaf53669141ab3299ce76db963` and published head
`892c5dd4b4638796a138400d8bbe30aee19c71dd` have the same tree,
`d135a98bdff58e3320cdc83976ffe1cf47f48b66`.

- Red: both new real-PostgreSQL cleanup tests failed on the old code.
The deadline was five minutes late and the first normal sweep made zero
teardown calls.
- Green: 87 cleanup, ownership and lifecycle tests pass. The
restored-work case stays unconfirmed until the real cleanup worker
destroys the lease; failure still backs off and the worker becomes idle
again.
- Red after master integration: both delayed document-panel browser
cases failed. Green: all 18 Chromium support checks pass.
- 77 journey contract tests pass.
- Product E2E typecheck passes with the documented low-memory path. The
initial ordinary attempt was killed by the local memory limit and is not
counted as a pass.
- The only follow-up after the passing checks removes new code comments
to follow the contribution guide. Runtime and test behavior are
unchanged. Final-head [CI run
43714742904](https://github.com/paperclipai/paperclip/actions/runs/43714742904)
completed successfully at this exact head. All 63 PR checks are
terminal: 58 success, 2 neutral and 3 conditional skips; no failures or
pending checks. Typecheck, build, tests and the final verify gate pass.
Greptile and Paperclip Review both score this head 5/5 with no
actionable findings; both historical inline threads are resolved.
- Hosted QA recovery is still unverified. No extra model run, merge,
deployment or QA setting change was made.

## Risks

Recovered workspace destruction starts sooner. Existing producer,
file-preservation, ownership, claim and provider checks still decide
whether teardown is allowed. Failed attempts retain the existing
cooldown. Agent termination and purge gates are unchanged. The panel
helper waits for visible controls and still fails when controls or saved
values are absent.

The PostgreSQL integration uses a controlled provider boundary. It does
not prove a new live Daytona or deployed QA pass. That requires the
fixed revision on QA and a later normal scheduled smoke.

## Model Used

OpenAI GPT-6-based Codex, with tool use and code execution. The host
does not expose a more specific model ID or context-window size for this
run.

## 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 references)
- [x] My branch name describes the change 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: Paperclip <noreply@paperclip.ing>
2026-11-15 08:52:49 -06:00

74 lines
5.3 KiB
TypeScript

import { expect, test } from "@playwright/test";
import { newProjectButton } from "./product-journeys/project-context-flow.js";
import { storyArtifactDownloadLink } from "./story-artifact.js";
import { taskProperties } from "./product-journeys/task-properties.js";
import { showPropertyRow } from "./product-journeys/task-panel.js";
import type { JourneyContext, JourneyEvidence, TargetSession } from "./product-journeys/types.js";
const id = "11111111-2222-4333-8444-555555555555";
test("property reads select Properties from an open panel and exclude inactive duplicate rows", async ({ page }) => {
const row = (value: string) => `<div data-property-row><span data-property-label="Project">Project</span><span data-property-value>${value}</span></div>`;
await page.setContent(`<aside inert aria-hidden="true">${row("Stale project")}</aside>
<aside><button role="tab" onclick="document.querySelector('#properties').hidden=false">Properties</button><section id="properties" hidden>${row("Saved project")}</section></aside>`);
const property = await showPropertyRow(page, "Project");
await expect(property.locator("[data-property-value]")).toHaveText("Saved project");
});
test("property reads cannot use an inert row when the panel has no open control", async ({ page }) => {
await page.setContent('<aside inert aria-hidden="true"><div data-property-row><span data-property-label="Project">Project</span><span data-property-value>Saved project</span></div></aside>');
await expect(showPropertyRow(page, "Project")).rejects.toThrow();
});
test("assignment opens the current side panel again after reload and verifies the saved user", async ({ page }) => {
const origin = "https://assignment-controls.test", title = "Owned assignment task", userId = "owned-user";
let assigned = false;
await page.route(`${origin}/**`, async route => {
const pathname = new URL(route.request().url()).pathname;
if (pathname === "/assign") {
assigned = true;
await route.fulfill({ json: {} });
return;
}
await route.fulfill({ contentType: "text/html", body: pathname === "/QA/issues"
? `<a href="/QA/issues/QA-201">${title}</a>`
: `<button aria-label="Toggle side panel" aria-pressed="false" onclick="const p=document.querySelector('aside');p.removeAttribute('inert');p.removeAttribute('aria-hidden');p.style.width='300px';this.setAttribute('aria-pressed','true')">Open</button>
<aside inert aria-hidden="true" style="width:0;overflow:hidden"><div style="width:300px" data-property-row><span data-property-label="Assignee">Assignee</span><div data-property-value><button onclick="document.querySelector('#choices').hidden=false">${assigned ? "You" : "Unassigned"}</button></div></div></aside>
<div id="choices" hidden><button onclick="fetch('/assign',{method:'POST'}).then(()=>this.parentElement.hidden=true)">Assign to me</button></div>` });
});
const context = { page, company: { issuePrefix: "QA" }, user: { id: userId }, capabilities: ["company", "board-user", "task-write"],
fixtures: { backlogTask: { id, title, identifier: "QA-201" } }, api: { origin,
get: async (route: string) => route.endsWith("/runs") ? [] : { assigneeUserId: assigned ? userId : null, assigneeAgentId: null, status: "backlog" } },
} as unknown as JourneyContext;
const evidence: JourneyEvidence = { checks: [], outcome: "passed", startingState: "recipe", phases: [], resourceDisposition: "released", privacy: "private" };
await taskProperties(context, {} as TargetSession, "owned-campaign", evidence);
expect(evidence.checks).toEqual([{ id: "assignment-persisted", passed: true }, { id: "no-agent-work", passed: true }]);
await expect(page.getByRole("button", { name: "You", exact: true })).toBeVisible();
});
test("finds the attachment download link in legacy and Artifacts V1 markup only", async ({ page }) => {
const markup = {
legacy: `<a href="/api/attachments/${id}/content?download=1">Download</a>`,
// Artifacts V1: an icon-only "Open raw" link precedes the icon-only download link.
v1: `<span>slugify.zip</span><a href="/api/attachments/${id}/content" aria-label="Open raw slugify.zip"><svg width="8" height="8"></svg></a>`
+ `<a href="/api/attachments/${id}/content?download=1" download="slugify.zip" aria-label="Download slugify.zip"><svg width="8" height="8"></svg></a>`,
none: `<a href="/api/attachments/${id}/content" aria-label="Open raw slugify.zip">Open</a>`
+ `<a href="/api/attachments/other/content?download=1" aria-label="Download other.zip">Download</a>`,
};
for (const kind of ["legacy", "v1"] as const) {
await page.setContent(markup[kind]);
await expect(storyArtifactDownloadLink(page, id)).toHaveAttribute("href", `/api/attachments/${id}/content?download=1`);
}
await page.setContent(markup.none);
await expect(storyArtifactDownloadLink(page, id)).toHaveCount(0);
});
test("opens new-project creation with the previous or current toolbar label only", async ({ page }) => {
for (const label of ["Add Project", "Create project"]) {
await page.setContent(`<button>Create project template</button><button>${label}</button>`);
await expect(newProjectButton(page)).toHaveText(label);
}
await page.setContent(`<button>Create project template</button><button>New issue</button>`);
await expect(newProjectButton(page)).toHaveCount(0);
});