@twentyfourg/chat-kit 1.0.0-beta.1 → 1.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -100,13 +100,34 @@ const engine = useChatEngine({ transport, agentId, typewriter: { speed: 1.5 } })
100
100
  | `showThinking` | `true`, `false` | `false` | Shows the model's reasoning: live while you wait, folded up on the finished reply. |
101
101
  | `autoScroll` | `'off'`, `'reply'`, `'bottom'` | `'reply'` | How far the view follows a streaming answer. `'reply'` stops once the answer's own header reaches the top, so a long answer can be read from the beginning. `'bottom'` keeps the newest line in view. `'off'` leaves the view alone. Under `'reply'` and `'bottom'`, scrolling up stops the follow until the reader comes back to the bottom. |
102
102
  | `showCopy` | `true`, `false` | `false` | Adds a copy button under each finished answer. |
103
+ | `beforeSend` | `(text, mode) => boolean \| Promise<boolean>` | off | Runs before the composer's text reaches the engine. Return `false` to hold it: your app has something to do first (show an offer, refine the question) and calls `engine.sendMessage` itself when ready. |
104
+
105
+ `copy` is read reactively, so a string that depends on app state (a placeholder
106
+ that changes once the conversation has started, say) can be a computed.
103
107
 
104
108
  ### Slots
105
109
 
106
110
  | Slot | What it's for |
107
111
  | --- | --- |
108
112
  | `welcome` | Replaces the default welcome block that shows before the first message. Use it for a logo, suggested questions, whatever you want. A text-only welcome can just set `copy.welcome` and skip the slot. |
113
+ | `message` | Scoped, gives you `{ message }`. Renders the messages your app put into the conversation itself with `engine.insertMessage`: an offer, a notice, a prompt to answer before the next question. The kit has no bubble for these, so without the slot they render as nothing. |
109
114
  | `message-actions` | Scoped, gives you `{ message }`. Sits on the left of the row that holds the thumbs, on finished replies. This is where an app's own button goes, an export for example, and it comes before the kit's copy button so your actions stay together. |
115
+ | `message-footer` | Scoped, gives you `{ message }`. Whatever your app wants under a reply, below its sources and actions: follow-up prompts, a link back to something above. Rendered for every reply, streaming included, so check `message.isStreaming` if it should wait. |
116
+ | `composer` | Replaces the whole composer. For a state the kit's field has no shape for, such as a locked bar with an upgrade prompt. Your content calls `engine.sendMessage` itself if it needs to send. |
117
+ | `send` | Scoped, gives you `{ send, canSend }`. Replaces the send button and nothing else, so the field keeps its own typing, dictation, and Enter handling. For a client whose send button is a finished asset that draws its own shape and disabled state. Not rendered while an answer streams, when the stop button has the spot. |
118
+ | `composer-footer` | Sits inside the composer, under the field. An option that changes how the next question is handled, a hint, a counter. |
119
+
120
+ Your own send button, keeping everything else the kit does:
121
+
122
+ ```vue
123
+ <Chat :engine="engine">
124
+ <template #send="{ send, canSend }">
125
+ <button :disabled="!canSend" @click="send">
126
+ <img :src="canSend ? sendIcon : sendDisabledIcon" alt="Send" />
127
+ </button>
128
+ </template>
129
+ </Chat>
130
+ ```
110
131
 
111
132
  ### Events
112
133
 
@@ -144,6 +165,24 @@ The heading, label, and interface fonts follow `--font-body` unless you set
144
165
  them. The citation and button accents follow `--accent`. An app that already
145
166
  defines the whole set itself can skip the import.
146
167
 
168
+ ### Room around the chat
169
+
170
+ Two properties control how much space the chat takes, separately from the rest
171
+ of the theme:
172
+
173
+ | Property | Default | What it does |
174
+ | --- | --- | --- |
175
+ | `--chat-inset` | `24px` | The gutter between the chat's edge and its contents. The conversation and the composer both read it, so they stay lined up with each other. |
176
+ | `--composer-padding` | `8px` | Space between the composer's border and the field inside it. The 40px buttons set the height, not the text, so this is added to those: the default makes a 56px composer plus its border. |
177
+
178
+ A roomier chat, for a design with space to spend:
179
+
180
+ ```css
181
+ :root {
182
+ --composer-padding: 24px;
183
+ }
184
+ ```
185
+
147
186
  One thing to watch. If your own tokens live inside a CSS cascade layer, layer
148
187
  order decides the winner before anything else does. Import `theme.css` before
149
188
  your layered styles, or state the order yourself: