-
Notifications
You must be signed in to change notification settings - Fork 365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Composer.unstable_on("send", callback) #1279
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Warning Rate limit exceeded@Yonom has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 56 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
WalkthroughThis pull request introduces version 0.7.21 of the Changes
Sequence DiagramsequenceDiagram
participant Client
participant Composer
participant Runtime
Client->>Composer: unstable_on("send", callback)
Composer->>Runtime: Register event subscriber
Runtime-->>Composer: Subscription confirmed
Client->>Composer: Send message
Composer->>Runtime: Handle send
Runtime->>Runtime: Notify event subscribers
Runtime->>Client: Trigger callback
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
WalkthroughThis update introduces a new feature, Changes
Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts belowEmoji Descriptions:
Interact with the Bot:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Summary
Added event subscription capabilities to the Composer component, introducing an unstable 'send' event listener and updating peer dependencies across packages to maintain compatibility.
- Added
unstable_on("send", callback)
method inBaseComposerRuntimeCore
with Map-based event storage - Renamed
cancel
tohandleCancel
in composer runtimes for consistent naming withhandleSend
- Updated peer dependency version of
@assistant-ui/react
from ^0.7.20 to ^0.7.21 across all packages - Modified
send()
method to notify subscribers of 'send' events before resetting state - Added version 0.7.21 entry in CHANGELOG.md documenting the new experimental feature
14 file(s) reviewed, 6 comment(s)
Edit PR Review Bot Settings | Greptile
packages/react/src/runtimes/composer/BaseComposerRuntimeCore.tsx
Outdated
Show resolved
Hide resolved
packages/react/src/runtimes/composer/BaseComposerRuntimeCore.tsx
Outdated
Show resolved
Hide resolved
packages/react/src/runtimes/composer/BaseComposerRuntimeCore.tsx
Outdated
Show resolved
Hide resolved
packages/react/src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
🔭 Outside diff range comments (1)
packages/react-syntax-highlighter/package.json (1)
Line range hint
30-37
: Well-structured version management approach.The coordinated version bump across packages demonstrates good practices:
- Using
^0.7.21
allows for patch updates while maintaining compatibility- The
unstable_
prefix properly indicates experimental features- The minor version bump (0.7.20 -> 0.7.21) correctly reflects the addition of a new feature
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (14)
packages/react-ai-sdk/package.json
(1 hunks)packages/react-hook-form/package.json
(1 hunks)packages/react-langgraph/package.json
(1 hunks)packages/react-markdown/package.json
(1 hunks)packages/react-playground/package.json
(1 hunks)packages/react-syntax-highlighter/package.json
(1 hunks)packages/react-trieve/package.json
(1 hunks)packages/react/CHANGELOG.md
(1 hunks)packages/react/package.json
(1 hunks)packages/react/src/api/ComposerRuntime.ts
(2 hunks)packages/react/src/runtimes/composer/BaseComposerRuntimeCore.tsx
(4 hunks)packages/react/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
(1 hunks)packages/react/src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx
(1 hunks)packages/react/src/runtimes/core/ComposerRuntimeCore.tsx
(2 hunks)
🧰 Additional context used
🪛 Biome (1.9.4)
packages/react/src/runtimes/composer/BaseComposerRuntimeCore.tsx
[error] 158-158: Forbidden non-null assertion.
(lint/style/noNonNullAssertion)
🔇 Additional comments (22)
packages/react/src/runtimes/composer/BaseComposerRuntimeCore.tsx (9)
8-11
: New import reference
Importing ComposerRuntimeEventType
appears correct. No issues noted.
54-54
: Visibility change: setRole
Elevating setRole
to public is sensible if external code needs to change the role. Validate that no privacy constraints are violated.
59-59
: Visibility change: setText
Making setText
public aligns with providing external control over the text state. Verify no side effects in external usage.
64-64
: Internal reset method
Encapsulating the reset logic in a private _resetInternal
method is clear and maintainable.
71-73
: Public reset method
Calling _resetInternal
directly helps ensure consistent reset behavior. No problems found.
93-93
: Reset on send
Resetting text, role, and attachments after sending might surprise some consumers who expect the data to remain. Confirm the design aligns with product requirements.
96-96
: New send event notification
_notifyEventSubscribers("send")
aligns with event-driven design. Good addition for external hooks.
99-101
: Cancel method
Delegating to handleCancel
is consistent. Confirm the overridden method is properly implemented in subclasses.
140-146
: Event notification method
_notifyEventSubscribers
uses the stored subscriber callbacks. Straightforward logic. Good job.
packages/react/src/runtimes/core/ComposerRuntimeCore.tsx (2)
4-4
: New typed event
Defining "send"
as ComposerRuntimeEventType
helps ensure clarity and type safety in event handling.
31-34
: New unstable_on method
Adding unstable_on
fosters an extensible event subscription mechanism. Keep an eye on naming if this stabilizes.
packages/react/src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx (1)
49-49
: Renamed cancel to handleCancel
Renaming to handleCancel
for clarity is consistent with the base class changes. Implementation remains straightforward.
packages/react/src/api/ComposerRuntime.ts (2)
4-4
: Import event type
Importing ComposerRuntimeEventType
clarifies usage in the unstable_on
method.
166-171
: New unstable_on method implementation
This effectively delegates to the core's unstable_on
. Make sure the composer is defined before registration.
packages/react-langgraph/package.json (1)
33-33
: Peer dependency version update
Upgrading @assistant-ui/react
to ^0.7.21
maintains alignment with newly introduced features.
packages/react-hook-form/package.json (1)
33-33
: LGTM! Version bump aligns with the new unstable feature.
The peer dependency update to ^0.7.21
is appropriate for the new Composer.unstable_on("send", callback)
feature. The unstable_
prefix correctly indicates this is an experimental API that may change in future versions.
packages/react-ai-sdk/package.json (1)
37-37
: LGTM! Version bump enables new event handling capabilities.
The peer dependency update to ^0.7.21
allows this AI SDK package to utilize the new Composer.unstable_on("send", callback)
feature. Since this package likely integrates closely with the Composer component, this update is particularly relevant.
Let's verify if this package uses the Composer component:
✅ Verification successful
Version bump is appropriate as the package actively uses composer functionality
The package indeed relies heavily on the @assistant-ui/react
package and specifically uses composer functionality, as evidenced by:
- Direct composer state management in
useInputSync.tsx
- Multiple imports of core components and types from
@assistant-ui/react
- Recent changelog entries showing composer-related features
The version bump to ^0.7.21
is necessary to maintain compatibility with the composer's event handling capabilities.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for Composer usage in the AI SDK package
rg -l "Composer" "packages/react-ai-sdk/src/"
Length of output: 43
Script:
#!/bin/bash
# Let's try a broader search for Composer usage in the package
rg -i "composer" "packages/react-ai-sdk/"
# Also search for any imports from @assistant-ui/react
rg -i "from ['|\"]@assistant-ui/react" "packages/react-ai-sdk/"
Length of output: 2608
packages/react-syntax-highlighter/package.json (1)
30-30
: LGTM! Version bump maintains ecosystem consistency.
The peer dependency update to ^0.7.21
maintains version alignment across the package ecosystem, even though this syntax highlighter package may not directly utilize the new Composer event handling feature.
packages/react-markdown/package.json (1)
44-44
: LGTM: Peer dependency version bump is consistent
The update to @assistant-ui/react ^0.7.21 aligns with the introduction of the new unstable_on("send") feature.
packages/react-playground/package.json (1)
50-50
: LGTM: Peer dependency version bump is consistent
The update to @assistant-ui/react ^0.7.21 aligns with other packages in the monorepo.
packages/react-trieve/package.json (1)
48-48
: LGTM: Peer dependency version bump is consistent
The update to @assistant-ui/react ^0.7.21 aligns with other packages. The existing @assistant-ui/react-markdown ^0.7.7 dependency remains compatible with this change.
✅ Verification successful
Version compatibility check confirms alignment across packages
The version check shows that all packages in the workspace are using compatible versions of @assistant-ui/react
:
- Most packages under
/packages
directory consistently use^0.7.21
- Example apps either use
workspace:*
(internal workspace dependency) or^0.7.17
which is compatible with^0.7.21
Let's verify the compatibility with @assistant-ui/react-markdown
as well:
Version bump is consistent and compatible across dependencies
The version checks confirm that:
- The
@assistant-ui/react
peer dependency update to^0.7.21
aligns with other packages in the workspace - The existing
@assistant-ui/react-markdown ^0.7.7
dependency is compatible, as other packages use either the same version or lower compatible versions (^0.7.5
) - No version conflicts or compatibility issues were found
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify version compatibility across the workspace
# Look for any potential version conflicts or mismatches
# Check all package.json files for @assistant-ui/react versions
echo "Checking @assistant-ui/react versions across workspace:"
fd package.json | xargs grep -l "@assistant-ui/react" | while read -r file; do
echo "=== $file ==="
cat "$file" | jq -r '.peerDependencies["@assistant-ui/react"] // .dependencies["@assistant-ui/react"] // empty'
done
Length of output: 5823
Script:
#!/bin/bash
# Check react-markdown dependency versions
echo "Checking @assistant-ui/react-markdown versions:"
fd package.json | xargs grep -l "@assistant-ui/react-markdown" | while read -r file; do
echo "=== $file ==="
cat "$file" | jq -r '.dependencies["@assistant-ui/react-markdown"] // .peerDependencies["@assistant-ui/react-markdown"] // empty'
done
Length of output: 2376
packages/react/package.json (1)
32-32
: LGTM: Version bump to 0.7.21
The version increment aligns with the new feature addition mentioned in the changelog.
packages/react/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx
Outdated
Show resolved
Hide resolved
packages/react/src/runtimes/composer/BaseComposerRuntimeCore.tsx
Outdated
Show resolved
Hide resolved
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…eCore.tsx Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
🔍 Review Summary
Purpose:
Changes:
Composer.unstable_on("send", callback)
for event subscription.cancel
tohandleCancel
for clarity.@assistant-ui/react
to^0.7.21
for compatibility.Impact:
Original Description
None
Summary by CodeRabbit
New Features
unstable_on("send", callback)
to theComposer
component, allowing developers to register a callback for send events.Chores
^0.7.21
@assistant-ui/react
package version to0.7.21