Skip to content

test(stories): add sample conversations for the chat stories - #117

Open
pratikbuilds wants to merge 2 commits into
conversation/12-panelfrom
conversation/02-samples
Open

pratikbuilds wants to merge 2 commits into
conversation/12-panelfrom
conversation/02-samples

Conversation

@pratikbuilds

Copy link
Copy Markdown
Collaborator

Add deterministic samples built only from the conversation contract: a short chat, a 300-message history, a tool storm with a batch, a failure and every approval outcome, generated images, a thread and a failed send. playTurn reveals a message's parts over time for streaming stories. Images are inline SVG, timestamps are fixed, and nothing reads the clock or Math.random.

Stacked on #116: review only this commit. Part of #94.

Notes for review

  • Sample unit tests live beside the samples under stories/ and run with bun test stories/chat/samples; bun run test only covers src/.
  • Streaming stories built on playTurn should start paused or play on a user action: the axe sweep waits for CSS animations, not timers.
  • Follow-up: stories/chat/conversation.stories.tsx still has its own placeholder history; move it onto the samples when it first renders contract messages.

Verification

  • This commit passes bun run typecheck and bun run lint on its own (the stack is checked commit by commit).
  • At the top of the stack: bun run check, bun run build, bun run dep-guard, bun run contrast-test and bun run test:e2e (Playwright specs and the Storybook axe sweep in light and dark) pass.

Closes #96

@corbits-triage

corbits-triage Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Triage: Pass

No changes needed from you. A maintainer will review this pull request.

Stacked on #116: only this pull request's own changes were checked.

Notes:

  • added code matches a code pattern: stories/chat/samples/samples.stories.tsx:47 Invented fallback `?? 0`; handle the missing value instead.

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated multi-agent review: independent review + second-agent validation of every flag; only confirmed items listed. Everything below is minor and verified by running the helper.

  • minor stories/chat/samples/play-turn.ts:49-60 — a queued call (status: "pending", no approval record) replays as running first, then regresses to pending: toolStages only short-circuits approval-requested and running, so bare queued traces fall through to the synthetic-running branch (verified repro). Add part.status === "pending" to the no-stage branch plus a regression test asserting a queued call never shows running before its final frame.
  • minor stories/chat/samples/play-turn.ts:100 — turnFrames can emit a duplicate no-op frame after a tool batch whose last call contributes no stage (final running/approval-requested with no record makes started[last] equal the settled form; verified). Fix: skip a frame whose parts equal the previous frame's, or stop the batch loop one short.

@pratikbuilds

pratikbuilds commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator Author

Thanks for the review. Both points are fixed.

1. A queued call replayed as running first, then went back to pending (minor)

  • The fix: a queued call (pending, no approval record) now shows as queued from the first frame, just like a waiting or running call.
  • Test: "shows a queued call in its final form at once, never as running".

2. A tool batch could produce a duplicate frame (minor)

  • The fix: the batch now steps through only the calls that actually change, one at a time, and leaves the rest in their final form. This also covers a stage-less call in the middle of a batch, and a batch where no call has a stage, which stopping the loop one short would have missed.
  • Tests: "never repeats a frame after a batch call that has no stage", plus a check across every sample message.

Commit: fix(stories): replay queued and stage-less tool calls faithfully

@pratikbuilds
pratikbuilds force-pushed the conversation/02-samples branch from 42b5877 to 9796dc0 Compare October 27, 2026 13:54

@TheGreatAxios TheGreatAxios left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review · Approve

Adds sample conversations and a play-turn helper for the chat stories.

Findings

No findings.

Add deterministic samples built only from the conversation contract:
a short chat, a 300-message history, a tool storm with a batch, a
failure and every approval outcome, generated images, a thread and a
failed send. playTurn reveals a message's parts over time for streaming
stories. Images are inline SVG, timestamps are fixed, and nothing reads
the clock or Math.random.
The sample replay gave a queued call (pending, no approval record) a
synthetic running frame, so it ran and then went back to pending. It
is now shown queued from the start, like a waiting or running call.

A tool batch also emitted one frame per call, so a call with no
earlier form produced a frame identical to the one before it. The
batch now finishes only the calls that change, one at a time, and
leaves the rest in their final form, so every frame differs from the
previous one.
@pratikbuilds
pratikbuilds force-pushed the conversation/02-samples branch from 9796dc0 to 475d220 Compare October 28, 2026 08:41
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.

2 participants