@assistant-ui/react 0.11.20 → 0.11.21

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.
Files changed (43) hide show
  1. package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts +1 -1
  2. package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
  3. package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts +1 -0
  4. package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts.map +1 -1
  5. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
  6. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.js +6 -0
  7. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
  8. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts +1 -0
  9. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts.map +1 -1
  10. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.js +1 -0
  11. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.js.map +1 -1
  12. package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts +1 -1
  13. package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +1 -1
  14. package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -1
  15. package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js +1 -0
  16. package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
  17. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  18. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js +1 -3
  19. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
  20. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts +3 -3
  21. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts.map +1 -1
  22. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js.map +1 -1
  23. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts +2 -2
  24. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
  25. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
  26. package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
  27. package/dist/primitives/branchPicker/BranchPickerNext.js +7 -3
  28. package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
  29. package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
  30. package/dist/primitives/branchPicker/BranchPickerPrevious.js +7 -3
  31. package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
  32. package/dist/tests/setup.js +8 -8
  33. package/dist/tests/setup.js.map +1 -1
  34. package/package.json +9 -9
  35. package/src/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.tsx +1 -0
  36. package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.tsx +7 -0
  37. package/src/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.tsx +1 -0
  38. package/src/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.tsx +1 -0
  39. package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +1 -4
  40. package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx +3 -3
  41. package/src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx +2 -1
  42. package/src/primitives/branchPicker/BranchPickerNext.tsx +11 -3
  43. package/src/primitives/branchPicker/BranchPickerPrevious.tsx +11 -3
package/package.json CHANGED
@@ -28,7 +28,7 @@
28
28
  "conversational-ui",
29
29
  "conversational-ai"
30
30
  ],
31
- "version": "0.11.20",
31
+ "version": "0.11.21",
32
32
  "license": "MIT",
33
33
  "type": "module",
34
34
  "exports": {
@@ -61,10 +61,10 @@
61
61
  "@standard-schema/spec": "^1.0.0",
62
62
  "assistant-stream": "^0.2.29",
63
63
  "json-schema": "^0.4.0",
64
- "nanoid": "5.1.5",
64
+ "nanoid": "5.1.6",
65
65
  "react-textarea-autosize": "^8.5.9",
66
- "zod": "^4.0.17",
67
- "zustand": "^5.0.7"
66
+ "zod": "^4.1.11",
67
+ "zustand": "^5.0.8"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "@types/react": "*",
@@ -81,13 +81,13 @@
81
81
  }
82
82
  },
83
83
  "devDependencies": {
84
- "@stryker-mutator/core": "^9.0.1",
85
- "@stryker-mutator/vitest-runner": "^9.0.1",
84
+ "@stryker-mutator/core": "^9.1.1",
85
+ "@stryker-mutator/vitest-runner": "^9.1.1",
86
86
  "@types/json-schema": "^7.0.15",
87
- "@types/node": "^24.3.0",
87
+ "@types/node": "^24.5.2",
88
88
  "eslint": "^9",
89
- "eslint-config-next": "15.4.6",
90
- "tsx": "^4.20.4",
89
+ "eslint-config-next": "15.5.4",
90
+ "tsx": "^4.20.6",
91
91
  "vitest": "^3.2.4",
92
92
  "@assistant-ui/x-buildutils": "0.0.1"
93
93
  },
@@ -14,6 +14,7 @@ import {
14
14
 
15
15
  export type RuntimeCapabilities = {
16
16
  readonly switchToBranch: boolean;
17
+ readonly switchBranchDuringRun: boolean;
17
18
  readonly edit: boolean;
18
19
  readonly reload: boolean;
19
20
  readonly cancel: boolean;
@@ -43,6 +43,7 @@ export class ExternalStoreThreadRuntimeCore
43
43
 
44
44
  private _capabilities: RuntimeCapabilities = {
45
45
  switchToBranch: false,
46
+ switchBranchDuringRun: false,
46
47
  edit: false,
47
48
  reload: false,
48
49
  cancel: false,
@@ -108,6 +109,7 @@ export class ExternalStoreThreadRuntimeCore
108
109
  this.suggestions = store.suggestions ?? EMPTY_ARRAY;
109
110
  this._capabilities = {
110
111
  switchToBranch: this._store.setMessages !== undefined,
112
+ switchBranchDuringRun: false, // External store never supports branch switching during run
111
113
  edit: this._store.onEdit !== undefined,
112
114
  reload: this._store.onReload !== undefined,
113
115
  cancel: this._store.onCancel !== undefined,
@@ -228,6 +230,11 @@ export class ExternalStoreThreadRuntimeCore
228
230
  if (!this._store.setMessages)
229
231
  throw new Error("Runtime does not support switching branches.");
230
232
 
233
+ // Silently ignore branch switches while running
234
+ if (this._store.isRunning) {
235
+ return;
236
+ }
237
+
231
238
  this.repository.switchToBranch(branchId);
232
239
  this.updateMessages(this.repository.getMessages());
233
240
  }
@@ -30,6 +30,7 @@ export class LocalThreadRuntimeCore
30
30
  {
31
31
  public readonly capabilities = {
32
32
  switchToBranch: true,
33
+ switchBranchDuringRun: true,
33
34
  edit: true,
34
35
  reload: true,
35
36
  cancel: true,
@@ -132,6 +132,7 @@ export const EMPTY_THREAD_CORE: ThreadRuntimeCore = {
132
132
 
133
133
  capabilities: {
134
134
  switchToBranch: false,
135
+ switchBranchDuringRun: false,
135
136
  edit: false,
136
137
  reload: false,
137
138
  cancel: false,
@@ -90,10 +90,7 @@ export class RemoteThreadListHookInstanceManager extends BaseSubscribable {
90
90
  throw new Error("Thread not found. This is a bug in assistant-ui.");
91
91
 
92
92
  aliveThread.runtime = threadBinding.getState();
93
-
94
- if (isMounted) {
95
- this._notifySubscribers();
96
- }
93
+ this._notifySubscribers();
97
94
  }, [threadId, threadBinding]);
98
95
 
99
96
  const isMounted = useRef(false);
@@ -16,14 +16,14 @@ import { InMemoryThreadListAdapter } from "./in-memory";
16
16
  import { CloudFileAttachmentAdapter } from "../../adapters";
17
17
 
18
18
  type ThreadData = {
19
- externalId: string;
19
+ externalId: string | undefined;
20
20
  };
21
21
 
22
22
  type CloudThreadListAdapterOptions = {
23
23
  cloud?: AssistantCloud | undefined;
24
24
 
25
- create?(): Promise<ThreadData>;
26
- delete?(threadId: string): Promise<void>;
25
+ create?: (() => Promise<ThreadData>) | undefined;
26
+ delete?: ((threadId: string) => Promise<void>) | undefined;
27
27
  };
28
28
 
29
29
  const baseUrl =
@@ -6,6 +6,7 @@ import { RemoteThreadListThreadListRuntimeCore } from "./RemoteThreadListThreadL
6
6
  import { RemoteThreadListOptions } from "./types";
7
7
  import { AssistantRuntimeImpl } from "../../../internal";
8
8
  import { AssistantRuntimeCore } from "../core/AssistantRuntimeCore";
9
+ import { AssistantRuntime } from "../../runtime/AssistantRuntime";
9
10
 
10
11
  class RemoteThreadListRuntimeCore
11
12
  extends BaseAssistantRuntimeCore
@@ -28,7 +29,7 @@ class RemoteThreadListRuntimeCore
28
29
 
29
30
  export const useRemoteThreadListRuntime = (
30
31
  options: RemoteThreadListOptions,
31
- ) => {
32
+ ): AssistantRuntime => {
32
33
  const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));
33
34
  useEffect(() => {
34
35
  runtime.threads.__internal_setOptions(options);
@@ -10,9 +10,17 @@ import { useAssistantState, useAssistantApi } from "../../context";
10
10
 
11
11
  const useBranchPickerNext = () => {
12
12
  const api = useAssistantApi();
13
- const disabled = useAssistantState(
14
- ({ message }) => message.branchNumber >= message.branchCount,
15
- );
13
+ const disabled = useAssistantState(({ thread, message }) => {
14
+ // Disabled if no next branch
15
+ if (message.branchNumber >= message.branchCount) return true;
16
+
17
+ // Disabled if running and capability not supported
18
+ if (thread.isRunning && !thread.capabilities.switchBranchDuringRun) {
19
+ return true;
20
+ }
21
+
22
+ return false;
23
+ });
16
24
 
17
25
  const callback = useCallback(() => {
18
26
  api.message().switchToBranch({ position: "next" });
@@ -31,9 +31,17 @@ import { useAssistantState, useAssistantApi } from "../../context";
31
31
  */
32
32
  const useBranchPickerPrevious = () => {
33
33
  const api = useAssistantApi();
34
- const disabled = useAssistantState(
35
- ({ message }) => message.branchNumber <= 1,
36
- );
34
+ const disabled = useAssistantState(({ thread, message }) => {
35
+ // Disabled if no previous branch
36
+ if (message.branchNumber <= 1) return true;
37
+
38
+ // Disabled if running and capability not supported
39
+ if (thread.isRunning && !thread.capabilities.switchBranchDuringRun) {
40
+ return true;
41
+ }
42
+
43
+ return false;
44
+ });
37
45
 
38
46
  const callback = useCallback(() => {
39
47
  api.message().switchToBranch({ position: "previous" });