mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 18:26:40 +01:00
## Thinking Path > - Paperclip is the open source app people use to manage AI agents for work > - The browser UI shows an optional announcement card. The `useAnnouncement` hook fetches it and cancels that fetch when the tab is hidden, when the user dismisses the card, or when the hook unmounts > - The hook aborts with no reason. The app handles that rejection. But a `fetch` wrapper outside the app, such as a browser extension, can drop it. The browser then reports `AbortError: signal is aborted without reason` as an unhandled rejection, and Sentry records an error that has no user effect > - #22090 adds a marked abort reason, `intentionalAbortReason()`, and a Sentry `beforeSend` rule that drops an unhandled rejection only when its value is that exact marked object > - This pull request makes the announcement hook use that marked reason for its own cancellations > - The benefit is that hiding a tab no longer appears as a production error, and every other `AbortError` is still reported ## Linked Issues or Issue Description Refs #22090, which is merged. This change uses its `intentionalAbortReason()` marker and its Sentry `beforeSend` rule. The diff against `master` contains only the `useAnnouncement` change. **What happened?** A hosted browser reported one unhandled rejection: `AbortError: signal is aborted without reason` (DOMException code 20, mechanism `onunhandledrejection`, native trusted promise, tab visibility `hidden` less than one second after the change). The stack is: `document` `visibilitychange` → `useAnnouncement` `onVisibility` → `suspend` → `fetchController.abort()`. **Expected behavior** An intentional cancellation of the announcement fetch does not appear in error monitoring. A real abort failure still appears. **Steps to reproduce** 1. Replace `window.fetch` with a wrapper that calls the real `fetch` and attaches only `.then(() => {})` to its promise. Some extensions and injected scripts do this. 2. Sign in, so that the announcement hook starts its fetch. 3. Hide the tab while that fetch is in flight. 4. The hook aborts the fetch. The wrapper's derived promise rejects with no handler. The app's own chain ends in `.catch()`, so the app does not cause the rejection. **Paperclip version or commit** Reported on release `651749bdb4`. `ui/src/hooks/useAnnouncement.ts` and `ui/src/api/announcements.ts` are unchanged on `master` up to this branch's base. **Deployment mode** Hosted, browser UI (Chrome-family message text). I searched open and closed PRs for this error message and for `useAnnouncement` abort changes. I found only #22090, which this change reuses. ## What Changed - `ui/src/hooks/useAnnouncement.ts`: the hide, dismiss, and unmount aborts now use `intentionalAbortReason()`. This includes the abort of pending dismissal writes on unmount. - The 10-second dismissal-write timeout still aborts with no reason. A timeout is a real failure, not a cancellation, so it stays reportable. - `ui/src/hooks/useAnnouncement.test.tsx`: a new test checks that each of those aborts carries the marked reason. ## Verification - Red first: with only the new test, `cd ui && npx vitest run src/hooks/useAnnouncement.test.tsx` failed (`isIntentionalAbortReason(hidden.reason)` was `false`). - Green (also again after the merge of `master` with #22090, head `afc31cb0ea`): `cd ui && npx vitest run src/hooks/useAnnouncement.test.tsx src/components/AnnouncementWell.test.tsx src/components/AnnouncementWell.onboarding.test.tsx src/lib/sentry.test.ts src/api/client.test.ts` → 5 files, 72 tests pass. - `cd ui && npx tsc --noEmit -p .` shows no errors in the changed files. The 14 errors it reports are in `storybook/support/feature-map` and are the same without this change. - The `beforeSend` filter itself is tested in #22090 with the real Sentry SDK. ## Risks - Low risk. The hook's behavior does not change: the same requests are cancelled at the same times. Only the abort reason object changes, and no code in the hook reads that reason. - The marked reason has the message "The operation was aborted." instead of the browser default. No code depends on the message. ## Model Used - Claude Opus 5.5 (`claude-opus-5-5`), Anthropic, used through Claude Code with tool use (shell, file edit, test runs). ## 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: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>