Files
PaperClipAI/ui/src
ce204a223a fix(ui): tag chunk-load reports with the reload recovery step that gave up (#23613)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The board UI loads each page as a lazy chunk. When a chunk fails to
load, chunk-load recovery reloads the page. It retries while a deploy
settles (#17349, #19361).
> - Safari reported `TypeError: Importing a module script failed.` from
the route error boundary. The build already had the retry logic. So
recovery gave up and the user saw the error page.
> - Recovery can give up for four reasons. The reload did not leave the
page within 10 seconds, the retries were used up, session storage was
blocked, or an earlier reload in this page was abandoned. The report
does not say which one occurred. Breadcrumbs are off for privacy, so the
event has no other clue.
> - This pull request records the recovery decision for each chunk-load
error and sends it as one enum tag.
> - The benefit is that the next report shows which recovery step
failed, so a real fix can target that step.

## Linked Issues or Issue Description

Refs #17349
Refs #19361

**What happened?**
A Safari user got `TypeError: Importing a module script failed.` from
the route error boundary. The page was more than 10 minutes old and had
become visible 10–60 seconds earlier. The build included the chunk-load
retry logic, so recovery gave up. The event does not tell why.

**Expected behavior**
A chunk-load error report states which recovery step gave up, without
URLs or page data.

**Steps to reproduce**
1. Open a lazy route in a build where its chunk can no longer load.
2. Let the reload stall for more than 10 seconds, or use up the retries
in the guard window.
3. Look at the Sentry event. It has no field that tells which case
occurred.

## What Changed

- `chunk-load-recovery.ts`: Record a `ChunkLoadRecoveryOutcome` for each
chunk-load error. The values are `reload_pending`, `reload_abandoned`,
`reload_cancelled`, `retries_exhausted`, `storage_unavailable`, and
`disabled_after_abandon`. Errors that wait on a reload change to
`reload_abandoned` or `reload_cancelled` when that reload ends. Add
`readChunkLoadRecoveryOutcome(error)`. The reload behavior does not
change.
- `sentry.ts`: In `beforeSend`, add the `browser_chunk_reload` tag when
the original exception has a recorded outcome.
- Tests for each outcome and for the tag.

## Verification

- `cd ui && npx vitest run src/lib/chunk-load-recovery.test.ts
src/lib/sentry.test.ts src/components/RouteErrorBoundary.test.tsx
src/components/AppErrorBoundary.test.tsx`: 83 tests pass.
- Red check: the 4 new tests fail on the old implementation and pass
with this change.
- `cd ui && npx tsc --noEmit -p tsconfig.json`: no errors in changed
files. The only errors are the ignored generated Storybook catalog
files, which were not generated locally.
- Note: `sentry.test.ts > initializes with the DSN it receives` can time
out at 5 s on a cold cache. The same flake occurs on unchanged `master`.
- `pnpm verify` did not finish in this environment (no output in 300 s,
also with `--explain`). CI supplies the broad coverage.

## Risks

Low risk. The change only adds one enum tag to Sentry events. It sends
no URL, path, or page data. The outcome map is a `WeakMap`, so it holds
no errors in memory. The reload timing and the guard logic do not
change.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`), agentic coding 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: paperclipbugbot <356415228+paperclipbugbot@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-03 06:25:58 -08:00
..
…