Skip to content

Queue Edit Mode changes for the agent and fix inline text editing - #457

Merged
jamesrochabrun merged 1 commit into
mainfrom
jroch-edit-mode-queue
Aug 18, 2026
Merged

Queue Edit Mode changes for the agent and fix inline text editing#457
jamesrochabrun merged 1 commit into
mainfrom
jroch-edit-mode-queue

Conversation

@jamesrochabrun

Copy link
Copy Markdown
Owner

Edit Mode had two problems, both about changes going nowhere visible.

Text was impossible to keep typing. The page bridge re-posts the selected element on every DOM mutation — including the live edit being typed — and its capture is textContent.trim(). A typed trailing space was echoed away, and with it the ability to start another word; the toolbar's own field also clipped at lineLimit(1...3) with no scroll. And proven direct writes applied silently, so a color change or a static-preview text edit could look ignored while an edit that happened to fall back to the agent was the only one that showed up in the tray.

Every change now queues. Agent-bound edits mirror into the session tray as one Edits chip per element — upsert keyed by selector, since element captures carry a fresh UUID on every DOM read, so a slider drag updates one chip instead of piling up. Reverting an edit drops the chip, removing a chip drops the batch behind it, and Send / ⌘↵ commits the element in progress and sends the whole tray (a failed send leaves it intact). Direct-to-source writes move behind the existing setting — now off by default, and it also gates the static-preview text splice.

Prompts carry the rules that were missing. A preamble leads every queued batch: change the value at its definition and never replace a var(--token) / variable / constant with a literal, add or pick a token when the definition is shared, keep the styling mechanism (Tailwind stays Tailwind, CSS modules stay CSS modules) and the value notation (unit, color form, clamp() shape), edit text where it is defined, change nothing else, and stop and explain rather than force it. Below that, a where these values live today section merges CSSOM declared values with proven project-relative files:

- font-size: declared as `clamp(1.5rem, 4vw, 3rem)` in rule `.hero-sub` (site.css) — verified in styles/site.css
- color: declared in styles/site.css

Rule proving still runs with direct writes off, because that provenance is what the section is made of. A failed direct write now downgrades into the batch keeping its original value, instead of a bare target value with no origin.

Text editing is AgentHub's own editor now (WebPreviewTextContentEditor): local draft, grows with content and scrolls instead of clipping, with a pure draft policy — the focused draft always wins, an unfocused one yields only to non-whitespace changes. refreshFromLiveElement syncs DesignToolbarValues in place rather than replacing the object, so a mutation echo no longer resets bound editors, the caret, or properties already edited. The pending-edits pill is removed; the tray says the same thing with more detail and one Send.

Tests: new draft-policy suite; queue upsert / chip labels / preamble appearing exactly once for a mixed queue; chip summaries and declaration-site lines; live read-back preserving in-flight text and toolbar state; peek-without-consume; queue-first routing for proven properties and static-preview text. The four direct-splice tests now opt into the setting so that path stays covered. Targeted AgentHubCore suites and the app build pass; the editor has not been exercised in the running UI yet.

Edit Mode had two problems. Text was impossible to keep typing: the page
bridge re-posts the selected element on every DOM mutation (including the
live edit being typed) and its capture is textContent.trim(), so a typed
trailing space was echoed away — and with it the ability to start another
word — while the toolbar's field clipped at three lines with no scroll.
And style/text changes that took a proven direct-write path applied
silently, so an edit could look ignored while the agent-bound ones were
the only ones that surfaced.

Every change now queues. Agent-bound edits mirror into the session tray
as one "Edits" chip per element (upsert keyed by selector, since element
captures carry a fresh UUID on each DOM read); reverting an edit drops
the chip, removing a chip drops the batch behind it, and Send/⌘↵ commits
the element in progress and sends the whole tray. Direct-to-source writes
move behind the existing setting, now off by default, which also gates
the static-preview text splice.

Prompts carry the rules that were missing: a preamble that leads every
queued batch (edit the token/variable/definition rather than inlining a
literal, keep the styling mechanism and value notation, change nothing
else) plus a "where these values live today" section merging CSSOM
declared values with proven project-relative files. Rule proving still
runs with writes off, because that provenance is what the section is made
of. A failed direct write now downgrades into the batch keeping its
original value instead of a bare target value.

Text editing moves to an AgentHub-owned editor: local draft, scrolls
instead of clipping, and a draft policy where the focused draft always
wins and an unfocused one yields only to non-whitespace changes.
refreshFromLiveElement syncs the toolbar object in place so a mutation
echo no longer resets bound editors or already-edited properties. The
pending-edits pill is gone — the tray says the same thing with more
detail.

Tests: new draft-policy suite; queue upsert, chip labels and single
preamble; chip summaries and declaration-site lines; live read-back
preserving in-flight text and toolbar state; peek-without-consume;
queue-first routing for proven properties and static-preview text. The
four direct-splice tests now opt into the setting so that path stays
covered.
@jamesrochabrun
jamesrochabrun merged commit 30d156d into main Aug 18, 2026
1 check 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.

1 participant