channel-worker 1.0.23 → 1.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/command-poller.js +24 -1
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -586,7 +586,30 @@ class CommandPoller {
|
|
|
586
586
|
|
|
587
587
|
ws.on('open', async () => {
|
|
588
588
|
try {
|
|
589
|
-
|
|
589
|
+
await send('DOM.enable');
|
|
590
|
+
// Focus the contenteditable editor inside dialog via CDP
|
|
591
|
+
const focusResult = await send('Runtime.evaluate', {
|
|
592
|
+
expression: `
|
|
593
|
+
(function() {
|
|
594
|
+
// Try dialog editor first
|
|
595
|
+
const dialog = document.querySelector('[role="dialog"]');
|
|
596
|
+
if (dialog) {
|
|
597
|
+
const editor = dialog.querySelector('[contenteditable="true"], [role="textbox"]');
|
|
598
|
+
if (editor) { editor.focus(); editor.click(); return 'focused_dialog'; }
|
|
599
|
+
}
|
|
600
|
+
// Fallback
|
|
601
|
+
const editors = document.querySelectorAll('[contenteditable="true"], [role="textbox"]');
|
|
602
|
+
for (const e of editors) {
|
|
603
|
+
if (e.offsetHeight >= 15) { e.focus(); e.click(); return 'focused_fallback'; }
|
|
604
|
+
}
|
|
605
|
+
return 'no_editor';
|
|
606
|
+
})()
|
|
607
|
+
`,
|
|
608
|
+
});
|
|
609
|
+
console.log('[commands] Focus result:', focusResult?.result?.value);
|
|
610
|
+
// Small delay for focus to take effect
|
|
611
|
+
await new Promise(r => setTimeout(r, 300));
|
|
612
|
+
// Type text
|
|
590
613
|
await send('Input.insertText', { text });
|
|
591
614
|
ws.close();
|
|
592
615
|
resolve({ success: true, length: text.length });
|