oramasearch / orama-ui-components

A set of UI components to help you integrate Orama on your website or app.
https://components.orama.com
Other
4 stars 0 forks source link

Refactor messages #13

Closed g-francesca closed 3 months ago

g-francesca commented 3 months ago

Here are the key points covered in the PR:

I also did some refactoring to the chatContext state, so it now only includes:

const { state: chatContext } = createStore({
  chatService: null as ChatService | null,
  interactions: [] as TChatInteraction[],
})

I removed messages in favor of interactions, and the status is now handled as a single interaction status (not a global one). This way, updating the UI according to the answer status (which. is what we mostly do) becomes simpler. The type of a single interaction is:

export type TChatInteraction = {
  query: string
  response?: string
  sources?: TSource[]
  status: TAnswerStatus
  interactionId?: string
}

Which is closer to the status we get from the server. These types should be imported by the client for consistency though

vercel[bot] commented 3 months ago

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
orama-ui-components-storybook βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jul 24, 2024 9:43pm
linear[bot] commented 3 months ago
ORM-1537 Stop answer button - fix

Currently, we only allow aborting the answer when the message is loading, not when it's updating. Therefore, if the answer is too long, we can't stop it

ORM-1547 Implement sources

Replace hardcoded sources with the real ones

ORM-1536 Quick actions fixes

* Quick actions must be displayed only on message complete βœ… * Add aria-label to buttons to make them accessible βœ… * implement regenerate logic and make sure to handle error if regenerate βœ… * Regenerate should be visible only for the last item βœ