fix(ui): let Request changes on a plan always take a revision note (#21721)

## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - In planning work, an agent saves a Plan document and asks the person
to confirm it with a request_confirmation card
> - The card offers "Request changes"; it opens a revision note only
when the request sets rejectRequiresReason, allowDeclineReason or
declineReasonPlaceholder
> - Paperclip's own plan confirmations (runner plan approval) always set
rejectRequiresReason, but an agent that writes its own confirmation may
not
> - Then "Request changes" rejects the plan at once and the person
cannot say what should change
> - This pull request makes plan confirmations always open the revision
note; the note stays optional unless required
> - The benefit is that a plan can always be sent back with a reason,
and the QA plan journey can complete

## Linked Issues or Issue Description

**What happened?**
On the QA Cloud stack the plan-revise-accept journey failed. The agent
saved a correct two-step Plan and a confirmation bound to the latest
revision, with labels "Confirm" / "Request changes" and
`rejectRequiresReason: false`. Clicking "Request changes" rejected the
plan immediately; no revision note opened.

**Steps to reproduce**
1. Create a request_confirmation that targets the issue's `plan`
document without `rejectRequiresReason`.
2. Open the task chat and click "Request changes".
3. The plan is rejected with no note.

**Expected behavior**
"Request changes" opens the revision note so the person can describe the
change, as for Paperclip's own plan approvals.

## What Changed

- `TaskChatCompactInteractionCard`: `collectsRejectReason` is true for
any plan confirmation (issue_document target with key `plan`). The note
label shows "(optional)" when a reason is not required, and the reject
button stays enabled with an empty note.

## Verification

- Red/green: new `TaskChatInteractionCard.test.tsx` case "opens the
revision note for a plan even when the request does not require a
reason" fails on master (the click rejects) and passes with the change.
- `ui` vitest for `src/components/task-chat` and
`IssueThreadInteractionCard`: 68 files, 1119 tests pass. UI typecheck
clean.
- QA Cloud: the plan journey failed at this step in run 43671188287 (the
only failing product step in a 22/24 run). It will be rerun after
deploy.

## Risks

- Low risk. Only plan confirmations change: one extra step (the note
box) before a plan rejection. Non-plan confirmations are unchanged.

## 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>
This commit is contained in:
DottaandClaude Opus 5.5 authored and GitHub committed 2026-11-15 04:14:27 +00:00
1 parent a78be8b601
commit f33db357f7
2 files changed
+36 -3

No files matched your search

@@ -858,14 +858,15 @@ function ConfirmationCard({
const setReason = (value: string) => updateDraft({ reason: value });
const [actionError, setActionError] = useState<string | null>(null);
const [revisionUploading, setRevisionUploading] = useState(false);
const isPlanConfirmation =
interaction.payload.target?.type === "issue_document" &&
interaction.payload.target.key === "plan";
const collectsRejectReason = Boolean(
isPlanConfirmation ||
interaction.payload.rejectRequiresReason ||
interaction.payload.allowDeclineReason ||
interaction.payload.declineReasonPlaceholder,
);
const isPlanConfirmation =
interaction.payload.target?.type === "issue_document" &&
interaction.payload.target.key === "plan";
useEffect(() => {
if (!draftKey) return;
const legacyReason = loadStructuredDraft(draftKey, "");
@@ -735,6 +735,38 @@ describe("TaskChatInteractionCard", () => {
expect(reasonGroup?.className).not.toContain("mt-3");
});
it("opens the revision note for a plan even when the request does not require a reason", async () => {
const reject = vi.fn();
const interaction = createRequestConfirmation({
sourceRunId: "run-plan",
title: "Confirm the two-step plan",
payload: {
version: 1,
prompt: "Please review the plan.",
acceptLabel: "Confirm",
rejectLabel: "Request changes",
rejectRequiresReason: false,
target: { type: "issue_document", issueId: "issue-1", key: "plan", revisionId: "revision-1", revisionNumber: 1 },
},
});
flushSync(() => {
root.render(
<TooltipProvider>
<ThemeProvider>
<TaskChatInteractionCard item={interactionItem(interaction)} presentation="takeover"
onAcceptInteraction={vi.fn()} onRejectInteraction={reject} onUploadImage={vi.fn()} />
</ThemeProvider>
</TooltipProvider>,
);
});
const requestChanges = Array.from(container.querySelectorAll<HTMLButtonElement>("button"))
.find((button) => button.textContent?.trim() === "Request changes");
flushSync(() => requestChanges?.click());
expect(reject).not.toHaveBeenCalled();
expect(container.querySelector('[data-testid="plan-revision-composer"]')).not.toBeNull();
expect(container.textContent).toContain("(optional)");
});
it("shows one question at a time and preserves answers across pages", async () => {
const submit = vi.fn();
flushSync(() => {