Skip to content

feat(studio): route element delete through SDK removeElement (§3.1)#1465

Open
vanceingalls wants to merge 1 commit into
06-15-fix_studio_wire_ontrysdkpersist_to_sdkcutoverpersist_cutover_was_unwired_from
06-15-feat_studio_route_element_delete_through_sdk_removeelement_3.1_
Open

feat(studio): route element delete through SDK removeElement (§3.1)#1465
vanceingalls wants to merge 1 commit into
06-15-fix_studio_wire_ontrysdkpersist_to_sdkcutoverpersist_cutover_was_unwired_from
06-15-feat_studio_route_element_delete_through_sdk_removeelement_3.1_

Conversation

@vanceingalls

@vanceingalls vanceingalls commented Jun 15, 2026

Copy link
Copy Markdown
Collaborator

Summary

Routes handleDomEditElementDelete through the SDK (sdkSession.removeElement) when an active session resolves the element's hf-id, falling back to the existing server-side /api/projects/{pid}/file-mutations/remove-element/ path otherwise. Also documents (via // ponytail: comment) that z-index reorder (§3.4) is already SDK-cut-over because it writes inline-style patches through commitPositionPatchToHtmlpersistDomEditOperationsonTrySdkPersist.

Stage 7 §3.1 — Delete → removeElement

Changes

  • sdkCutover.ts: Extract internal persistSdkSerialize helper (serialize → write → recordEdit → reload tail shared across ops); add exported sdkDeletePersist(hfId, originalContent, targetPath, session, deps). sdkCutoverPersist refactored to use persistSdkSerialize.
  • useElementLifecycleOps.ts: Add optional onTrySdkDelete? callback to params; handler tries it after reading originalContent and before the server API call. On success: clear selection, show toast, return. Z-index reorder // ponytail: note added (§3.4 verified cut-over).
  • useDomEditCommits.ts: Thread onTrySdkDelete? through UseDomEditCommitsParamsuseElementLifecycleOps.
  • useDomEditSession.ts: Wire onTrySdkDelete from sdkSession (same pattern as onTrySdkPersist).
  • sdkCutover.test.ts: 6 new tests for sdkDeletePersist (null session, element not found, removeElement called, history recorded, reload called, error fallback).

Open decisions (§7)

  • Undo ownership (D): sdkDeletePersist records into Studio editHistory (persistent), consistent with sdkCutoverPersist. SDK session also has in-memory history. Two stacks coexist — same as style/text edits today. s7.4 force-reload after undo/redo keeps Studio history authoritative; no regression introduced.
  • §3.4 z-index reorder: Writes inline-style patches → already SDK-cut-over as setStyle. No DOM-node reordering; no SDK reorder op exists or is needed. Documented with // ponytail: comment.

Verification

  • bun run build
  • bun run test ✅ (26 sdkCutover tests pass, full suite green)
  • bunx oxlint / bunx oxfmt --check
  • 600-line file gate ✅
  • Lefthook pre-commit hooks ✅

🤖 Generated with Claude Code

Co-authored-by: Miguel Ángel <miguel07alm@protonmail.com>
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