@theoremjs/web 0.3.4-next.375.ga2d1878 → 0.3.4-next.377.g4dbec64

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/client/chat.d.ts CHANGED
@@ -94,7 +94,10 @@ export type ChatUpdate<T> = T | ((prev: T) => T);
94
94
  */
95
95
  export type ChatController = {
96
96
  getState(): ChatState;
97
- /** Called after each change, once per batch of changes. Returns the unsubscribe. */
97
+ /**
98
+ * Called after each change, once per batch of changes. Returns the unsubscribe. A conversation
99
+ * resumed without its `conversationView` is read from the host once the first listener subscribes.
100
+ */
98
101
  subscribe(listener: () => void): () => void;
99
102
  /** The latest options. `conversation`, `conversationView` and `initialText` are read only at creation. */
100
103
  update(options: ChatOptions): void;
package/client/chat.js CHANGED
@@ -124,6 +124,8 @@ class Chat {
124
124
  getState = () => this.#state;
125
125
  subscribe = (listener) => {
126
126
  this.#listeners.add(listener);
127
+ if (this.#listeners.size === 1)
128
+ this.#settle();
127
129
  return () => this.#listeners.delete(listener);
128
130
  };
129
131
  update = (options) => {
@@ -377,11 +379,14 @@ class Chat {
377
379
  #resume(iface) {
378
380
  if (this.#resumed)
379
381
  return;
380
- this.#resumed = true;
381
382
  const ref = this.#conversation;
383
+ const shown = this.#options.conversationView;
384
+ // why: A chat no one follows yet (one React's strict mode builds and drops) reads nothing from the host.
385
+ if (ref !== undefined && !shown && this.#listeners.size === 0)
386
+ return;
387
+ this.#resumed = true;
382
388
  if (ref === undefined || !keepsConversation(iface))
383
389
  return;
384
- const shown = this.#options.conversationView;
385
390
  if (shown) {
386
391
  this.#draw(shown, this.#state.session, []);
387
392
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theoremjs/web",
3
- "version": "0.3.4-next.375.ga2d1878",
3
+ "version": "0.3.4-next.377.g4dbec64",
4
4
  "description": "Theorem on the web platform, with no UI framework: Web-standard server handlers that serve a profile, and the browser client that talks to them.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -25,6 +25,6 @@
25
25
  },
26
26
  "peerDependencies": {
27
27
  "zod": "^4.6.5",
28
- "@theoremjs/agents": "^0.3.4-next.375.ga2d1878"
28
+ "@theoremjs/agents": "^0.3.4-next.377.g4dbec64"
29
29
  }
30
30
  }