channel-worker 1.0.24 → 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 +17 -8
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -587,17 +587,26 @@ class CommandPoller {
|
|
|
587
587
|
ws.on('open', async () => {
|
|
588
588
|
try {
|
|
589
589
|
await send('DOM.enable');
|
|
590
|
-
// Focus the contenteditable editor via CDP
|
|
591
|
-
await send('Runtime.evaluate', {
|
|
590
|
+
// Focus the contenteditable editor inside dialog via CDP
|
|
591
|
+
const focusResult = await send('Runtime.evaluate', {
|
|
592
592
|
expression: `
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
if (
|
|
597
|
-
|
|
598
|
-
|
|
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
|
+
})()
|
|
599
607
|
`,
|
|
600
608
|
});
|
|
609
|
+
console.log('[commands] Focus result:', focusResult?.result?.value);
|
|
601
610
|
// Small delay for focus to take effect
|
|
602
611
|
await new Promise(r => setTimeout(r, 300));
|
|
603
612
|
// Type text
|