@noodleseed/assistant 1.16.0 → 1.16.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.
@@ -1,4 +1,4 @@
1
- import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-401BAJqk.cjs';
1
+ import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-BQ30Fq-c.cjs';
2
2
  import '../appearance-Cc-eqSbp.cjs';
3
3
  import 'ai';
4
4
 
@@ -1,4 +1,4 @@
1
- import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-Ii_xTV09.js';
1
+ import { A as AssistantPageContext, a as AssistantContext, C as CreateAssistantClientOptions, b as AssistantChatState, c as AssistantClient } from '../client-B6pnBmF8.js';
2
2
  import '../appearance-Cc-eqSbp.js';
3
3
  import 'ai';
4
4
 
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import {
3
3
  createAssistantClient
4
- } from "../chunk-NPV64PUX.js";
4
+ } from "../chunk-RIKRQFKS.js";
5
5
  import "../chunk-3YYTUJPJ.js";
6
6
  import "../chunk-5FUTL2UF.js";
7
7
 
package/dist/react.cjs CHANGED
@@ -27480,6 +27480,10 @@ var DefaultAssistantClient = class {
27480
27480
  getChatState() {
27481
27481
  return this.#chat.getState();
27482
27482
  }
27483
+ /** Whether a session already exists, so a caller can avoid re-entering its loading state. */
27484
+ hasSession() {
27485
+ return this.#session !== void 0;
27486
+ }
27483
27487
  async connect() {
27484
27488
  if (this.#session) return;
27485
27489
  await this.#singleFlight(async (signal) => {
@@ -32179,7 +32183,13 @@ var NoodleAssistantElement = class extends HTMLElementBase {
32179
32183
  if (this.#appearance.behavior.startOpen) this.#applyStartOpenPolicy();
32180
32184
  this.#render();
32181
32185
  this.dispatchEvent(new CustomEvent("assistant-ready"));
32182
- this.#primeSession();
32186
+ if (this.hasAttribute("start-open")) {
32187
+ this.setAttribute("open", "");
32188
+ this.#startOpenApplied = true;
32189
+ this.#primeSession();
32190
+ } else if (!this.embedId) {
32191
+ this.#primeSession();
32192
+ }
32183
32193
  }
32184
32194
  disconnectedCallback() {
32185
32195
  this.#conversationGeneration += 1;
@@ -32201,6 +32211,7 @@ var NoodleAssistantElement = class extends HTMLElementBase {
32201
32211
  }
32202
32212
  open() {
32203
32213
  this.setAttribute("open", "");
32214
+ this.#primeSession();
32204
32215
  this.dispatchEvent(new CustomEvent("assistant-open"));
32205
32216
  }
32206
32217
  close() {
@@ -32368,6 +32379,7 @@ var NoodleAssistantElement = class extends HTMLElementBase {
32368
32379
  }
32369
32380
  #primeSession() {
32370
32381
  if (!this.sessionEndpoint && !this.embedId) return;
32382
+ if (this.#sessionBootstrap || this.#client?.hasSession()) return;
32371
32383
  const client = this.#ensureClient();
32372
32384
  const generation = this.#conversationGeneration;
32373
32385
  this.#setSessionState("loading");