Files
hermes-agent/apps
salch-cred 64878d4311 fix(preview): use proper input events for React/contenteditable/sumbit in drive_preview type
drive_preview type/press/submit silently failed on React controlled inputs,
contenteditable rich-text editors, and Enter-to-submit forms — the tool
reported success but the text never landed and no DOM events fired (#98048).

Three fixes in the injected type handler:

1. contenteditable: use document.execCommand('insertText', false, text)
   instead of el.textContent = text.  execCommand fires beforeinput/
   insertText composition events that Lexical/ProseMirror/Draft editors
   (DeepSeek, ChatZhipu, Kimi) subscribe to.  Fallback to textContent
   + InputEvent for sandboxed pages where execCommand fails.

2. INPUT/TEXTAREA: replace new Event('input') with new InputEvent('input',
   {data: text, inputType: 'insertText', bubbles: true}).  React 16+
   controlled-input trackers compare lastTrackedValue against the event's
   .data property — a plain Event has no .data, so the value-change is
   deduplicated.

3. submit: add keyCode: 13 and which: 13 to the KeyboardEvent init dict.
   Modern React forms check both event.key AND event.keyCode for Enter;
   constructed KeyboardEvents read keyCode as 0 (read-only), so the
   event was silently swallowed.

Regression tests added in act-in-page.test.ts:
- contenteditable execCommand path
- InputEvent data property set correctly
- submit KeyboardEvent keyCode/which === 13

Fixes #98048
2026-09-29 11:41:51 -05:00
..