Overview

#3531000: Show progress when executing prompts added agent polling. This is a follow-up for #43.2 to decide on what do do in case of showing agent message and final message which could be duplicate.

Proposed resolution

The orchestrator message and status currently always appear at the top, while the sub-agent responses appear at the bottom. This creates a poor user experience. For example, the page builder agent may complete its task and display a message such as “components have been added,” but unless the orchestrator response is received, the components are not actually placed on the page. In this situation, the user may need to scroll up to notice the “thinking” status indicating that the orchestrator is still running. This results in a confusing and suboptimal experience. To improve this, the orchestrator response should be moved to the bottom.

The duplication of messages mentioned in #43.2 was caused by two reasons:

  • The orchestrator message was not actually being sent back to the user when it invoked a sub-agent. The $response['message'] rendered in the UI always contained the message from the last sub-agent invoked by the orchestrator. This has now been fixed.
  • The buildHtmlContent method in Aiwizard compiles messages from all agents obtained through polling, which also includes the orchestrator message. Once polling is complete, the orchestrator message should be removed from the list so that only the sub-agent messages are displayed.

User interface changes

Before

  • Orchestrator status (Thinking) appears at the top
  • The orchestrator status (“Thinking”) appears at the top.
  • The final message after polling is duplicated. It is the same message generated by the metadata generation agent, which appears below “Generate a Description”.

test

After

  • The orchestrator status always appears at the bottom.
  • The final orchestrator message is displayed at the end of polling, and there is no message duplication.

test

AI usage (if applicable)

[ ] AI Assisted Issue
This issue was generated with AI assistance, but was reviewed and refined by the creator.

[ ] AI Assisted Code
This code was mainly generated by a human, with AI autocompleting or parts AI generated, but under full human supervision.

[x] AI Generated Code
This code was mainly generated by an AI with human guidance, and reviewed, tested, and refined by a human.

[ ] Vibe Coded
This code was generated by an AI and has only been functionally tested.

Issue fork canvas-3548718

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

narendrar created an issue. See original summary.

akhil babu’s picture

akhil babu’s picture

Category: Task » Bug report

akhil babu’s picture

Issue summary: View changes
akhil babu’s picture

StatusFileSize
new1.77 MB
new2.65 MB
akhil babu’s picture

Issue summary: View changes
akhil babu’s picture

In this demo, once the component is placed, an error appears in the Canvas UI:

Your latest change was not saved because the content was modified elsewhere since you loaded the page. Please refresh your browser to receive the latest changes and continue.

This occurs intermittently. I have created a follow-up issue #3571988: Canvas AI: Error when placing components to track this separately.

akhil babu’s picture

Issue tags: +AI Innovation
akhil babu’s picture

Status: Active » Needs review
akhil babu’s picture

Issue summary: View changes
scott falconer’s picture

Status: Needs review » Reviewed & tested by the community

Reviewed MR !550 (https://git.drupalcode.org/project/canvas/-/merge_requests/550)

Code review notes:
- BE: CanvasBuilder now always uses the orchestrator agent's solve() output for the final user-visible message, instead of sometimes taking a tool wrapper's readable output.
- FE: AiWizard removes the orchestrator status item before composing the final "history" message so it doesn't appear twice. While polling, the orchestrator status is moved to the end of the list so it stays at the bottom.

Functional testing (local DDEV):
- Create/open a Canvas page in the editor.
- Open the Drupal Canvas AI panel.
- Run an AI action (e.g. Generate metadata / "Generate a description for this page").
- Confirm the orchestrator polling message is shown at the bottom while running, and the final orchestrator message is only shown once (no duplicate final message from a sub-agent + orchestrator).

Tests/lint run:
- ddev phpcs modules/canvas_ai/src/Controller/CanvasBuilder.php (pass; PHPCS deprecation warning only)
- ddev phpunit modules/canvas_ai/tests/src/Kernel/Plugin/AiFunctionCall/CreateComponentTest.php (pass; PHPUnit deprecations)
- ddev phpunit modules/canvas_ai/tests/src/Kernel/Plugin/AiFunctionCall/EditComponentJsTest.php (pass; PHPUnit deprecations)
- ddev exec --dir=/var/www/html/ui npm test -- --testTimeout 15000 (pass)

Notes (unrelated, but observed while testing on origin/1.x):
- ddev phpunit modules/canvas_ai/tests/src/Kernel/Plugin/AiFunctionCall/GetNodeFieldsTest.php currently errors: missing ai_agent:get_node_fields plugin.
- ddev exec --dir=/var/www/html/ui npm run type-check currently fails with TS2322 in ui/src/components/aiExtension/AiWizard.tsx for DeepChat ButtonPosition ('inside-start').

Based on the above, I think MR !550 is ready to move to Reviewed.

AI disclosure: I used an AI assistant for code review support, browser-driven functional testing, and to help summarize the results.

narendrar’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

akhil babu’s picture

Linking a related issue from AI agents module, which also triggers duplicate final messages

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.