@xh/hoist-chat-kit 2.0.0-SNAPSHOT.1793929937227 → 2.0.0

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/CHANGELOG.md CHANGED
@@ -12,7 +12,7 @@
12
12
  3. Plain ASCII punctuation only. Use " - " for in-sentence breaks, never an em dash.
13
13
  -->
14
14
 
15
- ## 2.0.0-SNAPSHOT - unreleased
15
+ ## 2.0.0 - 2026-11-16
16
16
 
17
17
  ### 💥 Breaking Changes (upgrade difficulty: 🟢 LOW - remove the busy-line settings)
18
18
 
@@ -30,19 +30,21 @@ detailed, step-by-step upgrade instructions with before/after code examples.
30
30
 
31
31
  ### 🎁 New Features
32
32
 
33
- * `ChatThreadsModel` now blocks sends while the store lists a thread as running and its history has
34
- no settled reply to that turn yet. The status region shows the block only with Refresh Status,
35
- once the automatic checks below stop.
36
-
37
33
  * `ChatThreadsModel` now checks on a turn that runs on the server while its chat does not follow
38
34
  it, and loads the reply once the thread list shows the run done. Set the interval with
39
- `ChatKit.defaults.statusRefreshMs` or `ChatThreadsConfig.statusRefreshMs`, null for none.
40
- * Added `chatAnnouncer.withdraw()`, to take back an announcement whose news no longer holds. The
41
- status region withdraws a status's announcement once it passes.
35
+ `ChatKit.defaults.statusRefreshMs` or `ChatThreadsConfig.statusRefreshMs`, null for none. The
36
+ checks stop after `statusRefreshTimeoutMs`, which both also take.
37
+ * `ChatThreadsModel` now blocks sends while the store lists a thread as running and its history has
38
+ no settled reply to that turn yet. The status region shows the block only with Refresh Status,
39
+ once the automatic checks stop.
42
40
  * `ChatMessageList` now shows "Still working on the server" for such a turn with no reply saved
43
41
  yet, in place of the empty state or after the user's question. The composer's start items breathe
44
42
  while it runs.
45
-
43
+ * `ChatModel.setStatusRefresher()` now takes `ChatStatusRefresherOptions`, for an app with a thread
44
+ layer of its own. They drive the new `ChatModel.isRunningOnServer` and
45
+ `ChatModel.isStatusRefreshAutomatic` getters.
46
+ * Added `chatAnnouncer.withdraw()`, to take back an announcement whose news no longer holds. The
47
+ status region withdraws a status's announcement once it passes.
46
48
  * Added `ChatThreadsModel.showThreadTitle()`, to show a title the backend already holds, such as
47
49
  one it wrote in the background. The list and the workspace header show it at once, with no
48
50
  store call and no list reload.
@@ -63,10 +65,28 @@ detailed, step-by-step upgrade instructions with before/after code examples.
63
65
  * Fixed a reply left running on the server, live, loaded or replayed, to show its unfinished server
64
66
  calls and sub-agents as "Not finished yet", not as failed, cancelled or "Stopped". Once the
65
67
  conversation moves past the reply, it reads as complete and its open work closes.
68
+ * Fixed a failed reply rebuilt by `replayChatEvents` to show as a failed reply, with its error.
69
+ Before, a reply with no parts, run id or error code showed as "Not sent" under the user's
70
+ message, though the backend had the turn. Each rebuilt reply now carries
71
+ `metadata.runStarted: true`, as a live reply does once its run starts. A live reply whose run
72
+ started with no run id, then failed with no parts or code, now shows as failed too.
73
+ * Fixed a reply rebuilt by `replayChatEvents` with `status: 'error'`, from events that end in
74
+ neither `RUN_FINISHED` nor `RUN_ERROR`, to read as not retry-safe in server mode. It now gets
75
+ error code `incomplete-stream`, as a live stream that broke off does, so the chat never offers
76
+ Try Again for it. Pass `metadata: {retrySafe: true}` to mark it safe. A record the decoder
77
+ rejects still fails the reply as `invalid-stream`, over the app's `errorCode` and `retrySafe`.
78
+ * `isChatRetrySafe` now takes `metadata.retrySafe: true` over the kit's own unsafe error codes.
79
+ Before, only `false` decided.
66
80
  * Fixed `replayChatEvents` to record no times for events with no `timestamp`. Before, it timed
67
- every tool call, sub-agent and reasoning part by the load, so each showed "<0.1s". The timeline,
68
- its screen reader labels and the reasoning label now show no time for them. A backend that
69
- stores events should stamp each one as the agent emits it.
81
+ every tool call, sub-agent and reasoning part by the load, so each showed "<0.1s". Such parts now
82
+ carry null `startedAt` and `endedAt`, and the timeline, its screen reader labels and the
83
+ reasoning label show no time for them. A backend that stores events should stamp each one as the
84
+ agent emits it.
85
+
86
+ ### ⚙️ Technical
87
+
88
+ * Added Zod 4 as a dependency of the kit. AG-UI 1.0.4 takes Zod as a peer, so the kit supplies it.
89
+ Apps no longer need the `zod` override that the 1.0.0 README advised, and can remove it.
70
90
 
71
91
  ### ✨ Styles
72
92
 
package/README.md CHANGED
@@ -85,13 +85,8 @@ as peer dependencies.
85
85
 
86
86
  The package ships as TypeScript and SCSS source, as `@xh/hoist` does, and your app compiles it
87
87
  with the rest of its code. It depends on the official AG-UI packages, `@ag-ui/core` and
88
- `@ag-ui/client`, which bring RxJS and Zod 3 with them.
89
-
90
- Every Zod 3 release carries advisory
91
- [GHSA-mrhx-c7xc-m3w5](https://github.com/advisories/GHSA-mrhx-c7xc-m3w5), fixed in Zod 4.6.6. The
92
- AG-UI packages import Zod's `zod/v4` entry point, which Zod 4 also serves, so they run on Zod 4.
93
- To clear the advisory, override `zod` to `^4.6.6` with your package manager, as the kit does in its
94
- own `pnpm-workspace.yaml`. Drop the override once an AG-UI release accepts Zod 4.
88
+ `@ag-ui/client`. They bring RxJS with them, and take Zod 4 as a peer, which the kit and
89
+ `@xh/hoist` both supply.
95
90
 
96
91
  1. Add the package: `pnpm add @xh/hoist-chat-kit`.
97
92
  2. Add it to `extraIncludePaths` in your app's `rsbuild.config.mjs`, so the build transpiles it:
package/core/README.md CHANGED
@@ -950,8 +950,8 @@ desktop
950
950
  The action for a failure depends on whether a resend is safe. `isChatRetrySafe(message,
951
951
  historyMode)` decides it:
952
952
 
953
- - A failure is retry-safe unless the server's `RUN_ERROR` sets `metadata.retrySafe: false`. The
954
- reply records the flag as `metadata.retrySafe`.
953
+ - A reply's `metadata.retrySafe`, when set, decides: the server's `RUN_ERROR` sets it, or an app
954
+ that rebuilt the reply. Otherwise a failure is retry-safe, but for the rules below.
955
955
  - In server mode, the kit's own `stalled`, `incomplete-stream` and `invalid-stream` errors are
956
956
  not retry-safe, because the server may still be running the turn.
957
957
  - In server mode, a stream that throws, such as on a network reset or a gateway timeout, records
@@ -219,10 +219,10 @@ export function getChatComposerStatus(spec: ChatComposerStatusSpec): ChatCompose
219
219
 
220
220
  /**
221
221
  * True if the turn that ended with this failed reply can be resent without running work twice.
222
- * A failure is retry-safe unless the server's `RUN_ERROR` says otherwise, with
223
- * `metadata.retrySafe: false`. In server mode, the kit's own `stalled`, `incomplete-stream`,
224
- * `invalid-stream` and `connection-lost` errors are not retry-safe either, as the server may still
225
- * be running the turn.
222
+ * `metadata.retrySafe` decides, if set, as by the server's `RUN_ERROR` or by an app that rebuilt
223
+ * the reply. Otherwise a failure is retry-safe, except in server mode for the kit's own `stalled`,
224
+ * `incomplete-stream`, `invalid-stream` and `connection-lost` errors, as the server may still be
225
+ * running the turn.
226
226
  *
227
227
  * @param historyMode - the chat's history mode. Default 'client'.
228
228
  */
@@ -231,7 +231,7 @@ export function isChatRetrySafe(
231
231
  historyMode: ChatHistoryMode = 'client'
232
232
  ): boolean {
233
233
  const {retrySafe, errorCode} = message?.metadata ?? {};
234
- if (retrySafe === false) return false;
234
+ if (retrySafe != null) return retrySafe === true;
235
235
  return !(historyMode === 'server' && KIT_UNSAFE_CODES.includes(errorCode));
236
236
  }
237
237
 
@@ -48,9 +48,9 @@ export interface ChatMessageSpec {
48
48
  /**
49
49
  * Open-ended data about the message. The kit records `elapsedMs`, `endedAt` (epoch millis),
50
50
  * `finishReason`, `stopReason`, `usage`, `runStarted: true` once the backend reports the run
51
- * began, `supersededCount` for the parts of attempts that a retry replaced, and, for a failed
52
- * turn, `errorCode`, `retryAfterSeconds` and `retrySafe` on assistant messages. Apps may add
53
- * their own keys.
51
+ * began or for a reply rebuilt from its history, `supersededCount` for the parts of attempts
52
+ * that a retry replaced, and, for a failed turn, `errorCode`, `retryAfterSeconds` and
53
+ * `retrySafe` on assistant messages. Apps may add their own keys.
54
54
  */
55
55
  metadata?: PlainObject;
56
56
  }
@@ -64,6 +64,14 @@ export interface ChatReplayOptions {
64
64
  * - neither - `aborted` and `metadata.detached`, for a turn still running on the server. The
65
65
  * chat then offers to refresh its status, as after the user left a live reply running.
66
66
  *
67
+ * A reply given `status: 'error'` whose events end in neither gets error code
68
+ * `incomplete-stream`, as a live stream that broke off - unless `opts.metadata` names its own
69
+ * `errorCode`. In server mode it is then not retry-safe, as the backend may have run some of its
70
+ * tools. Pass `metadata: {retrySafe: true}` if a resend is safe. See `isChatRetrySafe()`. A
71
+ * record the decoder rejects sets the decoder's code instead, and drops the app's `retrySafe`. Each
72
+ * reply is marked `metadata.runStarted`, as the backend has its turn, so that a failure shows as
73
+ * a failed reply and never as "Not sent".
74
+ *
67
75
  * Anything a turn leaves open, such as a tool call with no result, is closed as the live chat
68
76
  * would close it, at the time of the turn's last event. A detached turn's open tool calls and
69
77
  * sub-agents stay open, as the server may still finish them. An interrupt that a later run answered
@@ -114,11 +122,24 @@ export function replayChatEvents(
114
122
  ? settleStreamingParts(settleEarlierCalls(message, lastIdx, endedAt), endedAt)
115
123
  : settleOpenParts(message, SETTLE_REASONS[status], status === 'aborted', endedAt);
116
124
 
125
+ // The backend has the turn, so its message was sent - even if it stored no events of it.
117
126
  // A failure's details go with the failure, as for a stopped turn that a backend stored as one.
118
- let replyMetadata: PlainObject =
119
- status === 'error' ? settled.metadata : omit(settled.metadata, ERROR_KEYS);
127
+ let replyMetadata: PlainObject = {
128
+ ...(status === 'error' ? settled.metadata : omit(settled.metadata, ERROR_KEYS)),
129
+ runStarted: true
130
+ };
120
131
  if (decodeError) {
121
- replyMetadata = {...replyMetadata, errorCode: decodeError.code ?? 'invalid-stream'};
132
+ // The kit could not read the stored stream, so its own code decides, as for a live one.
133
+ replyMetadata = {
134
+ ...omit(replyMetadata, 'retrySafe'),
135
+ errorCode: decodeError.code ?? 'invalid-stream'
136
+ };
137
+ } else if (status === 'error' && !isEnded) {
138
+ // A failure whose events do not say how it ended reads as a live stream that broke off.
139
+ replyMetadata = {
140
+ ...replyMetadata,
141
+ errorCode: replyMetadata.errorCode ?? 'incomplete-stream'
142
+ };
122
143
  }
123
144
  // The time the runs took. Waits between them, such as for the user's answers, do not count.
124
145
  if (!isEmpty(times)) {
@@ -674,9 +674,10 @@ Esc stops a reply in progress, as does the composer's Stop button, whose tooltip
674
674
  A chat with `allowRetry` false never offers Try Again, and never retries on its own. See
675
675
  [Hide Edit, Regenerate and Try Again](../../../core/README.md#hide-edit-regenerate-and-try-again).
676
676
 
677
- A failure is retry-safe unless the server's `RUN_ERROR` sets `metadata.retrySafe: false`. In
678
- server mode, the kit's own `stalled`, `incomplete-stream` and `connection-lost` errors are not
679
- retry-safe either, because the server may still be running the turn. Refresh Status shows only
677
+ A reply's `metadata.retrySafe`, when set, decides whether a failure is retry-safe. The server's
678
+ `RUN_ERROR` sets it, or an app that rebuilt the reply. Otherwise a failure is retry-safe, but in
679
+ server mode the kit's own `stalled`, `incomplete-stream`, `invalid-stream` and `connection-lost`
680
+ errors are not, because the server may still be running the turn. Refresh Status shows only
680
681
  when the chat can reload the thread. `ChatThreadsModel` supplies that for its chats. See
681
682
  [Recover from a failed reply](../../../core/README.md#recover-from-a-failed-reply).
682
683
 
@@ -4,14 +4,16 @@ import type {ChatMessage} from '../../../../core';
4
4
 
5
5
  /**
6
6
  * True for a reply that failed before its run started - for example offline, or a failed thread
7
- * create - so that the turn's message was never sent. Such a reply has no parts, no run id from
8
- * the server, and no error code from a run. The user message shows "Not sent" in its place.
7
+ * create - so that the turn's message was never sent. Such a reply has no parts, no mark that its
8
+ * run started, no run id from the server, and no error code from a run. A reply rebuilt from the
9
+ * backend's history carries the mark, as the backend has its turn. The user message shows
10
+ * "Not sent" in its place.
9
11
  * @internal
10
12
  */
11
13
  export function isReplyNotSent(reply: ChatMessage): boolean {
12
14
  if (!reply?.isAssistant || reply.status !== 'error' || !isEmpty(reply.parts)) return false;
13
- const {runId, errorCode} = reply.metadata;
14
- return runId == null && errorCode == null;
15
+ const {runStarted, runId, errorCode} = reply.metadata;
16
+ return !runStarted && runId == null && errorCode == null;
15
17
  }
16
18
 
17
19
  /**
@@ -77,15 +77,17 @@ be repeated once the configuration is fixed.
77
77
  ### Cut a release
78
78
 
79
79
  `develop` always holds the next major version as a snapshot, in the Maven style that all XH
80
- libraries use. After 1.0.0 ships, `package.json` reads `2.0.0-SNAPSHOT`. A release without
81
- breaking changes still goes out as the next minor or patch version, and `develop` stays on the
82
- same snapshot.
80
+ libraries use. Each major release moves `develop` to the major after it. A release without
81
+ breaking changes goes out as the next minor or patch version, and `develop` stays on the same
82
+ snapshot. For example, once 1.0.0 ships, `package.json` reads `2.0.0-SNAPSHOT`. A later 1.1.0
83
+ leaves it there, and 2.0.0 moves it to `3.0.0-SNAPSHOT`.
83
84
 
84
85
  1. Make sure `develop` is green in CI and holds everything the release needs.
85
86
  2. Pick the version. A release with breaking changes is the major version that `develop` holds.
86
87
  Any other release is the next minor or patch from the latest `v*` tag, such as `1.1.0`.
87
88
  3. On `develop`, set the topmost `CHANGELOG.md` heading to the release version and today's date,
88
- as in `## 1.1.0 - 2026-11-20`. Commit and push.
89
+ as in `## 1.1.0 - 2026-11-20`. For a major release, also set the `Released` date in that
90
+ version's upgrade notes. Commit and push.
89
91
  4. Fast-forward `main` to `develop` and push it:
90
92
  ```bash
91
93
  git switch main && git merge --ff-only develop && git push
@@ -95,10 +97,10 @@ same snapshot.
95
97
  gh workflow run deployRelease.yml --ref main -f version=1.1.0 -f is-hotfix=false
96
98
  ```
97
99
  6. Back on `develop`, put a snapshot heading back on top of `CHANGELOG.md`, then push:
98
- - After a major release, bump `package.json` to the next major, such as `3.0.0-SNAPSHOT`, and
99
- add a matching `## 3.0.0-SNAPSHOT - unreleased` heading.
100
- - After a minor or patch release, leave `package.json` as it is, and add back the
101
- `## 2.0.0-SNAPSHOT - unreleased` heading above the new release entry.
100
+ - After a major release, bump `package.json` to the next major `-SNAPSHOT` version, and add a
101
+ matching `## {version} - unreleased` heading.
102
+ - After a minor or patch release, leave `package.json` as it is, and add back the heading for
103
+ the snapshot it holds, above the new release entry.
102
104
 
103
105
  ### Cut a hotfix
104
106
 
@@ -1,6 +1,6 @@
1
1
  # Hoist Chat Kit v2 Upgrade Notes
2
2
 
3
- > **From:** v1.x → v2.0.0 | **Released:** unreleased | **Difficulty:** 🟢 LOW
3
+ > **From:** v1.x → v2.0.0 | **Released:** 2026-11-16 | **Difficulty:** 🟢 LOW
4
4
 
5
5
  ## Overview
6
6
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xh/hoist-chat-kit",
3
- "version": "2.0.0-SNAPSHOT.1793929937227",
3
+ "version": "2.0.0",
4
4
  "description": "Chat with LLMs and agents in Hoist React apps: models, streaming transports, desktop components and generative UI.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -52,34 +52,35 @@
52
52
  "@types/node": "^26.6.6",
53
53
  "@types/react": "^19.3.0",
54
54
  "@types/react-dom": "^19.3.0",
55
- "@vitest/ui": "^5.0.5",
55
+ "@vitest/ui": "^5.1.0",
56
56
  "@xh/eslint-config": "^8.1.0",
57
57
  "@xh/hoist": "^89.3.1",
58
- "@xh/hoist-dev-utils": "^16.1.1",
58
+ "@xh/hoist-dev-utils": "^16.3.0",
59
59
  "ag-grid-community": "~36.2.0",
60
60
  "ag-grid-react": "~36.2.0",
61
- "eslint": "^10.13.0",
61
+ "eslint": "^10.15.0",
62
62
  "eslint-config-prettier": "^10.1.8",
63
- "globals": "^17.13.0",
63
+ "globals": "^17.14.0",
64
64
  "husky": "^9.1.7",
65
65
  "jsdom": "^30.1.3",
66
- "lint-staged": "^17.6.0",
67
- "msw": "^3.0.3",
68
- "prettier": "^3.9.10",
66
+ "lint-staged": "^17.6.1",
67
+ "msw": "^3.0.6",
68
+ "prettier": "^3.10.1",
69
69
  "react": "^19.3.1",
70
70
  "react-dom": "^19.3.1",
71
71
  "stylelint": "^17.16.0",
72
72
  "stylelint-config-recommended-scss": "^17.0.1",
73
73
  "type-fest": "^5.10.0",
74
74
  "typescript": "^7.0.2",
75
- "vitest": "^5.0.5"
75
+ "vitest": "^5.1.0"
76
76
  },
77
77
  "dependencies": {
78
- "@ag-ui/client": "1.0.3",
79
- "@ag-ui/core": "1.0.3",
78
+ "@ag-ui/client": "1.0.4",
79
+ "@ag-ui/core": "1.0.4",
80
80
  "classnames": "^2.5.1",
81
81
  "lodash": "^4.18.1",
82
- "rxjs": "7.8.1"
82
+ "rxjs": "7.8.1",
83
+ "zod": "^4.6.7"
83
84
  },
84
85
  "scripts": {
85
86
  "lint": "pnpm lint:all",
package/threads/README.md CHANGED
@@ -337,6 +337,15 @@ export class AssistantThreadStore implements ChatThreadStore {
337
337
  fails it. With neither, the turn is still running on the server, and the reply loads detached.
338
338
  Pass `status` when the backend records the outcome its own way, such as a turn the user stopped
339
339
  that it stores as a `RUN_ERROR`.
340
+ - **A failed reply** always shows as failed, with its error, never as "Not sent", even with no
341
+ events. The backend has the turn, so its message was sent. If you pass `status: 'error'` and
342
+ the events end in neither `RUN_FINISHED` nor `RUN_ERROR`, the reply gets error code
343
+ `incomplete-stream`, as a live stream that broke off does. In server mode that is not
344
+ retry-safe, since the backend may have run some of the turn's tools. So the chat never offers
345
+ Try Again for it. As for a live reply that broke off, the model reloads the thread once to
346
+ check on it, then offers Refresh Status. Pass `metadata: {retrySafe: true}` if you know a
347
+ resend is safe, or your own `errorCode`. A reply whose events end in `RUN_ERROR` keeps that
348
+ event's code and retry safety.
340
349
  - **A cut stream** should end with a `RUN_ERROR` as it is stored. AG-UI's checks reject a
341
350
  `RUN_FINISHED` while a message or tool call is still open, and a second `RUN_STARTED` or
342
351
  `RUN_FINISHED` for one run. A reply whose events fail the checks loads failed, with what came