Files
PaperClipAI/ui
Steven Nance c8ca682bf2 fix(ui): remount the composer takeover card per pending input (#15121)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Agents ask people for decisions through cards in the task chat
> - The composer shows one pending card at a time in a takeover slot
> - The checkbox card and the suggested-tasks card keep the selection,
the reason and the page in local React state
> - The takeover slot renders each pending card in the same position
without a React `key`, so React reuses one card instance for the next
pending card
> - The next card then starts with the state of the card before it
> - This pull request adds a `key` for each pending input, so each card
mounts with its own state
> - The benefit is that each card shows and sends only its own options

## Linked Issues or Issue Description

No public issue exists for this bug. The description follows the bug
report template.

**What happened?**

A task had two pending cards of the same kind. I answered the first
card. The takeover slot then showed the second card, but the second card
kept the selection state of the first card. The default ticks of the
second card did not show. The card also wrote the selection of the first
card into the saved draft of the second card. When I confirmed the
second checkbox card, it sent option ids that belong to the first card.
The server refused the request with `Unknown checkbox confirmation
optionId`.

**Expected behavior**

Each pending card starts with its own default selection. Each card sends
only its own option ids. Each card saves only its own draft.

**Steps to reproduce**

1. Create two pending `request_checkbox_confirmation` interactions on
one task. Give them different option ids and different
`defaultSelectedOptionIds`.
2. Open the task. The composer takeover shows one of the cards.
3. Change the ticks on that card, then confirm it.
4. Look at the next card in the takeover slot. Its default ticks do not
show.
5. Confirm the next card. The request fails with `Unknown checkbox
confirmation optionId`.

The same fault occurs with two pending `suggest_tasks` cards.

**Paperclip version or commit**

`master` at `1c07b5903b1b11139b1e1ce052a3cd4885865d90`.

**Deployment mode**

Self-hosted server. The bug is in the UI and does not depend on the
deployment mode.

Related work: a search of issues and pull requests found no report and
no fix for this bug. #14613 and #9290 change the same cards, but they do
not change how the takeover slot mounts a card.

## What Changed

- `ui/src/components/TaskChatThread.tsx`: the takeover
`TaskChatProtocolCard` and `TaskChatInteractionCard` now have
`key={selectedPendingInput.key}`. React mounts a new card when the
pending input changes.
- `ui/src/components/TaskChatThread.test.tsx`: two new tests. One test
covers two pending checkbox cards. One test covers two pending
suggested-tasks cards. Each test answers the first card and then checks
the ticks, the submitted ids and the saved draft of the second card.
- The branch has two commits. The first commit adds only the tests. The
second commit adds the fix.

## Verification

Run these commands from the repository root:

- `pnpm exec vitest run --project @paperclipai/ui
ui/src/components/TaskChatThread.test.tsx`
- On the tests-only commit: 2 failed, 195 passed. The two failures are
the new tests.
  - On the head commit: 197 passed.
- `pnpm exec vitest run --project @paperclipai/ui`: 679 test files
passed, 7316 tests passed.
- `pnpm --filter @paperclipai/ui typecheck`: no errors.
- `pnpm check:token-gates`: all gates clean.
- `pnpm check:tokens`: no forbidden tokens.

Manual check: on a self-hosted build that has the same two-line change,
two pending checkbox cards on one task were accepted one after the
other. Each request sent the option ids of its own card. This build was
not the head commit of this branch.

I did not run `pnpm -r typecheck`, the full `pnpm test:run`, `pnpm
build` or the browser suites. The change touches only the two UI files
above.

## Risks

Low risk. A card in the takeover slot now mounts again when the selected
pending input changes. Unsaved local state of the card that leaves the
slot is not kept in memory. Selections and reasons stay in the saved
draft for each card, as before. The card does not mount again while the
same pending input stays selected, because the key is stable for one
pending input.

## Model Used

Claude Opus 5.5 (`claude-opus-5-5`) from Anthropic, run as a coding
agent with tool use (shell, file edit, test runs). The context window
size of the run was not recorded. A person reviews the change before the
pull request opens.

## 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 (not
applicable: no documentation describes this behavior)
- [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
2026-12-04 21:09:46 -08:00
..
…

@paperclipai/ui

Published static assets for the Paperclip board UI.

What gets published

The npm package contains the production build under dist/. It does not ship the UI source tree or workspace-only dependencies.

Storybook

Storybook config, stories, and fixtures live under ui/storybook/.

pnpm --filter @paperclipai/ui storybook
pnpm --filter @paperclipai/ui build-storybook

Typical use

Install the package, then serve or copy the built files from node_modules/@paperclipai/ui/dist.

Editor dependency identity

Keep the root and workspace overrides for @codemirror/state, @codemirror/view, and @lezer/common aligned. CodeMirror requires shared extension identity, while Lezer parsers and syntax highlighters require shared NodeProp IDs. Multiple Lezer copies can crash code-block highlighting with tags is not iterable. src/lib/codemirror-single-instance.test.ts checks the installed dependency graph and highlights sample code through the editor's real language dependencies. GitHub Actions owns regeneration of pnpm-lock.yaml.