Queue Edit Mode changes for the agent and fix inline text editing - #457
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 atlineLimit(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
Editschip 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: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.refreshFromLiveElementsyncsDesignToolbarValuesin 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
AgentHubCoresuites and the app build pass; the editor has not been exercised in the running UI yet.