PluginProbe
Extendify / trunk
Extendify vtrunk
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 0.5.0 0.6.0 All 127 releases
← All changes | src/Agent/Agent.jsx +29 -3 3.2.0 → trunk View file →
@@ -29,8 +29,9 @@
29 29 import { useStatusStore } from '@agent/state/status';
30 30 import { useSuggestionsStore } from '@agent/state/suggestions';
31 31 import { useWorkflowStore } from '@agent/state/workflows';
32 32 import { hasRunComponent } from '@agent/workflows/abilities/components/run';
33 +import startOnboardingWorkflow from '@agent/workflows/misc/start-onboarding';
33 34 import { useQuickEditStore } from '@quick-edit/state/store';
34 35 import { digest } from '@shared/api/digest';
35 36 import {
36 37 useCallback,
@@ -271,18 +272,32 @@
271 272 setCanType(true);
272 273 }, [addMessage, pushStatus, whenFinishedToolProps, workflow]);
273 274
274 275 const handleSubmit = useCallback(
275 - async (message) => {
276 + async (message, { hidden = false } = {}) => {
276 277 // Suggestions reach the agent without the textarea; disabling it isn't enough.
277 278 if (useQuickEditStore.getState().selected) return;
278 279 setWaitingOnToolOrUser(false);
279 280 agentWorking.current = false;
280 - addMessage('message', { role: 'user', content: message });
281 + addMessage('message', { role: 'user', content: message, hidden });
281 282
282 283 // Without this a typed message would drop the workflow and close the canvas.
283 284 if (canvasOpen && canvasAssist) return handleCanvasMessage();
284 285
286 + // A staged tool the user walked away from still owes its receipt.
287 + if (workflow?.id && whenFinishedToolProps?.id) {
288 + const { answerId, whenFinishedTool } =
289 + whenFinishedToolProps.agentResponse || {};
290 + addMessage('workflow', {
291 + status: 'canceled',
292 + label: whenFinishedTool?.labels?.cancel,
293 + agent: workflow.agent,
294 + workflowId: workflow.id,
295 + answerId,
296 + suggestions: getSuggestions(),
297 + });
298 + }
299 +
285 300 // Let some phrases auto load workflows
286 301 const bypass = getWorkflowByExample(message);
287 302 if (bypass?.example?.agentResponse) {
288 303 // whenFinishedTool → inline input UI; none → ask for a typed reply.
@@ -330,8 +345,9 @@
330 345 setWorkflow,
331 346 workflow,
332 347 workflowData,
333 348 getAvailableWorkflows,
349 + getSuggestions,
334 350 ],
335 351 );
336 352
337 353 // Used to inject a workflow final state
@@ -387,9 +403,9 @@
387 403 useEffect(() => {
388 404 // Allow external messages to trigger the agent
389 405 const handleMessage = ({ detail }) => {
390 406 if (!detail?.message) return;
391 - handleSubmit(detail.message);
407 + handleSubmit(detail.message, { hidden: detail.hidden });
392 408 };
393 409 // Allow external code to clear the block and workflow
394 410 const handleCleanup = () => {
395 411 // cleanup() resets canType and agentWorking, so read them before it runs.
@@ -430,8 +446,18 @@
430 446 qaSuggestions,
431 447 getSuggestions,
432 448 canType,
433 449 ]);
450 +
451 + // Dispatching before chat-submit has a listener drops the workflow.
452 + useEffect(() => {
453 + if (!startOnboardingWorkflow.available()) return;
454 + window.dispatchEvent(
455 + new CustomEvent('extendify-agent:chat-submit', {
456 + detail: { message: startOnboardingWorkflow.example.text, hidden: true },
457 + }),
458 + );
459 + }, []);
434 460
435 461 // Handle whenFinished component confirm/cancel
436 462 useEffect(() => {
437 463 const handleConfirm = async ({ detail }) => {