Files
PaperClipAI/server/src/services
DottaandClaude Opus 5.5 d169dd5a90 fix(presentation): offer Retry only when no automatic continuation or scheduled retry is pending (#21264, includes #21200)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - When a run fails with a transient error, Paperclip schedules the
next attempt by itself and shows "retrying automatically" with a
countdown.
> - The task presentation also offered the Retry button next to that
countdown.
> - The system owns the next attempt while the run is `scheduled_retry`,
so the button is misleading: it suggests that a person must act.
> - This pull request stops offering Retry while a scheduled retry is
pending. Retry returns when the scheduled retry is past due with nothing
pending, or when the retries are exhausted.
> - The benefit is one clear message: Paperclip retries by itself, and
Retry appears only when it is the way forward.

## Linked Issues or Issue Description

**What happened?**
A legacy run in status `scheduled_retry` (for example reason
`transient_failure`, which is not a shared-resource wait and has no
system recovery) projected `state: "retry_scheduled"` with `canRetry:
true`. The UI then showed the Retry button beside "retrying
automatically". The cause is in `projectTaskInterruptionState` in
`server/src/services/task-interruption-presentation.ts`: the `retryAt >
now` branch set `canRetry: !preparationPending && !nativeResumeAt`,
which ignores that the run itself is the scheduled attempt.

**Expected behavior**
While a run is `scheduled_retry` and its retry time is in the future,
the task shows the countdown and offers no Retry. When the scheduled
retry is past due with nothing pending, or the retries are exhausted,
Retry is offered.

**Steps to reproduce**
1. Let a task's run fail with a transient failure that schedules an
automatic retry.
2. Open the task before the retry time.
3. The task shows "retrying automatically" and the Retry button.

**What a Retry click does today in this state**
`requestTaskRetry` (`server/src/services/task-retry.ts`) treats a latest
run in `scheduled_retry` as busy. It accepts the click (202), records
the request as `coalesced` onto the scheduled run and returns
`scheduledRetryRunId`. It does not start a second attempt next to the
scheduled one. The button is therefore misleading but not unsafe, and
this pull request changes only what the task shows.

## What Changed

- `server/src/services/task-interruption-presentation.ts`: in the
`retry_scheduled` branch, `canRetry` is now also false when `run.status
=== "scheduled_retry"`.
- `server/src/services/task-interruption-presentation.test.ts`: three
tests for a scheduled transient-failure retry.
- This branch is based on current `master` and includes #21200, which
has not merged yet and changes the same file. The diff of this pull
request against #21200 is one line and the tests.

## Verification

- `cd server && npx vitest run
src/services/task-interruption-presentation.test.ts -t "automatic
scheduled retry"`
- "shows a pending transient-failure retry as scheduled without a
competing Retry": red on `master` (`canRetry: true`), green with this
change.
- "offers Retry once the scheduled retry is past due with nothing else
pending": green before and after.
- "offers Retry once the scheduled retries are exhausted": green before
and after.
- Locally: `task-interruption-presentation.test.ts`,
`task-interruption-query.test.ts` and
`task-interruption-automatic-path.test.ts` pass (107 tests). Server
typecheck: 0 errors. The wider suites that read the presentation run in
CI; they were not repeated locally because the machine was under memory
pressure.

## Risks

- Low risk. The change affects presentation only. The Retry route still
accepts a click and coalesces it onto the scheduled run, as before.
- If a scheduled retry never dispatches, the task offers Retry again
once the retry time passes, as before this change.
- No schema, API or UI change.

## Model Used

- Claude Opus 5.5 (Anthropic), model ID `claude-opus-5-5`, used in
Claude Code with tool use (shell, file edits, test execution). Extended
reasoning was available.

## 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>
2026-11-12 21:14:41 -06:00
..
…
…
…
…
…