Skip to content

fix(sdk): decode scoped IDs when replaying patches - #5243

Merged
jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/sdk-scoped-patch-replay
Oct 8, 2026
Merged

jrusso1020 merged 1 commit into
heygen-com:mainfrom
user-github-me:fix/sdk-scoped-patch-replay

Conversation

@user-github-me

Copy link
Copy Markdown
Contributor

An SDK edit to hf-host/hf-leaf emits a JSON Pointer such as /elements/hf-host~1hf-leaf/text. The patch reader passes that encoded segment to the scoped DOM resolver, so replay, saved overrides, and iframe synchronization lose the edit. Decode element IDs once, in JSON Pointer order, before resolving the target.

The patch format stays the same. Style, text, attribute, timing, hold, and removal patches now replay against the same nested element that the forward edit changed, including literal ~1 IDs.

Validation:

  • Reproduced on main: forward style edit succeeded while emitted-patch replay and reopening saved overrides left the nested element unchanged.
  • All 14 new regressions failed before the fix; all 621 SDK tests pass afterward, covering emitted patches, override replay, batch rollback, and a literal ~1 ID.
  • Built SDK in Chrome 152 with a real iframe: nested text/style edits, undo, redo, iframe reload, saved-override reopening, and event replay all passed; the sibling with the same ID stayed unchanged and no runtime errors occurred.
  • SDK build, repository lint, and changed-file formatting passed.

@jrusso1020 jrusso1020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified: patch paths escape scoped IDs as JSON Pointer (hf-host~1hf-leaf), but the replay parser hands the escaped segment straight to findById. So replay, saved overrides and batch rollback all miss nested elements. Decoding once, in RFC 6902 order, before resolving is correct and leaves the patch format unchanged. Optional nit: this duplicates decodePathSegment in patches.ts, which could be exported and reused. The tests cover every element patch kind and check that the same-ID sibling stays untouched.

— Rames

@jrusso1020
jrusso1020 enabled auto-merge October 8, 2026 19:46
@jrusso1020
jrusso1020 added this pull request to the merge queue Oct 8, 2026
Merged via the queue into heygen-com:main with commit 548426f Oct 8, 2026
79 checks passed
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.

2 participants