Skip to content

fix/2556 reload button in image captcha mode loads a new challenge#2560

Open
forgetso wants to merge 1 commit into
mainfrom
fix/2556-reload-image-captcha
Open

fix/2556 reload button in image captcha mode loads a new challenge#2560
forgetso wants to merge 1 commit into
mainfrom
fix/2556-reload-image-captcha

Conversation

@forgetso
Copy link
Copy Markdown
Member

Summary

Fixes #2556 — the reload button in image captcha mode used to bounce the user back to the checkbox: the modal closed and never reopened with a fresh challenge.

Manager.reload called resetState(frictionlessState?.restart), which on the bundle path restarts the entire frictionless flow by re-keying the ProcaptchaFrictionless wrapper, unmounting the image captcha widget. On the direct path it synchronously set showModal: false. Either way the modal disappeared.

reload now clears the active timeout, fires onReload, resets the loading flag so start() won't no-op against a stale loading: true, and calls start() to request a fresh challenge using the existing frictionless session (if any). The modal stays open through the transition.

  • packages/procaptcha/src/modules/Manager.ts — new reload body
  • packages/procaptcha — vitest infrastructure + Manager.reload tests
  • .changeset — patch bump for @prosopo/procaptcha

Test plan

  • npm run -w @prosopo/procaptcha test — 6/6 pass
  • npm run -w @prosopo/procaptcha build:tsc
  • npm run -w @prosopo/procaptcha-react build:tsc
  • npm run -w @prosopo/procaptcha-frictionless build:tsc
  • npm run -w @prosopo/procaptcha-bundle build:tsc
  • npm run -w @prosopo/procaptcha-common test
  • npm run -w @prosopo/procaptcha-frictionless test
  • Manual smoke: click "I'm not a robot" → solve modal opens → click reload → new challenge appears in the same modal (no checkbox flash)

🤖 Generated with Claude Code

The reload button used to bounce the user back to the checkbox: the modal
closed and never re-opened to show the fresh challenge.

`Manager.reload` called `resetState(frictionlessState?.restart)`, which (on
the bundle path) restarted the entire frictionless flow by re-keying the
ProcaptchaFrictionless wrapper, unmounting the image captcha widget. On
the direct path it synchronously set `showModal: false`. Either way the
modal disappeared.

`reload` now just clears the active timeout, fires `onReload`, resets the
loading flag so `start()` won't no-op against a stale `loading: true`, and
calls `start()` to request a fresh challenge using the existing
frictionless session (if any). The modal stays open through the
transition.

Adds vitest infrastructure for the @prosopo/procaptcha package and tests
covering: onReload firing, start() being invoked, no frictionless restart,
modal staying open, timeout being cleared, and the loading-guard being
cleared so start() proceeds.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@forgetso forgetso force-pushed the fix/2556-reload-image-captcha branch from 4653ff3 to be256ea Compare May 20, 2026 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Reload button in image captcha mode just closes the image captcha

1 participant