@icanbwell/baileyai-chat-ui 1.0.0 → 1.0.2

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/dist/index.d.ts CHANGED
@@ -496,8 +496,38 @@ export declare interface UseBaileyChatResult {
496
496
  /** Dismisses the current error without resending — distinct from retryLast, which resends. */
497
497
  clearError: () => void;
498
498
  /** Aborts any in-flight turn and resets the conversation to empty, so a host can offer a
499
- * "start over" control without remounting the component. */
499
+ * "start over" control without remounting the component.
500
+ *
501
+ * `BaileyChatPanel`'s own "New chat" button calls whatever `newChat` sits on the `chat`
502
+ * object it was given (read off `props.chat`, not this hook directly) — so a host that
503
+ * needs to react to a reset (e.g. to also clear its own persisted conversation identity)
504
+ * wraps this function before handing `chat` to the panel:
505
+ *
506
+ * ```ts
507
+ * const chat = useBaileyChat({ transport, model, instructions });
508
+ * const chatForPanel = useMemo(
509
+ * () => ({ ...chat, newChat: () => { chat.newChat(); onHostReset(); } }),
510
+ * [chat]
511
+ * );
512
+ * ```
513
+ *
514
+ * `newChat()` is fully synchronous, so the wrapper returning is the only "did it finish"
515
+ * signal a host needs — no callback or promise required. */
500
516
  newChat: () => void;
517
+ /** Replaces the current transcript with a caller-supplied one, for resuming a previously
518
+ * started conversation or switching to a different one a host's user selected from a
519
+ * history list. Call once per conversation load (e.g. from an effect keyed on the loaded
520
+ * data), not on every render — repeated calls silently re-apply the same reset each time,
521
+ * the same class of bug as a wrong `useEffect` dependency.
522
+ *
523
+ * Aborts any in-flight turn first (switching conversations is decisive, unlike
524
+ * `sendHidden`/`retryLast`, which no-op instead). Every provided message is normalized to
525
+ * `streaming: false` — a restored message can never legitimately be mid-stream. `hidden`
526
+ * messages are excluded from the visible transcript but retained in the model-context
527
+ * history sent on the next turn, mirroring `sendHidden`'s live behaviour exactly. Any entry
528
+ * whose `role` isn't `'user'` or `'assistant'` is dropped rather than trusted, since a
529
+ * restored transcript crosses a service boundary this hook doesn't control. */
530
+ loadMessages: (messages: BaileyMessage[]) => void;
501
531
  }
502
532
 
503
533
  export { }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icanbwell/baileyai-chat-ui",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Shared React chat UI and streaming logic for Bailey, the icanbwell AI assistant",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {