Skip to content

fix(react)+test: lock down PR #5 regressions and close three useChat gaps#7

Merged
yyyyaaa merged 2 commits into
mainfrom
test/regression-tests-from-pr5-review
May 13, 2026
Merged

fix(react)+test: lock down PR #5 regressions and close three useChat gaps#7
yyyyaaa merged 2 commits into
mainfrom
test/regression-tests-from-pr5-review

Conversation

@yyyyaaa
Copy link
Copy Markdown
Contributor

@yyyyaaa yyyyaaa commented May 13, 2026

Summary

Follow-up to #5. Adds the regression tests originally drafted on review/pr-5 as permanent acceptance criteria, plus fixes three useChat gaps the review surfaced that weren't addressed in the merged PR.

useChat fixes (packages/react/src/use-chat.ts)

  • send() sync ref: rapid synchronous sends now both reach the outgoing request body. Previously the second send read a stale messagesRef.current because the ref was only updated by a useEffect, not synchronously inside the callback.
  • pendingDecisions hydration: initialMessages containing a paused tool call now populates pendingDecisions on mount. Previously the map was initialized empty and only filled via stream events, so rehydrated sessions couldn't render decision UI for prior pauses.
  • Unmount abort: a cleanup useEffect now aborts the in-flight AbortController when the hook unmounts. Previously an unmount mid-stream leaked the fetch.

Regression tests

  • packages/agent/__tests__/agent.test.ts: injectDeferralResults() + prompt() places the synthetic toolResult adjacent to its assistant block (verifies the documented "user typed instead of deciding" recovery pattern produces provider-valid ordering).
  • packages/react/__tests__/use-chat.test.ts: three tests covering the three fixes above.

Together these lock down the four behaviors and document the recovery pattern via executable example.

Test plan

  • pnpm --filter @agentic-kit/agent test — 42/42 pass (incl. new injectDeferralResults adjacency test)
  • pnpm --filter @agentic-kit/react test — 31/31 pass (incl. three new tests, which fail on main and pass with the fixes here)
  • pnpm --filter agentic-kit test — 17/17 pass
  • All provider package tests pass

🤖 Generated with Claude Code

yyyyaaa and others added 2 commits May 13, 2026 22:11
- send(): sync messagesRef before runStream so rapid synchronous sends
  both reach the outgoing request body
- useState init: hydrate pendingDecisions from initialMessages so
  rehydrated paused tool calls render decision UI immediately
- unmount: abort the in-flight fetch on cleanup to prevent leaked
  streams when the consumer unmounts mid-request

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Adds four regression tests that act as acceptance criteria for the
fixes shipped in PR #5 and the companion useChat fixes in this branch.

agent.test.ts:
- injectDeferralResults() + prompt() places the synthetic toolResult
  adjacent to its assistant block (verifies the documented "user typed
  instead of deciding" recovery pattern produces provider-valid order).

use-chat.test.ts:
- initialMessages with a paused tool call hydrates pendingDecisions.
- Two rapid synchronous send() calls both reach the outgoing body.
- Unmount aborts the in-flight fetch.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@yyyyaaa yyyyaaa merged commit d27ab7b into main May 13, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant