Skip to content
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

AttachmentUI decomposition #1160

Open
Yonom opened this issue Nov 12, 2024 · 2 comments
Open

AttachmentUI decomposition #1160

Yonom opened this issue Nov 12, 2024 · 2 comments

Comments

@Yonom
Copy link
Owner

Yonom commented Nov 12, 2024

No description provided.

@utkarsh-alpuria
Copy link

Thank you for your response @Yonom and opening this new thread, I tried editing the code accordingly and got a different error.

ERROR
Unhandled Runtime Error
Error: This component must be used within a ComposerPrimitive.Attachments or MessagePrimitive.Attachments component.

CODE

import { FC } from "react";
import { Composer, ThreadPrimitive } from "@assistant-ui/react";

import { AttachmentUI } from "@assistant-ui/react";

const MyAttachmentUI: FC = () => {
return (
<AttachmentUI.Root>
attachment
<AttachmentUI.Remove />
</AttachmentUI.Root>
);
};

export const MyComposer: FC = () => {
return (
<Composer.Root>

<Composer.AddAttachment />
<Composer.Input autoFocus />
<Composer.Action />
</Composer.Root>
);
};

@Yonom
Copy link
Owner Author

Yonom commented Nov 19, 2024

@utkarsh-alpuria can you try this in order to render MyAttachmentUI for each attachment:

export const MyComposer: FC = () => {
  return (
    <Composer.Root>
      <Composer.AddAttachment />
      <Composer.Attachments components={{ Attachment: MyAttachmentUI }} />
      <Composer.Input autoFocus />
      <Composer.Action />
    </Composer.Root>
  );
};

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

No branches or pull requests

2 participants