@tambo-ai/react 0.47.0 → 0.48.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.
Files changed (73) hide show
  1. package/dist/context-helpers/current-interactables-context-helper.d.ts +28 -0
  2. package/dist/context-helpers/current-interactables-context-helper.d.ts.map +1 -0
  3. package/dist/context-helpers/current-interactables-context-helper.js +61 -0
  4. package/dist/context-helpers/current-interactables-context-helper.js.map +1 -0
  5. package/dist/context-helpers/index.d.ts +1 -0
  6. package/dist/context-helpers/index.d.ts.map +1 -1
  7. package/dist/context-helpers/index.js +1 -0
  8. package/dist/context-helpers/index.js.map +1 -1
  9. package/dist/index.d.ts +1 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +2 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/mcp/__tests__/tambo-mcp-provider.test.d.ts +2 -0
  14. package/dist/mcp/__tests__/tambo-mcp-provider.test.d.ts.map +1 -0
  15. package/dist/mcp/__tests__/tambo-mcp-provider.test.js +115 -0
  16. package/dist/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -0
  17. package/dist/mcp/tambo-mcp-provider.d.ts +6 -0
  18. package/dist/mcp/tambo-mcp-provider.d.ts.map +1 -1
  19. package/dist/mcp/tambo-mcp-provider.js +25 -2
  20. package/dist/mcp/tambo-mcp-provider.js.map +1 -1
  21. package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts +2 -0
  22. package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map +1 -0
  23. package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js +339 -0
  24. package/dist/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js.map +1 -0
  25. package/dist/providers/__tests__/tambo-interactables-additional-context.test.d.ts +2 -0
  26. package/dist/providers/__tests__/tambo-interactables-additional-context.test.d.ts.map +1 -0
  27. package/dist/providers/__tests__/tambo-interactables-additional-context.test.js +299 -0
  28. package/dist/providers/__tests__/tambo-interactables-additional-context.test.js.map +1 -0
  29. package/dist/providers/tambo-interactable-provider.d.ts +20 -0
  30. package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
  31. package/dist/providers/tambo-interactable-provider.js +32 -2
  32. package/dist/providers/tambo-interactable-provider.js.map +1 -1
  33. package/esm/context-helpers/current-interactables-context-helper.d.ts +28 -0
  34. package/esm/context-helpers/current-interactables-context-helper.d.ts.map +1 -0
  35. package/esm/context-helpers/current-interactables-context-helper.js +56 -0
  36. package/esm/context-helpers/current-interactables-context-helper.js.map +1 -0
  37. package/esm/context-helpers/index.d.ts +1 -0
  38. package/esm/context-helpers/index.d.ts.map +1 -1
  39. package/esm/context-helpers/index.js +1 -0
  40. package/esm/context-helpers/index.js.map +1 -1
  41. package/esm/index.d.ts +1 -1
  42. package/esm/index.d.ts.map +1 -1
  43. package/esm/index.js +1 -1
  44. package/esm/index.js.map +1 -1
  45. package/esm/mcp/__tests__/tambo-mcp-provider.test.d.ts +2 -0
  46. package/esm/mcp/__tests__/tambo-mcp-provider.test.d.ts.map +1 -0
  47. package/esm/mcp/__tests__/tambo-mcp-provider.test.js +113 -0
  48. package/esm/mcp/__tests__/tambo-mcp-provider.test.js.map +1 -0
  49. package/esm/mcp/tambo-mcp-provider.d.ts +6 -0
  50. package/esm/mcp/tambo-mcp-provider.d.ts.map +1 -1
  51. package/esm/mcp/tambo-mcp-provider.js +24 -2
  52. package/esm/mcp/tambo-mcp-provider.js.map +1 -1
  53. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts +2 -0
  54. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.d.ts.map +1 -0
  55. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js +334 -0
  56. package/esm/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.js.map +1 -0
  57. package/esm/providers/__tests__/tambo-interactables-additional-context.test.d.ts +2 -0
  58. package/esm/providers/__tests__/tambo-interactables-additional-context.test.d.ts.map +1 -0
  59. package/esm/providers/__tests__/tambo-interactables-additional-context.test.js +294 -0
  60. package/esm/providers/__tests__/tambo-interactables-additional-context.test.js.map +1 -0
  61. package/esm/providers/tambo-interactable-provider.d.ts +20 -0
  62. package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
  63. package/esm/providers/tambo-interactable-provider.js +30 -1
  64. package/esm/providers/tambo-interactable-provider.js.map +1 -1
  65. package/package.json +8 -8
  66. package/dist/mcp/mcp-tools-client.d.ts +0 -96
  67. package/dist/mcp/mcp-tools-client.d.ts.map +0 -1
  68. package/dist/mcp/mcp-tools-client.js +0 -178
  69. package/dist/mcp/mcp-tools-client.js.map +0 -1
  70. package/esm/mcp/mcp-tools-client.d.ts +0 -96
  71. package/esm/mcp/mcp-tools-client.d.ts.map +0 -1
  72. package/esm/mcp/mcp-tools-client.js +0 -174
  73. package/esm/mcp/mcp-tools-client.js.map +0 -1
@@ -0,0 +1,339 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const react_1 = require("@testing-library/react");
7
+ const react_2 = __importDefault(require("react"));
8
+ const zod_1 = require("zod");
9
+ const tambo_context_helpers_provider_1 = require("../tambo-context-helpers-provider");
10
+ const tambo_interactable_provider_1 = require("../tambo-interactable-provider");
11
+ const tambo_stubs_1 = require("../tambo-stubs");
12
+ const with_tambo_interactable_1 = require("../hoc/with-tambo-interactable");
13
+ function wrapperWithProviders(children) {
14
+ const thread = {
15
+ id: "t-1",
16
+ projectId: "p-1",
17
+ createdAt: new Date().toISOString(),
18
+ updatedAt: new Date().toISOString(),
19
+ messages: [],
20
+ metadata: {},
21
+ };
22
+ return (react_2.default.createElement(tambo_stubs_1.TamboStubProvider, { thread: thread, registerTool: () => { }, registerTools: () => { }, registerComponent: () => { }, addToolAssociation: () => { } },
23
+ react_2.default.createElement(tambo_context_helpers_provider_1.TamboContextHelpersProvider, null, children)));
24
+ }
25
+ describe("Interactables AdditionalContext - Edge Cases & Advanced Scenarios", () => {
26
+ test("handles components without propsSchema gracefully", async () => {
27
+ const SimpleComponent = ({ text }) => (react_2.default.createElement("div", null, text));
28
+ const InteractableSimpleComponent = (0, with_tambo_interactable_1.withTamboInteractable)(SimpleComponent, {
29
+ componentName: "SimpleComponent",
30
+ description: "A component without schema",
31
+ // No propsSchema provided
32
+ });
33
+ let capturedContexts = [];
34
+ const TestComponent = () => {
35
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
36
+ react_2.default.useEffect(() => {
37
+ let mounted = true;
38
+ getAdditionalContext().then((contexts) => {
39
+ if (mounted) {
40
+ capturedContexts = contexts;
41
+ }
42
+ });
43
+ return () => {
44
+ mounted = false;
45
+ };
46
+ }, [getAdditionalContext]);
47
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
48
+ };
49
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
50
+ react_2.default.createElement(InteractableSimpleComponent, { text: "test" }),
51
+ react_2.default.createElement(TestComponent, null))));
52
+ await (0, react_1.waitFor)(() => {
53
+ expect(getByTestId("ready")).toBeInTheDocument();
54
+ const entry = capturedContexts.find((c) => c.name === "interactables");
55
+ expect(entry).toBeDefined();
56
+ const component = entry.context.components[0];
57
+ expect(component.propsSchema).toBe("Not specified");
58
+ });
59
+ });
60
+ test("handles component unmounting and remounting correctly", async () => {
61
+ const Note = ({ title }) => react_2.default.createElement("div", null, title);
62
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
63
+ componentName: "Note",
64
+ description: "A note",
65
+ propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
66
+ });
67
+ let capturedContexts = [];
68
+ const TestComponent = () => {
69
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
70
+ react_2.default.useEffect(() => {
71
+ let mounted = true;
72
+ const interval = setInterval(() => {
73
+ getAdditionalContext().then((contexts) => {
74
+ if (mounted) {
75
+ capturedContexts = contexts;
76
+ }
77
+ });
78
+ }, 50);
79
+ return () => {
80
+ mounted = false;
81
+ clearInterval(interval);
82
+ };
83
+ }, [getAdditionalContext]);
84
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
85
+ };
86
+ const Host = () => {
87
+ const [showNote, setShowNote] = react_2.default.useState(true);
88
+ react_2.default.useEffect(() => {
89
+ // Toggle the note on/off to test unmounting
90
+ const timeout = setTimeout(() => setShowNote(false), 100);
91
+ const timeout2 = setTimeout(() => setShowNote(true), 200);
92
+ return () => {
93
+ clearTimeout(timeout);
94
+ clearTimeout(timeout2);
95
+ };
96
+ }, []);
97
+ return (react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
98
+ showNote && react_2.default.createElement(InteractableNote, { title: "dynamic note" }),
99
+ react_2.default.createElement(TestComponent, null)));
100
+ };
101
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(Host, null)));
102
+ await (0, react_1.waitFor)(() => {
103
+ expect(getByTestId("ready")).toBeInTheDocument();
104
+ }, { timeout: 1000 });
105
+ // Eventually should show the note again
106
+ await (0, react_1.waitFor)(() => {
107
+ const entry = capturedContexts.find((c) => c.name === "interactables");
108
+ expect(entry?.context?.components).toHaveLength(1);
109
+ }, { timeout: 1000 });
110
+ });
111
+ test("context helper updates when props change from parent", async () => {
112
+ const Counter = ({ count, label = "Count", }) => (react_2.default.createElement("div", null,
113
+ label,
114
+ ": ",
115
+ count));
116
+ const InteractableCounter = (0, with_tambo_interactable_1.withTamboInteractable)(Counter, {
117
+ componentName: "Counter",
118
+ description: "A counter component",
119
+ propsSchema: zod_1.z.object({
120
+ count: zod_1.z.number(),
121
+ label: zod_1.z.string().optional(),
122
+ }),
123
+ });
124
+ let capturedContexts = [];
125
+ const TestComponent = () => {
126
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
127
+ react_2.default.useEffect(() => {
128
+ let mounted = true;
129
+ const interval = setInterval(() => {
130
+ getAdditionalContext().then((contexts) => {
131
+ if (mounted) {
132
+ capturedContexts = contexts;
133
+ }
134
+ });
135
+ }, 50);
136
+ return () => {
137
+ mounted = false;
138
+ clearInterval(interval);
139
+ };
140
+ }, [getAdditionalContext]);
141
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
142
+ };
143
+ const Host = () => {
144
+ const [count, setCount] = react_2.default.useState(0);
145
+ const [label, setLabel] = react_2.default.useState("Items");
146
+ react_2.default.useEffect(() => {
147
+ const timeout1 = setTimeout(() => setCount(5), 100);
148
+ const timeout2 = setTimeout(() => setLabel("Updated Items"), 200);
149
+ return () => {
150
+ clearTimeout(timeout1);
151
+ clearTimeout(timeout2);
152
+ };
153
+ }, []);
154
+ return (react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
155
+ react_2.default.createElement(InteractableCounter, { count: count, label: label }),
156
+ react_2.default.createElement(TestComponent, null)));
157
+ };
158
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(Host, null)));
159
+ await (0, react_1.waitFor)(() => {
160
+ expect(getByTestId("ready")).toBeInTheDocument();
161
+ });
162
+ // Wait for updates to propagate
163
+ await (0, react_1.waitFor)(() => {
164
+ const entry = capturedContexts.find((c) => c.name === "interactables");
165
+ if (entry?.context?.components?.[0]) {
166
+ const props = entry.context.components[0].props;
167
+ expect(props.count).toBe(5);
168
+ expect(props.label).toBe("Updated Items");
169
+ }
170
+ }, { timeout: 1000 });
171
+ });
172
+ test("multiple providers with nested context helpers work correctly", async () => {
173
+ const Note = ({ title }) => react_2.default.createElement("div", null, title);
174
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
175
+ componentName: "Note",
176
+ description: "A note",
177
+ propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
178
+ });
179
+ let outerContexts = [];
180
+ let innerContexts = [];
181
+ const OuterTestComponent = () => {
182
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
183
+ react_2.default.useEffect(() => {
184
+ let mounted = true;
185
+ getAdditionalContext().then((contexts) => {
186
+ if (mounted) {
187
+ outerContexts = contexts;
188
+ }
189
+ });
190
+ return () => {
191
+ mounted = false;
192
+ };
193
+ }, [getAdditionalContext]);
194
+ return react_2.default.createElement("div", { "data-testid": "outer-ready" }, "outer ready");
195
+ };
196
+ const InnerTestComponent = () => {
197
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
198
+ react_2.default.useEffect(() => {
199
+ let mounted = true;
200
+ getAdditionalContext().then((contexts) => {
201
+ if (mounted) {
202
+ innerContexts = contexts;
203
+ }
204
+ });
205
+ return () => {
206
+ mounted = false;
207
+ };
208
+ }, [getAdditionalContext]);
209
+ return react_2.default.createElement("div", { "data-testid": "inner-ready" }, "inner ready");
210
+ };
211
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
212
+ react_2.default.createElement(InteractableNote, { title: "outer note" }),
213
+ react_2.default.createElement(OuterTestComponent, null),
214
+ react_2.default.createElement(tambo_context_helpers_provider_1.TamboContextHelpersProvider, { contextHelpers: {
215
+ customContext: () => ({ custom: "inner" }),
216
+ } },
217
+ react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
218
+ react_2.default.createElement(InteractableNote, { title: "inner note" }),
219
+ react_2.default.createElement(InnerTestComponent, null))))));
220
+ await (0, react_1.waitFor)(() => {
221
+ expect(getByTestId("outer-ready")).toBeInTheDocument();
222
+ expect(getByTestId("inner-ready")).toBeInTheDocument();
223
+ });
224
+ await (0, react_1.waitFor)(() => {
225
+ // Outer context should have outer note
226
+ const outerEntry = outerContexts.find((c) => c.name === "interactables");
227
+ expect(outerEntry?.context?.components).toHaveLength(1);
228
+ expect(outerEntry?.context?.components[0]?.props?.title).toBe("outer note");
229
+ // Inner context should have inner note and custom context
230
+ const innerEntry = innerContexts.find((c) => c.name === "interactables");
231
+ expect(innerEntry?.context?.components).toHaveLength(1);
232
+ expect(innerEntry?.context?.components[0]?.props?.title).toBe("inner note");
233
+ const customEntry = innerContexts.find((c) => c.name === "customContext");
234
+ expect(customEntry?.context).toEqual({ custom: "inner" });
235
+ });
236
+ });
237
+ test("provider cleanup removes helper when last provider unmounts", async () => {
238
+ const Note = ({ title }) => react_2.default.createElement("div", null, title);
239
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
240
+ componentName: "Note",
241
+ description: "A note",
242
+ propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
243
+ });
244
+ let capturedContexts = [];
245
+ const TestComponent = () => {
246
+ const { getAdditionalContext } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
247
+ react_2.default.useEffect(() => {
248
+ let mounted = true;
249
+ const interval = setInterval(() => {
250
+ getAdditionalContext().then((contexts) => {
251
+ if (mounted) {
252
+ capturedContexts = contexts;
253
+ }
254
+ });
255
+ }, 50);
256
+ return () => {
257
+ mounted = false;
258
+ clearInterval(interval);
259
+ };
260
+ }, [getAdditionalContext]);
261
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
262
+ };
263
+ const Host = () => {
264
+ const [showProvider, setShowProvider] = react_2.default.useState(true);
265
+ react_2.default.useEffect(() => {
266
+ const timeout = setTimeout(() => setShowProvider(false), 200);
267
+ return () => clearTimeout(timeout);
268
+ }, []);
269
+ return (react_2.default.createElement(react_2.default.Fragment, null,
270
+ showProvider && (react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
271
+ react_2.default.createElement(InteractableNote, { title: "will disappear" }))),
272
+ react_2.default.createElement(TestComponent, null)));
273
+ };
274
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(Host, null)));
275
+ // Initially should have the context
276
+ await (0, react_1.waitFor)(() => {
277
+ expect(getByTestId("ready")).toBeInTheDocument();
278
+ const entry = capturedContexts.find((c) => c.name === "interactables");
279
+ expect(entry).toBeDefined();
280
+ });
281
+ // After provider unmounts, context should be gone
282
+ await (0, react_1.waitFor)(() => {
283
+ const entry = capturedContexts.find((c) => c.name === "interactables");
284
+ expect(entry).toBeUndefined();
285
+ }, { timeout: 1000 });
286
+ });
287
+ test("helper error handling doesn't crash the system", async () => {
288
+ const Note = ({ title }) => react_2.default.createElement("div", null, title);
289
+ const InteractableNote = (0, with_tambo_interactable_1.withTamboInteractable)(Note, {
290
+ componentName: "Note",
291
+ description: "A note",
292
+ propsSchema: zod_1.z.object({ title: zod_1.z.string() }),
293
+ });
294
+ // Mock console.error to capture error logs
295
+ const consoleSpy = jest
296
+ .spyOn(console, "error")
297
+ .mockImplementation(() => { });
298
+ let capturedContexts = [];
299
+ const TestComponent = () => {
300
+ const { getAdditionalContext, addContextHelper } = (0, tambo_context_helpers_provider_1.useTamboContextHelpers)();
301
+ react_2.default.useEffect(() => {
302
+ // Add a helper that throws an error
303
+ addContextHelper("errorHelper", () => {
304
+ throw new Error("Test error in helper");
305
+ });
306
+ }, [addContextHelper]);
307
+ react_2.default.useEffect(() => {
308
+ let mounted = true;
309
+ getAdditionalContext()
310
+ .then((contexts) => {
311
+ if (mounted) {
312
+ capturedContexts = contexts;
313
+ }
314
+ })
315
+ .catch(() => {
316
+ // Should not reach here - errors should be handled gracefully
317
+ });
318
+ return () => {
319
+ mounted = false;
320
+ };
321
+ }, [getAdditionalContext]);
322
+ return react_2.default.createElement("div", { "data-testid": "ready" }, "ready");
323
+ };
324
+ const { getByTestId } = (0, react_1.render)(wrapperWithProviders(react_2.default.createElement(tambo_interactable_provider_1.TamboInteractableProvider, null,
325
+ react_2.default.createElement(InteractableNote, { title: "test" }),
326
+ react_2.default.createElement(TestComponent, null))));
327
+ await (0, react_1.waitFor)(() => {
328
+ expect(getByTestId("ready")).toBeInTheDocument();
329
+ // Should still have the interactables context despite the error
330
+ const entry = capturedContexts.find((c) => c.name === "interactables");
331
+ expect(entry).toBeDefined();
332
+ // Error helper should not be present (filtered out)
333
+ const errorEntry = capturedContexts.find((c) => c.name === "errorHelper");
334
+ expect(errorEntry).toBeUndefined();
335
+ });
336
+ consoleSpy.mockRestore();
337
+ });
338
+ });
339
+ //# sourceMappingURL=tambo-interactables-additional-context-edge-cases.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-interactables-additional-context-edge-cases.test.js","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-interactables-additional-context-edge-cases.test.tsx"],"names":[],"mappings":";;;;;AAAA,kDAAyD;AACzD,kDAA0B;AAC1B,6BAAwB;AACxB,sFAG2C;AAC3C,gFAA2E;AAC3E,gDAAmD;AACnD,4EAAuE;AAEvE,SAAS,oBAAoB,CAAC,QAAyB;IACrD,MAAM,MAAM,GAAG;QACb,EAAE,EAAE,KAAK;QACT,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,SAAS,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;QACnC,QAAQ,EAAE,EAAE;QACZ,QAAQ,EAAE,EAAE;KACN,CAAC;IAET,OAAO,CACL,8BAAC,+BAAiB,IAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,GAAG,EAAE,GAAE,CAAC,EACtB,aAAa,EAAE,GAAG,EAAE,GAAE,CAAC,EACvB,iBAAiB,EAAE,GAAG,EAAE,GAAE,CAAC,EAC3B,kBAAkB,EAAE,GAAG,EAAE,GAAE,CAAC;QAE5B,8BAAC,4DAA2B,QAAE,QAAQ,CAA+B,CACnD,CACrB,CAAC;AACJ,CAAC;AAED,QAAQ,CAAC,mEAAmE,EAAE,GAAG,EAAE;IACjF,IAAI,CAAC,mDAAmD,EAAE,KAAK,IAAI,EAAE;QACnE,MAAM,eAAe,GAA+B,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAChE,2CAAM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AoB,CAAC,CAAC,CAAC;YAE3B,OAAO,sDAAiB,OAAO,YAAY,CAAC;QAC9C,CAAC,CAAC;QAEF,MAAM,EAAE,WAAW,EAAE,GAAG,IAAA,cAAM,EAC5B,oBAAoB,CAClB,8BAAC,uDAAyB;YACxB,8BAAC,gBAAgB,IAAC,KAAK,EAAC,MAAM,GAAG;YACjC,8BAAC,aAAa,OAAG,CACS,CAC7B,CACF,CAAC;QAEF,MAAM,IAAA,eAAO,EAAC,GAAG,EAAE;YACjB,MAAM,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;YACjD,gEAAgE;YAChE,MAAM,KAAK,GAAG,gBAAgB,CAAC,IAAI,CACjC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,eAAe,CACvC,CAAC;YACF,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC;YAE5B,oDAAoD;YACpD,MAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI,CACtC,CAAC,CAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CACrC,CAAC;YACF,MAAM,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;QACrC,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,WAAW,EAAE,CAAC;IAC3B,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod\";\nimport {\n useTamboContextHelpers,\n TamboContextHelpersProvider,\n} from \"../tambo-context-helpers-provider\";\nimport { TamboInteractableProvider } from \"../tambo-interactable-provider\";\nimport { TamboStubProvider } from \"../tambo-stubs\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\n\nfunction wrapperWithProviders(children: React.ReactNode) {\n const thread = {\n id: \"t-1\",\n projectId: \"p-1\",\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n messages: [],\n metadata: {},\n } as any;\n\n return (\n <TamboStubProvider\n thread={thread}\n registerTool={() => {}}\n registerTools={() => {}}\n registerComponent={() => {}}\n addToolAssociation={() => {}}\n >\n <TamboContextHelpersProvider>{children}</TamboContextHelpersProvider>\n </TamboStubProvider>\n );\n}\n\ndescribe(\"Interactables AdditionalContext - Edge Cases & Advanced Scenarios\", () => {\n test(\"handles components without propsSchema gracefully\", async () => {\n const SimpleComponent: React.FC<{ text: string }> = ({ text }) => (\n <div>{text}</div>\n );\n\n const InteractableSimpleComponent = withTamboInteractable(SimpleComponent, {\n componentName: \"SimpleComponent\",\n description: \"A component without schema\",\n // No propsSchema provided\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableSimpleComponent text=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n const component = entry!.context.components[0];\n expect(component.propsSchema).toBe(\"Not specified\");\n });\n });\n\n test(\"handles component unmounting and remounting correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showNote, setShowNote] = React.useState(true);\n\n React.useEffect(() => {\n // Toggle the note on/off to test unmounting\n const timeout = setTimeout(() => setShowNote(false), 100);\n const timeout2 = setTimeout(() => setShowNote(true), 200);\n return () => {\n clearTimeout(timeout);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n {showNote && <InteractableNote title=\"dynamic note\" />}\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(\n () => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n },\n { timeout: 1000 },\n );\n\n // Eventually should show the note again\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry?.context?.components).toHaveLength(1);\n },\n { timeout: 1000 },\n );\n });\n\n test(\"context helper updates when props change from parent\", async () => {\n const Counter: React.FC<{ count: number; label?: string }> = ({\n count,\n label = \"Count\",\n }) => (\n <div>\n {label}: {count}\n </div>\n );\n\n const InteractableCounter = withTamboInteractable(Counter, {\n componentName: \"Counter\",\n description: \"A counter component\",\n propsSchema: z.object({\n count: z.number(),\n label: z.string().optional(),\n }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [count, setCount] = React.useState(0);\n const [label, setLabel] = React.useState(\"Items\");\n\n React.useEffect(() => {\n const timeout1 = setTimeout(() => setCount(5), 100);\n const timeout2 = setTimeout(() => setLabel(\"Updated Items\"), 200);\n return () => {\n clearTimeout(timeout1);\n clearTimeout(timeout2);\n };\n }, []);\n\n return (\n <TamboInteractableProvider>\n <InteractableCounter count={count} label={label} />\n <TestComponent />\n </TamboInteractableProvider>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n });\n\n // Wait for updates to propagate\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n if (entry?.context?.components?.[0]) {\n const props = entry.context.components[0].props;\n expect(props.count).toBe(5);\n expect(props.label).toBe(\"Updated Items\");\n }\n },\n { timeout: 1000 },\n );\n });\n\n test(\"multiple providers with nested context helpers work correctly\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let outerContexts: any[] = [];\n let innerContexts: any[] = [];\n\n const OuterTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n outerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"outer-ready\">outer ready</div>;\n };\n\n const InnerTestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n innerContexts = contexts;\n }\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"inner-ready\">inner ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"outer note\" />\n <OuterTestComponent />\n <TamboContextHelpersProvider\n contextHelpers={{\n customContext: () => ({ custom: \"inner\" }),\n }}\n >\n <TamboInteractableProvider>\n <InteractableNote title=\"inner note\" />\n <InnerTestComponent />\n </TamboInteractableProvider>\n </TamboContextHelpersProvider>\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"outer-ready\")).toBeInTheDocument();\n expect(getByTestId(\"inner-ready\")).toBeInTheDocument();\n });\n\n await waitFor(() => {\n // Outer context should have outer note\n const outerEntry = outerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(outerEntry?.context?.components).toHaveLength(1);\n expect(outerEntry?.context?.components[0]?.props?.title).toBe(\n \"outer note\",\n );\n\n // Inner context should have inner note and custom context\n const innerEntry = innerContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(innerEntry?.context?.components).toHaveLength(1);\n expect(innerEntry?.context?.components[0]?.props?.title).toBe(\n \"inner note\",\n );\n\n const customEntry = innerContexts.find(\n (c: any) => c.name === \"customContext\",\n );\n expect(customEntry?.context).toEqual({ custom: \"inner\" });\n });\n });\n\n test(\"provider cleanup removes helper when last provider unmounts\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext } = useTamboContextHelpers();\n\n React.useEffect(() => {\n let mounted = true;\n const interval = setInterval(() => {\n getAdditionalContext().then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n });\n }, 50);\n return () => {\n mounted = false;\n clearInterval(interval);\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const Host = () => {\n const [showProvider, setShowProvider] = React.useState(true);\n\n React.useEffect(() => {\n const timeout = setTimeout(() => setShowProvider(false), 200);\n return () => clearTimeout(timeout);\n }, []);\n\n return (\n <>\n {showProvider && (\n <TamboInteractableProvider>\n <InteractableNote title=\"will disappear\" />\n </TamboInteractableProvider>\n )}\n <TestComponent />\n </>\n );\n };\n\n const { getByTestId } = render(wrapperWithProviders(<Host />));\n\n // Initially should have the context\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n });\n\n // After provider unmounts, context should be gone\n await waitFor(\n () => {\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeUndefined();\n },\n { timeout: 1000 },\n );\n });\n\n test(\"helper error handling doesn't crash the system\", async () => {\n const Note: React.FC<{ title: string }> = ({ title }) => <div>{title}</div>;\n const InteractableNote = withTamboInteractable(Note, {\n componentName: \"Note\",\n description: \"A note\",\n propsSchema: z.object({ title: z.string() }),\n });\n\n // Mock console.error to capture error logs\n const consoleSpy = jest\n .spyOn(console, \"error\")\n .mockImplementation(() => {});\n\n let capturedContexts: any[] = [];\n const TestComponent = () => {\n const { getAdditionalContext, addContextHelper } =\n useTamboContextHelpers();\n\n React.useEffect(() => {\n // Add a helper that throws an error\n addContextHelper(\"errorHelper\", () => {\n throw new Error(\"Test error in helper\");\n });\n }, [addContextHelper]);\n\n React.useEffect(() => {\n let mounted = true;\n getAdditionalContext()\n .then((contexts) => {\n if (mounted) {\n capturedContexts = contexts;\n }\n })\n .catch(() => {\n // Should not reach here - errors should be handled gracefully\n });\n return () => {\n mounted = false;\n };\n }, [getAdditionalContext]);\n\n return <div data-testid=\"ready\">ready</div>;\n };\n\n const { getByTestId } = render(\n wrapperWithProviders(\n <TamboInteractableProvider>\n <InteractableNote title=\"test\" />\n <TestComponent />\n </TamboInteractableProvider>,\n ),\n );\n\n await waitFor(() => {\n expect(getByTestId(\"ready\")).toBeInTheDocument();\n // Should still have the interactables context despite the error\n const entry = capturedContexts.find(\n (c: any) => c.name === \"interactables\",\n );\n expect(entry).toBeDefined();\n\n // Error helper should not be present (filtered out)\n const errorEntry = capturedContexts.find(\n (c: any) => c.name === \"errorHelper\",\n );\n expect(errorEntry).toBeUndefined();\n });\n\n consoleSpy.mockRestore();\n });\n});\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=tambo-interactables-additional-context.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tambo-interactables-additional-context.test.d.ts","sourceRoot":"","sources":["../../../src/providers/__tests__/tambo-interactables-additional-context.test.tsx"],"names":[],"mappings":""}