@tambo-ai/react 0.66.0 → 0.66.2
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/dist/hooks/use-current-message.d.ts +2 -0
- package/dist/hooks/use-current-message.d.ts.map +1 -1
- package/dist/hooks/use-current-message.js +1 -0
- package/dist/hooks/use-current-message.js.map +1 -1
- package/dist/hooks/use-current-message.test.js +5 -0
- package/dist/hooks/use-current-message.test.js.map +1 -1
- package/dist/model/component-metadata.d.ts +2 -2
- package/dist/model/component-metadata.d.ts.map +1 -1
- package/dist/model/component-metadata.js.map +1 -1
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js +87 -87
- package/dist/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/dist/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/dist/providers/tambo-interactable-provider.js +46 -40
- package/dist/providers/tambo-interactable-provider.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js +8 -8
- package/dist/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/dist/providers/tambo-interactables-additional-context.test.js +10 -10
- package/dist/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/dist/providers/tambo-registry-provider.test.js +28 -18
- package/dist/providers/tambo-registry-provider.test.js.map +1 -1
- package/dist/providers/tambo-registry-schema-compat.test.js +57 -28
- package/dist/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/dist/providers/tambo-thread-provider.test.js +21 -19
- package/dist/providers/tambo-thread-provider.test.js.map +1 -1
- package/dist/schema/alias.d.ts +3 -0
- package/dist/schema/alias.d.ts.map +1 -0
- package/dist/schema/alias.js +6 -0
- package/dist/schema/alias.js.map +1 -0
- package/dist/schema/json-schema.js +29 -29
- package/dist/schema/json-schema.js.map +1 -1
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/schema/schema.js +27 -19
- package/dist/schema/schema.js.map +1 -1
- package/dist/schema/schema.test.js +291 -3
- package/dist/schema/schema.test.js.map +1 -1
- package/dist/schema/standard-schema.js +8 -8
- package/dist/schema/standard-schema.js.map +1 -1
- package/dist/schema/validate.test.js +31 -31
- package/dist/schema/validate.test.js.map +1 -1
- package/dist/schema/zod.d.ts +5 -5
- package/dist/schema/zod.d.ts.map +1 -1
- package/dist/schema/zod.js +45 -32
- package/dist/schema/zod.js.map +1 -1
- package/dist/util/registry-validators.d.ts.map +1 -1
- package/dist/util/registry-validators.js +40 -0
- package/dist/util/registry-validators.js.map +1 -1
- package/dist/util/registry-validators.test.js +69 -0
- package/dist/util/registry-validators.test.js.map +1 -1
- package/dist/util/registry.d.ts +1 -5
- package/dist/util/registry.d.ts.map +1 -1
- package/dist/util/registry.js +1 -5
- package/dist/util/registry.js.map +1 -1
- package/dist/util/registry.test.js +80 -67
- package/dist/util/registry.test.js.map +1 -1
- package/esm/hooks/use-current-message.d.ts +2 -0
- package/esm/hooks/use-current-message.d.ts.map +1 -1
- package/esm/hooks/use-current-message.js +1 -0
- package/esm/hooks/use-current-message.js.map +1 -1
- package/esm/hooks/use-current-message.test.js +5 -0
- package/esm/hooks/use-current-message.test.js.map +1 -1
- package/esm/model/component-metadata.d.ts +2 -2
- package/esm/model/component-metadata.d.ts.map +1 -1
- package/esm/model/component-metadata.js.map +1 -1
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js +1 -1
- package/esm/providers/tambo-interactable-provider-partial-updates.test.js.map +1 -1
- package/esm/providers/tambo-interactable-provider.d.ts.map +1 -1
- package/esm/providers/tambo-interactable-provider.js +17 -11
- package/esm/providers/tambo-interactable-provider.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js +1 -1
- package/esm/providers/tambo-interactables-additional-context-edge-cases.test.js.map +1 -1
- package/esm/providers/tambo-interactables-additional-context.test.js +1 -1
- package/esm/providers/tambo-interactables-additional-context.test.js.map +1 -1
- package/esm/providers/tambo-registry-provider.test.js +16 -6
- package/esm/providers/tambo-registry-provider.test.js.map +1 -1
- package/esm/providers/tambo-registry-schema-compat.test.js +57 -28
- package/esm/providers/tambo-registry-schema-compat.test.js.map +1 -1
- package/esm/providers/tambo-thread-provider.test.js +8 -6
- package/esm/providers/tambo-thread-provider.test.js.map +1 -1
- package/esm/schema/alias.d.ts +3 -0
- package/esm/schema/alias.d.ts.map +1 -0
- package/esm/schema/alias.js +13 -0
- package/esm/schema/alias.js.map +1 -0
- package/esm/schema/json-schema.js +1 -1
- package/esm/schema/json-schema.js.map +1 -1
- package/esm/schema/schema.d.ts.map +1 -1
- package/esm/schema/schema.js +27 -19
- package/esm/schema/schema.js.map +1 -1
- package/esm/schema/schema.test.js +258 -3
- package/esm/schema/schema.test.js.map +1 -1
- package/esm/schema/standard-schema.js +1 -1
- package/esm/schema/standard-schema.js.map +1 -1
- package/esm/schema/validate.test.js +1 -1
- package/esm/schema/validate.test.js.map +1 -1
- package/esm/schema/zod.d.ts +5 -5
- package/esm/schema/zod.d.ts.map +1 -1
- package/esm/schema/zod.js +45 -32
- package/esm/schema/zod.js.map +1 -1
- package/esm/util/registry-validators.d.ts.map +1 -1
- package/esm/util/registry-validators.js +40 -0
- package/esm/util/registry-validators.js.map +1 -1
- package/esm/util/registry-validators.test.js +69 -0
- package/esm/util/registry-validators.test.js.map +1 -1
- package/esm/util/registry.d.ts +1 -5
- package/esm/util/registry.d.ts.map +1 -1
- package/esm/util/registry.js +1 -5
- package/esm/util/registry.js.map +1 -1
- package/esm/util/registry.test.js +80 -67
- package/esm/util/registry.test.js.map +1 -1
- package/package.json +1 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-interactable-provider-partial-updates.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider-partial-updates.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAErC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;oBACN,4DAA4D;oBAC5D,QAAQ,EAAE;wBACR,qEAAqE;wBACrE,YAAY,EAAE;4BACZ,IAAI,EAAE,IAAI,EAAE,UAAU;4BACtB,8CAA8C;yBAC/C;qBACF;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zodInternalAlias\";\nimport { TamboInteractableComponent } from \"../model/tambo-interactable\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\n\n// Mock the context helpers\nconst mockAddContextHelper = jest.fn();\nconst mockRemoveContextHelper = jest.fn();\n\njest.mock(\"./tambo-context-helpers-provider\", () => ({\n TamboContextHelpersProvider: ({\n children,\n }: {\n children: React.ReactNode;\n }) => <>{children}</>,\n useTamboContextHelpers: () => ({\n addContextHelper: mockAddContextHelper,\n removeContextHelper: mockRemoveContextHelper,\n }),\n}));\n\n// Mock the component provider\nconst mockRegisterTool = jest.fn();\n\njest.mock(\"./tambo-component-provider\", () => ({\n useTamboComponent: () => ({\n registerTool: mockRegisterTool,\n }),\n}));\n\n// Mock the context helper creation\njest.mock(\"../context-helpers/current-interactables-context-helper\", () => ({\n createInteractablesContextHelper: () =>\n jest.fn(() => ({\n name: \"interactables\",\n context: {\n description: \"Test interactables context\",\n components: [],\n },\n })),\n}));\n\ndescribe(\"updateInteractableComponentProps - Partial Updates\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n describe(\"Partial Updates Functionality\", () => {\n it(\"should apply partial updates to existing props\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 0,\n active: true,\n metadata: { type: \"test\", version: \"1.0\" },\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n active: z.boolean(),\n metadata: z.object({\n type: z.string(),\n version: z.string(),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Verify initial state\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n count: 0,\n active: true,\n metadata: { type: \"test\", version: \"1.0\" },\n });\n\n // Apply partial update - only change count\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n {\n count: 5,\n },\n );\n });\n\n expect(updateResult).toBe(\"Updated successfully\");\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\", // unchanged\n count: 5, // updated\n active: true, // unchanged\n metadata: { type: \"test\", version: \"1.0\" }, // unchanged\n });\n });\n\n it(\"should apply multiple partial updates in sequence\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 0,\n active: true,\n description: \"Original description\",\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n active: z.boolean(),\n description: z.string(),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // First partial update - change title and count\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n title: \"Updated Title\",\n count: 10,\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Updated Title\",\n count: 10,\n active: true,\n description: \"Original description\",\n });\n\n // Second partial update - change active and description\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n active: false,\n description: \"Updated description\",\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Updated Title\", // from previous update\n count: 10, // from previous update\n active: false, // new update\n description: \"Updated description\", // new update\n });\n });\n\n it(\"should handle nested object partial updates (shallow merge behavior)\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n config: {\n theme: \"light\",\n language: \"en\",\n features: {\n notifications: true,\n analytics: false,\n },\n },\n },\n propsSchema: z.object({\n title: z.string(),\n config: z.object({\n theme: z.string(),\n language: z.string(),\n features: z.object({\n notifications: z.boolean(),\n analytics: z.boolean(),\n }),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Partial update - replace entire config object (shallow merge behavior)\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n config: {\n theme: \"dark\",\n // Note: language and features are not provided, so they will be undefined\n // This demonstrates the shallow merge behavior\n },\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n config: {\n theme: \"dark\", // updated\n // language and features are now undefined due to shallow merge\n },\n });\n });\n\n it(\"should handle array partial updates\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n items: [\"item1\", \"item2\", \"item3\"],\n tags: [\"tag1\", \"tag2\"],\n },\n propsSchema: z.object({\n title: z.string(),\n items: z.array(z.string()),\n tags: z.array(z.string()),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Partial update - only change items array\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n items: [\"newItem1\", \"newItem2\"],\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\", // unchanged\n items: [\"newItem1\", \"newItem2\"], // updated\n tags: [\"tag1\", \"tag2\"], // unchanged\n });\n });\n\n it(\"should handle null and undefined values in partial updates\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 5,\n description: \"Original description\",\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n description: z.string(),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Partial update with null value\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n description: null as any,\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n count: 5,\n description: null,\n });\n\n // Partial update with undefined value\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n count: undefined as any,\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n count: undefined,\n description: null,\n });\n });\n });\n\n describe(\"Error Handling\", () => {\n it(\"should return error for non-existent component\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n \"non-existent\",\n {\n title: \"New Title\",\n },\n );\n });\n\n expect(updateResult).toBe(\"Updated successfully\");\n });\n\n it(\"should throw error when component name contains spaces\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const invalidComponent: Omit<\n TamboInteractableComponent,\n \"id\" | \"createdAt\"\n > = {\n name: \"Invalid Component Name\", // Contains spaces\n description: \"A component with spaces in name\",\n component: () => <div>Invalid</div>,\n props: { title: \"Test\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n expect(() => {\n act(() => {\n result.current.addInteractableComponent(invalidComponent);\n });\n }).toThrow(\n 'component \"Invalid Component Name\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n\n it(\"should return warning for empty props object\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Original Title\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n {},\n );\n });\n\n expect(updateResult).toBe(\n `Warning: No props provided for component with ID ${componentId}.`,\n );\n });\n\n it(\"should return warning for null props\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Original Title\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n null as any,\n );\n });\n\n expect(updateResult).toBe(\n `Warning: No props provided for component with ID ${componentId}.`,\n );\n });\n\n it(\"should return warning for undefined props\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Original Title\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n undefined as any,\n );\n });\n\n expect(updateResult).toBe(\n `Warning: No props provided for component with ID ${componentId}.`,\n );\n });\n });\n\n describe(\"Performance and Efficiency\", () => {\n it(\"should only update changed properties without affecting others\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 0,\n active: true,\n metadata: { type: \"test\", version: \"1.0\" },\n items: [\"item1\", \"item2\"],\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n active: z.boolean(),\n metadata: z.object({\n type: z.string(),\n version: z.string(),\n }),\n items: z.array(z.string()),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const originalProps = result.current.interactableComponents[0].props;\n const originalMetadata = originalProps.metadata;\n const originalItems = originalProps.items;\n\n // Apply minimal partial update - only change count\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n count: 1,\n });\n });\n\n const updatedProps = result.current.interactableComponents[0].props;\n\n // Verify that only count changed\n expect(updatedProps.count).toBe(1);\n expect(updatedProps.title).toBe(\"Original Title\");\n expect(updatedProps.active).toBe(true);\n\n // Verify that nested objects are preserved (same reference for efficiency)\n expect(updatedProps.metadata).toBe(originalMetadata);\n expect(updatedProps.items).toBe(originalItems);\n });\n\n it(\"should handle large objects efficiently with partial updates\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n // Create a component with a large initial state\n const largeData = {\n users: Array.from({ length: 1000 }, (_, i) => ({\n id: i,\n name: `User ${i}`,\n })),\n settings: {\n theme: \"light\",\n language: \"en\",\n notifications: true,\n privacy: {\n shareData: false,\n analytics: true,\n marketing: false,\n },\n },\n metadata: {\n version: \"1.0.0\",\n build: \"12345\",\n timestamp: Date.now(),\n },\n };\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component with large data\",\n component: () => <div>Test</div>,\n props: largeData,\n propsSchema: z.object({\n users: z.array(\n z.object({\n id: z.number(),\n name: z.string(),\n }),\n ),\n settings: z.object({\n theme: z.string(),\n language: z.string(),\n notifications: z.boolean(),\n privacy: z.object({\n shareData: z.boolean(),\n analytics: z.boolean(),\n marketing: z.boolean(),\n }),\n }),\n metadata: z.object({\n version: z.string(),\n build: z.string(),\n timestamp: z.number(),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const originalProps = result.current.interactableComponents[0].props;\n const originalUsers = originalProps.users;\n\n // Apply a small partial update - only change theme (shallow merge behavior)\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n settings: {\n theme: \"dark\",\n // Note: other settings properties are not provided, so they will be undefined\n // This demonstrates the shallow merge behavior\n },\n });\n });\n\n const updatedProps = result.current.interactableComponents[0].props;\n\n // Verify the update worked\n expect(updatedProps.settings.theme).toBe(\"dark\");\n // Due to shallow merge, other properties are now undefined\n expect(updatedProps.settings.language).toBeUndefined();\n expect(updatedProps.settings.notifications).toBeUndefined();\n\n // Verify that large arrays are preserved (same reference for efficiency)\n expect(updatedProps.users).toBe(originalUsers);\n\n // Verify that metadata is preserved (not updated)\n expect(updatedProps.metadata).toBe(originalProps.metadata);\n });\n });\n\n describe(\"Edge Cases\", () => {\n it(\"should handle updating a property that doesn't exist in original props\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 0,\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n newProperty: z.string().optional(),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Add a new property that wasn't in the original props\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n newProperty: \"New Value\",\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n count: 0,\n newProperty: \"New Value\",\n });\n });\n\n it(\"should handle updating with same values (no-op updates)\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 5,\n active: true,\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n active: z.boolean(),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const originalProps = result.current.interactableComponents[0].props;\n\n // Update with the same values\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n {\n title: \"Original Title\",\n count: 5,\n active: true,\n },\n );\n });\n\n expect(updateResult).toBe(\"Updated successfully\");\n expect(result.current.interactableComponents[0].props).toEqual(\n originalProps,\n );\n });\n\n it(\"should handle proper nested partial updates by providing complete nested structure\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n config: {\n theme: \"light\",\n language: \"en\",\n features: {\n notifications: true,\n analytics: false,\n experimental: {\n beta: false,\n alpha: true,\n },\n },\n },\n },\n propsSchema: z.object({\n title: z.string(),\n config: z.object({\n theme: z.string(),\n language: z.string(),\n features: z.object({\n notifications: z.boolean(),\n analytics: z.boolean(),\n experimental: z.object({\n beta: z.boolean(),\n alpha: z.boolean(),\n }),\n }),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Proper nested partial update - provide complete nested structure\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n config: {\n theme: \"light\", // keep original\n language: \"en\", // keep original\n features: {\n notifications: true, // keep original\n analytics: false, // keep original\n experimental: {\n beta: true, // update this\n alpha: true, // keep original\n },\n },\n },\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n config: {\n theme: \"light\", // unchanged\n language: \"en\", // unchanged\n features: {\n notifications: true, // unchanged\n analytics: false, // unchanged\n experimental: {\n beta: true, // updated\n alpha: true, // unchanged\n },\n },\n },\n });\n });\n\n it(\"should handle complex nested partial updates (shallow merge behavior)\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n config: {\n theme: \"light\",\n language: \"en\",\n features: {\n notifications: true,\n analytics: false,\n experimental: {\n beta: false,\n alpha: true,\n },\n },\n },\n },\n propsSchema: z.object({\n title: z.string(),\n config: z.object({\n theme: z.string(),\n language: z.string(),\n features: z.object({\n notifications: z.boolean(),\n analytics: z.boolean(),\n experimental: z.object({\n beta: z.boolean(),\n alpha: z.boolean(),\n }),\n }),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Deep nested partial update - only change beta flag (shallow merge behavior)\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n config: {\n features: {\n experimental: {\n beta: true,\n // Note: alpha is not provided, so it will be undefined\n // This demonstrates the shallow merge behavior\n },\n },\n },\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n config: {\n // theme and language are now undefined due to shallow merge\n features: {\n // notifications and analytics are now undefined due to shallow merge\n experimental: {\n beta: true, // updated\n // alpha is now undefined due to shallow merge\n },\n },\n },\n });\n });\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"tambo-interactable-provider-partial-updates.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider-partial-updates.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAE3B,OAAO,EACL,y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D;oBAC5D,QAAQ,EAAE;wBACR,qEAAqE;wBACrE,YAAY,EAAE;4BACZ,IAAI,EAAE,IAAI,EAAE,UAAU;4BACtB,8CAA8C;yBAC/C;qBACF;iBACF;aACF,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { act, renderHook } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zod/v4\";\nimport { TamboInteractableComponent } from \"../model/tambo-interactable\";\nimport {\n TamboInteractableProvider,\n useTamboInteractable,\n} from \"./tambo-interactable-provider\";\n\n// Mock the context helpers\nconst mockAddContextHelper = jest.fn();\nconst mockRemoveContextHelper = jest.fn();\n\njest.mock(\"./tambo-context-helpers-provider\", () => ({\n TamboContextHelpersProvider: ({\n children,\n }: {\n children: React.ReactNode;\n }) => <>{children}</>,\n useTamboContextHelpers: () => ({\n addContextHelper: mockAddContextHelper,\n removeContextHelper: mockRemoveContextHelper,\n }),\n}));\n\n// Mock the component provider\nconst mockRegisterTool = jest.fn();\n\njest.mock(\"./tambo-component-provider\", () => ({\n useTamboComponent: () => ({\n registerTool: mockRegisterTool,\n }),\n}));\n\n// Mock the context helper creation\njest.mock(\"../context-helpers/current-interactables-context-helper\", () => ({\n createInteractablesContextHelper: () =>\n jest.fn(() => ({\n name: \"interactables\",\n context: {\n description: \"Test interactables context\",\n components: [],\n },\n })),\n}));\n\ndescribe(\"updateInteractableComponentProps - Partial Updates\", () => {\n beforeEach(() => {\n jest.clearAllMocks();\n });\n\n const wrapper = ({ children }: { children: React.ReactNode }) => (\n <TamboInteractableProvider>{children}</TamboInteractableProvider>\n );\n\n describe(\"Partial Updates Functionality\", () => {\n it(\"should apply partial updates to existing props\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 0,\n active: true,\n metadata: { type: \"test\", version: \"1.0\" },\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n active: z.boolean(),\n metadata: z.object({\n type: z.string(),\n version: z.string(),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Verify initial state\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n count: 0,\n active: true,\n metadata: { type: \"test\", version: \"1.0\" },\n });\n\n // Apply partial update - only change count\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n {\n count: 5,\n },\n );\n });\n\n expect(updateResult).toBe(\"Updated successfully\");\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\", // unchanged\n count: 5, // updated\n active: true, // unchanged\n metadata: { type: \"test\", version: \"1.0\" }, // unchanged\n });\n });\n\n it(\"should apply multiple partial updates in sequence\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 0,\n active: true,\n description: \"Original description\",\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n active: z.boolean(),\n description: z.string(),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // First partial update - change title and count\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n title: \"Updated Title\",\n count: 10,\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Updated Title\",\n count: 10,\n active: true,\n description: \"Original description\",\n });\n\n // Second partial update - change active and description\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n active: false,\n description: \"Updated description\",\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Updated Title\", // from previous update\n count: 10, // from previous update\n active: false, // new update\n description: \"Updated description\", // new update\n });\n });\n\n it(\"should handle nested object partial updates (shallow merge behavior)\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n config: {\n theme: \"light\",\n language: \"en\",\n features: {\n notifications: true,\n analytics: false,\n },\n },\n },\n propsSchema: z.object({\n title: z.string(),\n config: z.object({\n theme: z.string(),\n language: z.string(),\n features: z.object({\n notifications: z.boolean(),\n analytics: z.boolean(),\n }),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Partial update - replace entire config object (shallow merge behavior)\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n config: {\n theme: \"dark\",\n // Note: language and features are not provided, so they will be undefined\n // This demonstrates the shallow merge behavior\n },\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n config: {\n theme: \"dark\", // updated\n // language and features are now undefined due to shallow merge\n },\n });\n });\n\n it(\"should handle array partial updates\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n items: [\"item1\", \"item2\", \"item3\"],\n tags: [\"tag1\", \"tag2\"],\n },\n propsSchema: z.object({\n title: z.string(),\n items: z.array(z.string()),\n tags: z.array(z.string()),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Partial update - only change items array\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n items: [\"newItem1\", \"newItem2\"],\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\", // unchanged\n items: [\"newItem1\", \"newItem2\"], // updated\n tags: [\"tag1\", \"tag2\"], // unchanged\n });\n });\n\n it(\"should handle null and undefined values in partial updates\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 5,\n description: \"Original description\",\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n description: z.string(),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Partial update with null value\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n description: null as any,\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n count: 5,\n description: null,\n });\n\n // Partial update with undefined value\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n count: undefined as any,\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n count: undefined,\n description: null,\n });\n });\n });\n\n describe(\"Error Handling\", () => {\n it(\"should return error for non-existent component\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n \"non-existent\",\n {\n title: \"New Title\",\n },\n );\n });\n\n expect(updateResult).toBe(\"Updated successfully\");\n });\n\n it(\"should throw error when component name contains spaces\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const invalidComponent: Omit<\n TamboInteractableComponent,\n \"id\" | \"createdAt\"\n > = {\n name: \"Invalid Component Name\", // Contains spaces\n description: \"A component with spaces in name\",\n component: () => <div>Invalid</div>,\n props: { title: \"Test\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n expect(() => {\n act(() => {\n result.current.addInteractableComponent(invalidComponent);\n });\n }).toThrow(\n 'component \"Invalid Component Name\" must only contain letters, numbers, underscores, and hyphens.',\n );\n });\n\n it(\"should return warning for empty props object\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Original Title\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n {},\n );\n });\n\n expect(updateResult).toBe(\n `Warning: No props provided for component with ID ${componentId}.`,\n );\n });\n\n it(\"should return warning for null props\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Original Title\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n null as any,\n );\n });\n\n expect(updateResult).toBe(\n `Warning: No props provided for component with ID ${componentId}.`,\n );\n });\n\n it(\"should return warning for undefined props\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: { title: \"Original Title\" },\n propsSchema: z.object({ title: z.string() }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n undefined as any,\n );\n });\n\n expect(updateResult).toBe(\n `Warning: No props provided for component with ID ${componentId}.`,\n );\n });\n });\n\n describe(\"Performance and Efficiency\", () => {\n it(\"should only update changed properties without affecting others\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 0,\n active: true,\n metadata: { type: \"test\", version: \"1.0\" },\n items: [\"item1\", \"item2\"],\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n active: z.boolean(),\n metadata: z.object({\n type: z.string(),\n version: z.string(),\n }),\n items: z.array(z.string()),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const originalProps = result.current.interactableComponents[0].props;\n const originalMetadata = originalProps.metadata;\n const originalItems = originalProps.items;\n\n // Apply minimal partial update - only change count\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n count: 1,\n });\n });\n\n const updatedProps = result.current.interactableComponents[0].props;\n\n // Verify that only count changed\n expect(updatedProps.count).toBe(1);\n expect(updatedProps.title).toBe(\"Original Title\");\n expect(updatedProps.active).toBe(true);\n\n // Verify that nested objects are preserved (same reference for efficiency)\n expect(updatedProps.metadata).toBe(originalMetadata);\n expect(updatedProps.items).toBe(originalItems);\n });\n\n it(\"should handle large objects efficiently with partial updates\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n // Create a component with a large initial state\n const largeData = {\n users: Array.from({ length: 1000 }, (_, i) => ({\n id: i,\n name: `User ${i}`,\n })),\n settings: {\n theme: \"light\",\n language: \"en\",\n notifications: true,\n privacy: {\n shareData: false,\n analytics: true,\n marketing: false,\n },\n },\n metadata: {\n version: \"1.0.0\",\n build: \"12345\",\n timestamp: Date.now(),\n },\n };\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component with large data\",\n component: () => <div>Test</div>,\n props: largeData,\n propsSchema: z.object({\n users: z.array(\n z.object({\n id: z.number(),\n name: z.string(),\n }),\n ),\n settings: z.object({\n theme: z.string(),\n language: z.string(),\n notifications: z.boolean(),\n privacy: z.object({\n shareData: z.boolean(),\n analytics: z.boolean(),\n marketing: z.boolean(),\n }),\n }),\n metadata: z.object({\n version: z.string(),\n build: z.string(),\n timestamp: z.number(),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const originalProps = result.current.interactableComponents[0].props;\n const originalUsers = originalProps.users;\n\n // Apply a small partial update - only change theme (shallow merge behavior)\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n settings: {\n theme: \"dark\",\n // Note: other settings properties are not provided, so they will be undefined\n // This demonstrates the shallow merge behavior\n },\n });\n });\n\n const updatedProps = result.current.interactableComponents[0].props;\n\n // Verify the update worked\n expect(updatedProps.settings.theme).toBe(\"dark\");\n // Due to shallow merge, other properties are now undefined\n expect(updatedProps.settings.language).toBeUndefined();\n expect(updatedProps.settings.notifications).toBeUndefined();\n\n // Verify that large arrays are preserved (same reference for efficiency)\n expect(updatedProps.users).toBe(originalUsers);\n\n // Verify that metadata is preserved (not updated)\n expect(updatedProps.metadata).toBe(originalProps.metadata);\n });\n });\n\n describe(\"Edge Cases\", () => {\n it(\"should handle updating a property that doesn't exist in original props\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 0,\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n newProperty: z.string().optional(),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Add a new property that wasn't in the original props\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n newProperty: \"New Value\",\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n count: 0,\n newProperty: \"New Value\",\n });\n });\n\n it(\"should handle updating with same values (no-op updates)\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n count: 5,\n active: true,\n },\n propsSchema: z.object({\n title: z.string(),\n count: z.number(),\n active: z.boolean(),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n const originalProps = result.current.interactableComponents[0].props;\n\n // Update with the same values\n let updateResult = \"\";\n act(() => {\n updateResult = result.current.updateInteractableComponentProps(\n componentId,\n {\n title: \"Original Title\",\n count: 5,\n active: true,\n },\n );\n });\n\n expect(updateResult).toBe(\"Updated successfully\");\n expect(result.current.interactableComponents[0].props).toEqual(\n originalProps,\n );\n });\n\n it(\"should handle proper nested partial updates by providing complete nested structure\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n config: {\n theme: \"light\",\n language: \"en\",\n features: {\n notifications: true,\n analytics: false,\n experimental: {\n beta: false,\n alpha: true,\n },\n },\n },\n },\n propsSchema: z.object({\n title: z.string(),\n config: z.object({\n theme: z.string(),\n language: z.string(),\n features: z.object({\n notifications: z.boolean(),\n analytics: z.boolean(),\n experimental: z.object({\n beta: z.boolean(),\n alpha: z.boolean(),\n }),\n }),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Proper nested partial update - provide complete nested structure\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n config: {\n theme: \"light\", // keep original\n language: \"en\", // keep original\n features: {\n notifications: true, // keep original\n analytics: false, // keep original\n experimental: {\n beta: true, // update this\n alpha: true, // keep original\n },\n },\n },\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n config: {\n theme: \"light\", // unchanged\n language: \"en\", // unchanged\n features: {\n notifications: true, // unchanged\n analytics: false, // unchanged\n experimental: {\n beta: true, // updated\n alpha: true, // unchanged\n },\n },\n },\n });\n });\n\n it(\"should handle complex nested partial updates (shallow merge behavior)\", () => {\n const { result } = renderHook(() => useTamboInteractable(), { wrapper });\n\n const component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\"> = {\n name: \"TestComponent\",\n description: \"A test component\",\n component: () => <div>Test</div>,\n props: {\n title: \"Original Title\",\n config: {\n theme: \"light\",\n language: \"en\",\n features: {\n notifications: true,\n analytics: false,\n experimental: {\n beta: false,\n alpha: true,\n },\n },\n },\n },\n propsSchema: z.object({\n title: z.string(),\n config: z.object({\n theme: z.string(),\n language: z.string(),\n features: z.object({\n notifications: z.boolean(),\n analytics: z.boolean(),\n experimental: z.object({\n beta: z.boolean(),\n alpha: z.boolean(),\n }),\n }),\n }),\n }),\n };\n\n let componentId = \"\";\n act(() => {\n componentId = result.current.addInteractableComponent(component);\n });\n\n // Deep nested partial update - only change beta flag (shallow merge behavior)\n act(() => {\n result.current.updateInteractableComponentProps(componentId, {\n config: {\n features: {\n experimental: {\n beta: true,\n // Note: alpha is not provided, so it will be undefined\n // This demonstrates the shallow merge behavior\n },\n },\n },\n });\n });\n\n expect(result.current.interactableComponents[0].props).toEqual({\n title: \"Original Title\",\n config: {\n // theme and language are now undefined due to shallow merge\n features: {\n // notifications and analytics are now undefined due to shallow merge\n experimental: {\n beta: true, // updated\n // alpha is now undefined due to shallow merge\n },\n },\n },\n });\n });\n });\n});\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-interactable-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAGf,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,6BAA6B,CAAC;AAKrC,QAAA,MAAM,wBAAwB,yCAQ5B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,
|
|
1
|
+
{"version":3,"file":"tambo-interactable-provider.d.ts","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAEZ,iBAAiB,EAKlB,MAAM,OAAO,CAAC;AAGf,OAAO,EAEL,KAAK,wBAAwB,EAC9B,MAAM,6BAA6B,CAAC;AAKrC,QAAA,MAAM,wBAAwB,yCAQ5B,CAAC;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,yBAAyB,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA0RjE,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,gCAEhC,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,+BAA+B;;;;;;;;;;;;GAS3C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// react-sdk/src/providers/tambo-interactable-provider.tsx
|
|
2
2
|
"use client";
|
|
3
3
|
import React, { createContext, useCallback, useContext, useEffect, useState, } from "react";
|
|
4
|
-
import { z } from "
|
|
4
|
+
import { z } from "zod/v3";
|
|
5
5
|
import { createInteractablesContextHelper } from "../context-helpers/current-interactables-context-helper";
|
|
6
6
|
import { assertValidName } from "../util/validate-component-name";
|
|
7
7
|
import { useTamboComponent } from "./tambo-component-provider";
|
|
@@ -48,7 +48,7 @@ export const TamboInteractableProvider = ({ children, }) => {
|
|
|
48
48
|
components: interactableComponents,
|
|
49
49
|
};
|
|
50
50
|
},
|
|
51
|
-
inputSchema: z.
|
|
51
|
+
inputSchema: z.object({}),
|
|
52
52
|
outputSchema: z.object({
|
|
53
53
|
components: z.array(z.object({
|
|
54
54
|
id: z.string(),
|
|
@@ -61,7 +61,7 @@ export const TamboInteractableProvider = ({ children, }) => {
|
|
|
61
61
|
registerTool({
|
|
62
62
|
name: "get_interactable_component_by_id",
|
|
63
63
|
description: "Get a specific interactable component by its ID",
|
|
64
|
-
tool: (componentId) => {
|
|
64
|
+
tool: ({ componentId }) => {
|
|
65
65
|
const component = interactableComponents.find((c) => c.id === componentId);
|
|
66
66
|
if (!component) {
|
|
67
67
|
return {
|
|
@@ -78,7 +78,9 @@ export const TamboInteractableProvider = ({ children, }) => {
|
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
80
|
},
|
|
81
|
-
inputSchema: z.
|
|
81
|
+
inputSchema: z.object({
|
|
82
|
+
componentId: z.string().describe("The ID of the component"),
|
|
83
|
+
}),
|
|
82
84
|
outputSchema: z.discriminatedUnion("success", [
|
|
83
85
|
z.object({
|
|
84
86
|
success: z.literal(true),
|
|
@@ -99,7 +101,7 @@ export const TamboInteractableProvider = ({ children, }) => {
|
|
|
99
101
|
registerTool({
|
|
100
102
|
name: "remove_interactable_component",
|
|
101
103
|
description: "Remove an interactable component from the system",
|
|
102
|
-
tool: (componentId) => {
|
|
104
|
+
tool: ({ componentId }) => {
|
|
103
105
|
const component = interactableComponents.find((c) => c.id === componentId);
|
|
104
106
|
if (!component) {
|
|
105
107
|
return {
|
|
@@ -118,7 +120,9 @@ export const TamboInteractableProvider = ({ children, }) => {
|
|
|
118
120
|
},
|
|
119
121
|
};
|
|
120
122
|
},
|
|
121
|
-
inputSchema: z.
|
|
123
|
+
inputSchema: z.object({
|
|
124
|
+
componentId: z.string().describe("The ID of the component"),
|
|
125
|
+
}),
|
|
122
126
|
outputSchema: z.discriminatedUnion("success", [
|
|
123
127
|
z.object({
|
|
124
128
|
success: z.literal(true),
|
|
@@ -179,13 +183,15 @@ export const TamboInteractableProvider = ({ children, }) => {
|
|
|
179
183
|
registerTool({
|
|
180
184
|
name: `${tamboToolNamePart}${component.id}`,
|
|
181
185
|
description: `Update the props of interactable component ${component.id} (${component.name}). You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.`,
|
|
182
|
-
tool: (componentId, newProps) => {
|
|
186
|
+
tool: ({ componentId, newProps }) => {
|
|
183
187
|
return updateInteractableComponentProps(componentId, newProps);
|
|
184
188
|
},
|
|
185
|
-
inputSchema: z.
|
|
186
|
-
z
|
|
187
|
-
|
|
188
|
-
|
|
189
|
+
inputSchema: z.object({
|
|
190
|
+
componentId: z
|
|
191
|
+
.string()
|
|
192
|
+
.describe("The ID of the interactable component to update"),
|
|
193
|
+
newProps: schemaForArgs.describe("The props to update the component with. You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated."),
|
|
194
|
+
}),
|
|
189
195
|
outputSchema: z.string(),
|
|
190
196
|
});
|
|
191
197
|
}, [registerTool, updateInteractableComponentProps]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAAE,gCAAgC,EAAE,MAAM,yDAAyD,CAAC;AAK3G,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,MAAM,wBAAwB,GAAG,aAAa,CAA2B;IACvE,sBAAsB,EAAE,EAAE;IAC1B,wBAAwB,EAAE,GAAG,EAAE,CAAC,EAAE;IAClC,2BAA2B,EAAE,GAAG,EAAE,GAAE,CAAC;IACrC,gCAAgC,EAAE,GAAG,EAAE,CAAC,EAAE;IAC1C,wBAAwB,EAAE,GAAG,EAAE,CAAC,SAAS;IACzC,+BAA+B,EAAE,GAAG,EAAE,CAAC,EAAE;IACzC,8BAA8B,EAAE,GAAG,EAAE,G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O,UAAU,CAAC,wBAAwB,CAAC,CAAC;AAC9C,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,MAAM,EAAE,sBAAsB,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAC1D,0DAA0D;IAC1D,MAAM,IAAI,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9C,GAAG,CAAC;QACJ,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE;KACtB,CAAC,CAAC,CAAC;IAEJ,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { z } from \"zodInternalAlias\";\nimport { createInteractablesContextHelper } from \"../context-helpers/current-interactables-context-helper\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { assertValidName } from \"../util/validate-component-name\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => \"\",\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Create a stable context helper function\n const contextHelper = useCallback(() => {\n return createInteractablesContextHelper(() => interactableComponents)();\n }, [interactableComponents]);\n\n // Register the default interactables context helper\n useEffect(() => {\n addContextHelper(\"interactables\", contextHelper);\n\n return () => {\n removeContextHelper(\"interactables\");\n };\n }, [contextHelper, addContextHelper, removeContextHelper]);\n\n useEffect(() => {\n if (interactableComponents.length > 0) {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n inputSchema: z.tuple([]),\n outputSchema: z.object({\n components: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n props: z.record(z.string(), z.any()),\n propsSchema: z.record(z.string(), z.any()).optional(),\n }),\n ),\n }),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.tuple([z.string()]),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n })\n .optional(),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: (componentId: string) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.tuple([z.string()]),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n }),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n }\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>): string => {\n if (!newProps || Object.keys(newProps).length === 0) {\n return `Warning: No props provided for component with ID ${id}.`;\n }\n\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === id);\n if (!component) {\n return prev;\n }\n\n // Compare props shallowly\n const propsChanged = Object.entries(newProps).some(([key, value]) => {\n return component.props[key] !== value;\n });\n\n if (!propsChanged) {\n return prev; // unchanged\n }\n\n // Apply partial update\n const updated = {\n ...component,\n props: { ...component.props, ...newProps },\n };\n\n const updatedComponents = [...prev];\n const idx = prev.findIndex((c) => c.id === id);\n updatedComponents[idx] = updated;\n\n return updatedComponents;\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const registerInteractableComponentUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n const schemaForArgs =\n typeof component.propsSchema === \"object\" &&\n \"describe\" in component.propsSchema &&\n \"partial\" in component.propsSchema\n ? (component.propsSchema as any).partial()\n : z.object({});\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name}). You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.`,\n tool: (componentId: string, newProps?: any) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n inputSchema: z.tuple([\n z.string().describe(\"The ID of the interactable component to update\"),\n schemaForArgs.describe(\n \"The props to update the component with. You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.\",\n ),\n ]),\n outputSchema: z.string(),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n // Validate component name\n assertValidName(component.name, \"component\");\n\n // Add a random part to the component name to make it unique when using multiple instances of the same component.\n const tamboGeneratedNamePart = `-${Math.random().toString(36).slice(2, 5)}`;\n const id = `${component.name}${tamboGeneratedNamePart}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n };\n\n registerInteractableComponentUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [registerInteractableComponentUpdateTool],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n (id: string) => {\n return interactableComponents.find((c) => c.id === id);\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n\n/**\n * Hook to get a cloned snapshot of the current interactables.\n * Returns a shallow copy of the array with cloned items and props to prevent\n * external mutation from affecting internal state.\n * @returns The current interactables snapshot (cloned).\n */\nexport const useCurrentInteractablesSnapshot = () => {\n const { interactableComponents } = useTamboInteractable();\n // Clone the array and each item/props to prevent mutation\n const copy = interactableComponents.map((c) => ({\n ...c,\n props: { ...c.props },\n }));\n\n return copy;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"tambo-interactable-provider.js","sourceRoot":"","sources":["../../src/providers/tambo-interactable-provider.tsx"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,YAAY,CAAC;AACb,OAAO,KAAK,EAAE,EACZ,aAAa,EAEb,WAAW,EACX,UAAU,EACV,SAAS,EACT,QAAQ,GACT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,gCAAgC,EAAE,MAAM,yDAAyD,CAAC;AAK3G,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,MAAM,wBAAwB,GAAG,aAAa,CAA2B;IACvE,sBAAsB,EAAE,EAAE;IAC1B,wBAAwB,EAAE,GAAG,EAAE,CAAC,EAAE;IAClC,2BAA2B,EAAE,GAAG,EAAE,GAAE,CAAC;IACrC,gCAAgC,EAAE,GAAG,EAAE,CAAC,EAAE;IAC1C,wBAAwB,EAAE,GAAG,EAAE,CAAC,SAAS;IACzC,+BAA+B,EAAE,GAAG,EAAE,CAAC,EAAE;IACzC,8BAA8B,EAAE,GAAG,EAAE,GAAE,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAgC,CAAC,EACrE,QAAQ,GACT,EAAE,EAAE;IACH,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAElE,EAAE,CAAC,CAAC;IACN,MAAM,EAAE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KG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,GAAG,EAAE;IAClD,MAAM,EAAE,sBAAsB,EAAE,GAAG,oBAAoB,EAAE,CAAC;IAC1D,0DAA0D;IAC1D,MAAM,IAAI,GAAG,sBAAsB,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC9C,GAAG,CAAC;QACJ,KAAK,EAAE,EAAE,GAAG,CAAC,CAAC,KAAK,EAAE;KACtB,CAAC,CAAC,CAAC;IAEJ,OAAO,IAAI,CAAC;AACd,CAAC,CAAC","sourcesContent":["// react-sdk/src/providers/tambo-interactable-provider.tsx\n\"use client\";\nimport React, {\n createContext,\n PropsWithChildren,\n useCallback,\n useContext,\n useEffect,\n useState,\n} from \"react\";\nimport { z } from \"zod/v3\";\nimport { createInteractablesContextHelper } from \"../context-helpers/current-interactables-context-helper\";\nimport {\n TamboInteractableComponent,\n type TamboInteractableContext,\n} from \"../model/tambo-interactable\";\nimport { assertValidName } from \"../util/validate-component-name\";\nimport { useTamboComponent } from \"./tambo-component-provider\";\nimport { useTamboContextHelpers } from \"./tambo-context-helpers-provider\";\n\nconst TamboInteractableContext = createContext<TamboInteractableContext>({\n interactableComponents: [],\n addInteractableComponent: () => \"\",\n removeInteractableComponent: () => {},\n updateInteractableComponentProps: () => \"\",\n getInteractableComponent: () => undefined,\n getInteractableComponentsByName: () => [],\n clearAllInteractableComponents: () => {},\n});\n\n/**\n * The TamboInteractableProvider manages a list of components that are currently\n * interactable, allowing tambo to interact with them by updating their props. It also registers tools\n * for Tambo to perform CRUD operations on the components list.\n * @param props - The props for the TamboInteractableProvider\n * @param props.children - The children to wrap\n * @returns The TamboInteractableProvider component\n */\nexport const TamboInteractableProvider: React.FC<PropsWithChildren> = ({\n children,\n}) => {\n const [interactableComponents, setInteractableComponents] = useState<\n TamboInteractableComponent[]\n >([]);\n const { registerTool } = useTamboComponent();\n const { addContextHelper, removeContextHelper } = useTamboContextHelpers();\n\n // Create a stable context helper function\n const contextHelper = useCallback(() => {\n return createInteractablesContextHelper(() => interactableComponents)();\n }, [interactableComponents]);\n\n // Register the default interactables context helper\n useEffect(() => {\n addContextHelper(\"interactables\", contextHelper);\n\n return () => {\n removeContextHelper(\"interactables\");\n };\n }, [contextHelper, addContextHelper, removeContextHelper]);\n\n useEffect(() => {\n if (interactableComponents.length > 0) {\n registerTool({\n name: \"get_all_interactable_components\",\n description:\n \"Only use this tool if the user is asking about interactable components.Get all currently interactable components with their details including their current props. These are components that you can interact with on behalf of the user.\",\n tool: () => {\n return {\n components: interactableComponents,\n };\n },\n inputSchema: z.object({}),\n outputSchema: z.object({\n components: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n props: z.record(z.string(), z.any()),\n propsSchema: z.record(z.string(), z.any()).optional(),\n }),\n ),\n }),\n });\n\n registerTool({\n name: \"get_interactable_component_by_id\",\n description: \"Get a specific interactable component by its ID\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n return {\n success: true,\n component: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n component: z\n .object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n })\n .optional(),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n\n registerTool({\n name: \"remove_interactable_component\",\n description: \"Remove an interactable component from the system\",\n tool: ({ componentId }) => {\n const component = interactableComponents.find(\n (c) => c.id === componentId,\n );\n\n if (!component) {\n return {\n success: false,\n error: `Component with ID ${componentId} not found`,\n } as const;\n }\n\n setInteractableComponents((prev) =>\n prev.filter((c) => c.id !== componentId),\n );\n\n return {\n success: true,\n componentId,\n removedComponent: {\n id: component.id,\n componentName: component.name,\n props: component.props,\n },\n } as const;\n },\n inputSchema: z.object({\n componentId: z.string().describe(\"The ID of the component\"),\n }),\n outputSchema: z.discriminatedUnion(\"success\", [\n z.object({\n success: z.literal(true),\n componentId: z.string(),\n removedComponent: z.object({\n id: z.string(),\n componentName: z.string(),\n props: z.record(z.string(), z.any()),\n }),\n }),\n z.object({\n success: z.literal(false),\n error: z.string(),\n }),\n ]),\n });\n }\n }, [interactableComponents, registerTool]);\n\n const updateInteractableComponentProps = useCallback(\n (id: string, newProps: Record<string, any>): string => {\n if (!newProps || Object.keys(newProps).length === 0) {\n return `Warning: No props provided for component with ID ${id}.`;\n }\n\n setInteractableComponents((prev) => {\n const component = prev.find((c) => c.id === id);\n if (!component) {\n return prev;\n }\n\n // Compare props shallowly\n const propsChanged = Object.entries(newProps).some(([key, value]) => {\n return component.props[key] !== value;\n });\n\n if (!propsChanged) {\n return prev; // unchanged\n }\n\n // Apply partial update\n const updated = {\n ...component,\n props: { ...component.props, ...newProps },\n };\n\n const updatedComponents = [...prev];\n const idx = prev.findIndex((c) => c.id === id);\n updatedComponents[idx] = updated;\n\n return updatedComponents;\n });\n\n return \"Updated successfully\";\n },\n [],\n );\n\n const registerInteractableComponentUpdateTool = useCallback(\n (component: TamboInteractableComponent, maxNameLength = 60) => {\n const tamboToolNamePart = `update_component_`;\n const availableLength = maxNameLength - tamboToolNamePart.length;\n if (component.id.length > availableLength) {\n throw new Error(\n `Interactable component id ${component.id} is too long. It must be less than ${availableLength} characters.`,\n );\n }\n\n const schemaForArgs =\n typeof component.propsSchema === \"object\" &&\n \"describe\" in component.propsSchema &&\n \"partial\" in component.propsSchema\n ? (component.propsSchema as any).partial()\n : z.object({});\n\n registerTool({\n name: `${tamboToolNamePart}${component.id}`,\n description: `Update the props of interactable component ${component.id} (${component.name}). You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.`,\n tool: ({ componentId, newProps }) => {\n return updateInteractableComponentProps(componentId, newProps);\n },\n inputSchema: z.object({\n componentId: z\n .string()\n .describe(\"The ID of the interactable component to update\"),\n newProps: schemaForArgs.describe(\n \"The props to update the component with. You can provide partial props (only the props you want to change) or complete props (all props). Only the props you specify will be updated.\",\n ),\n }),\n outputSchema: z.string(),\n });\n },\n [registerTool, updateInteractableComponentProps],\n );\n\n const addInteractableComponent = useCallback(\n (\n component: Omit<TamboInteractableComponent, \"id\" | \"createdAt\">,\n ): string => {\n // Validate component name\n assertValidName(component.name, \"component\");\n\n // Add a random part to the component name to make it unique when using multiple instances of the same component.\n const tamboGeneratedNamePart = `-${Math.random().toString(36).slice(2, 5)}`;\n const id = `${component.name}${tamboGeneratedNamePart}`;\n const newComponent: TamboInteractableComponent = {\n ...component,\n id,\n };\n\n registerInteractableComponentUpdateTool(newComponent);\n\n setInteractableComponents((prev) => {\n return [...prev, newComponent];\n });\n\n return id;\n },\n [registerInteractableComponentUpdateTool],\n );\n\n const removeInteractableComponent = useCallback((id: string) => {\n setInteractableComponents((prev) => prev.filter((c) => c.id !== id));\n }, []);\n\n const getInteractableComponent = useCallback(\n (id: string) => {\n return interactableComponents.find((c) => c.id === id);\n },\n [interactableComponents],\n );\n\n const getInteractableComponentsByName = useCallback(\n (componentName: string) => {\n return interactableComponents.filter((c) => c.name === componentName);\n },\n [interactableComponents],\n );\n\n const clearAllInteractableComponents = useCallback(() => {\n setInteractableComponents([]);\n }, []);\n\n const value: TamboInteractableContext = {\n interactableComponents,\n addInteractableComponent,\n removeInteractableComponent,\n updateInteractableComponentProps,\n getInteractableComponent,\n getInteractableComponentsByName,\n clearAllInteractableComponents,\n };\n\n return (\n <TamboInteractableContext.Provider value={value}>\n {children}\n </TamboInteractableContext.Provider>\n );\n};\n\n/**\n * The useTamboInteractable hook provides access to the interactable component\n * management functions.\n * @returns The interactable component management functions\n */\nexport const useTamboInteractable = () => {\n return useContext(TamboInteractableContext);\n};\n\n/**\n * Hook to get a cloned snapshot of the current interactables.\n * Returns a shallow copy of the array with cloned items and props to prevent\n * external mutation from affecting internal state.\n * @returns The current interactables snapshot (cloned).\n */\nexport const useCurrentInteractablesSnapshot = () => {\n const { interactableComponents } = useTamboInteractable();\n // Clone the array and each item/props to prevent mutation\n const copy = interactableComponents.map((c) => ({\n ...c,\n props: { ...c.props },\n }));\n\n return copy;\n};\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { render, waitFor } from "@testing-library/react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { z } from "
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
4
|
import { withTamboInteractable } from "../hoc/with-tambo-interactable";
|
|
5
5
|
import { TamboContextHelpersProvider, useTamboContextHelpers, } from "./tambo-context-helpers-provider";
|
|
6
6
|
import { TamboInteractableProvider } from "./tambo-interactable-provider";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tambo-interactables-additional-context-edge-cases.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactables-additional-context-edge-cases.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AACrC,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,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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CAAC,CAAC","sourcesContent":["import { render, waitFor } from \"@testing-library/react\";\nimport React from \"react\";\nimport { z } from \"zodInternalAlias\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport { TamboInteractableProvider } from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"./tambo-stubs\";\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 void 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 void 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 void 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 void 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 void 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 void 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"]}
|
|
1
|
+
{"version":3,"file":"tambo-interactables-additional-context-edge-cases.test.js","sourceRoot":"","sources":["../../src/providers/tambo-interactables-additional-context-edge-cases.test.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EACL,2BAA2B,EAC3B,sBAAsB,GACvB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,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,oBAAC,iBAA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from \"react\";\nimport { z } from \"zod/v4\";\nimport { withTamboInteractable } from \"../hoc/with-tambo-interactable\";\nimport {\n TamboContextHelpersProvider,\n useTamboContextHelpers,\n} from \"./tambo-context-helpers-provider\";\nimport { TamboInteractableProvider } from \"./tambo-interactable-provider\";\nimport { TamboStubProvider } from \"./tambo-stubs\";\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 void 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 void 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 void 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 void 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 void 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 void 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"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { render, waitFor } from "@testing-library/react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { z } from "
|
|
3
|
+
import { z } from "zod/v4";
|
|
4
4
|
import { withTamboInteractable } from "../hoc/with-tambo-interactable";
|
|
5
5
|
import { TamboContextHelpersProvider, useTamboContextHelpers, } from "./tambo-context-helpers-provider";
|
|
6
6
|
import { TamboInteractableProvider, useCurrentInteractablesSnapshot, } from "./tambo-interactable-provider";
|