Skip to content

fix(sdk-recorder): reset React state when replacing the recorder - #3387

Open
vedanth-jadhav wants to merge 1 commit into
CapSoftware:mainfrom
vedanth-jadhav:fix/sdk-hook-reset-state
Open

vedanth-jadhav wants to merge 1 commit into
CapSoftware:mainfrom
vedanth-jadhav:fix/sdk-hook-reset-state

Conversation

@vedanth-jadhav

@vedanth-jadhav vedanth-jadhav commented Oct 26, 2026 •

Copy link
Copy Markdown

Changing a useCapRecorder key, API base, user or camera creates a fresh idle recorder, but the hook currently keeps the previous recorder's phase, video ID and elapsed time. The UI can therefore keep showing an active or completed recording after its tracks have been destroyed.

Initialize the hook state from each replacement recorder. Equivalent rerenders and max-duration-only updates retain the active capture.

Validation:

  • Six mounted React regressions with the real hook/recorder; five fail before the state reset, all six pass afterward. Covers four configuration changes, completed-video identity and stable rerenders.
  • All 35 existing SDK tests pass.
  • SDK package typecheck, scoped strict hook/test typecheck, ESM/declaration build, scoped Biome and diff checks pass.
  • Add the mounted test to the existing web compatibility CI list, reusing its React/jsdom dependencies.

The small unsubscribe typing correction reuses the same registered callback for add/delete. It fixes an existing TS2345 exposed by importing the SDK source into the web test; the identical supporting hunk is also in #3380. This PR does not include that PR's upload ownership changes. No dependency or lockfile changes. Browser capture/storage are controlled in tests; physical devices were not exercised.

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge.

Summary

useCapRecorder now resets its phase, video ID, and elapsed time when it installs a replacement recorder.

  • A replacement recorder resets the hook's capture details.
  • Event listeners use the same callback to add and remove handlers.

No actionable issues found. Checks were based on source review; tests and physical devices were not run.

Reviews (1) · Last reviewed commit: "fix(sdk-recorder): reset React state whe..." · Reviewed by Greptile

@vercel

vercel Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Someone is attempting to deploy a commit to the Cap Software Inc Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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.

1 participant