@runtypelabs/persona 1.45.0 → 1.46.1
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 +33 -0
- package/dist/index.cjs +30 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.global.js +48 -48
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +30 -30
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/event-stream-view.test.ts +26 -0
- package/src/components/event-stream-view.ts +6 -3
- package/src/session.ts +14 -0
- package/src/types.ts +7 -0
- package/src/ui.ts +61 -15
package/README.md
CHANGED
|
@@ -253,6 +253,22 @@ chat.isEventStreamVisible() // returns boolean
|
|
|
253
253
|
|
|
254
254
|
These methods are no-ops if `showEventStreamToggle` is not enabled.
|
|
255
255
|
|
|
256
|
+
#### Input focus control
|
|
257
|
+
|
|
258
|
+
Focus the chat input programmatically:
|
|
259
|
+
|
|
260
|
+
```ts
|
|
261
|
+
const chat = initAgentWidget({
|
|
262
|
+
target: '#chat-root',
|
|
263
|
+
config: { apiUrl: '/api/chat/dispatch' }
|
|
264
|
+
})
|
|
265
|
+
|
|
266
|
+
// Focus the input (returns true if successful, false if panel is closed or unavailable)
|
|
267
|
+
chat.focusInput()
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
In launcher mode, `focusInput()` returns `false` when the panel is closed and does not auto-open it. Use `chat.open()` first if you want to open and focus in one flow.
|
|
271
|
+
|
|
256
272
|
#### Accessing from window
|
|
257
273
|
|
|
258
274
|
To access the controller globally (e.g., from browser console or external scripts), use the `windowKey` option:
|
|
@@ -361,6 +377,22 @@ window.dispatchEvent(new CustomEvent('persona:showEventStream', {
|
|
|
361
377
|
// ^ No effect — no widget has this instanceId
|
|
362
378
|
```
|
|
363
379
|
|
|
380
|
+
#### `persona:focusInput`
|
|
381
|
+
|
|
382
|
+
Dispatched to programmatically focus the chat input on a widget instance.
|
|
383
|
+
|
|
384
|
+
```ts
|
|
385
|
+
// Focus input on all widget instances
|
|
386
|
+
window.dispatchEvent(new CustomEvent('persona:focusInput'))
|
|
387
|
+
|
|
388
|
+
// Focus input on a specific instance
|
|
389
|
+
window.dispatchEvent(new CustomEvent('persona:focusInput', {
|
|
390
|
+
detail: { instanceId: 'inline-widget' }
|
|
391
|
+
}))
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
**Instance scoping:** Same as `persona:showEventStream` — use `detail.instanceId` to target a specific widget. Without `instanceId`, all instances receive the event.
|
|
395
|
+
|
|
364
396
|
### Controller Events
|
|
365
397
|
|
|
366
398
|
The widget controller exposes an event system for reacting to chat events. Use `controller.on(eventName, callback)` to subscribe and `controller.off(eventName, callback)` to unsubscribe.
|
|
@@ -1251,6 +1283,7 @@ This ensures all configuration values are set to sensible defaults while allowin
|
|
|
1251
1283
|
| `copy` | `{ welcomeTitle?, welcomeSubtitle?, inputPlaceholder?, sendButtonLabel? }` | Customize user-facing text. |
|
|
1252
1284
|
| `theme` | `{ primary?, secondary?, surface?, muted?, accent?, radiusSm?, radiusMd?, radiusLg?, radiusFull? }` | Override CSS variables for the widget. Colors: `primary` (text/UI), `secondary` (unused), `surface` (backgrounds), `muted` (secondary text), `accent` (buttons/links). Border radius: `radiusSm` (0.75rem, inputs), `radiusMd` (1rem, cards), `radiusLg` (1.5rem, panels/bubbles), `radiusFull` (9999px, pills/buttons). |
|
|
1253
1285
|
| `features` | `AgentWidgetFeatureFlags` | Toggle UI features: `showReasoning?` (show thinking bubbles, default: `true`), `showToolCalls?` (show tool usage bubbles, default: `true`), `showEventStreamToggle?` (show event stream inspector toggle in header, default: `false`). |
|
|
1286
|
+
| `autoFocusInput` | `boolean` | When `true`, focus the chat input after the panel opens and the open animation completes. Applies to launcher mode (user click, `controller.open()`, `autoExpand`) and inline mode (on init). Skips when voice is active. Default: `false`. |
|
|
1254
1287
|
| `launcher` | `{ enabled?, autoExpand?, title?, subtitle?, iconUrl?, position? }` | Controls the floating launcher button. |
|
|
1255
1288
|
| `initialMessages` | `AgentWidgetMessage[]` | Seed the conversation transcript. |
|
|
1256
1289
|
| `suggestionChips` | `string[]` | Render quick reply buttons above the composer. |
|