assistant-ui icon indicating copy to clipboard operation
assistant-ui copied to clipboard

feat: expose `hasAttachments` and `isEmpty` state to Composer

Open okisdev opened this issue 1 month ago • 3 comments

This PR exposing hasAttachments and isEmpty state to Composer


[!IMPORTANT] Expose hasAttachments and isEmpty states in ComposerIf to conditionally render children based on attachments and emptiness.

  • Behavior:
    • Exposes hasAttachments and isEmpty states in ComposerIf to conditionally render children based on attachments and emptiness.
    • Updates useComposerIf in ComposerIf.tsx to handle hasAttachments and isEmpty conditions.
  • Documentation:
    • Updates Composer.mdx to include hasAttachments and isEmpty in the API reference and examples.

This description was created by Ellipsis for f44ab2d77e590d51111ede8e9cd427350b2bcb68. You can customize this summary. It will automatically update as commits are pushed.

okisdev avatar Nov 29 '25 07:11 okisdev

⚠️ No Changeset found

Latest commit: f44ab2d77e590d51111ede8e9cd427350b2bcb68

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

changeset-bot[bot] avatar Nov 29 '25 07:11 changeset-bot[bot]

I've been thinking about replacing all the if components with a more generic:

<AssistantIf query={({ composer }) => composer.isEmpty}>

what do you think of this? (it would use useAssistantState under the hood) this way we don't have to add all sorts of small checks to the Thread/Composer.If primitives

Yonom avatar Nov 29 '25 10:11 Yonom

@Yonom

That's an interesting refactor on Composer.If. Makes the simple things simple, and the complex things possible.

It becomes clear, an intuitively way to understand what it is doing through the query, so I strongly agree.

We also don't need to manually manage these things expose and they are entirely controlled by the users, which is a great practice.

okisdev avatar Nov 29 '25 14:11 okisdev

replaced by the new AssistantIf API! thanks Harry for the idea! :)

Yonom avatar Dec 01 '25 17:12 Yonom