Skip to content

feat(studio): sourcePatcher data-hf-id targeting (R1, T3)#1271

Draft
vanceingalls wants to merge 1 commit into
06-07-feat_core_clip-model_hf-_ids_minted_at_parse_emitted_as_data-hf-id_r1_from
06-07-feat_studio_sourcepatcher_data-hf-id_targeting_r1_t3_
Draft

feat(studio): sourcePatcher data-hf-id targeting (R1, T3)#1271
vanceingalls wants to merge 1 commit into
06-07-feat_core_clip-model_hf-_ids_minted_at_parse_emitted_as_data-hf-id_r1_from
06-07-feat_studio_sourcepatcher_data-hf-id_targeting_r1_t3_

Conversation

@vanceingalls
Copy link
Copy Markdown
Collaborator

@vanceingalls vanceingalls commented Jun 8, 2026

What

Adds hfId as a first-class target field to sourcePatcher (packages/studio/src/utils/sourcePatcher.ts). When target.hfId is set, the patcher finds the element via [data-hf-id="${hfId}"] before falling back to id or CSS selector.

Also tightens the existing id= regex patterns with a negative lookbehind to prevent false matches on attributes like data-id= or composition-id=.

Why

T3 spec — the sourcePatcher path handles the studio's in-browser rich-text editing. It needs to accept hfId targets so the studio can address elements by stable content-based id (R1) rather than a positional CSS selector that can drift when siblings are inserted. Depends on PR #1270.

How

  • hfId?: string added to the patch target type
  • Target resolution order: hfIdidselector
  • [data-hf-id] lookup uses the same attribute-selector pattern as sourceMutation
  • Negative lookbehind fix: (?<!\w)id= prevents data-id= from matching id-based patterns

Test plan

  • T3 spec tests in sourcePatcher.test.ts — hfId targeting cases pass
  • All pre-existing sourcePatcher tests pass (no regressions)

Copy link
Copy Markdown
Collaborator Author

vanceingalls commented Jun 8, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

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