| @@ -116,8 +116,14 @@ | ||
| 116 | 116 | // DOMHighlighter's class; a sync listener can't read a React prop. |
| 117 | 117 | export const isAgentWorking = () => |
| 118 | 118 | !!document.querySelector('.wp-site-blocks.extendify-agent-working'); |
| 119 | 119 | |
| 120 | +const isAgentWaiting = () => | |
| 121 | + !!document.querySelector('.wp-site-blocks.extendify-agent-waiting'); | |
| 122 | + | |
| 123 | +const hasAgentTask = () => | |
| 124 | + !!document.querySelector('.wp-site-blocks.extendify-agent-task'); | |
| 125 | + | |
| 120 | 126 | // Resolve the live DOM node for the currently-staged agent block, so the |
| 121 | 127 | // click + hover gates can carve out "inside the staged block." Returns |
| 122 | 128 | // null when no block is staged or its node has detached from the tree. |
| 123 | 129 | // Without the slug an id matches another part's block of the same number, and |
| @@ -285,10 +291,12 @@ | ||
| 285 | 291 | // id spaces have to be checked or the pill returns on pages. |
| 286 | 292 | const compositeId = |
| 287 | 293 | target?.el?.getAttribute?.(PART_ATTR) ?? |
| 288 | 294 | target?.el?.getAttribute?.(POST_ATTR); |
| 295 | + // An open editor blocks sending, so it would stall the agent's task. | |
| 289 | 296 | const quickEditable = |
| 290 | 297 | quickEditEnabled && |
| 298 | + !hasAgentTask() && | |
| 291 | 299 | hasQuickEditModalFor(target?.blockType) && |
| 292 | 300 | !isSyncedPatternId(compositeId); |
| 293 | 301 | const sourceKind = target?.source?.kind ?? null; |
| 294 | 302 | // A ref-nav item routes Quick Edit's save through wp_navigation, but the |
| @@ -453,9 +461,13 @@ | ||
| 453 | 461 | aiBtn.type = 'button'; |
| 454 | 462 | aiBtn.className = 'extendify-quick-edit-pill extendify-quick-edit-pill-ai'; |
| 455 | 463 | aiBtn.setAttribute('data-extendify-quick-edit-pill', ''); |
| 456 | 464 | aiBtn.innerHTML = '<span aria-hidden="true">✦</span>'; |
| 457 | - aiBtn.append(__('Ask AI', 'extendify-local')); | |
| 465 | + // translators: Button on a page block that hands it to the AI agent, which asked the user to pick one. | |
| 466 | + const shareLabel = __('Share with agent', 'extendify-local'); | |
| 467 | + aiBtn.append( | |
| 468 | + isAgentWaiting() ? shareLabel : __('Ask AI', 'extendify-local'), | |
| 469 | + ); | |
| 458 | 470 | aiBtn.addEventListener('mousedown', stopMouseDown); |
| 459 | 471 | aiBtn.addEventListener('click', (ev) => { |
| 460 | 472 | ev.preventDefault(); |
| 461 | 473 | ev.stopPropagation(); |