Skip to content

feat: track element deletions in the agent context - #127

Merged
rezailmi merged 3 commits into
mainfrom
feat/track-element-deletions
Jun 14, 2026
Merged

feat: track element deletions in the agent context#127
rezailmi merged 3 commits into
mainfrom
feat/track-element-deletions

Conversation

@rezailmi

Copy link
Copy Markdown
Owner

Summary

Deleting an element in the overlay was invisible to coding agents. deleteSelection removed the element's session edit entirely and recorded the removal only in the local undo stack, so nothing in the exported/sent context told the agent to remove the element from source. If you styled an element and then deleted it, even the styling edit was wiped.

This PR makes deletions first-class session edits that flow to agents through every send/copy surface.

What changed (feature — 80fe237)

  • types.ts — optional deleted?: boolean on SessionEdit.
  • use-session-manager.tsdeleteSelection marks the edit deleted: true (capturing the locator before DOM removal) instead of dropping it; undo restores the prior state. getSessionEdits keeps deleted edits and only prunes genuinely-stale disconnected ones (!isConnected && !deleted).
  • utils.tshasSessionEditChanges counts deletions; buildSessionExport emits an action: delete this element block; getExportContentProfile/buildExportInstruction gain a delete directive.
  • use-agent-comms.ts — the per-item send adds deleted: true to the agent payload; apply-all/copy-all pick it up via getSessionItems.
  • edits-popover.tsx — deleted items render as deleted: <element>.

Code review fixes (7559cc6)

Ran a structured multi-agent review (8 reviewers). One real defect surfaced and is fixed here:

  • P1 — move + delete contradiction: a deleted element that also had a pending move emitted a "move this element" plan alongside "delete this element". Fixed at the root in buildMoveEntries (a deleted edit produces no move intent/plan/profile-flag). Kept deleted-and-moved edits visible in the popover.
  • Documented the new deleted field in the mcp-server, runner-workflow, and mac-app-integration contracts.
  • Added tests: delete+move suppression, the deleted:true payload reaching the agent, and multi-element deletion tracking.

Also included (docs — a8e1aaf)

Backlog implementation plans 010017 under plans/ (utils god-module slice, overlay/canvas tests, color-scan perf, eslint+prettier, test:fast, preload version field, rotated-drag scale, provider footer wiring). Pure planning docs — no code impact. Split into its own commit if you'd prefer a separate PR.

Verification

  • bunx tsc --noEmit clean; bun run test green (515 tests, +7 from baseline).
  • Live: deleted an element in the dev app and confirmed it appears in the "Copy to AI agents" popover as deleted: ….

Notes / follow-ups

  • The deleted field rides to the out-of-repo Mac app broker; even if stripped, exportMarkdown carries the delete instruction. Confirm passthrough (same open question as moveIntent/movePlan).
  • When the session-edit stale lifecycle (plan 006) lands, its reconciler must skip deleted edits and extend the getSessionEdits guard.

rezailmi added 3 commits June 14, 2026 08:08
Deleting an element previously removed its session edit entirely and
recorded the removal only in the local undo stack, so agents never
learned the element should be removed from source. Now mark the edit
as deleted (capturing its locator before DOM removal) instead of
dropping it, keep deleted edits through the disconnected-edit filter,
and emit a delete action + instruction in the export text and the
agent payload. Undo cleanly restores the prior state.
Expand the eight vetted backlog items in plans/README.md into
self-contained handoff plans: utils god-module slice extraction,
overlay/canvas-store tests, replaceSelectionColor scan perf (gated),
eslint+prettier baseline, test:fast script, preload hook version
field, rotated-element drag scale (gated), and provider footer wiring.
Numbered 010-017 to avoid colliding with the 008/009 commit
references in the execution record.
…ument deletion send

Code review of the deletion-tracking feature found one real defect: a
deleted element that also had a pending move emitted a contradictory
"move this element" plan alongside the "delete this element" action
across every export/send surface. Skip deleted edits in buildMoveEntries
so no move intent/plan/profile-flag is generated for them. Keep a
deleted-and-moved edit visible in the edits popover. Add tests for the
delete+move suppression, the deleted:true agent payload, and multi-element
deletion tracking. Document the deleted payload field in the mcp-server,
runner-workflow, and mac-app-integration contracts.
@rezailmi
rezailmi merged commit c75b67c into main Jun 14, 2026
3 checks passed
@rezailmi
rezailmi deleted the feat/track-element-deletions branch June 14, 2026 01:06
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