Repository navigation
fix(ui): handle reader host callback exceptions (YPE-6811) - #493
Conversation
🦋 Changeset detectedLatest commit: 7d740b6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 4 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@greptileai review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
cameronapak
left a comment
There was a problem hiding this comment.
Review
Summary
Standards: 0 must-fix. Spec: 0 must-fix. Primary concern: none.
Review evidence
- Scope: 3a74ed0, compared with merge-base f4a3ddb. Read YPE-6811, applicable repository guidance, the full diff, surrounding code, and existing discussion; there were no review threads.
- Method: separate Standards, Spec, and Correctness passes, plus a bounded reuse check, performed directly without delegation.
| Behavior or check | Method / command | Result | Evidence source |
|---|---|---|---|
| Reader and popover behavior | vitest run --project unit src/components/bible-reader-controlled.test.tsx src/components/bible-reader.test.tsx src/components/verse-action-popover.test.tsx |
109 passed | Reviewer-run, isolated checkout |
| Regression sensitivity | vitest run --project unit src/components/bible-reader-controlled.test.tsx -t 'host callback', with only the reader implementation reverted to base |
Both immediate-throw cases failed: uncaught errors, missing empty-selection notification, retained selection and popover. Both rejected-promise cases passed. | Reviewer-run |
| Restored fix | Same four-case command at HEAD | 4 passed; 45 unrelated cases skipped | Reviewer-run |
| Callback timing and compatibility | Traced host handlers, helper, payload construction, and native branches | Callback invoked before the first await; cleanup remains immediate. Payload and native paths unchanged. | Source inspection |
- Limits: runtime checks used jsdom, not real-browser user activation or native Share. No full-suite rerun. pnpm rejected the linked worktree dependency layout; recovered by running installed Vitest directly after building unchanged core/hooks dependencies.
- CI and bot review: inspected checks passed for build, tests, types, lint, and browser journeys. Older red release entries were canceled by concurrency; replacement release checks succeeded. Existing bots reported no findings.
- Event: APPROVE.
Written by Code Reviewer bot on behalf of Cam.
| data: BibleReaderShareData, | ||
| ): Promise<void> { | ||
| try { | ||
| await action(data); |
There was a problem hiding this comment.
praise: This catches both failure forms without deferring the host callback or delaying selection cleanup.
For Agents: callback timing and cleanup
action(data)runs before the first await, preserving direct invocation during the click handler. Both callers leave cleanup outside the unawaited helper, so a throwing or pending host callback cannot prevent selection clearing and popover dismissal. The four regression cases also distinguish the original synchronous-throw bug from the already-handled rejected-promise path.
Written by Code Reviewer bot on behalf of Cam.
* chore: sync react localization from platform-localization (#478) chore: sync react localization Co-authored-by: camrun91 <16566029+camrun91@users.noreply.github.com> * fix(core): sanitize planted footnote content in Bible HTML (#486) * fix(core): sanitize planted footnote content in Bible HTML Co-Authored-By: Cameron Pak <cameronandrewpak@gmail.com> * fix(core): address review on footnote sanitization Sanitize footnote content in an inert template, drop non-HTML-namespace elements, sanitize generated footnote content for idempotency, document the sanitization contract, and consolidate tests. Co-Authored-By: Cameron Pak <cameronandrewpak@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * refactor(ui): organize Bible reader modules (#489) * refactor(ui): organize Bible reader modules (YPE-6808) * refactor(ui): extract reader settings lifecycle and toolbar (#495) * refactor(ui): extract reader settings lifecycle and toolbar (YPE-6815) * fix(ui): address reader settings review feedback * feat(ui): re-export passage and versions hooks (#500) * feat(ui): re-export passage and versions hooks Amp-Thread-ID: https://ampcode.com/threads/T-01a20e73-4446-71f0-950a-3054df5492c7 * chore(ci): remove packed UI consumer check * docs(ui): clarify shared provider import guidance Amp-Thread-ID: https://ampcode.com/threads/T-01a20e73-4446-71f0-950a-3054df5492c7 * docs: address hook re-export review nits Amp-Thread-ID: https://ampcode.com/threads/T-01a20e73-4446-71f0-950a-3054df5492c7 --------- Co-authored-by: Amp <amp@ampcode.com> * fix(ui): preserve focus at high zoom (#485) * fix(ui): preserve focus at high zoom * fix(ui): harden zoom focus coverage * refactor(ui): simplify zoom focus handling * test(ui): cover zoom focus behavior * test(ui): focus reader close before asserting * fix(ui): address zoom review findings * test(ui): compare pointer focus styles * test(ui): respect focus-visible heuristics * test(ui): use native focus traversal * fix(ui): scope focus preservation * fix(ui): preserve sign-in focus contrast * test(ui): await close focus transition * refactor(ui): centralize picker scroll geometry * fix(ui): keep picker focus visible in constrained panels * fix(ui): preserve the expanded book trigger in compact panels * test(ui): reach reader settings close with native keys * fix(ui): honor reduced motion in chapter reveal * fix(ui): address focus and scroll review feedback * fix(ui): reveal focused chapters in Firefox Keep focused book triggers fully visible within the built-in accordion on Linux Firefox. Wait for the settings dialog opening animation before asserting visibility in WebKit. * test(ui): query the current settings dialog while opening * feat(core): add Content Library video APIs (YPE-6573) (#488) * feat(core): add content library video APIs * refactor(core): simplify video schema ownership * fix(core): harden content library contracts * fix(core): validate video response boundaries * fix(core): distinguish no-content responses * fix(core): scope no-content status handling * fix(core): distinguish empty response bodies * test(core): isolate Content Library smoke coverage * feat(core): keep content library APIs compatible with v3 * fix(core): align content library rollout contracts (YPE-6573) * fix(core): accept empty video filters and trim search bundles (YPE-6573) * fix(core): address content library review feedback (YPE-6573) * docs(core): clarify video APIs and live validation (YPE-6573) * fix(core): use stable Content Library routes (YPE-6573) * feat(core): add Notes API client (#497) * feat(core): add Notes API client Amp-Thread-ID: https://ampcode.com/threads/T-01a2095d-25a9-72c5-a0fb-baa79c35e05a * fix(core): address Notes API review feedback Amp-Thread-ID: https://ampcode.com/threads/T-01a2095d-25a9-72c5-a0fb-baa79c35e05a * fix(core): normalize Notes write colors * fix(core): address Notes API contract review * fix(core): enforce Notes version filters and tolerate malformed passages * fix(core): isolate malformed Notes list records Amp-Thread-ID: https://ampcode.com/threads/T-01a2095d-25a9-72c5-a0fb-baa79c35e05a * chore: refresh combined core bundle budget Amp-Thread-ID: https://ampcode.com/threads/T-01a2095d-25a9-72c5-a0fb-baa79c35e05a --------- Co-authored-by: Amp <amp@ampcode.com> * fix(ui): preserve newer selection after native Share (YPE-6812) (#494) * fix(ui): label reader sign-in menu trigger (YPE-6810) (#492) * fix(ui): label reader sign-in menu trigger (YPE-6810) * test(ui): capture Linux WebKit dialog visibility failures * test(ui): stress WebKit visibility diagnostics * test(ui): check settings visibility after keyboard focus Assert dialog opening state after Enter and visibility on the Close button after native Tab, alongside the focus-ring checks. Remove temporary WebKit diagnostics and repeated CI groups. * fix(ui): handle reader clipboard failures (#490) * fix(ui): handle reader clipboard failures (YPE-6809) * fix(ui): report clipboard failures and retry failed shares * fix(ui): keep clipboard warnings visible while scrolling * fix(ui): ignore stale clipboard action results * fix(ui): support Bible reader interactions in iframes (YPE-6410) (#491) * fix(ui): retain iframe verse selection and anchors (YPE-6410) * test(ui): cover iframe highlight painting and reset * fix(ui): complete iframe reader text and focus handling * fix(ui): handle reader host callback exceptions (YPE-6811) (#493) * chore(ui): align declaration build with strict checks (YPE-6464) (#503) chore(ui): align declaration build with strict checks Refs: YPE-6464 * chore: enable additional TypeScript safety checks (#505) * chore(ui): align declaration build with strict checks Refs: YPE-6464 * chore: enable additional TypeScript safety checks Refs: YPE-6832 * feat(ui): customize verse actions and indicators (#506) * feat(ui): customize verse actions and indicators Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> * test(ui): wait for verse layout in browser journeys Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> * fix(ui): keep configured verse actions reachable Make exiting actions inert and keep the visible verse indicator inside its pointer target. Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> * fix(ui): keep verse callbacks scoped to the displayed passage Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> * fix(ui): preserve verse action focus and warning visibility Signed-off-by: Austin <abharms@gmail.com> * fix(ui): restore focus after rejected verse action dismissal Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> --------- Signed-off-by: Austin <abharms@gmail.com> * test(ui): wait for host isolation colors to settle Amp-Thread-ID: https://ampcode.com/threads/T-01a22d50-d764-7577-a16d-dcc6f7081eba * fix(core): address Notes and serializer review feedback Amp-Thread-ID: https://ampcode.com/threads/T-01a22d5e-80f8-71c4-80b9-80b0e2702720 * fix(ui): preserve failed verse actions and guard browser stories Keep built-in Copy and Share fallback retryable until copying succeeds, and ignore stale clipboard completions after selection changes. Restrict chapter-picker native keyboard helpers to Vitest browser runs. Amp-Thread-ID: https://ampcode.com/threads/T-01a22d5e-80f8-71c4-80b9-80b0e2702720 * fix(ui): invalidate verse actions on prompt takeover and unmount Amp-Thread-ID: https://ampcode.com/threads/T-01a22d5e-80f8-71c4-80b9-80b0e2702720 --------- Signed-off-by: Austin <abharms@gmail.com> Co-authored-by: platform-localization-pr-bot[bot] <294853593+platform-localization-pr-bot[bot]@users.noreply.github.com> Co-authored-by: camrun91 <16566029+camrun91@users.noreply.github.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Austin <abharms@gmail.com> Co-authored-by: Amp <amp@ampcode.com>
* chore: sync react localization from platform-localization (#478) chore: sync react localization Co-authored-by: camrun91 <16566029+camrun91@users.noreply.github.com> * fix(core): sanitize planted footnote content in Bible HTML (#486) * fix(core): sanitize planted footnote content in Bible HTML Co-Authored-By: Cameron Pak <cameronandrewpak@gmail.com> * fix(core): address review on footnote sanitization Sanitize footnote content in an inert template, drop non-HTML-namespace elements, sanitize generated footnote content for idempotency, document the sanitization contract, and consolidate tests. Co-Authored-By: Cameron Pak <cameronandrewpak@gmail.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> * refactor(ui): organize Bible reader modules (#489) * refactor(ui): organize Bible reader modules (YPE-6808) * refactor(ui): extract reader settings lifecycle and toolbar (#495) * refactor(ui): extract reader settings lifecycle and toolbar (YPE-6815) * fix(ui): address reader settings review feedback * feat(ui): re-export passage and versions hooks (#500) * feat(ui): re-export passage and versions hooks Amp-Thread-ID: https://ampcode.com/threads/T-01a20e73-4446-71f0-950a-3054df5492c7 * chore(ci): remove packed UI consumer check * docs(ui): clarify shared provider import guidance Amp-Thread-ID: https://ampcode.com/threads/T-01a20e73-4446-71f0-950a-3054df5492c7 * docs: address hook re-export review nits Amp-Thread-ID: https://ampcode.com/threads/T-01a20e73-4446-71f0-950a-3054df5492c7 --------- Co-authored-by: Amp <amp@ampcode.com> * fix(ui): preserve focus at high zoom (#485) * fix(ui): preserve focus at high zoom * fix(ui): harden zoom focus coverage * refactor(ui): simplify zoom focus handling * test(ui): cover zoom focus behavior * test(ui): focus reader close before asserting * fix(ui): address zoom review findings * test(ui): compare pointer focus styles * test(ui): respect focus-visible heuristics * test(ui): use native focus traversal * fix(ui): scope focus preservation * fix(ui): preserve sign-in focus contrast * test(ui): await close focus transition * refactor(ui): centralize picker scroll geometry * fix(ui): keep picker focus visible in constrained panels * fix(ui): preserve the expanded book trigger in compact panels * test(ui): reach reader settings close with native keys * fix(ui): honor reduced motion in chapter reveal * fix(ui): address focus and scroll review feedback * fix(ui): reveal focused chapters in Firefox Keep focused book triggers fully visible within the built-in accordion on Linux Firefox. Wait for the settings dialog opening animation before asserting visibility in WebKit. * test(ui): query the current settings dialog while opening * feat(core): add Content Library video APIs (YPE-6573) (#488) * feat(core): add content library video APIs * refactor(core): simplify video schema ownership * fix(core): harden content library contracts * fix(core): validate video response boundaries * fix(core): distinguish no-content responses * fix(core): scope no-content status handling * fix(core): distinguish empty response bodies * test(core): isolate Content Library smoke coverage * feat(core): keep content library APIs compatible with v3 * fix(core): align content library rollout contracts (YPE-6573) * fix(core): accept empty video filters and trim search bundles (YPE-6573) * fix(core): address content library review feedback (YPE-6573) * docs(core): clarify video APIs and live validation (YPE-6573) * fix(core): use stable Content Library routes (YPE-6573) * feat(core): add Notes API client (#497) * feat(core): add Notes API client Amp-Thread-ID: https://ampcode.com/threads/T-01a2095d-25a9-72c5-a0fb-baa79c35e05a * fix(core): address Notes API review feedback Amp-Thread-ID: https://ampcode.com/threads/T-01a2095d-25a9-72c5-a0fb-baa79c35e05a * fix(core): normalize Notes write colors * fix(core): address Notes API contract review * fix(core): enforce Notes version filters and tolerate malformed passages * fix(core): isolate malformed Notes list records Amp-Thread-ID: https://ampcode.com/threads/T-01a2095d-25a9-72c5-a0fb-baa79c35e05a * chore: refresh combined core bundle budget Amp-Thread-ID: https://ampcode.com/threads/T-01a2095d-25a9-72c5-a0fb-baa79c35e05a --------- Co-authored-by: Amp <amp@ampcode.com> * fix(ui): preserve newer selection after native Share (YPE-6812) (#494) * fix(ui): label reader sign-in menu trigger (YPE-6810) (#492) * fix(ui): label reader sign-in menu trigger (YPE-6810) * test(ui): capture Linux WebKit dialog visibility failures * test(ui): stress WebKit visibility diagnostics * test(ui): check settings visibility after keyboard focus Assert dialog opening state after Enter and visibility on the Close button after native Tab, alongside the focus-ring checks. Remove temporary WebKit diagnostics and repeated CI groups. * fix(ui): handle reader clipboard failures (#490) * fix(ui): handle reader clipboard failures (YPE-6809) * fix(ui): report clipboard failures and retry failed shares * fix(ui): keep clipboard warnings visible while scrolling * fix(ui): ignore stale clipboard action results * fix(ui): support Bible reader interactions in iframes (YPE-6410) (#491) * fix(ui): retain iframe verse selection and anchors (YPE-6410) * test(ui): cover iframe highlight painting and reset * fix(ui): complete iframe reader text and focus handling * fix(ui): handle reader host callback exceptions (YPE-6811) (#493) * chore(ui): align declaration build with strict checks (YPE-6464) (#503) chore(ui): align declaration build with strict checks Refs: YPE-6464 * chore: enable additional TypeScript safety checks (#505) * chore(ui): align declaration build with strict checks Refs: YPE-6464 * chore: enable additional TypeScript safety checks Refs: YPE-6832 * feat(ui): customize verse actions and indicators (#506) * feat(ui): customize verse actions and indicators Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> * test(ui): wait for verse layout in browser journeys Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> * fix(ui): keep configured verse actions reachable Make exiting actions inert and keep the visible verse indicator inside its pointer target. Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> * fix(ui): keep verse callbacks scoped to the displayed passage Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> * fix(ui): preserve verse action focus and warning visibility Signed-off-by: Austin <abharms@gmail.com> * fix(ui): restore focus after rejected verse action dismissal Refs: YPE-6782 Signed-off-by: Austin <abharms@gmail.com> --------- Signed-off-by: Austin <abharms@gmail.com> * feat(ui): add Reader note saving Ref: YPE-6783 * fix: recover Reader Notes after interrupted authorization Preserve the draft on browser Back and clean up a partially persisted automatic token refresh. Keep the composer within narrow viewports and simplify the shared action and highlight paths. Ref: YPE-6783 * fix: preserve Reader Notes through authorization Keep note handoffs bound to their initiating Reader and authorization attempt. Preserve focus, existing verse actions, and a recoverable draft across OAuth failures and navigation. Ref: YPE-6783 * fix: preserve Reader sessions and highlight refresh Keep OAuth recovery bound to the initiating draft and restore focus around the Notes composer. Refresh highlights for the passage on screen and preserve existing host sign-in behavior. Ref: YPE-6783 * fix: preserve Reader draft recovery and auth compatibility Keep host-controlled toolbar scopes, restore legacy startup token rotation, and retain the captured draft through a verified failed callback. Verify the workflow with isolated browser fixtures and native Safari. Ref: YPE-6783 * fix: preserve Reader auth and passage ownership Keep verified legacy auth tokens available, discard drafts for ended sessions, restore selection during host takeover, and gate highlight writes to the rendered passage. Ref: YPE-6783 * fix: preserve Reader drafts and OAuth attempt ownership Retain clean-canceled drafts across navigation, allow matching-chapter highlight intents, and keep verified auth state bound to its active account and handoff. Ref: YPE-6783 * fix: isolate Reader authorization handoffs Resume Notes on the verified configured callback, supersede an older pending highlight action, and keep account-bound requests and drafts tied to the right session. Preserve standalone swatch outlines under host styling. Ref: YPE-6783 * fix: recover Reader note edits after a lost response Retry the original create payload, then reconcile the current draft against the recovered note ID using the verified writer token. Keep that ID and draft after a failed update. Ref: YPE-6783 * fix: retry Notes writes after definite rejections Allow corrected create fields and retain known blank content after a definitive HTTP rejection, while preserving recovery from earlier uncertain writes. Ref: YPE-6783 * fix: retry corrected Notes payloads after a 413 Release an unresolved create payload after a size rejection. Retain the request UUID and preserve recovery when the note ID is already known. Ref: YPE-6783 * fix(ui): preload destination highlights (YPE-6783) * docs: clarify legacy auth recovery (YPE-6783) * test(ui): await destination passage before save refresh (YPE-6783) * test(ui): await settled highlight colors (YPE-6783) * chore: sync react localization * fix(ui): announce note highlight color names * fix(ci): verify imported localization provenance * fix(ui): expose action labels and record Notes QA evidence * chore: remove pilot reports and obsolete localization support Keep QA evidence in Jira, the PR, and BrowserStack. Restore the main localization ownership policy and remove superseded sync changesets now that PR507 is merged. SDK implementation and locale catalogs are unchanged. * fix: harden Reader Notes authorization and integration * fix: refresh OAuth tree-shaking sentinel * refactor: narrow reader notes auth and test scope * test: remove redundant notes browser scenarios * refactor: reuse oauth cleanup and reader scope checks * fix(ui): align notes composer with save design * test(ui): wait for clipboard retry action visibility * fix(ui): accept normalized note save responses Reconcile current draft fields against the original submitted fields rather than the API response. Trust validated successful updates while retaining the resource-ID check. Existing Notes journeys cover trimmed update content and normalized create line endings. * fix(ui): preserve verse action compatibility for notes Keep the published built-in action union and explicit custom action lists unchanged. Save remains in the default actions, so Notes can ship as a minor addition. Preserve both sample demonstrations with a default/custom action toggle. * fix(ui): recover note drafts after validation rejections * chore: sync react localization * fix(ui): name the note visibility selector accessibly * chore(demo): remove preloaded verse marker * fix(ui): toggle note visibility directly * docs(demo): update verse marker smoke instructions * fix(ui): align reader notes actions and authorization * test(ui): wait for custom action popover visibility --------- Signed-off-by: Austin <abharms@gmail.com> Co-authored-by: platform-localization-pr-bot[bot] <294853593+platform-localization-pr-bot[bot]@users.noreply.github.com> Co-authored-by: camrun91 <16566029+camrun91@users.noreply.github.com> Co-authored-by: Cameron Pak <cameronandrewpak@gmail.com> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Amp <amp@ampcode.com> Co-authored-by: abharms <16394621+abharms@users.noreply.github.com>
YPE-6811
Immediate exceptions from host onCopy/onShare callbacks previously escaped before Promise.resolve could wrap them, skipping verse-selection clearing and popover dismissal. A private shared helper now catches both immediate exceptions and returned rejected promises. The host callback is still invoked directly during the click handler, preserving browser user activation; cleanup remains immediate.
Four reader regression cases cover Copy and Share with immediate throws and rejected promises. They verify direct callback invocation, no uncaught browser error, the empty-selection notification, cleared selection styling and dismissed popover. Against unchanged main, both immediate-throw cases failed and both rejected-promise cases passed. With this fix, all four pass.
Validation: all 626 UI tests passed across 56 files, plus type checking, focused lint, formatting and diff checks. Core/hooks use the unchanged base validated earlier in this session (352 core tests passed, 2 opt-in tests skipped; 200 hooks tests passed). Includes a UI patch changeset.
Independently based on main. This does not include the reader refactor, clipboard-fallback, iframe or accessible-name changes, and does not address the separate native Share completion race.


Confidence Score: 5/5
This PR appears safe to merge.Summary
Catches immediate throws and rejected promises from host
onCopyandonSharecallbacks.Reviews (2) · Last reviewed commit: "fix(ui): resolve reader host callback ba..." · Reviewed by Greptile