@copilotkit/web-inspector 1.57.4 → 1.58.0-canary.thread-id-propagation

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/web-inspector",
3
- "version": "1.57.4",
3
+ "version": "1.58.0-canary.thread-id-propagation",
4
4
  "description": "Lit-based web component for the CopilotKit web inspector",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,7 +27,7 @@
27
27
  "lit": "^3.2.0",
28
28
  "lucide": "^0.525.0",
29
29
  "marked": "^12.0.2",
30
- "@copilotkit/core": "1.57.4"
30
+ "@copilotkit/core": "1.58.0-canary.thread-id-propagation"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@tailwindcss/cli": "^4.1.11",
package/vitest.config.ts CHANGED
@@ -5,6 +5,7 @@ export default defineConfig({
5
5
  environment: "jsdom",
6
6
  globals: true,
7
7
  clearMocks: true,
8
+ setupFiles: ["./vitest.setup.ts"],
8
9
  reporters: [["default", { summary: false }]],
9
10
  silent: true,
10
11
  },
@@ -0,0 +1,76 @@
1
+ // Node 25 ships an experimental built-in `localStorage` global (gated on the
2
+ // `--localstorage-file` flag, but the accessor exists unconditionally). When
3
+ // vitest boots the jsdom environment, jsdom defines its own `localStorage` on
4
+ // the synthetic `window`, but Node's global accessor still wins on
5
+ // `globalThis.localStorage` AND — because vitest's jsdom integration aliases
6
+ // `window` to `globalThis` — also on `window.localStorage`. The result is that
7
+ // `window.localStorage` resolves to Node's stub object which has no `clear`,
8
+ // `setItem`, `removeItem`, etc., breaking every test that touches localStorage.
9
+ //
10
+ // This setup file installs a proper in-memory Storage implementation on both
11
+ // `globalThis` and `window` BEFORE any test code runs. The shim is a plain
12
+ // object (not a class) so `vi.spyOn(window.localStorage, "getItem")` works —
13
+ // vitest needs the methods to be own properties on the spied target.
14
+ //
15
+ // We re-install the shim in `beforeEach` so a test that did
16
+ // `vi.restoreAllMocks()` (which restores spied methods) still sees the shim's
17
+ // methods, and so each test starts with a fresh empty store.
18
+
19
+ import { beforeEach } from "vitest";
20
+
21
+ function createStorageShim(): Storage {
22
+ const store = new Map<string, string>();
23
+ const shim = {
24
+ get length() {
25
+ return store.size;
26
+ },
27
+ key(index: number): string | null {
28
+ return Array.from(store.keys())[index] ?? null;
29
+ },
30
+ getItem(key: string): string | null {
31
+ return store.has(key) ? store.get(key)! : null;
32
+ },
33
+ setItem(key: string, value: string): void {
34
+ store.set(String(key), String(value));
35
+ },
36
+ removeItem(key: string): void {
37
+ store.delete(key);
38
+ },
39
+ clear(): void {
40
+ store.clear();
41
+ },
42
+ } as Storage;
43
+ return shim;
44
+ }
45
+
46
+ function installLocalStorageShim(): void {
47
+ const shim = createStorageShim();
48
+ // Override the Node 25 global accessor (and any jsdom accessor) with a
49
+ // plain data property pointing at our shim. `configurable: true` so a
50
+ // subsequent install can replace it.
51
+ Object.defineProperty(globalThis, "localStorage", {
52
+ value: shim,
53
+ writable: true,
54
+ configurable: true,
55
+ enumerable: true,
56
+ });
57
+ if (typeof window !== "undefined" && window !== (globalThis as unknown)) {
58
+ Object.defineProperty(window, "localStorage", {
59
+ value: shim,
60
+ writable: true,
61
+ configurable: true,
62
+ enumerable: true,
63
+ });
64
+ }
65
+ }
66
+
67
+ // Install once at module load so any top-level code in test files (e.g.
68
+ // imports that read localStorage on init) sees the shim.
69
+ installLocalStorageShim();
70
+
71
+ // Re-install before each test so `vi.restoreAllMocks()` from a prior test
72
+ // can't leave behind spied/replaced methods, and each test starts with an
73
+ // empty store.
74
+ beforeEach(() => {
75
+ installLocalStorageShim();
76
+ });