Commit Graph

1601 Commits

Author SHA1 Message Date
Tyler Slaton 596b5cd1b5 Merge branch 'main' into fix/261-sidebar-full-height 2026-04-02 09:27:32 -07:00
Maxim b2bc508f95 test: add missing throttleMs edge case coverage
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 18:11:31 +02:00
Maxim c2dcee2751 fix: unify effectiveThrottleMs to return 0, upgrade validation to console.error
Also fixes JSDoc inaccuracies: documents trailing-edge window restart,
uses enum names instead of callback names, adds notificationThrottle
interaction note.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 18:06:58 +02:00
Maxim 9b6d444c43 fix: trailing edge restarts throttle window to prevent back-to-back renders
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 18:01:43 +02:00
Alem Tuzlak 401a27c981 fix: resolve rebase conflicts and format files
- Remove stale eslint-config-custom refs from package.json files
- Regenerate pnpm-lock.yaml
- Format agentcore and other files with oxfmt
2026-04-02 16:43:34 +02:00
Alem Tuzlak 79ce60c580 chore: migrate from eslint+prettier to oxlint+oxfmt
Replace eslint and prettier with oxlint and oxfmt for faster linting
and formatting across the monorepo. Remove all eslint and prettier
configs, dependencies, and related packages. Add .oxlintrc.json and
.oxfmtrc.json for the new tooling. Update CI workflows and lefthook
hooks accordingly. Reformat codebase with oxfmt.

https://claude.ai/code/session_01GMkSf29p78HuMR1mbXn8He
2026-04-02 16:39:05 +02:00
Maxim a4109ad3be refactor: enhance message handling in useAgent tests
- Introduced message factory functions to eliminate `as any` type assertions for message literals.
- Updated test cases to utilize the new message factories for improved clarity and type safety.
- Added helper functions for subscriber notifications to streamline test setup.

This refactor improves code readability and maintainability in the test suite for the useAgent hook.
2026-04-02 16:33:13 +02:00
Maxim d1357083da fix: harden throttleMs implementation from code review
- Replace Date.now()-based throttle with flag-based leading+trailing
  pattern that is immune to wall-clock jumps
- Wrap throttleMs validation in useMemo to warn once per value change
  instead of on every render
- Remove phantom AbstractAgent.notificationThrottleMs JSDoc reference
- Reorder cleanup to clear timer before unsubscribing for safety
- Add tests for trailing-edge data freshness, timer precision, and
  dynamic throttleMs prop changes

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 16:13:56 +02:00
Maxim f2b148c0d2 fix: improve throttleMs validation, simplify handlers, add invalid-input tests
- Fix JSDoc to accurately describe behavior for negative/non-finite values
- Remove NODE_ENV guard so console.warn fires in all environments
- Use derived effectiveThrottleMs instead of mutating destructured param
- Simplify handler wrappers: direct references instead of arrow wrappers
- Remove stale comment about content stripping
- Add parameterized tests for invalid throttleMs (NaN, Infinity, -1, -Infinity)
- Fix misleading test comment

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:44:13 +02:00
Maxim 3cdaaf089d fix: consolidate throttleMs into single useEffect, add input validation and edge-case tests
Addresses code review findings:
- Merge two separate useEffect hooks into one to eliminate dual-subscription
  race window and simplify cleanup
- Add active boolean guard to prevent forceUpdate after unmount/re-run
- Validate throttleMs input (reject NaN, Infinity, negatives with dev warning)
- Expand JSDoc with scope, constraints, and notificationThrottleMs interaction
- Replace JSON.stringify(updateFlags) with direct ref in effect deps
- Strengthen unmount test with render counter instead of not.toThrow()
- Add 5 new test cases: explicit zero, rapid burst, new cycle after trailing,
  updates excluding OnMessagesChanged, subscription cleanup verification

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 15:34:43 +02:00
Maxim 30916a6ab7 feat: add throttleMs option to useAgent for streaming render throttling
Adds optional `throttleMs` parameter to `useAgent()` that coalesces
rapid onMessagesChanged notifications (per-token TEXT_MESSAGE_CHUNK
events) into fewer React re-renders using a leading+trailing throttle.

- throttleMs=0 (default): exact current behavior, zero overhead
- throttleMs>0: only onMessagesChanged is throttled; onStateChanged
  and onRunStatusChanged always fire immediately
- Leading+trailing: first call immediate, last call guaranteed

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 14:09:17 +02:00
Claude 0d9e3b88f6 chore(post-release): update version to 1.55.0-next.8
The previous publish workflow released 1.55.0-next.8 to npm but the
post-release commit failed to push to main (blocked by branch
protection). This applies the version bumps and pre.json updates that
the workflow would have committed, unblocking future releases.

https://claude.ai/code/session_01N8sLK9h9p6FdRjyHqzKzVV
2026-04-02 02:23:27 +00:00
Claude d55ce2c87b fix: add React keys to CopilotMessages children to suppress warning
CopilotMessages received an array of children (memoizedChildren +
RegisteredActionsRenderer) without keys, causing a React "unique key prop"
warning in dev mode. Wrap memoizedChildren in a keyed Fragment and add a
key to RegisteredActionsRenderer.

https://claude.ai/code/session_01N8sLK9h9p6FdRjyHqzKzVV
2026-04-02 01:32:52 +00:00
Alem Tuzlak fc241efce1 test(core): add ProxiedCopilotRuntimeAgent capabilities tests 2026-04-01 18:42:48 +02:00
Alem Tuzlak 2f38e945e2 feat(react-core): add useCapabilities hook 2026-04-01 18:34:20 +02:00
Alem Tuzlak 6a5126d76f feat(core): pass capabilities through AgentRegistry 2026-04-01 18:32:02 +02:00
Alem Tuzlak a3237a4d09 feat(core): add capabilities to ProxiedCopilotRuntimeAgent 2026-04-01 18:30:16 +02:00
Alem Tuzlak 1c255f1381 feat(runtime): include agent capabilities in /info response 2026-04-01 18:27:53 +02:00
Alem Tuzlak 6c25fbd8dc feat(runtime): implement getCapabilities() on BuiltInAgent 2026-04-01 18:24:30 +02:00
Alem Tuzlak bde44f35cf feat(shared): add capabilities to AgentDescription 2026-04-01 18:21:34 +02:00
Alem Tuzlak 232c9eb994 chore: bump @ag-ui/core and @ag-ui/client to 0.0.49 2026-04-01 18:18:40 +02:00
alex mitre 818e4e767b fix(sidebar): allow full-height children inside CopilotSidebar 2026-04-01 08:28:13 -07:00
Claude fb8160cec6 fix: clear web inspector body-transition timers on disconnect
The WebInspectorElement schedules 300ms setTimeout callbacks to clean up
document.body.style.transition after dock/undock animations. When the
element is removed from the DOM (e.g. during test teardown), these timers
fire after jsdom has been destroyed, causing "ReferenceError: document is
not defined" — which vitest reports as unhandled errors and fails the run.

Track all body-transition timer IDs and clear them in disconnectedCallback.
Skip transition animation entirely during disconnect since the element is
being removed and the animation serves no purpose.

https://claude.ai/code/session_01W2Kb2HXsjZett3HdqM9zay
2026-04-01 11:50:57 +02:00
Claude 5d612556d4 fix: address flaky CI unit tests
- Add fail-fast: false to unit test matrix strategies so one Node
  version failing doesn't cancel all other matrix jobs
- Add retry: 2 to runtime-client-gql vitest config (Nx confirmed
  this package's tests as flaky during parallel execution)
- Replace fragile setTimeout waits in middleware express tests with
  vi.waitFor() polling, which is resilient to CI timing variance

https://claude.ai/code/session_01W2Kb2HXsjZett3HdqM9zay
2026-04-01 11:50:56 +02:00
Martha Kelly Schumann e38d6ede25 fix: multiple CopilotChat components with different threadIds share message state (#3525) 2026-03-31 13:29:09 -07:00
Martha Schumann 9060f2a930 fix(runtime): address code review feedback on reasoning lifecycle fix
- Call closeReasoningIfOpen() once before the switch instead of in every case branch
- Remove as-casts from closeReasoningIfOpen by using typed const variables
- Remove as-casts from new test code; use typed imports and unknown-safe casts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 08:14:45 -07:00
Martha Schumann 0f01f3ea2d fix(state-manager): address code review feedback
- Replace boolean param with SubscribeConfig object on subscribeToAgent
- Invert handleNewMessage guard to early-return on missing input
- Remove module-scope isAnthropic variable in demo route (SSR safety)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-31 07:51:35 -07:00
Martha Schumann 5aa901f122 test(agent): strengthen reasoning lifecycle test coverage
- Add cardinality assertions (toHaveLength(1)) to all 5 auto-close tests
  so duplicate REASONING_MESSAGE_END / REASONING_END events are caught
- Add missing RUN_FINISHED final-event assertion to abort auto-close test
- Add test for consecutive reasoning blocks with no reasoning-end between
  them (exercises closeReasoningIfOpen inside reasoning-start)
- Add test for exception thrown mid-stream (exercises catch block path)
- Add test for stream exhaustion without terminal event while reasoning is
  open (exercises !terminalEventEmitted fallback)
- Expand changeset description to cover all three behavioral fixes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 13:09:15 -07:00
Martha Schumann f78bb6d9b0 fix(agent): make reasoning-end idempotent, close reasoning in catch block
- reasoning-end case now delegates to closeReasoningIfOpen() so a late
  SDK-emitted reasoning-end is a no-op when auto-close already fired,
  preventing duplicate REASONING_MESSAGE_END + REASONING_END events
- Hoist isInReasoning / reasoningMessageId / closeReasoningIfOpen before
  the try block so the catch block can call closeReasoningIfOpen() --
  exceptions thrown mid-reasoning now emit proper lifecycle events before
  RUN_ERROR instead of leaking an unclosed reasoning state
- Remove dead (part as any).delta fallback in reasoning-delta case; the
  SDK always provides part.text in this branch

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 13:09:14 -07:00
Martha Schumann fb63dc0cc9 fix(agent): regenerate reasoningMessageId for consecutive blocks with no SDK id
When closeReasoningIfOpen() auto-closes a prior block and a second
reasoning-start arrives with id="0" or no id, the handler was silently
reusing the previous reasoningMessageId. Mirror the text-start pattern:
always call randomUUID() when the provider id is falsy or "0".

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 13:09:14 -07:00
Martha Schumann 0b76b2979d fix(agent): close reasoning on consecutive-start, fallback block, abort, and error paths
- Call closeReasoningIfOpen() in the reasoning-start handler before opening
  a new block, guarding against consecutive reasoning blocks without an
  intervening reasoning-end (e.g. Anthropic extended thinking with tools)
- Call closeReasoningIfOpen() in the !terminalEventEmitted fallback block
  so streams that end without a finish/abort/error event still close properly
- Add abort() test-helper and tests for abort + error cases with open reasoning
- Strengthen auto-close ordering assertions to explicitly verify
  REASONING_MESSAGE_END precedes REASONING_END in all three auto-close tests

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 13:09:14 -07:00
Martha Schumann 8aafcbe2af fix(agent): skip empty reasoning deltas and auto-close reasoning lifecycle
Two fixes for Anthropic model stalls (fixes #3323):

1. Skip reasoning-delta events with empty text — EventSchemas.parse()
   rejects delta: "" and kills the RxJS Observable before any other
   events can fire.

2. Auto-close open reasoning lifecycle at every phase transition —
   @ai-sdk/anthropic never emits reasoning-end, leaving the state
   machine stuck.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 13:09:14 -07:00
Martha Schumann 092956d299 style: fix prettier formatting across all changed files 2026-03-30 13:09:10 -07:00
Martha Schumann 6395a9a42d style: fix prettier formatting in CopilotChatMessageView after merge 2026-03-30 13:04:44 -07:00
Martha Schumann 83f58ee3de Merge branch 'main' into fix/cpk-7155-thread-shared-state
Incorporates the V1/V2 flat package consolidation (96885b595). All our
thread-isolation changes auto-merged to the new package paths. Three
content conflicts resolved (import paths updated from @/ aliases to
relative paths and @copilotkitnext/* to @copilotkit/*):
- packages/react-core/src/v2/hooks/use-agent.tsx
- packages/react-core/src/v2/hooks/use-render-custom-messages.tsx
- packages/react-core/src/v2/components/chat/CopilotChatMessageView.tsx

File location conflict resolved: use-agent-thread-isolation.test.tsx
moved from packages/v2/react/... to packages/react-core/src/v2/...
2026-03-30 12:33:16 -07:00
Martha Schumann f1da7a9c61 fix(state-manager): restore registry agent cleanup and cache Error-state provisional
Two bugs found in CR:

1. unsubscribeFromAgent() was a no-op: subscribeToAgent() always used the
   composite agentId:threadId key (since agent.threadId defaults to a UUID),
   but unsubscribeFromAgent() looked for the bare agentId key, which was
   never written. Registry agents subscribed via onAgentsChanged were never
   cleaned up on replacement. Fix: add isClone flag to subscribeToAgent() —
   registry agents (isClone=false, default) use bare key; per-thread clones
   (isClone=true, via subscribeAgentToStateManager) use composite key.

2. Error-state provisional agent was not cached in provisionalAgentCache,
   unlike the Disconnected/Connecting path. Any dependency change while in
   Error state produced a new agent reference, triggering spurious
   re-subscriptions. Fix: cache the Error-state provisional using the same
   cacheKey and headers-refresh pattern as the other provisional paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 12:10:13 -07:00
Martha Schumann 6c209bb24a fix(suggestions): pass thread clone agent to reloadSuggestions
With per-thread agent clones, the registry agent has empty messages.
reloadSuggestions was checking messageCount on the registry agent, so
dynamic suggestions (which require messageCount > 0) never fired after
the first message. Fix by passing the thread clone (with actual messages)
through reloadSuggestions → generateSuggestions.

Also updates the demo to use claude-3-7-sonnet (extended thinking support)
when ANTHROPIC_API_KEY is set.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 09:57:23 -07:00
Martha Schumann 0ac2c27c66 fix(web-inspector): prevent flaky test from timer firing after jsdom teardown
Add afterEach with vi.clearAllTimers() to prevent the 300ms setTimeout in
WebInspectorElement (src/index.ts:2065) from firing after the jsdom environment
tears down, which caused intermittent "document is not defined" errors in CI.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 09:39:28 -07:00
Martha Schumann 2397e3aa9b fix(state-manager): isolate per-thread state and prevent run collisions in sequential runs
- StateManager now uses composite `agentId:threadId` subscription keys so
  per-thread clones get independent subscriptions without stomping the
  registry agent's subscription.
- Added `activeRun` map so `handleNewMessage` (called without `input` by
  ag-ui's addMessage path) can still associate messages with the correct run.
- Added `revoked` flag + `subRunId`/`runFinished` run-isolation logic to
  handle the timing race where a new run's events arrive through the previous
  pipeline before `subscribeAgentToStateManager` has set up a new one —
  detected via `runFinished && input.runId === subRunId`, resolved by minting
  a fresh UUID so both runs get distinct state entries.
- Empty state `{}` is no longer persisted; `getStateByRun` returns `undefined`
  so renderers can distinguish "no snapshot received yet" from a real state.
- `useAgent`: per-thread clones are shared via a module-level WeakMap so all
  components on the same (agentId, threadId) see the same instance.
- Tests updated to cover sequential-run state isolation and the empty-state
  semantics change.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 09:05:04 -07:00
github-actions[bot] a1edf59eae chore(post-release): update version to 1.55.0-next.7 2026-03-29 00:19:22 +00:00
Claude 1ceb963a84 Revert "fix: resolve changeset version errors from stale @copilotkitnext package refs"
This reverts commit 1f6ae0d629.
2026-03-28 17:04:55 -07:00
Claude 369266f1be fix: resolve changeset version errors from stale @copilotkitnext package refs
After the V1/V2 consolidation merge, several changesets still referenced
old @copilotkitnext/* package names that no longer exist. Fixed package
references and ran changeset version to apply pending version bumps.

https://claude.ai/code/session_01A5aahBWFTmLPR3xZSeh4SD
2026-03-28 17:04:55 -07:00
Tyler Slaton 96885b5959 refactor: consolidate V1/V2 packages into flat @copilotkit/* structure
Flatten all packages from packages/v1/* and packages/v2/* into packages/* —
every package now lives directly under the @copilotkit/ scope with no v1/v2
subdirectories.

- Move all v1 packages (react-core, react-ui, runtime, shared, etc.) from
  packages/v1/* to packages/*
- Absorb v2 react code into packages/react-core/src/v2/ (exported via /v2 subpath)
- Absorb v2 agent code into packages/runtime/src/agent/ (exported via /v2 subpath)
- Move v2 packages (core, angular, demo-agents, etc.) to packages/*
- Replace all @copilotkitnext/* imports with @copilotkit/* equivalents
- Keep @copilotkitnext/angular as the sole exception (angular remains on next)
- Update CI workflows, renovate config, release scripts for flat structure
- No public API surface changes — all exports fields are preserved

Co-authored-by: Alem Tuzlak <t.zlak@hotmail.com>
Signed-off-by: Tyler Slaton <tyler@copilotkit.ai>
2026-03-28 16:45:10 -07:00
Martha Schumann ab8a92ef4f Merge remote-tracking branch 'origin/main' into fix/cpk-7155-thread-shared-state 2026-03-27 08:53:24 -07:00
Martha Schumann c198d13ec1 fix(use-agent): address critical review issues from ranst91
- Fix 1: store {source, clone} in threadAgentCache to invalidate stale
  clones when registry agent is replaced (reconnect/hot-reload)
- Fix 2: add lastConnectedAgentRef in V1 wrapper to prevent connectAgent
  firing on every Connected render; ref reset in cleanup for StrictMode
- Fix 3: throw if clone() returns same instance to prevent silent state
  destruction via setMessages([]) / setState({}) on the source agent
- Fix 4: clear bare agentId key from provisionalAgentCache on threadId
  transition to eliminate phantom provisionals
- Fix 5: clear threadAgentCache on unmount to release clones holding
  listeners, WebSocket connections, or timers
- Fix 6: move HttpAgent headers sync out of useMemo into useEffect to
  avoid side effects in concurrent-mode pure computation

Tests: T-1 registry replacement, T-2 threadId switching, T-3 provisional
→ real transition, T-4 V1 threadId passthrough, T-5 non-vacuous isolation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-27 08:53:17 -07:00
Martha Kelly Schumann 1993ca20de fix(react-ui): stabilize Markdown components ref to prevent re-renders on streaming (#3535)
## Summary

- `{ ...defaultComponents, ...components }` in `Markdown.tsx` created a
new object reference on every render
- `MemoizedReactMarkdown` has a custom memo comparator checking
`prevProps.components === nextProps.components` — referential equality
always failed, so every prior message re-rendered on every streaming
chunk
- Fix: wrap the merge in `useMemo([components])` so the reference is
stable

Fixes CPK-7156 / closes #2543

## Test plan

- [x] Verified locally with the form-filling example: completed messages
no longer log new renders while a new message streams
- [x] `nx build @copilotkit/react-ui` passes
- [x] `nx test @copilotkit/react-ui` passes

🤖 Generated with [Claude Code](https://claude.com/claude-code)
2026-03-27 07:56:47 -07:00
Martha Schumann a03c6eb325 fix(react-ui): stabilize Markdown components ref to prevent full re-renders on streaming
{ ...defaultComponents, ...components } created a new object reference on
every render, causing MemoizedReactMarkdown's custom comparator to always
fail and re-render every prior message on each new streaming chunk.

Wrapping the merge in useMemo([components]) gives a stable reference so
the memo comparator works as intended.

Fixes CPK-7156

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-26 16:21:13 -07:00
Max Korp cd722213f4 chore: Update to published license-verifier 2026-03-26 16:19:03 -07:00
Max Korp 73bce637b5 feat: move license checks to the backend 2026-03-26 16:19:03 -07:00
Max Korp f43433c4c1 feat(runtime): add intelligence license checks to runtime
feat(runtime-v2): wire createLicenseChecker into CopilotRuntime

feat(runtime-v2): wire license checks into route handlers

feat(runtime-v1): pass licenseToken through to v2 runtime
2026-03-26 16:19:03 -07:00