Context
Promoted from @neo-opus-ada's defect-note (MESSAGE:671786e5, observed on examples/fieldWithPrefix at dev 53ed5d36e5 while capturing covers for #21551 under #21329):
- Typing into a
Neo.plugin.PrefixField-masked TextField faster than an App-Worker round trip (pressSequentially with 0 ms delay or fast typing) reorders and mangles characters — e.g. date 201120260930 becomes 02/60/9302 01:1m, and MAC ABCDEF becomes DE:FA:BX:XX:XX:XX.
- Filling five masked fields back-to-back without artificial ~
700 ms pauses (fill() / paste / autofill) leaves fields 2–4 raw/unmasked and the Credit Card field empty.
- Also blocks reliable Playwright typing verification on contributor GFI #21502 (
AC-1: typing 001A2B3C4D5E into the MAC Address field).
The Problem
Neo.plugin.PrefixField (src/plugin/PrefixField.mjs:127-136, 207-226) currently performs live DOM input masking and caret placement asynchronously from the App Worker:
- Cross-thread VDOM/caret clobber on fast keystrokes:
PrefixField listens to selectionchange, keydown, focusin, and focusout in the App Worker, sets el.value = clean(value).join('') (triggering an async VDOM delta), and calls Neo.main.DomAccess.selectNode(...) (an async RMA call) while setting me.ignoreSelection = true and immediately me.ignoreSelection = false synchronously before the RMA even crosses to Main (:220-223). Any keystroke arriving on the Main Thread <input> before the worker VDOM delta + selectNode return gets overwritten or inserted at a stale caret index.
- Missed
fill() / paste events without selectionchange: src/plugin/PrefixField.mjs:131-136 never listens to input at all — it relies on document's selectionchange, which browsers coalesce per frame/activeElement and do not emit per field across rapid programmatic fill() or autofill sequences.
- Orphan single-instance
src/main/addon/PrefixField.mjs: An experimental Neo.main.addon.PrefixField (src/main/addon/PrefixField.mjs:1-139) already ships as a lazy Main-Thread addon chunk in every build, but is completely unwired, stores single-element state (this.el, this.pattern, this.back) on the singleton instead of per-element in a Map (breaking multi-field views like examples/fieldWithPrefix's 5 inputs), listens to keypress (which never fires for Backspace), and leaves console.log in format() (:126).
- RegExp flag loss in
clean(): new RegExp(this.accept || "\\d", "g") (src/plugin/PrefixField.mjs:193) strips flags like 'i' when accept is a case-insensitive RegExp (e.g. /[0-9a-f]/i).
The Architectural Reality
- Design authority:
examples/fieldWithPrefix/MainContainer.mjs:15 ("Type into a field: the mask fills its slots as you go and refuses characters it does not accept") and src/form/field/Text.mjs:1550-1557 ("The user's input has changed the real DOM on the Main Thread. We must manually update our 'last known state' (this.vnode) to match this reality before the next diffing cycle runs. This prevents the framework from sending a redundant delta update that could overwrite the user's input or cause cursor jumps.").
src/main/DomEvents.mjs:11-15, 565-581, 642-651: DomEvents delegates input, keydown, focusin, and focusout in bubble phase on document.body, and onChange(event) reads value: target.value. Therefore, direct target-phase listeners on the <input> element inside Neo.main.addon.PrefixField execute synchronously on the Main Thread before DomEvents#onChange reads target.value:
- On
input: <input>.value and setSelectionRange(i, j) settle synchronously on Main before the next keystroke AND before DomEvents#onChange forwards {type: 'input', value: masked} to TextField#onInputValueChange, which updates inputVNode.attributes.value and reportedInputValue without emitting a clobbering worker-to-main value delta.
- On
focusin / focusout: when focus shows the empty mask template or blur clears an unfilled template (el.value === pattern), dispatching a bubbling input event from <input> (guarded against re-entry) synchronizes TextField in FIFO order before focusout reaches TextField#onFocusLeave (resolving to TextField#emptyValue).
The Fix
- Promote
Neo.main.addon.PrefixField (src/main/addon/PrefixField.mjs) into the multi-instance Main-Thread mask controller:
- Key per-input state in
this.fields = new Map() (id -> {el, accept, pattern, slots, prev, first, back, formatting, listeners}), removing singleton this.el state and console.log.
- Expose
remote.app: register, setConfigs, unregister (matching test/playwright/setup.mjs:58-62).
- Handle
keydown (Backspace tracking), input (synchronous clean + setSelectionRange before DomEvents#onChange), focusin (template display + caret at first unfilled slot), click (snap collapsed caret into valid slot range when clicking outside filled slots while preserving range selections), and focusout (clear untouched pattern to '' before DomEvents#onFocusOut).
- Preserve
RegExp flags ('i', 'u') alongside 'g' when compiling accept.
- Wire
Neo.plugin.PrefixField (src/plugin/PrefixField.mjs) to Neo.main.addon.PrefixField:
- Remove the async App-Worker
selectionchange / keydown / focusin / focusout DOM listeners and broken synchronous ignoreSelection toggle around DomAccess.selectNode.
- Load
Neo.currentWorker.getAddon('PrefixField', owner.windowId) on onOwnerMounted() (supporting remounts per Neo.plugin.Base and destroy() cleanup via unregister), forwarding serialized {id: owner.getInputElId(), acceptSource, acceptFlags, pattern, slots, windowId} on register and setConfigs.
- Retain
clean(input) (with RegExp flag preservation) and wrap owner.beforeSetValue (restored in destroy()) in the App Worker so Node unit specs and programmatic field.value = ... mutations format atomically without DOM round-trips.
- Add Playwright unit + real-browser component coverage:
test/playwright/unit/plugin/PrefixField.spec.mjs: unit coverage for clean(), RegExp flag preservation (/[0-9a-f]/i), programmatic TextField value formatting, and register/setConfigs/unregister lifecycle.
test/playwright/component/form/field/PrefixField.spec.mjs: real OMT browser test mounting five masked TextFields and verifying zero-delay pressSequentially('201120260930') ('20/11/2026 09:30'), zero-delay MAC keystrokes, five consecutive pause-free fill() calls across all five fieldWithPrefix masks, Backspace across separators, untouched focus/blur clearing, and live runtime config updates.
Contract Ledger
| Target Surface |
Source of Authority |
Proposed Behavior |
Fallback / Edge Case |
Docs |
Evidence |
Neo.plugin.PrefixField (accept_, pattern_, slots_, clean()) (src/plugin/PrefixField.mjs:53-62, 191-201) |
examples/fieldWithPrefix/MainContainer.mjs:15, 22-32 & #21502 Out of Scope |
Preserves public config names (accept, pattern, slots, inputCls, labelCls, ownerCls); registers/updates/unregisters Neo.main.addon.PrefixField per owner.windowId (register, setConfigs, unregister) and preserves RegExp flags (e.g. 'i') when matching accept. |
Unmounted/unit-test TextField formats programmatic non-empty value in App Worker via beforeSetValue without calling Main addon (''/null resolves to TextField#emptyValue); null accept defaults to /\d/g; null slots defaults to '_'. |
Yes (JSDoc) |
test/playwright/unit/plugin/PrefixField.spec.mjs |
Neo.main.addon.PrefixField (register, setConfigs, unregister) (src/main/addon/PrefixField.mjs:21-27) |
src/form/field/Text.mjs:1550-1557 & src/main/DomEvents.mjs:565-581 |
Manages per-input state in Map by id; stamps data-neo-prefix-ready="true" while registered; formats <input>.value and setSelectionRange synchronously on Main during input, focusin, click, and focusout before bubble-phase DomEvents reads target.value. |
Missing DOM node on register returns false without throwing; setConfigs on unregistered id delegates to register; re-registering existing id detaches prior listeners first; drag/range selection on click is preserved. |
Yes (JSDoc) |
test/playwright/component/form/field/PrefixField.spec.mjs |
Acceptance Criteria
Out of Scope
- Changing
examples/fieldWithPrefix/MainContainer.mjs phone-width sizing or MAC label/config (#21502, reserved for external contributor pickup).
- Modifying
apps/portal/resources/data/examples.json (#21552).
Avoided Traps
- Keeping masking in App-Worker
selectionchange with await DomAccess.selectNode: Even awaiting the RMA leaves a full worker round-trip gap during which fast native keystrokes land at unformatted indices on Main.
- Singleton
this.el field state in Neo.main.addon.PrefixField: Clobbers earlier masked fields whenever a page mounts more than one PrefixField (examples/fieldWithPrefix mounts five).
- Mutating
examples/fieldWithPrefix/MainContainer.mjs: Collides with open contributor GFI #21502.
Related
Parent #21329 · #21140 · unblocks #21502 (AC-1 fast typing) · surfaced while capturing #21551 (#21552).
Ownership: self-assigned maintainer lane (@neo-gemini-maryam); curated good first issue / help wanted omitted because fixing an OMT cross-worker DOM/VDOM input-synchronization race across src/plugin/ and src/main/addon/ requires maintainer engine context ahead of the Engine 14 cut and unblocks contributor GFI #21502.
Decision Record impact: none.
Live latest-open + closed sweep: checked latest 20 open (#21553..#21359, 60 open — red band, filed under owning epic #21329 which has 19 subs) + open and closed search (PrefixField, fieldWithPrefix, "input mask", Out of Scope and Avoided Traps read on #21337, #21502, #21329) at 2026-11-20T02:47Z; no equivalent or prior exclusion found.
A2A in-flight claim sweep: latest 30 messages across all read-states (through 2026-11-20T02:45:26Z), promoted from @neo-opus-ada's defect-note (MESSAGE:671786e5), zero competing claims on PrefixField.
MC sweep: "fieldWithPrefix PrefixField back-to-back key presses reorder characters unmasked fill", 5 results + ask_knowledge_base (ticket), no prior decision found.
Own-assignment sweep: 3 open (#21553, #21547, #21512, all 3 in APPROVED PRs at merge gate), none overlapping.
Origin Session ID: 095892f3-027f-47aa-8092-a13ae31f72ca
Retrieval Hint: "PrefixField Main thread addon input mask back-to-back keystrokes reorder characters unmasked fill race"
Context
Promoted from
@neo-opus-ada's defect-note (MESSAGE:671786e5, observed onexamples/fieldWithPrefixatdev53ed5d36e5while capturing covers for #21551 under #21329):Neo.plugin.PrefixField-maskedTextFieldfaster than an App-Worker round trip (pressSequentiallywith0 msdelay or fast typing) reorders and mangles characters — e.g. date201120260930becomes02/60/9302 01:1m, and MACABCDEFbecomesDE:FA:BX:XX:XX:XX.700 mspauses (fill()/ paste / autofill) leaves fields 2–4 raw/unmasked and the Credit Card field empty.AC-1: typing001A2B3C4D5Einto the MAC Address field).The Problem
Neo.plugin.PrefixField(src/plugin/PrefixField.mjs:127-136, 207-226) currently performs live DOM input masking and caret placement asynchronously from the App Worker:PrefixFieldlistens toselectionchange,keydown,focusin, andfocusoutin the App Worker, setsel.value = clean(value).join('')(triggering an async VDOM delta), and callsNeo.main.DomAccess.selectNode(...)(an async RMA call) while settingme.ignoreSelection = trueand immediatelyme.ignoreSelection = falsesynchronously before the RMA even crosses to Main (:220-223). Any keystroke arriving on the Main Thread<input>before the worker VDOM delta +selectNodereturn gets overwritten or inserted at a stale caret index.fill()/ paste events withoutselectionchange:src/plugin/PrefixField.mjs:131-136never listens toinputat all — it relies ondocument'sselectionchange, which browsers coalesce per frame/activeElement and do not emit per field across rapid programmaticfill()or autofill sequences.src/main/addon/PrefixField.mjs: An experimentalNeo.main.addon.PrefixField(src/main/addon/PrefixField.mjs:1-139) already ships as a lazy Main-Thread addon chunk in every build, but is completely unwired, stores single-element state (this.el,this.pattern,this.back) on the singleton instead of per-element in aMap(breaking multi-field views likeexamples/fieldWithPrefix's 5 inputs), listens tokeypress(which never fires forBackspace), and leavesconsole.loginformat()(:126).clean():new RegExp(this.accept || "\\d", "g")(src/plugin/PrefixField.mjs:193) strips flags like'i'whenacceptis a case-insensitiveRegExp(e.g./[0-9a-f]/i).The Architectural Reality
examples/fieldWithPrefix/MainContainer.mjs:15("Type into a field: the mask fills its slots as you go and refuses characters it does not accept") andsrc/form/field/Text.mjs:1550-1557("The user's input has changed the real DOM on the Main Thread. We must manually update our 'last known state' (this.vnode) to match this reality before the next diffing cycle runs. This prevents the framework from sending a redundant delta update that could overwrite the user's input or cause cursor jumps.").src/main/DomEvents.mjs:11-15, 565-581, 642-651:DomEventsdelegatesinput,keydown,focusin, andfocusoutin bubble phase ondocument.body, andonChange(event)readsvalue: target.value. Therefore, direct target-phase listeners on the<input>element insideNeo.main.addon.PrefixFieldexecute synchronously on the Main Thread beforeDomEvents#onChangereadstarget.value:input:<input>.valueandsetSelectionRange(i, j)settle synchronously on Main before the next keystroke AND beforeDomEvents#onChangeforwards{type: 'input', value: masked}toTextField#onInputValueChange, which updatesinputVNode.attributes.valueandreportedInputValuewithout emitting a clobbering worker-to-mainvaluedelta.focusin/focusout: when focus shows the empty mask template or blur clears an unfilled template (el.value === pattern), dispatching a bubblinginputevent from<input>(guarded against re-entry) synchronizesTextFieldin FIFO order beforefocusoutreachesTextField#onFocusLeave(resolving toTextField#emptyValue).The Fix
Neo.main.addon.PrefixField(src/main/addon/PrefixField.mjs) into the multi-instance Main-Thread mask controller:this.fields = new Map()(id -> {el, accept, pattern, slots, prev, first, back, formatting, listeners}), removing singletonthis.elstate andconsole.log.remote.app:register,setConfigs,unregister(matchingtest/playwright/setup.mjs:58-62).keydown(Backspacetracking),input(synchronousclean+setSelectionRangebeforeDomEvents#onChange),focusin(template display + caret at first unfilled slot),click(snap collapsed caret into valid slot range when clicking outside filled slots while preserving range selections), andfocusout(clear untouchedpatternto''beforeDomEvents#onFocusOut).RegExpflags ('i','u') alongside'g'when compilingaccept.Neo.plugin.PrefixField(src/plugin/PrefixField.mjs) toNeo.main.addon.PrefixField:selectionchange/keydown/focusin/focusoutDOM listeners and broken synchronousignoreSelectiontoggle aroundDomAccess.selectNode.Neo.currentWorker.getAddon('PrefixField', owner.windowId)ononOwnerMounted()(supporting remounts perNeo.plugin.Baseanddestroy()cleanup viaunregister), forwarding serialized{id: owner.getInputElId(), acceptSource, acceptFlags, pattern, slots, windowId}onregisterandsetConfigs.clean(input)(withRegExpflag preservation) and wrapowner.beforeSetValue(restored indestroy()) in the App Worker so Node unit specs and programmaticfield.value = ...mutations format atomically without DOM round-trips.test/playwright/unit/plugin/PrefixField.spec.mjs: unit coverage forclean(),RegExpflag preservation (/[0-9a-f]/i), programmaticTextFieldvalue formatting, andregister/setConfigs/unregisterlifecycle.test/playwright/component/form/field/PrefixField.spec.mjs: real OMT browser test mounting five maskedTextFields and verifying zero-delaypressSequentially('201120260930')('20/11/2026 09:30'), zero-delay MAC keystrokes, five consecutive pause-freefill()calls across all fivefieldWithPrefixmasks,Backspaceacross separators, untouched focus/blur clearing, and live runtime config updates.Contract Ledger
Neo.plugin.PrefixField(accept_,pattern_,slots_,clean()) (src/plugin/PrefixField.mjs:53-62, 191-201)examples/fieldWithPrefix/MainContainer.mjs:15, 22-32叾Out of Scopeaccept,pattern,slots,inputCls,labelCls,ownerCls); registers/updates/unregistersNeo.main.addon.PrefixFieldperowner.windowId(register,setConfigs,unregister) and preservesRegExpflags (e.g.'i') when matchingaccept.TextFieldformats programmatic non-emptyvaluein App Worker viabeforeSetValuewithout calling Main addon (''/nullresolves toTextField#emptyValue);nullacceptdefaults to/\d/g;nullslotsdefaults to'_'.test/playwright/unit/plugin/PrefixField.spec.mjsNeo.main.addon.PrefixField(register,setConfigs,unregister) (src/main/addon/PrefixField.mjs:21-27)src/form/field/Text.mjs:1550-1557&src/main/DomEvents.mjs:565-581Mapbyid; stampsdata-neo-prefix-ready="true"while registered; formats<input>.valueandsetSelectionRangesynchronously on Main duringinput,focusin,click, andfocusoutbefore bubble-phaseDomEventsreadstarget.value.registerreturnsfalsewithout throwing;setConfigson unregisterediddelegates toregister; re-registering existingiddetaches prior listeners first; drag/range selection onclickis preserved.test/playwright/component/form/field/PrefixField.spec.mjsAcceptance Criteria
pressSequentiallywithdelay: 0) in a real browser OMTTextFieldwithNeo.plugin.PrefixFieldpreserve exact character order and slot separators (e.g.'201120260930'indd/mm/yyyy hh:mm→'20/11/2026 09:30';'ABCDEF123456'in hex MAC mask →'AB:CD:EF:12:34:56').fill()calls across five maskedTextFields in one container mask every field and synchronizeTextField#valuein the App Worker without dropping or leaving raw values.patternat the first slot, blurring without accepted input clears<input>.valueto''andTextField#valuetoemptyValue(null),Backspacesteps back across literal separators, and runtimepattern/slots/acceptconfig updates re-sync the live mask.npm run test-unit -- test/playwright/unit/plugin/PrefixField.spec.mjsandnpm run test-components -- test/playwright/component/form/field/PrefixField.spec.mjspass (and fail ondevbefore the fix).Out of Scope
examples/fieldWithPrefix/MainContainer.mjsphone-width sizing or MAC label/config (#21502, reserved for external contributor pickup).apps/portal/resources/data/examples.json(#21552).Avoided Traps
selectionchangewithawait DomAccess.selectNode: Even awaiting the RMA leaves a full worker round-trip gap during which fast native keystrokes land at unformatted indices on Main.this.elfield state inNeo.main.addon.PrefixField: Clobbers earlier masked fields whenever a page mounts more than onePrefixField(examples/fieldWithPrefixmounts five).examples/fieldWithPrefix/MainContainer.mjs: Collides with open contributor GFI#21502.Related
Parent #21329 · #21140 · unblocks #21502 (
AC-1fast typing) · surfaced while capturing #21551 (#21552).Ownership: self-assigned maintainer lane (
@neo-gemini-maryam); curatedgood first issue/help wantedomitted because fixing an OMT cross-worker DOM/VDOM input-synchronization race acrosssrc/plugin/andsrc/main/addon/requires maintainer engine context ahead of the Engine 14 cut and unblocks contributor GFI #21502.Decision Record impact:
none.Live latest-open + closed sweep: checked latest 20 open (
#21553..#21359, 60 open — red band, filed under owning epic#21329which has 19 subs) + open and closed search (PrefixField,fieldWithPrefix,"input mask",Out of ScopeandAvoided Trapsread on#21337,#21502,#21329) at 2026-11-20T02:47Z; no equivalent or prior exclusion found. A2A in-flight claim sweep: latest 30 messages across all read-states (through2026-11-20T02:45:26Z), promoted from@neo-opus-ada'sdefect-note(MESSAGE:671786e5), zero competing claims onPrefixField. MC sweep:"fieldWithPrefix PrefixField back-to-back key presses reorder characters unmasked fill", 5 results +ask_knowledge_base(ticket), no prior decision found. Own-assignment sweep: 3 open (#21553,#21547,#21512, all 3 inAPPROVEDPRs at merge gate), none overlapping.Origin Session ID: 095892f3-027f-47aa-8092-a13ae31f72ca Retrieval Hint: "PrefixField Main thread addon input mask back-to-back keystrokes reorder characters unmasked fill race"