mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-16 11:59:26 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - The QA Cloud plan-revise-accept journey checks that a person can
revise and approve an agent's Plan
> - It first checks that the saved Plan chip is visible, scoped to a
settled `task-chat-turn` so a live "Writing plan" chip cannot count
> - The Coordinator workspace renders the Plan chip directly in the chat
thread; there is no `task-chat-turn` element and no `data-settled`
attribute
> - So the journey never finds the chip and fails before the person
reviews the plan
> - This pull request also accepts the chip in the chat thread
> - The benefit is that the plan journey reaches the revision and
approval steps it exists to test
## Linked Issues or Issue Description
**What happened?**
On QA Cloud (build 5acf27bc), plan-revise-accept failed with
`journey_operation_failed`, no checks passed, one run. The agent saved a
correct two-step Plan and a revision-bound confirmation. The
confirmation stayed pending until cleanup closed the task, so the
browser never reached it.
**Steps to reproduce**
1. Open the failed journey task on QA (Coordinator workspace).
2. Query `[data-testid="task-chat-turn"][data-settled="true"]
[data-testid="task-chat-plan-preview"]`: 0 matches.
3. Query `[data-testid="task-chat-thread"]
[data-testid="task-chat-plan-preview"]`: 1 visible match, aria-label
"Open Plan revision 1 in task sidebar".
**Expected behavior**
The journey finds the saved Plan chip and continues to "Request
changes".
## What Changed
- `planStageRootSelector(native)`: native root is a settled task-chat
turn or the task chat thread. `expectPlanStageVisible` uses it. The
revision-name check from #21701 is unchanged.
Why this still detects the failure that matters:
`runPlanRevisionAcceptance` waits through the API until every task run
is terminal before this check, and the aria-label must name the exact
revision, which a live "Writing plan" chip does not.
## Verification
- On the live failed QA page: old scope finds 0 chips; new scope finds 1
visible chip whose label matches `planPreviewLabel(1)`.
- `tests/runner-e2e` plan-revision tests: 4 pass (new selector test
included).
- QA Cloud rerun of plan-revise-accept follows after merge and the
harness pin update.
## Risks
- Low risk: journey code only.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.
## 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
- [ ] 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
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
52 lines
2.9 KiB
TypeScript
52 lines
2.9 KiB
TypeScript
import { expect, it, vi } from "vitest";
|
|
import type { Page } from "@playwright/test";
|
|
import { planPreviewLabel, planStageRootSelector, runPlanRevisionAcceptance } from "./plan-revision-flow.js";
|
|
|
|
const state = {
|
|
currentIssue: { status: "in_progress" },
|
|
taskRuns: [{ status: "succeeded" }],
|
|
interactions: [{ id: "confirmation", kind: "request_confirmation", status: "pending",
|
|
payload: { target: { type: "issue_document", key: "plan", revisionId: "draft" } } }],
|
|
};
|
|
|
|
it("keeps the classic Plan story alive through a transient observation failure", async () => {
|
|
const reachedDocument = new Error("reached the canonical Plan read");
|
|
const load = vi.fn().mockRejectedValueOnce(new Error("temporary read failure")).mockResolvedValue(state);
|
|
const get = vi.fn(async () => { throw reachedDocument; });
|
|
await expect(runPlanRevisionAcceptance({
|
|
page: {} as Page, api: { get }, origin: "https://qa.example.test", issue: { id: "owned" },
|
|
issuePrefix: "QA", native: true, planMarkers: { draft: "draft", revised: "revised" },
|
|
revisionRequest: "revise", deadlineAt: Date.now() + 5000,
|
|
load, reject: () => undefined, capture: async () => {},
|
|
})).rejects.toBe(reachedDocument);
|
|
expect(load).toHaveBeenCalledTimes(2);
|
|
expect(get).toHaveBeenCalledWith("/api/issues/owned/documents/plan");
|
|
});
|
|
|
|
it("lets deployment callers reject a binding failure without another observation", async () => {
|
|
const bindingFailure = new Error("owned task binding changed");
|
|
const load = vi.fn().mockRejectedValueOnce(bindingFailure).mockResolvedValue(state);
|
|
const get = vi.fn(async () => { throw new Error("must not read an unbound document"); });
|
|
await expect(runPlanRevisionAcceptance({
|
|
page: {} as Page, api: { get }, origin: "https://qa.example.test", issue: { id: "owned" },
|
|
issuePrefix: "QA", native: true, planMarkers: { draft: "draft", revised: "revised" },
|
|
revisionRequest: "revise", deadlineAt: Date.now() + 5000,
|
|
load, retryOnError: error => error !== bindingFailure, reject: () => undefined, capture: async () => {},
|
|
})).rejects.toBe(bindingFailure);
|
|
expect(load).toHaveBeenCalledOnce();
|
|
expect(get).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("accepts the classic and Coordinator Plan preview names for the exact revision only", () => {
|
|
expect(planPreviewLabel(1).test("Open Plan revision 1")).toBe(true);
|
|
expect(planPreviewLabel(1).test("Open Plan revision 1 in task sidebar")).toBe(true);
|
|
expect(planPreviewLabel(1).test("Open Plan revision 12 in task sidebar")).toBe(false);
|
|
expect(planPreviewLabel(2).test("Open Plan revision 1 in task sidebar")).toBe(false);
|
|
expect(planPreviewLabel(1).test("Open Plan in task sidebar")).toBe(false);
|
|
});
|
|
|
|
it("finds the native Plan chip in a settled turn or directly in the Coordinator chat thread", () => {
|
|
expect(planStageRootSelector(true).split(", ")).toEqual(['[data-testid="task-chat-turn"][data-settled="true"]', '[data-testid="task-chat-thread"]']);
|
|
expect(planStageRootSelector(false)).toBe("body");
|
|
});
|