Skip to content

/enroll: a stale approval's completion clears a newer link's code #912

Description

@nedtwigg

Code: approve and clearEnrollment in hosted/src/App.tsx; the hashchange handler takeLink in the same file.

Failure path: the user clicks Approve for code A, and approveEnrollment(A) is in flight. A second enrollment link opens in the same tab, and hashchange sets enrolling to code B. A's request resolves, and approve calls clearEnrollment(), which sets enrolling to null and replaces the URL. Code B is gone from memory and from the URL, and the notice reads "Approved A". The user has to open link B again. hosted.md -> "Burrow enrollment" says "A fragment change on /enroll takes the new code without reloading". Here a completion that is already in flight undoes that take.

Suggested fix: in approve, clear only if the enrollment still being shown is the one approved (if (enrollingRef.current?.code === code) clearEnrollment()). Otherwise leave B in place and show the A notice. Add an App test: start an approval, fire a hashchange to a new code, resolve the approval, then assert that the new code is still shown.

Found while trimming #904, which had parked this as a spec "Known gap".

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions