Assistant panel — Chat block

Free

chat-assistant-panel · for app pages

Assistant panel

A narrow companion panel with sourced answers and follow-up prompts supplied by the host.

Documentation

Installation

One command copies the block into your project with the shadcn CLI (the registry is set once: Installation).

pnpm dlx shadcn-vue@latest add @trame/chat-assistant-panel

Usage

Its demo data, shortened (Using blocks).

<script setup lang="ts">
import ChatAssistantPanel from '@/components/trame/blocks/chat/chat-assistant-panel.vue'

const props = {
title: "A hand with this reservation",
description: "Ember & Rye’s notes, menus and booking rules, before you reply to a guest.",
messages: [
{
id: "q1",
role: "user",
body: "A table of eight on Saturday, one guest with a nut allergy: what do we need before confirming?",
at: "10:24 a.m."
},
{
id: "a1",
role: "assistant",
body: "The party size and time are set. You still need the guest’s allergy details in writing and a card for the deposit, since groups of eight or more pay a $60 deposit per guest.\n\nThe tasting menu’s romesco and dessert both contain nuts: chef Ana Ruiz has a nut-free version if the kitchen knows by Friday noon.",
at: "10:24 a.m.",
sources: [
{
label: "Group booking rules",
action: "open-source",
record: {
id: "groups"
}
},
{
label: "Reservation, Saturday 8 p.m.",
action: "open-booking",
record: {
id: "res-824"
}
}
],
actions: [
{
label: "Open the reservation",
action: "open-booking",
record: {
id: "res-824"
}
}
]
}
],
prompts: [
"Draft a reply to the guest",
"Show the nut-free tasting menu"
],
action: "ask-assistant",
options: {
footnote: "Check the sources before confirming anything to a guest."
}
}
</script>

<template>
<ChatAssistantPanel v-bind="props" />
</template>

Props

Each prop says who changes it: Words, Picture, Action, Design, Data.* required.

PropTypeDescription
title*stringWordsthe section’s heading
descriptionstringWordsa few words saying more, under the heading
messages*Message[]Datathe conversation, oldest first
promptsstring[]Wordssuggested questions to start with
actionstringActionPOST destination; receives body
optionsOptionsthe block’s settings: layout choices and secondary words, read by every variant
Message messages[] · 7 props
PropTypeDescription
id*string | numberDatathe message’s id
role*'user' | 'assistant'who speaks: the user or the assistant
authorAuthorwho wrote it
body*stringWordsthe message itself
atstringWordswhen it was sent, as the host writes it
sourcesSource[]the sources the answer cites
actionsAction[]links the answer offers
Author messages[].author · 6 props
PropTypeDescription
idstring | numberDatathe record’s id in the tool that answers it
name*stringWordsthe person’s name
rolestringWordstheir role or job title
companystringWordswhere they work
avatarstringPicturea picture: a root-relative path (/media/…) or an absolute URL
urlstringDesigna page about them
Source messages[].sources[] · 3 props
PropTypeDescription
label*stringWordsthe words on the button or link
action*stringActiona named action of the page
recordRecord<string, unknown>Datathe record the action applies to, passed to the host with it, if any
Action messages[].actions[] · 3 props
PropTypeDescription
label*stringWordsthe words on the button or link
action*stringActiona named action of the page
recordRecord<string, unknown>Datathe record the action applies to, passed to the host with it, if any
Options options · 2 props
PropTypeDescription
footnotestringWordsa small line at the foot of the section
mood'inverse' | 'brand' | 'warm' | 'tint' | stringa band of the page that redefines the theme surfaces inside it
What it asks your app for

The block never knows your app: it asks it, through one context provided once, where its links lead, what its actions do, how a price reads and which words to say (The host context).

MemberWhat it is for
hrefthe address an action leads to, or null to hide what leads there
actruns a change (subscribe, add to cart, save) and answers { ok } or { ok: false, error }
canwhether the page has this action
Linkyour router’s link component
cartCountthe cart badge’s number
cartDrawerwhether your app has a cart drawer
cartOpenwhether the cart drawer is open
labelyour word for an interface key, or undefined to keep the block’s own

The words it says itself, in English and French; label(key) replaces any of them:

KeyEnglishFrench
newsletter.alreadyYou are already subscribed.Vous êtes déjà inscrit.
newsletter.doneDone: you are subscribed.C’est noté : vous êtes inscrit.
newsletter.invalidCheck the email address.Vérifiez l’adresse e-mail.
newsletter.tooManyToo many attempts, try again in a moment.Trop de tentatives, réessayez dans un moment.

Features

  • Every word in the server HTML
  • Same markup in Vue and React
  • Theme tokens only: every theme, light and dark
  • Shows what you give it, invents nothing
  • No motion; still under reduced motion
  • Real buttons and links, a visible focus
  • Asks your app through actions: messages[].sources[], messages[].actions[], action
  • Reads messages from your app

A chat section, for app pages; it uses @lucide/vue, @vueuse/core, class-variance-authority, clsx, tailwind-merge.

Built with

The components this block is made of; each one installs on its own too.

More chat blocks

  • Conversation bubbles: a customer conversation on a ticket or an order: two sides, the team dark, notes tinted, reply and note tabs.
  • Conversation page sidebar: A full workspace with conversation history beside the host-provided conversation.
  • Inbox three pane: triage support tickets or messages on a wide screen: the list, the thread and its properties side by side.
  • Inbox two pane: email-like reading: the list beside the thread, the correspondent’s details in the thread header.
  • Message digest sections: an app-home widget: threads grouped in labelled sections with their unread counts, no reading pane.
  • Support widget: a support entry point on a page: an invitation, the people who answer, chat and knowledge-base buttons.
  • Thread correspondence: A spacious message ledger beside a separate writing desk for sustained replies to the merchant’s own conversation.
  • Thread flat: comments on a record: everyone left-aligned with avatar and name, an anchor quote, resolve and assign.

All 10 chat blocks