mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-05 14:35:17 +01:00
## Thinking Path
> - Paperclip is the open source app people use to manage AI agents for
work
> - Issue routes can cancel a heartbeat run as a side effect, for
example when a comment supersedes a scheduled retry or when the issue is
set to `cancelled`
> - Other cancel paths pass a reason, an error code and a run event to
`heartbeat.cancelRun`
> - These two route paths called `cancelRun` without a reason, so the
run showed `cancelled` with no error code and no run event that says why
> - An operator who looks at the run, or a recovery path that reads the
error code, cannot tell these cancels apart from other cancels
> - This pull request passes a reason, an error code, an event message
and the issue id to both calls
> - The benefit is that every route-driven cancel explains itself in the
run record and the run events
## Linked Issues or Issue Description
No issue exists.
**What happened?**
A run that was cancelled because a comment superseded its scheduled
retry, or because its issue was set to `cancelled`, had no `error`, no
`errorCode` and no run event with a cancel reason.
**What did you expect?**
The run record and the run events say why the run was cancelled, like
other cancel paths do.
**Steps to reproduce**
1. Let a run fail so that it gets a scheduled retry (`scheduled_retry`).
2. Post a comment on the issue before the retry starts.
3. Open the cancelled retry run. It has no error code and no event that
explains the cancel.
4. Do the same with a running issue that you set to `cancelled`.
**Paperclip version**
`master` at the time of this PR.
## What Changed
- `server/src/routes/issues.ts`:
- The scheduled-retry cancel passes `"Cancelled because a comment
superseded the scheduled retry"`, `errorCode:
"scheduled_retry_superseded"`, an event message and `eventPayload: {
issueId }`. The `expectedStatus: "scheduled_retry"` guard does not
change.
- The cancel on a status change to `cancelled` passes `"Cancelled
because the issue was set to cancelled"`, `errorCode:
"issue_cancelled"`, an event message and `eventPayload: { issueId }`.
- `server/src/__tests__/issue-comment-reopen-routes.test.ts`: six
expectations now check the reason, the error code, the event message and
the event payload.
## Verification
- `cd server && npx vitest run
src/__tests__/issue-comment-reopen-routes.test.ts`: passes.
- `pnpm --filter @paperclipai/server typecheck`: passes.
## Risks
- Low risk. Only the arguments of two existing `cancelRun` calls change.
The cancel decision, the expected status guard and the activity log
entries do not change.
- The two error codes are new values. Code that matches on known cancel
error codes sees them as unknown codes, as before when the code was
empty.
## Model Used
- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use
(shell, git, test runs). Extended reasoning on.
## 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>