mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 20:09:33 +01:00
## Thinking Path > - Paperclip manages work by AI agents. > - Its product journeys verify hiring and task delegation through chat. > - Cleanup uses saved creation intents to track possible writes. > - The hiring journey saves each task intent before browser preparation. > - A navigation or editor failure can therefore leave an intent for a request that was never sent. > - This pull request saves the intent after message validation and before Send. > - Cleanup can retain strict write protection without treating failed preparation as a possible task creation. ## Linked Issues or Issue Description **What happened?** The hiring journey can save a review-task intent even when a browser failure stops the third chat request before submission. Cleanup then reports an uncertain creation outcome. A controlled navigation failure reproduces this tracking defect. The original retained browser exception is unavailable; this change does not claim its cause. **Expected behavior** Browser preparation must not register a task write. The creation intent must be saved before submission can create work. A failed intent save must stop submission. A send with a possible committed write must retain the intent. **Steps to reproduce** Inject a navigation failure before the review request after the checklist completes. The original code records the review intent despite making only two sends. The new code preserves the checklist receipt and records no review intent. **Paperclip version or commit** Reproduced from source at `5a9c06b315d9612022908b7fc189f30bac3619af`. **Deployment mode** Linux source checkout, focused workflow tests, and Chromium against the real production composer. The paid hosted acceptance case remains pending until merge. Related earlier hiring coverage and spacing fixes: #18351 and #22825. ## What Changed - Save delegated-task intents through an awaited callback after the exact mention chips are verified and before the browser clicks Send. - Cover failed review navigation, failed intent persistence, rejected mentions, and a send failure after the intent boundary. - Keep handoff references and task name in one typed object. A handoff without its intent name is no longer representable. - Keep the existing ownership, initial assignment, saved-body, seven-run, budget, and cleanup checks. - Document the submission boundary. ## Verification - Red: the new review-navigation regression failed because the old flow saved the review intent without sending that request. - Green: 78 focused flow and evidence tests pass. - All 8 real-composer Chromium checks pass. They cover both composer modes, exact saved messages, failed intent persistence, page loss after persistence, and rejected agent/project mentions. - `pnpm test:e2e:runner:typecheck` passes. - `pnpm verify --explain` could not select checks because the managed Git storage guard rejects `git ls-files`. Even the suggested shallow fetch fails. This unavailable check is not a pass. The source was compared with master through the repository API before publication. - Original head `6914c4b` passed [CI](https://github.com/paperclipai/paperclip/actions/runs/46723605434) and Greptile 5/5 with Low impact. Typecheck, four support shards, six Runner package shards, static checks, and aggregate verification passed. Build was skipped by the test-only path policy. - Review head `cd7b03f36d6d9fcac37cf80906fad2f7cd167958` passes the 78 focused tests, all 8 browser checks, and runner E2E typecheck. Its first browser attempt could not start because the resumed sandbox lacked Chromium; installation restored the check, which then passed. The current head passed [CI](https://github.com/paperclipai/paperclip/actions/runs/46727370488), including Typecheck + Release Registry, four support shards, six Runner package shards, static checks, and aggregate verification. Build is skipped by the test-only path policy. Greptile, Feynman and Ponytail each gave this head 5/5, with Low impact from Greptile. The actionable thread is resolved. Hosted acceptance must run only `hire-delegate-reuse` after merge. ## Risks The callback and Send cannot form one atomic operation. A failure after intent persistence still keeps the intent and the existing uncertain-write protection. This patch does not manufacture absence proof for old retained manifests. The original browser error remains unknown. ## Model Used OpenAI GPT-6 through Codex, with reasoning, shell tools, source editing, and Chromium. The runtime does not expose a more specific backend model revision or context size. ## 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: Paperclip <noreply@paperclip.ing>
81 lines
4.9 KiB
TypeScript
81 lines
4.9 KiB
TypeScript
import { expect, test, type Page } from "@playwright/test";
|
|
import { sendChatMessage } from "./chat-flow.js";
|
|
import { hireHandoffMentions } from "./product-journeys/hire-delegate-flow.js";
|
|
import { sendHireHandoffMessage } from "./product-journeys/hire-delegate-composer.js";
|
|
import { composerResources as r, startHireComposerFixture } from "./hire-delegate-composer.fixture.js";
|
|
|
|
test.setTimeout(45_000);
|
|
let fixture: Awaited<ReturnType<typeof startHireComposerFixture>>;
|
|
test.beforeAll(async () => { fixture = await startHireComposerFixture(); });
|
|
test.afterAll(async () => { await fixture?.close(); });
|
|
const references = hireHandoffMentions({ companyId: r.companyId, leadId: r.leadId, projectId: r.projectId, campaignId: r.campaignId }, r.agentId,
|
|
{ id: r.agentId, companyId: r.companyId, reportsTo: r.leadId, name: `Morgan Reviewer ${r.campaignId}`, icon: "code" },
|
|
{ id: r.projectId, companyId: r.companyId, name: `Journey QA hire-delegate-reuse ${r.campaignId}`, color: "#336699" });
|
|
const message = (review = false) => `Have the existing ${references.teammate} ${review ? "review the checklist on QA-1 and write a separate saved review" : 'write a concise launch checklist as a saved Paperclip document with the line "Reference: HIREjourney1deadbeef"'}. Create exactly one task in ${references.project}, already assigned to that teammate when it is created. Link the result here.`;
|
|
async function open(page: Page, key: string, variant = "valid", mode = "production") {
|
|
const url = new URL("/__hire.html", fixture.url); url.searchParams.set("case", key); url.searchParams.set("variant", variant); url.searchParams.set("mode", mode);
|
|
await page.goto(url.href);
|
|
await expect(page.getByTestId("task-chat-composer-input").locator('[contenteditable="true"]')).toBeVisible({ timeout: 30_000 });
|
|
}
|
|
async function saved(page: Page, key: string) { return (await page.request.get(new URL(`/__saved/${encodeURIComponent(key)}`, fixture.url).href)).json() as Promise<Array<{ id: string; body: string }>>; }
|
|
|
|
test("raw fill escapes mention syntax in the real production composer", async ({ page }) => {
|
|
await open(page, "raw"); const text = message(); await sendChatMessage(page, text);
|
|
await expect.poll(async () => (await saved(page, "raw")).length).toBe(1);
|
|
const [row] = await saved(page, "raw"); expect(row!.body).not.toBe(text); expect(row!.body).toContain("\\[@");
|
|
});
|
|
for (const [review, mode] of [[false, "production"], [true, "streamlined"]] as const) {
|
|
test(`normal mention controls preserve the exact ${review ? "review" : "checklist"} body in ${mode} composer`, async ({ page }) => {
|
|
const key = mode; await open(page, key, "valid", mode); const text = message(review);
|
|
let intentSaved = false;
|
|
await sendHireHandoffMessage(page, text, references, Date.now() + 10_000, async () => {
|
|
expect(await saved(page, key)).toEqual([]);
|
|
await expect(page.locator('a[data-mention-kind]')).toHaveCount(2);
|
|
intentSaved = true;
|
|
});
|
|
expect(intentSaved).toBe(true);
|
|
await expect.poll(async () => (await saved(page, key)).length).toBe(1);
|
|
expect(await saved(page, key)).toEqual([{ id: "1", body: text }]);
|
|
});
|
|
}
|
|
for (const variant of ["wrong-agent", "duplicate", "missing-project"] as const) {
|
|
test(`normal mention controls reject ${variant} without sending`, async ({ page }) => {
|
|
await open(page, variant, variant);
|
|
let intentSaved = false;
|
|
const send = sendHireHandoffMessage(page, message(), references, Date.now() + (variant === "missing-project" ? 5_000 : 10_000), async () => { intentSaved = true; });
|
|
if (variant !== "missing-project") await expect(send).rejects.toMatchObject({
|
|
code: variant === "wrong-agent" ? "hire_handoff_mention_mismatch" : "hire_handoff_mention_ambiguous",
|
|
});
|
|
else {
|
|
await expect(send).rejects.toThrow();
|
|
await expect(page.locator('a[data-mention-kind="agent"]')).toHaveCount(1);
|
|
await expect(page.locator('a[data-mention-kind="project"]')).toHaveCount(0);
|
|
}
|
|
expect(intentSaved).toBe(false);
|
|
expect(await saved(page, variant)).toEqual([]);
|
|
});
|
|
}
|
|
|
|
test("a failed intent save stops submission after valid composer preparation", async ({ page }) => {
|
|
await open(page, "intent-save-failed");
|
|
const failure = new Error("intent_save_failed");
|
|
let attempts = 0;
|
|
await expect(sendHireHandoffMessage(page, message(true), references, Date.now() + 10_000, async () => {
|
|
attempts++;
|
|
throw failure;
|
|
})).rejects.toBe(failure);
|
|
expect(attempts).toBe(1);
|
|
expect(await saved(page, "intent-save-failed")).toEqual([]);
|
|
});
|
|
|
|
test("page loss after intent persistence keeps the intent without replaying Send", async ({ page }) => {
|
|
await open(page, "page-loss-after-intent");
|
|
const intents: string[] = [];
|
|
await expect(sendHireHandoffMessage(page, message(true), references, Date.now() + 10_000, async () => {
|
|
intents.push("review");
|
|
await page.close();
|
|
})).rejects.toThrow(/closed/);
|
|
expect(intents).toEqual(["review"]);
|
|
expect(await saved(page, "page-loss-after-intent")).toEqual([]);
|
|
});
|