PluginProbe
Extendify / 3.2.3
Extendify v3.2.3
3.2.3 3.2.2 3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 All 129 releases
← All changes | src/Agent/Agent.jsx +181 -69 3.1.5 → 3.2.3 View file →
@@ -5,12 +5,23 @@
5 5 pickWorkflow,
6 6 recordAgentActivity,
7 7 } from '@agent/api';
8 8 import { Chat } from '@agent/Chat';
9 -import { Canvas, useCanvasOpen } from '@agent/components/Canvas';
9 +import {
10 + Canvas,
11 + useCanvasAssist,
12 + useCanvasOpen,
13 +} from '@agent/components/Canvas';
10 14 import { ChatInput } from '@agent/components/ChatInput';
11 15 import { ChatMessages } from '@agent/components/ChatMessages';
16 +import { StatusIndicator } from '@agent/components/messages/StatusIndicator';
12 17 import { UsageMessage } from '@agent/components/messages/UsageMessage';
18 +import { useFollowUpHistory } from '@agent/follow-ups/history';
19 +import {
20 + cardMessageIndex,
21 + pickNextCard,
22 + toolCallsThisRun,
23 +} from '@agent/follow-ups/pick-next';
13 24 import { useLockPost } from '@agent/hooks/useLockPost';
14 25 import { isAbilityTool, isAbilityWorkflow } from '@agent/lib/abilities';
15 26 import {
16 27 getClientToolFallbackReply,
@@ -16,17 +27,16 @@
16 27 getClientToolFallbackReply,
17 28 getClientTools,
18 29 } from '@agent/lib/client-tools';
19 30 import { localPickWorkflow } from '@agent/lib/local-pick';
20 -import { getRedirectUrl } from '@agent/lib/redirects';
21 31 import { doReload } from '@agent/lib/reload';
22 32 import { useCanvasStore } from '@agent/state/canvas';
23 33 import { useChatStore } from '@agent/state/chat';
24 34 import { useGlobalStore } from '@agent/state/global';
25 35 import { useStatusStore } from '@agent/state/status';
26 -import { useSuggestionsStore } from '@agent/state/suggestions';
27 36 import { useWorkflowStore } from '@agent/state/workflows';
28 37 import { hasRunComponent } from '@agent/workflows/abilities/components/run';
38 +import startOnboardingWorkflow from '@agent/workflows/misc/start-onboarding';
29 39 import { useQuickEditStore } from '@quick-edit/state/store';
30 40 import { digest } from '@shared/api/digest';
31 41 import {
32 42 useCallback,
@@ -54,8 +64,25 @@
54 64 ]);
55 65 return result;
56 66 };
57 67
68 +// cleanup() swaps in a fresh controller; a signal read after the wait is never aborted.
69 +const canceledDuring = async (ms) => {
70 + const { signal } = controller;
71 + await new Promise((resolve) => setTimeout(resolve, ms));
72 + return signal.aborted;
73 +};
74 +
75 +const nextSteps = (workflowId, status, messages) => {
76 + if (status === 'completed') {
77 + useFollowUpHistory.getState().markDone(workflowId);
78 + }
79 + const card = pickNextCard({ workflowId, status, messages });
80 + return card
81 + ? { followUp: card.id, followUpData: card.data }
82 + : { followUp: null };
83 +};
84 +
58 85 export const Agent = () => {
59 86 const { addMessage, updateMessage, popMessage, messages } = useChatStore();
60 87 const { pushStatus, clearStatuses, leavingPage } = useStatusStore();
61 88 const {
@@ -85,10 +112,11 @@
85 112 });
86 113 const [loop, setLoop] = useState(0);
87 114 const workflow = getWorkflow();
88 115 const canvasOpen = useCanvasOpen();
116 + const canvasAssist = useCanvasAssist();
117 + const canvasNoticeShown = useRef(false);
89 118 const chatAvailable = useMemo(() => isChatAvailable(), [isChatAvailable]);
90 - const { addSuggestions, getSuggestions } = useSuggestionsStore();
91 119 // Options render only while their message is last; a reply dismisses them.
92 120 const lastMessage = messages.at(-1);
93 121 const qaSuggestions =
94 122 lastMessage?.type === 'message' &&
@@ -96,12 +124,24 @@
96 124 Array.isArray(lastMessage.details?.qaSuggestions)
97 125 ? lastMessage.details.qaSuggestions
98 126 : null;
99 127
128 + useEffect(() => {
129 + const { messages, updateMessage } = useChatStore.getState();
130 + const index = cardMessageIndex(messages);
131 + const { id, details } = messages[index] ?? {};
132 + if (!id || details.followUp !== undefined || details.followUpClosed) return;
133 + const { workflowId, status } = details;
134 + const steps = nextSteps(workflowId, status, messages.slice(0, index));
135 + if (steps.followUp) updateMessage(id, steps);
136 + }, []);
137 +
100 138 // Without this the input stays disabled for as long as the canvas is open.
101 139 useEffect(() => {
102 - if (canvasOpen) setCanType(true);
103 - }, [canvasOpen]);
140 + if (canvasOpen && canvasAssist) setCanType(true);
141 + // A workflow reached by example carries no sessionId to key this on.
142 + if (!canvasOpen) canvasNoticeShown.current = false;
143 + }, [canvasOpen, canvasAssist]);
104 144
105 145 const cleanup = useCallback(() => {
106 146 setCanType(true);
107 147 agentWorking.current = false;
@@ -111,9 +151,14 @@
111 151 agentBlock && setBlock(null);
112 152 // A class or pin left up freezes Quick Edit hover site-wide.
113 153 document
114 154 .querySelector('.wp-site-blocks')
115 - ?.classList.remove('extendify-agent-working', 'extendify-agent-busy');
155 + ?.classList.remove(
156 + 'extendify-agent-working',
157 + 'extendify-agent-busy',
158 + 'extendify-agent-waiting',
159 + 'extendify-agent-task',
160 + );
116 161 setCommittedSelection(null);
117 162 clearStatuses();
118 163 window.dispatchEvent(new Event('extendify-agent:remove-block-highlight'));
119 164 }, [setBlock, clearStatuses]);
@@ -135,13 +180,14 @@
135 180
136 181 const findAgent = useCallback(
137 182 async (options = {}) => {
138 183 pushStatus('calling-agent');
184 + const { signal } = controller;
139 185 const response = await withMinDuration(
140 186 pickWorkflow({
141 187 // A mid-turn drop clears the block after this closure was made.
142 188 workflows: getAvailableWorkflows().map((w) => w.id),
143 - options: { signal: controller.signal, ...options },
189 + options: { signal, ...options },
144 190 }).catch(async (error) => {
145 191 devmode && console.error(error);
146 192 if (error?.response?.status === 429) {
147 193 updateRetryAfter(error?.response?.headers?.get('Retry-After'));
@@ -149,15 +195,9 @@
149 195 pushStatus('credits-exhausted');
150 196 return;
151 197 }
152 198 setCanType(true);
153 - if (error === 'Workflow aborted') {
154 - addMessage('workflow', {
155 - status: 'canceled',
156 - suggestions: getSuggestions(),
157 - });
158 - return;
159 - }
199 + if (error === 'Workflow aborted') return;
160 200
161 201 await new Promise((resolve) => setTimeout(resolve, 1000));
162 202 addMessage('message', {
163 203 role: 'assistant',
@@ -171,9 +211,9 @@
171 211 return;
172 212 }),
173 213 500,
174 214 );
175 - if (!response) return;
215 + if (!response || signal.aborted) return;
176 216
177 217 const { workflow: wf, reply } = response;
178 218 if (wf?.id) setWorkflow(wf);
179 219 if (reply) {
@@ -187,9 +227,8 @@
187 227 pushStatus,
188 228 updateRetryAfter,
189 229 setWorkflow,
190 230 getAvailableWorkflows,
191 - getSuggestions,
192 231 ],
193 232 );
194 233
195 234 // The backend caps tool runs; nothing here bounds the loop.
@@ -235,8 +274,13 @@
235 274 followup: !!response.tool,
236 275 agent: workflow?.agent,
237 276 });
238 277 }
278 + // The model is never told what is on screen around the canvas.
279 + if (response.cannotHelp && !canvasNoticeShown.current) {
280 + canvasNoticeShown.current = true;
281 + addMessage('canvas-notice', {});
282 + }
239 283 if (!response.tool) break;
240 284 const { id, inputs, labels } = response.tool;
241 285 pushStatus('tool-started', labels?.started);
242 286 const result = await callTool({
@@ -257,18 +301,34 @@
257 301 setCanType(true);
258 302 }, [addMessage, pushStatus, whenFinishedToolProps, workflow]);
259 303
260 304 const handleSubmit = useCallback(
261 - async (message) => {
262 - // Suggestions reach the agent without the textarea; disabling it isn't enough.
305 + async (message, { hidden = false, step } = {}) => {
306 + // chat-submit events skip the textarea; disabling it isn't enough.
263 307 if (useQuickEditStore.getState().selected) return;
308 + if (whenFinishedToolProps?.processing) return;
264 309 setWaitingOnToolOrUser(false);
265 310 agentWorking.current = false;
266 - addMessage('message', { role: 'user', content: message });
311 + if (step) addMessage('tool', { ...step, inputs: {}, fromCard: true });
312 + addMessage('message', { role: 'user', content: message, hidden });
267 313
268 314 // Without this a typed message would drop the workflow and close the canvas.
269 - if (canvasOpen) return handleCanvasMessage();
315 + if (canvasOpen && canvasAssist) return handleCanvasMessage();
270 316
317 + // A staged tool the user walked away from still owes its receipt.
318 + if (workflow?.id && whenFinishedToolProps?.id) {
319 + const { answerId, whenFinishedTool } =
320 + whenFinishedToolProps.agentResponse || {};
321 + addMessage('workflow', {
322 + status: 'canceled',
323 + label: whenFinishedTool?.labels?.cancel,
324 + agent: workflow.agent,
325 + workflowId: workflow.id,
326 + answerId,
327 + followUp: null,
328 + });
329 + }
330 +
271 331 // Let some phrases auto load workflows
272 332 const bypass = getWorkflowByExample(message);
273 333 if (bypass?.example?.agentResponse) {
274 334 // whenFinishedTool → inline input UI; none → ask for a typed reply.
@@ -296,9 +356,9 @@
296 356
297 357 // Skip the network find-agent when the staged block makes the edit certain.
298 358 const localPick = localPickWorkflow({ block });
299 359 if (localPick) {
300 - await new Promise((resolve) => setTimeout(resolve, 500));
360 + if (await canceledDuring(500)) return;
301 361 setWorkflow(localPick);
302 362 return;
303 363 }
304 364
@@ -306,8 +366,9 @@
306 366 },
307 367 [
308 368 addMessage,
309 369 block,
370 + canvasAssist,
310 371 canvasOpen,
311 372 findAgent,
312 373 handleCanvasMessage,
313 374 mergeWorkflowData,
@@ -326,9 +387,9 @@
326 387 if (!agentResponse) return;
327 388 setWorkflow(workflow);
328 389 setCanType(false);
329 390 agentWorking.current = true;
330 - await new Promise((resolve) => setTimeout(resolve, 750));
391 + if (await canceledDuring(750)) return;
331 392 addMessage('message', {
332 393 role: 'assistant',
333 394 content: agentResponse.reply,
334 395 });
@@ -352,9 +413,9 @@
352 413 // Without this the loop calls the backend before the user has typed.
353 414 setWaitingOnToolOrUser(true);
354 415 setCanType(false);
355 416 agentWorking.current = true;
356 - await new Promise((resolve) => setTimeout(resolve, 750));
417 + if (await canceledDuring(750)) return;
357 418 addMessage('message', {
358 419 role: 'assistant',
359 420 content: agentResponse.reply,
360 421 // A workflow example can carry its own suggestions; none still asks.
@@ -372,12 +433,15 @@
372 433 useEffect(() => {
373 434 // Allow external messages to trigger the agent
374 435 const handleMessage = ({ detail }) => {
375 436 if (!detail?.message) return;
376 - handleSubmit(detail.message);
437 + const { message, hidden, step } = detail;
438 + handleSubmit(message, { hidden, step });
377 439 };
378 440 // Allow external code to clear the block and workflow
379 441 const handleCleanup = () => {
442 + // cleanup() resets canType and agentWorking, so read them before it runs.
443 + const interrupted = agentWorking.current || !canType;
380 444 controller.abort('Workflow aborted');
381 445 cleanup();
382 446 // Deferred a frame: the input stays disabled until the cancel lands.
383 447 requestAnimationFrame(() =>
@@ -384,15 +448,15 @@
384 448 document.querySelector('#extendify-agent-chat-textarea')?.focus(),
385 449 );
386 450
387 451 // An options panel can outlive its workflow; cancel must still clear it.
388 - if (!workflow?.id && !qaSuggestions) return;
452 + if (!workflow?.id && !qaSuggestions && !interrupted) return;
389 453 setWorkflow(null);
390 454 addMessage('workflow', {
391 455 status: 'canceled',
392 456 agent: workflow?.agent,
393 457 workflowId: workflow?.id,
394 - suggestions: getSuggestions(),
458 + ...nextSteps(workflow?.id, 'canceled'),
395 459 });
396 460 return;
397 461 };
398 462 window.addEventListener('extendify-agent:cancel-workflow', handleCleanup);
@@ -410,25 +474,52 @@
410 474 setWorkflow,
411 475 addMessage,
412 476 workflow,
413 477 qaSuggestions,
414 - getSuggestions,
478 + canType,
415 479 ]);
416 480
481 + // Dispatching before chat-submit has a listener drops the workflow.
482 + useEffect(() => {
483 + if (!startOnboardingWorkflow.available()) return;
484 + window.dispatchEvent(
485 + new CustomEvent('extendify-agent:chat-submit', {
486 + detail: { message: startOnboardingWorkflow.example.text, hidden: true },
487 + }),
488 + );
489 + }, []);
490 +
491 + // ChatMessages hides a confirm restored by a reload; left open, the workflow would sit unfinishable.
492 + useEffect(() => {
493 + const { getWorkflow, reloadedToolProps } = useWorkflowStore.getState();
494 + const { whenFinished, needsRedirect } = getWorkflow() ?? {};
495 + if (!reloadedToolProps?.id || !whenFinished?.component) return;
496 + if (whenFinished.canvas || needsRedirect?.()) return;
497 + window.dispatchEvent(new Event('extendify-agent:cancel-workflow'));
498 + }, []);
499 +
417 500 // Handle whenFinished component confirm/cancel
418 501 useEffect(() => {
419 502 const handleConfirm = async ({ detail }) => {
420 503 if (toolWorking.current) return;
421 - setWhenFinishedToolProps(null);
422 504 toolWorking.current = true;
423 505 const { data, whenFinishedToolProps, shouldRefreshPage, redirectUrl } =
424 506 detail ?? {};
425 - const { whenFinishedTool, answerId, redirectTo } =
507 + // Staged until the tool returns, so the chat shows it saving.
508 + setWhenFinishedToolProps(
509 + whenFinishedToolProps
510 + ? { ...whenFinishedToolProps, processing: true }
511 + : null,
512 + );
513 + const { whenFinishedTool, answerId } =
426 514 whenFinishedToolProps?.agentResponse || {};
427 515 const { id, labels } = whenFinishedTool || {};
428 516 // Staged unanswered so its own component can show the run in progress.
429 517 const runMessageId = id ? addMessage('tool', { id, inputs: data }) : null;
430 - if (!hasRunComponent(id)) pushStatus('workflow-tool-processing');
518 + // In the chat, the saving state shows this label instead.
519 + if (!hasRunComponent(id) && workflow?.whenFinished?.canvas) {
520 + pushStatus('workflow-tool-processing', labels?.started);
521 + }
431 522 // Not all workflows have a tool at the end (e.g. tours)
432 523 const toolResponse = await callTool?.({ tool: id, inputs: data }).catch(
433 524 (error) => {
434 525 const { sessionId } = workflow || {};
@@ -444,8 +535,9 @@
444 535 return { error: { message: error?.message, code: error?.code } };
445 536 },
446 537 );
447 538 toolWorking.current = false;
539 + setWhenFinishedToolProps(null);
448 540 if (runMessageId) updateMessage(runMessageId, { result: toolResponse });
449 541 if (toolResponse?.refused) {
450 542 await new Promise((resolve) => setTimeout(resolve, 1000));
451 543 const refusalMessages = {
@@ -453,13 +545,8 @@
453 545 'no-op': __(
454 546 "That edit came back unchanged, which wasn't expected. Please try rephrasing what you'd like to change.",
455 547 'extendify-local',
456 548 ),
457 - // translators: Shown when the user asked the AI agent to edit a block that lives in a site template (e.g. the header or footer), which the agent cannot save yet.
458 - 'template-part': __(
459 - "That block is part of your site's template, like the header or footer, and I can't make changes there yet.",
460 - 'extendify-local',
461 - ),
462 549 };
463 550 addMessage('message', {
464 551 role: 'assistant',
465 552 content:
@@ -483,9 +570,13 @@
483 570 setLoop((prev) => prev + 1);
484 571 return;
485 572 }
486 573
487 - addSuggestions(whenFinishedToolProps.agentResponse?.recommendations);
574 + // Reloading here unmounts a run component still watching its ability finish.
575 + const refreshForAbility =
576 + isAbilityTool(id) && shouldRefreshPage !== false;
577 + const willReload = redirectUrl || shouldRefreshPage || refreshForAbility;
578 + // A card shown now would flash just before the reload.
488 579 addMessage('workflow', {
489 580 status: 'completed',
490 581 label: labels?.confirm,
491 582 agent: workflow.agent,
@@ -490,9 +581,9 @@
490 581 label: labels?.confirm,
491 582 agent: workflow.agent,
492 583 workflowId: workflow.id,
493 584 answerId,
494 - suggestions: getSuggestions(),
585 + ...(willReload ? {} : nextSteps(workflow.id, 'completed')),
495 586 });
496 587 // A chat message persists, so the next turn's model knows the save was partial.
497 588 const refusedCount = toolResponse?.refusedOperations?.length;
498 589 if (refusedCount) {
@@ -512,13 +603,9 @@
512 603 }
513 604 setWorkflow(null);
514 605 useCanvasStore.getState().endSession();
515 606
516 - const url = getRedirectUrl(redirectTo, whenFinishedToolProps?.inputs);
517 - const refreshForAbility = isAbilityTool(id);
518 - if (url || redirectUrl || shouldRefreshPage || refreshForAbility) {
519 - return doReload(url || redirectUrl);
520 - }
607 + if (willReload) return doReload(redirectUrl);
521 608 cleanup();
522 609 };
523 610 const handleCancel = ({ detail }) => {
524 611 if (toolWorking.current) return;
@@ -531,9 +618,9 @@
531 618 label: whenFinishedTool?.labels?.cancel,
532 619 agent: workflow.agent,
533 620 workflowId: workflow.id,
534 621 answerId,
535 - suggestions: getSuggestions(),
622 + ...nextSteps(workflow.id, 'canceled'),
536 623 });
537 624 setWorkflow(null);
538 625 useCanvasStore.getState().endSession();
539 626 cleanup();
@@ -558,18 +645,9 @@
558 645 handleCancel,
559 646 );
560 647 window.removeEventListener('extendify-agent:workflow-retry', handleRetry);
561 648 };
562 - }, [
563 - addMessage,
564 - pushStatus,
565 - popMessage,
566 - cleanup,
567 - setWorkflow,
568 - workflow,
569 - getSuggestions,
570 - addSuggestions,
571 - ]);
649 + }, [addMessage, pushStatus, popMessage, cleanup, setWorkflow, workflow]);
572 650
573 651 useEffect(() => {
574 652 const handleClose = () => setOpen(false);
575 653 const handleOpen = () => setOpen(true);
@@ -589,9 +667,26 @@
589 667 if (open) return;
590 668 if (block) setBlock(null);
591 669 }, [open, block, setBlock]);
592 670
671 + // A pick answers select-block's "which one?"; making the user also type stalls it.
672 + const previousBlock = useRef(block);
593 673 useEffect(() => {
674 + const picked = block && !previousBlock.current;
675 + previousBlock.current = block;
676 + if (!picked || workflow?.id !== 'select-block') return;
677 + if (!waitingOnToolOrUser || !canType || whenFinishedToolProps?.id) return;
678 + handleSubmit('This is the block I mean.', { hidden: true });
679 + }, [
680 + block,
681 + workflow?.id,
682 + waitingOnToolOrUser,
683 + canType,
684 + whenFinishedToolProps?.id,
685 + handleSubmit,
686 + ]);
687 +
688 + useEffect(() => {
594 689 if (waitingOnToolOrUser || !open || !workflow?.id) return;
595 690 // Some workflows require they dont change pages
596 691 const theyMoved = workflow?.startingPage !== window.location.href;
597 692 // Requires a block to be selected
@@ -602,9 +697,9 @@
602 697 addMessage('workflow', {
603 698 status: 'canceled',
604 699 agent: workflow.agent,
605 700 workflowId: workflow.id,
606 - suggestions: getSuggestions(),
701 + ...nextSteps(workflow.id, 'canceled'),
607 702 });
608 703 setWorkflow(null);
609 704 cleanup();
610 705 return;
@@ -679,9 +774,9 @@
679 774 // translators: Shown while the AI agent deselects a block that can't serve the request.
680 775 __('Removing selected block', 'extendify-local'),
681 776 );
682 777 // findAgent pushes its own status right away; let this one read first.
683 - await new Promise((resolve) => setTimeout(resolve, 2500));
778 + if (await canceledDuring(2500)) return;
684 779 agentWorking.current = false;
685 780 await findAgent();
686 781 return;
687 782 }
@@ -701,9 +796,8 @@
701 796 status: 'completed',
702 797 inputs,
703 798 workflowId: workflow.id,
704 799 });
705 - addSuggestions(agentResponse.recommendations);
706 800 setWorkflow(null);
707 801 addMessage('workflow', {
708 802 status: 'completed',
709 803 agent: workflow.agent,
@@ -708,9 +802,9 @@
708 802 status: 'completed',
709 803 agent: workflow.agent,
710 804 workflowId: workflow.id,
711 805 answerId,
712 - suggestions: getSuggestions(),
806 + ...nextSteps(workflow.id, 'completed'),
713 807 });
714 808 cleanup();
715 809 }
716 810 return;
@@ -716,19 +810,21 @@
716 810 return;
717 811 }
718 812 // If we're done, it means the AI has the answer
719 813 if (agentResponse.status !== 'in-progress') {
720 - const { recommendations, status } = agentResponse;
721 - const isCompleted = status === 'completed';
722 - if (recommendations) addSuggestions(recommendations);
814 + const status =
815 + agentResponse.status === 'completed' ? 'completed' : 'canceled';
816 + // A reply that changed nothing isn't a finished task to follow up.
817 + const didWork =
818 + toolCallsThisRun(useChatStore.getState().messages).length > 0;
723 819 setWorkflow(null);
724 820 cleanup();
725 821 addMessage('workflow', {
726 - status: isCompleted ? 'completed' : 'canceled',
822 + status,
727 823 agent: workflow.agent,
728 824 workflowId: workflow.id,
729 825 answerId,
730 - suggestions: getSuggestions(),
826 + ...(didWork ? nextSteps(workflow.id, status) : { followUp: null }),
731 827 });
732 828 return;
733 829 }
734 830 if (sessionId && sessionId !== workflow.sessionId) {
@@ -748,9 +844,10 @@
748 844 setWaitingOnToolOrUser(true);
749 845 setCanType(false);
750 846 return;
751 847 }
752 - pushStatus('tool-started', labels?.started);
848 + // A reply sent with the tool clears the status, blanking the line.
849 + pushStatus('agent-working');
753 850 const toolData = await Promise.all([
754 851 callTool({ tool: id, inputs }),
755 852 new Promise((resolve) => setTimeout(resolve, 3000)),
756 853 ])
@@ -781,8 +878,9 @@
781 878 id,
782 879 inputs,
783 880 result: toolData,
784 881 label: labels?.confirm,
882 + started: labels?.started,
785 883 });
786 884 setWaitingOnToolOrUser(false);
787 885 agentWorking.current = false;
788 886 setLoop((prev) => prev + 1); // Trigger next loop
@@ -828,10 +926,8 @@
828 926 setWhenFinishedToolProps,
829 927 block,
830 928 setBlock,
831 929 findAgent,
832 - addSuggestions,
833 - getSuggestions,
834 930 ]);
835 931
836 932 useEffect(() => {
837 933 if (!canType) return;
@@ -837,9 +933,15 @@
837 933 if (!canType) return;
838 934 document.querySelector('#extendify-agent-chat-textarea')?.focus();
839 935 }, [canType]);
840 936
841 - const busy = !canType || !chatAvailable || workflow?.id;
937 + // A task waiting on a reply leaves the page pickable so the user can answer by pointing.
938 + const waiting =
939 + canType &&
940 + chatAvailable &&
941 + Boolean(workflow?.id) &&
942 + !whenFinishedToolProps?.id;
943 + const busy = !canType || !chatAvailable || (workflow?.id && !waiting);
842 944 // `busy` is true at rest; 429 is blocked, not working.
843 945 const working = !canType && chatAvailable;
844 946
845 947 return (
@@ -844,9 +946,14 @@
844 946
845 947 return (
846 948 <>
847 949 <Canvas />
848 - <Chat busy={busy} working={working}>
950 + <Chat
951 + busy={busy}
952 + working={working}
953 + waiting={waiting}
954 + taskActive={Boolean(workflow?.id)}
955 + >
849 956 <div className="relative z-50 flex h-full flex-col justify-between overflow-auto">
850 957 <ChatMessages
851 958 redirectComponent={
852 959 workflow?.needsRedirect?.() ? workflow.redirectComponent : null
@@ -861,11 +968,16 @@
861 968 }}
862 969 />
863 970 </div>
864 971 <div className="p-4 pb-2 pt-0">
972 + <StatusIndicator />
865 973 <ChatInput
866 974 disabled={
867 - !canType || !chatAvailable || !!qaSuggestions || leavingPage
975 + !canType ||
976 + !chatAvailable ||
977 + !!qaSuggestions ||
978 + leavingPage ||
979 + whenFinishedToolProps?.processing
868 980 }
869 981 handleSubmit={handleSubmit}
870 982 />
871 983 </div>