Skip to content

chore(atomic): implement MSW mock of agent api#7174

Merged
erocheleau merged 21 commits intomainfrom
SFINT-6636
Apr 14, 2026
Merged

chore(atomic): implement MSW mock of agent api#7174
erocheleau merged 21 commits intomainfrom
SFINT-6636

Conversation

@erocheleau
Copy link
Copy Markdown
Collaborator

@erocheleau erocheleau commented Feb 25, 2026

SFINT-6636

In this PR

  • Added a story and an MSW mock for atomic-generated-answer when using an agent-id.
  • Created a head answer mocked response and a follow-up mocked response. The head answer intentionally excludes the Searching and Thinking steps to reflect the current behavior of the /answer and /follow-up endpoints.
  • Fixed a story issue where switching between stories could duplicate the query in the search box.
  • Updated the generated answer story interaction helper to use Storybook userEvent APIs instead of manual DOM event dispatching.

Issue fixed

Screen.Recording.2026-04-13.at.12.24.06.PM.mov

Demo of the new story

Screen.Recording.2026-04-13.at.12.03.49.PM.mov

Comment thread packages/atomic/storybook-utils/api/agent/generate-response.ts Fixed
Comment thread packages/atomic/storybook-utils/api/agent/generate-response.ts Fixed
@github-actions
Copy link
Copy Markdown
Contributor

🔗 Scratch Orgs ready to test this PR:

Comment thread packages/atomic/storybook-utils/api/agent/generate-response.ts Dismissed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a Storybook/MSW mock implementation for the Agent Answer API so atomic-generated-answer can be demoed with agent-id, and refactors the story play functions to avoid query duplication when switching stories.

Changes:

  • Added MockAgentApi MSW handlers for /agents/:agentId/answer and /agents/:agentId/follow-up streaming responses.
  • Introduced streaming mock event sequences for “head answer” vs “follow-up” behavior.
  • Updated atomic-generated-answer stories to include the new mock and to submit the query in a way that doesn’t duplicate text across story switches.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pnpm-lock.yaml Locks the newly added dev dependency for the Agent API event types.
packages/atomic/package.json Adds @ag-ui/client as a devDependency to build Agent API mock events.
packages/atomic/storybook-utils/api/agent/mock.ts New MSW mock API class wiring up Agent answer + follow-up endpoints.
packages/atomic/storybook-utils/api/agent/generate-response.ts New SSE streaming response builder and mocked Agent event payloads.
packages/atomic/src/components/search/atomic-generated-answer/atomic-generated-answer.new.stories.tsx Adds a “With Agent ID” story, registers Agent handlers, and fixes query duplication when switching stories.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

Comment thread packages/atomic/storybook-utils/api/agent/generate-response.ts
Comment thread packages/atomic/storybook-utils/api/agent/mock.ts
Copy link
Copy Markdown
Collaborator Author

@erocheleau erocheleau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Copy Markdown
Contributor

@SimonMilord SimonMilord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Copy Markdown
Collaborator

@louis-bompart louis-bompart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Holding off approval because of the use of JS api instead of user input

Comment thread packages/atomic/storybook-utils/api/agent/generate-response.ts
Copy link
Copy Markdown
Contributor

@mmitiche mmitiche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GG!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants