@copilotkit/react-core 1.56.2-canary.pin-to-send → 1.56.2-canary.test-welcome-screen

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{copilotkit-D5JT2Pu3.cjs → copilotkit-By2G6-Zx.cjs} +22 -9
  2. package/dist/copilotkit-By2G6-Zx.cjs.map +1 -0
  3. package/dist/{copilotkit-DArT2Iuw.d.mts → copilotkit-DFaI4j2r.d.mts} +3 -1
  4. package/dist/copilotkit-DFaI4j2r.d.mts.map +1 -0
  5. package/dist/{copilotkit-KEc28l8G.d.cts → copilotkit-Dg4r4Gi_.d.cts} +3 -1
  6. package/dist/copilotkit-Dg4r4Gi_.d.cts.map +1 -0
  7. package/dist/{copilotkit-BBYbekCa.mjs → copilotkit-PzJlPKcU.mjs} +22 -9
  8. package/dist/copilotkit-PzJlPKcU.mjs.map +1 -0
  9. package/dist/index.cjs +1 -1
  10. package/dist/index.d.cts +2 -1
  11. package/dist/index.d.cts.map +1 -1
  12. package/dist/index.d.mts +2 -1
  13. package/dist/index.d.mts.map +1 -1
  14. package/dist/index.mjs +1 -1
  15. package/dist/index.umd.js +15 -4
  16. package/dist/index.umd.js.map +1 -1
  17. package/dist/v2/index.cjs +1 -1
  18. package/dist/v2/index.d.cts +1 -1
  19. package/dist/v2/index.d.mts +1 -1
  20. package/dist/v2/index.mjs +1 -1
  21. package/dist/v2/index.umd.js +21 -8
  22. package/dist/v2/index.umd.js.map +1 -1
  23. package/package.json +6 -6
  24. package/src/components/copilot-provider/__tests__/v1-explicit-threadid-bridge.test.tsx +107 -0
  25. package/src/components/copilot-provider/copilotkit.tsx +6 -1
  26. package/src/context/__tests__/threads-context.test.tsx +116 -3
  27. package/src/context/threads-context.tsx +18 -1
  28. package/src/v2/components/chat/CopilotChat.tsx +19 -8
  29. package/src/v2/components/chat/__tests__/CopilotChat.welcomeGate.test.tsx +186 -0
  30. package/src/v2/providers/CopilotChatConfigurationProvider.tsx +29 -1
  31. package/src/v2/providers/__tests__/CopilotChatConfigurationProvider.test.tsx +106 -0
  32. package/dist/copilotkit-BBYbekCa.mjs.map +0 -1
  33. package/dist/copilotkit-D5JT2Pu3.cjs.map +0 -1
  34. package/dist/copilotkit-DArT2Iuw.d.mts.map +0 -1
  35. package/dist/copilotkit-KEc28l8G.d.cts.map +0 -1
@@ -513,6 +513,112 @@ describe("CopilotChatConfigurationProvider", () => {
513
513
  });
514
514
  });
515
515
 
516
+ /**
517
+ * Regression coverage for the welcome-screen / /connect 404 bug
518
+ * (fix/welcome-not-showing-at-all). `hasExplicitThreadId` distinguishes a
519
+ * caller-chosen thread from a UUID auto-minted inside the provider chain —
520
+ * consumers that only make sense against a real backend thread (/connect,
521
+ * switch-flash suppression) must gate on this signal, not on !!threadId.
522
+ */
523
+ describe("hasExplicitThreadId", () => {
524
+ function ExplicitProbe({ id = "probe" }: { id?: string } = {}) {
525
+ const config = useCopilotChatConfiguration();
526
+ return (
527
+ <div data-testid={`${id}-explicit`}>
528
+ {String(config?.hasExplicitThreadId)}
529
+ </div>
530
+ );
531
+ }
532
+
533
+ it("infers true when threadId prop is supplied and hasExplicitThreadId is omitted", () => {
534
+ render(
535
+ <CopilotChatConfigurationProvider threadId="customer-thread">
536
+ <ExplicitProbe />
537
+ </CopilotChatConfigurationProvider>,
538
+ );
539
+
540
+ expect(screen.getByTestId("probe-explicit").textContent).toBe("true");
541
+ });
542
+
543
+ it("infers false when no threadId prop is supplied and hasExplicitThreadId is omitted", () => {
544
+ render(
545
+ <CopilotChatConfigurationProvider>
546
+ <ExplicitProbe />
547
+ </CopilotChatConfigurationProvider>,
548
+ );
549
+
550
+ expect(screen.getByTestId("probe-explicit").textContent).toBe("false");
551
+ });
552
+
553
+ it("respects hasExplicitThreadId={false} even when a threadId prop is present (v1 bridge case)", () => {
554
+ // The v1 <CopilotKit> wrapper always pipes a UUID through as `threadId`
555
+ // (from ThreadsProvider). Without this override the provider would
556
+ // mis-infer the UUID as explicit, causing /connect to 404 and the
557
+ // welcome screen to stay hidden for fresh empty chats.
558
+ render(
559
+ <CopilotChatConfigurationProvider
560
+ threadId="auto-minted-uuid"
561
+ hasExplicitThreadId={false}
562
+ >
563
+ <ExplicitProbe />
564
+ </CopilotChatConfigurationProvider>,
565
+ );
566
+
567
+ expect(screen.getByTestId("probe-explicit").textContent).toBe("false");
568
+ });
569
+
570
+ it("parent=true overrides child's hasExplicitThreadId={false} via OR inheritance", () => {
571
+ // resolvedHasExplicitThreadId = ownHasExplicit || parentHasExplicit.
572
+ // Once an ancestor has marked the thread as caller-chosen, descendants
573
+ // cannot mask that — pinning the contract so "try to hide explicitness
574
+ // from a child" doesn't silently work.
575
+ render(
576
+ <CopilotChatConfigurationProvider threadId="real-thread">
577
+ <CopilotChatConfigurationProvider
578
+ threadId="other-uuid"
579
+ hasExplicitThreadId={false}
580
+ >
581
+ <ExplicitProbe />
582
+ </CopilotChatConfigurationProvider>
583
+ </CopilotChatConfigurationProvider>,
584
+ );
585
+
586
+ expect(screen.getByTestId("probe-explicit").textContent).toBe("true");
587
+ });
588
+
589
+ it("propagates through a three-level chain where the middle provider is bare", () => {
590
+ // Matches the real stack: outer layout provider (no threadId) →
591
+ // CopilotChat's own provider (no threadId) → inner feature provider
592
+ // (explicit threadId). Explicitness must cross the empty middle.
593
+ render(
594
+ <CopilotChatConfigurationProvider>
595
+ <CopilotChatConfigurationProvider>
596
+ <CopilotChatConfigurationProvider threadId="deeply-picked-thread">
597
+ <ExplicitProbe />
598
+ </CopilotChatConfigurationProvider>
599
+ </CopilotChatConfigurationProvider>
600
+ </CopilotChatConfigurationProvider>,
601
+ );
602
+
603
+ expect(screen.getByTestId("probe-explicit").textContent).toBe("true");
604
+ });
605
+
606
+ it("non-explicit parent does not taint an explicit child", () => {
607
+ render(
608
+ <CopilotChatConfigurationProvider
609
+ threadId="auto-uuid"
610
+ hasExplicitThreadId={false}
611
+ >
612
+ <CopilotChatConfigurationProvider threadId="user-picked">
613
+ <ExplicitProbe />
614
+ </CopilotChatConfigurationProvider>
615
+ </CopilotChatConfigurationProvider>,
616
+ );
617
+
618
+ expect(screen.getByTestId("probe-explicit").textContent).toBe("true");
619
+ });
620
+ });
621
+
516
622
  describe("Nested providers", () => {
517
623
  it("should handle multiple nested providers correctly", () => {
518
624
  render(