@copilotkitnext/react 0.0.28 → 0.0.29

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/index.mjs CHANGED
@@ -1378,7 +1378,7 @@ import "katex/dist/katex.min.css";
1378
1378
  import { Streamdown } from "streamdown";
1379
1379
 
1380
1380
  // src/hooks/use-render-tool-call.tsx
1381
- import React6, { useCallback as useCallback2, useEffect as useEffect5, useMemo as useMemo4, useState as useState4, useSyncExternalStore } from "react";
1381
+ import React6, { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo4, useState as useState4, useSyncExternalStore } from "react";
1382
1382
  import { ToolCallStatus } from "@copilotkitnext/core";
1383
1383
 
1384
1384
  // src/providers/CopilotKitProvider.tsx
@@ -1386,9 +1386,9 @@ import {
1386
1386
  createContext as createContext2,
1387
1387
  useContext as useContext2,
1388
1388
  useMemo as useMemo3,
1389
- useEffect as useEffect4,
1389
+ useEffect as useEffect3,
1390
1390
  useReducer,
1391
- useRef as useRef4,
1391
+ useRef as useRef3,
1392
1392
  useState as useState3
1393
1393
  } from "react";
1394
1394
  import { z } from "zod";
@@ -1438,36 +1438,23 @@ var CopilotKitCoreReact = class extends CopilotKitCore {
1438
1438
  // src/components/CopilotKitInspector.tsx
1439
1439
  import * as React4 from "react";
1440
1440
  import { createComponent } from "@lit-labs/react";
1441
- import {
1442
- WEB_INSPECTOR_TAG,
1443
- WebInspectorElement,
1444
- defineWebInspector
1445
- } from "@copilotkitnext/web-inspector";
1446
1441
  import { jsx as jsx7 } from "react/jsx-runtime";
1447
- defineWebInspector();
1448
- var CopilotKitInspectorBase = createComponent({
1449
- tagName: WEB_INSPECTOR_TAG,
1450
- elementClass: WebInspectorElement,
1451
- react: React4
1452
- });
1453
- var CopilotKitInspector = React4.forwardRef(
1454
- ({ core, ...rest }, ref) => {
1455
- const innerRef = React4.useRef(null);
1456
- React4.useImperativeHandle(ref, () => innerRef.current, []);
1457
- React4.useEffect(() => {
1458
- if (innerRef.current) {
1459
- innerRef.current.core = core ?? null;
1460
- }
1461
- }, [core]);
1462
- return /* @__PURE__ */ jsx7(
1463
- CopilotKitInspectorBase,
1464
- {
1465
- ...rest,
1466
- ref: innerRef
1467
- }
1468
- );
1442
+ var CopilotKitInspectorBase = React4.lazy(() => {
1443
+ if (typeof window === "undefined") {
1444
+ const NullComponent = () => null;
1445
+ return Promise.resolve({ default: NullComponent });
1469
1446
  }
1470
- );
1447
+ return import("@copilotkitnext/web-inspector").then((mod) => {
1448
+ mod.defineWebInspector?.();
1449
+ const Component = createComponent({
1450
+ tagName: mod.WEB_INSPECTOR_TAG,
1451
+ elementClass: mod.WebInspectorElement,
1452
+ react: React4
1453
+ });
1454
+ return { default: Component };
1455
+ });
1456
+ });
1457
+ var CopilotKitInspector = ({ core, ...rest }) => /* @__PURE__ */ jsx7(React4.Suspense, { fallback: null, children: /* @__PURE__ */ jsx7(CopilotKitInspectorBase, { ...rest, core: core ?? null }) });
1471
1458
  CopilotKitInspector.displayName = "CopilotKitInspector";
1472
1459
 
1473
1460
  // src/providers/CopilotKitProvider.tsx
@@ -1478,8 +1465,8 @@ var CopilotKitContext = createContext2({
1478
1465
  function useStableArrayProp(prop, warningMessage, isMeaningfulChange) {
1479
1466
  const empty = useMemo3(() => [], []);
1480
1467
  const value = prop ?? empty;
1481
- const initial = useRef4(value);
1482
- useEffect4(() => {
1468
+ const initial = useRef3(value);
1469
+ useEffect3(() => {
1483
1470
  if (warningMessage && value !== initial.current && (isMeaningfulChange ? isMeaningfulChange(initial.current, value) : true)) {
1484
1471
  console.error(warningMessage);
1485
1472
  }
@@ -1501,7 +1488,7 @@ var CopilotKitProvider = ({
1501
1488
  useSingleEndpoint = false
1502
1489
  }) => {
1503
1490
  const [shouldRenderInspector, setShouldRenderInspector] = useState3(false);
1504
- useEffect4(() => {
1491
+ useEffect3(() => {
1505
1492
  if (typeof window === "undefined") {
1506
1493
  return;
1507
1494
  }
@@ -1614,7 +1601,7 @@ var CopilotKitProvider = ({
1614
1601
  return copilotkit2;
1615
1602
  }, [allTools, allRenderToolCalls, renderActivityMessagesList, renderCustomMessagesList, useSingleEndpoint]);
1616
1603
  const [, forceUpdate] = useReducer((x) => x + 1, 0);
1617
- useEffect4(() => {
1604
+ useEffect3(() => {
1618
1605
  const subscription = copilotkit.subscribe({
1619
1606
  onRenderToolCallsChanged: () => {
1620
1607
  forceUpdate();
@@ -1624,7 +1611,7 @@ var CopilotKitProvider = ({
1624
1611
  subscription.unsubscribe();
1625
1612
  };
1626
1613
  }, [copilotkit]);
1627
- useEffect4(() => {
1614
+ useEffect3(() => {
1628
1615
  copilotkit.setRuntimeUrl(runtimeUrl);
1629
1616
  copilotkit.setRuntimeTransport(useSingleEndpoint ? "single" : "rest");
1630
1617
  copilotkit.setHeaders(headers);
@@ -1650,7 +1637,7 @@ var useCopilotKit = () => {
1650
1637
  if (!context) {
1651
1638
  throw new Error("useCopilotKit must be used within CopilotKitProvider");
1652
1639
  }
1653
- useEffect4(() => {
1640
+ useEffect3(() => {
1654
1641
  const subscription = context.copilotkit.subscribe({
1655
1642
  onRuntimeConnectionStatusChanged: () => {
1656
1643
  forceUpdate();
@@ -1738,7 +1725,7 @@ function useRenderToolCall() {
1738
1725
  () => copilotkit.renderToolCalls,
1739
1726
  () => copilotkit.renderToolCalls
1740
1727
  );
1741
- useEffect5(() => {
1728
+ useEffect4(() => {
1742
1729
  const subscription = copilotkit.subscribe({
1743
1730
  onToolExecutionStart: ({ toolCallId }) => {
1744
1731
  setExecutingToolCallIds((prev) => {
@@ -1894,12 +1881,12 @@ function useRenderActivityMessage() {
1894
1881
  }
1895
1882
 
1896
1883
  // src/hooks/use-frontend-tool.tsx
1897
- import { useEffect as useEffect6 } from "react";
1884
+ import { useEffect as useEffect5 } from "react";
1898
1885
  var EMPTY_DEPS = [];
1899
1886
  function useFrontendTool(tool, deps) {
1900
1887
  const { copilotkit } = useCopilotKit();
1901
1888
  const extraDeps = deps ?? EMPTY_DEPS;
1902
- useEffect6(() => {
1889
+ useEffect5(() => {
1903
1890
  const name = tool.name;
1904
1891
  if (copilotkit.getTool({ toolName: name, agentId: tool.agentId })) {
1905
1892
  console.warn(
@@ -1931,11 +1918,11 @@ function useFrontendTool(tool, deps) {
1931
1918
  }
1932
1919
 
1933
1920
  // src/hooks/use-human-in-the-loop.tsx
1934
- import { useCallback as useCallback4, useRef as useRef5, useEffect as useEffect7 } from "react";
1921
+ import { useCallback as useCallback4, useRef as useRef4, useEffect as useEffect6 } from "react";
1935
1922
  import React7 from "react";
1936
1923
  function useHumanInTheLoop(tool, deps) {
1937
1924
  const { copilotkit } = useCopilotKit();
1938
- const resolvePromiseRef = useRef5(null);
1925
+ const resolvePromiseRef = useRef4(null);
1939
1926
  const respond = useCallback4(async (result) => {
1940
1927
  if (resolvePromiseRef.current) {
1941
1928
  resolvePromiseRef.current(result);
@@ -1985,7 +1972,7 @@ function useHumanInTheLoop(tool, deps) {
1985
1972
  render: RenderComponent
1986
1973
  };
1987
1974
  useFrontendTool(frontendTool, deps);
1988
- useEffect7(() => {
1975
+ useEffect6(() => {
1989
1976
  return () => {
1990
1977
  const keyOf = (rc) => `${rc.agentId ?? ""}:${rc.name}`;
1991
1978
  const currentRenderToolCalls = copilotkit.renderToolCalls;
@@ -1998,7 +1985,7 @@ function useHumanInTheLoop(tool, deps) {
1998
1985
  }
1999
1986
 
2000
1987
  // src/hooks/use-agent.tsx
2001
- import { useMemo as useMemo5, useEffect as useEffect8, useReducer as useReducer2 } from "react";
1988
+ import { useMemo as useMemo5, useEffect as useEffect7, useReducer as useReducer2 } from "react";
2002
1989
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID4 } from "@copilotkitnext/shared";
2003
1990
  import { ProxiedCopilotRuntimeAgent, CopilotKitCoreRuntimeConnectionStatus } from "@copilotkitnext/core";
2004
1991
  var ALL_UPDATES = [
@@ -2044,7 +2031,7 @@ function useAgent({ agentId, updates } = {}) {
2044
2031
  JSON.stringify(copilotkit.headers),
2045
2032
  copilotkit
2046
2033
  ]);
2047
- useEffect8(() => {
2034
+ useEffect7(() => {
2048
2035
  if (updateFlags.length === 0) {
2049
2036
  return;
2050
2037
  }
@@ -2079,7 +2066,7 @@ function useAgent({ agentId, updates } = {}) {
2079
2066
  }
2080
2067
 
2081
2068
  // src/hooks/use-agent-context.tsx
2082
- import { useEffect as useEffect9, useMemo as useMemo6 } from "react";
2069
+ import { useEffect as useEffect8, useMemo as useMemo6 } from "react";
2083
2070
  function useAgentContext(context) {
2084
2071
  const { description, value } = context;
2085
2072
  const { copilotkit } = useCopilotKit();
@@ -2089,7 +2076,7 @@ function useAgentContext(context) {
2089
2076
  }
2090
2077
  return JSON.stringify(value);
2091
2078
  }, [value]);
2092
- useEffect9(() => {
2079
+ useEffect8(() => {
2093
2080
  if (!copilotkit) return;
2094
2081
  const id = copilotkit.addContext({ description, value: stringValue });
2095
2082
  return () => {
@@ -2099,7 +2086,7 @@ function useAgentContext(context) {
2099
2086
  }
2100
2087
 
2101
2088
  // src/hooks/use-suggestions.tsx
2102
- import { useCallback as useCallback5, useEffect as useEffect10, useMemo as useMemo7, useState as useState5 } from "react";
2089
+ import { useCallback as useCallback5, useEffect as useEffect9, useMemo as useMemo7, useState as useState5 } from "react";
2103
2090
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID5 } from "@copilotkitnext/shared";
2104
2091
  function useSuggestions({ agentId } = {}) {
2105
2092
  const { copilotkit } = useCopilotKit();
@@ -2113,12 +2100,12 @@ function useSuggestions({ agentId } = {}) {
2113
2100
  const result = copilotkit.getSuggestions(resolvedAgentId);
2114
2101
  return result.isLoading;
2115
2102
  });
2116
- useEffect10(() => {
2103
+ useEffect9(() => {
2117
2104
  const result = copilotkit.getSuggestions(resolvedAgentId);
2118
2105
  setSuggestions(result.suggestions);
2119
2106
  setIsLoading(result.isLoading);
2120
2107
  }, [copilotkit, resolvedAgentId]);
2121
- useEffect10(() => {
2108
+ useEffect9(() => {
2122
2109
  const subscription = copilotkit.subscribe({
2123
2110
  onSuggestionsChanged: ({ agentId: changedAgentId, suggestions: suggestions2 }) => {
2124
2111
  if (changedAgentId !== resolvedAgentId) {
@@ -2163,7 +2150,7 @@ function useSuggestions({ agentId } = {}) {
2163
2150
  }
2164
2151
 
2165
2152
  // src/hooks/use-configure-suggestions.tsx
2166
- import { useCallback as useCallback6, useEffect as useEffect11, useMemo as useMemo8, useRef as useRef6 } from "react";
2153
+ import { useCallback as useCallback6, useEffect as useEffect10, useMemo as useMemo8, useRef as useRef5 } from "react";
2167
2154
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID6 } from "@copilotkitnext/shared";
2168
2155
  function useConfigureSuggestions(config, deps) {
2169
2156
  const { copilotkit } = useCopilotKit();
@@ -2171,7 +2158,7 @@ function useConfigureSuggestions(config, deps) {
2171
2158
  const extraDeps = deps ?? [];
2172
2159
  const resolvedConsumerAgentId = useMemo8(() => chatConfig?.agentId ?? DEFAULT_AGENT_ID6, [chatConfig?.agentId]);
2173
2160
  const rawConsumerAgentId = useMemo8(() => config ? config.consumerAgentId : void 0, [config]);
2174
- const normalizationCacheRef = useRef6({
2161
+ const normalizationCacheRef = useRef5({
2175
2162
  serialized: null,
2176
2163
  config: null
2177
2164
  });
@@ -2205,9 +2192,9 @@ function useConfigureSuggestions(config, deps) {
2205
2192
  normalizationCacheRef.current = { serialized, config: built };
2206
2193
  return { normalizedConfig: built, serializedConfig: serialized };
2207
2194
  }, [config, resolvedConsumerAgentId, ...extraDeps]);
2208
- const latestConfigRef = useRef6(null);
2195
+ const latestConfigRef = useRef5(null);
2209
2196
  latestConfigRef.current = normalizedConfig;
2210
- const previousSerializedConfigRef = useRef6(null);
2197
+ const previousSerializedConfigRef = useRef5(null);
2211
2198
  const targetAgentId = useMemo8(() => {
2212
2199
  if (!normalizedConfig) {
2213
2200
  return resolvedConsumerAgentId;
@@ -2241,7 +2228,7 @@ function useConfigureSuggestions(config, deps) {
2241
2228
  }
2242
2229
  copilotkit.reloadSuggestions(targetAgentId);
2243
2230
  }, [copilotkit, isGlobalConfig, normalizedConfig, targetAgentId]);
2244
- useEffect11(() => {
2231
+ useEffect10(() => {
2245
2232
  if (!serializedConfig || !latestConfigRef.current) {
2246
2233
  return;
2247
2234
  }
@@ -2251,7 +2238,7 @@ function useConfigureSuggestions(config, deps) {
2251
2238
  copilotkit.removeSuggestionsConfig(id);
2252
2239
  };
2253
2240
  }, [copilotkit, serializedConfig, requestReload]);
2254
- useEffect11(() => {
2241
+ useEffect10(() => {
2255
2242
  if (!normalizedConfig) {
2256
2243
  previousSerializedConfigRef.current = null;
2257
2244
  return;
@@ -2264,7 +2251,7 @@ function useConfigureSuggestions(config, deps) {
2264
2251
  }
2265
2252
  requestReload();
2266
2253
  }, [normalizedConfig, requestReload, serializedConfig]);
2267
- useEffect11(() => {
2254
+ useEffect10(() => {
2268
2255
  if (!normalizedConfig || extraDeps.length === 0) {
2269
2256
  return;
2270
2257
  }
@@ -3115,13 +3102,13 @@ CopilotChatMessageView.Cursor = function Cursor({ className, ...props }) {
3115
3102
  var CopilotChatMessageView_default = CopilotChatMessageView;
3116
3103
 
3117
3104
  // src/components/chat/CopilotChatView.tsx
3118
- import React12, { useRef as useRef7, useState as useState9, useEffect as useEffect13 } from "react";
3105
+ import React12, { useRef as useRef6, useState as useState9, useEffect as useEffect12 } from "react";
3119
3106
  import { twMerge as twMerge7 } from "tailwind-merge";
3120
3107
  import { StickToBottom, useStickToBottom, useStickToBottomContext } from "use-stick-to-bottom";
3121
3108
  import { ChevronDown } from "lucide-react";
3122
3109
 
3123
3110
  // src/hooks/use-keyboard-height.tsx
3124
- import { useState as useState8, useEffect as useEffect12 } from "react";
3111
+ import { useState as useState8, useEffect as useEffect11 } from "react";
3125
3112
  function useKeyboardHeight() {
3126
3113
  const [keyboardState, setKeyboardState] = useState8({
3127
3114
  isKeyboardOpen: false,
@@ -3129,7 +3116,7 @@ function useKeyboardHeight() {
3129
3116
  availableHeight: typeof window !== "undefined" ? window.innerHeight : 0,
3130
3117
  viewportHeight: typeof window !== "undefined" ? window.innerHeight : 0
3131
3118
  });
3132
- useEffect12(() => {
3119
+ useEffect11(() => {
3133
3120
  if (typeof window === "undefined") {
3134
3121
  return;
3135
3122
  }
@@ -3182,12 +3169,12 @@ function CopilotChatView({
3182
3169
  className,
3183
3170
  ...props
3184
3171
  }) {
3185
- const inputContainerRef = useRef7(null);
3172
+ const inputContainerRef = useRef6(null);
3186
3173
  const [inputContainerHeight, setInputContainerHeight] = useState9(0);
3187
3174
  const [isResizing, setIsResizing] = useState9(false);
3188
- const resizeTimeoutRef = useRef7(null);
3175
+ const resizeTimeoutRef = useRef6(null);
3189
3176
  const { isKeyboardOpen, keyboardHeight, availableHeight } = useKeyboardHeight();
3190
- useEffect13(() => {
3177
+ useEffect12(() => {
3191
3178
  const element = inputContainerRef.current;
3192
3179
  if (!element) return;
3193
3180
  const resizeObserver = new ResizeObserver((entries) => {
@@ -3299,10 +3286,10 @@ function CopilotChatView({
3299
3286
  const [hasMounted, setHasMounted] = useState9(false);
3300
3287
  const { scrollRef, contentRef, scrollToBottom } = useStickToBottom();
3301
3288
  const [showScrollButton, setShowScrollButton] = useState9(false);
3302
- useEffect13(() => {
3289
+ useEffect12(() => {
3303
3290
  setHasMounted(true);
3304
3291
  }, []);
3305
- useEffect13(() => {
3292
+ useEffect12(() => {
3306
3293
  if (autoScroll) return;
3307
3294
  const scrollElement = scrollRef.current;
3308
3295
  if (!scrollElement) return;
@@ -3434,7 +3421,7 @@ var CopilotChatView_default = CopilotChatView;
3434
3421
 
3435
3422
  // src/components/chat/CopilotChat.tsx
3436
3423
  import { DEFAULT_AGENT_ID as DEFAULT_AGENT_ID7, randomUUID as randomUUID2 } from "@copilotkitnext/shared";
3437
- import { useCallback as useCallback7, useEffect as useEffect14, useMemo as useMemo10 } from "react";
3424
+ import { useCallback as useCallback7, useEffect as useEffect13, useMemo as useMemo10 } from "react";
3438
3425
  import { merge } from "ts-deepmerge";
3439
3426
  import { AGUIConnectNotImplementedError } from "@ag-ui/client";
3440
3427
  import { jsx as jsx19 } from "react/jsx-runtime";
@@ -3454,7 +3441,7 @@ function CopilotChat({ agentId, threadId, labels, chatView, isModalDefaultOpen,
3454
3441
  suggestionView: providedSuggestionView,
3455
3442
  ...restProps
3456
3443
  } = props;
3457
- useEffect14(() => {
3444
+ useEffect13(() => {
3458
3445
  const connect = async (agent2) => {
3459
3446
  try {
3460
3447
  await copilotkit.connectAgent({ agent: agent2 });
@@ -3673,7 +3660,7 @@ CopilotChatToggleButton.displayName = "CopilotChatToggleButton";
3673
3660
  var CopilotChatToggleButton_default = CopilotChatToggleButton;
3674
3661
 
3675
3662
  // src/components/chat/CopilotSidebarView.tsx
3676
- import { useEffect as useEffect15, useRef as useRef8, useState as useState11 } from "react";
3663
+ import { useEffect as useEffect14, useRef as useRef7, useState as useState11 } from "react";
3677
3664
 
3678
3665
  // src/components/chat/CopilotModalHeader.tsx
3679
3666
  import { useCallback as useCallback8 } from "react";
@@ -3766,7 +3753,7 @@ var SIDEBAR_TRANSITION_MS = 260;
3766
3753
  function CopilotSidebarView({ header, width, ...props }) {
3767
3754
  const configuration = useCopilotChatConfiguration();
3768
3755
  const isSidebarOpen = configuration?.isModalOpen ?? false;
3769
- const sidebarRef = useRef8(null);
3756
+ const sidebarRef = useRef7(null);
3770
3757
  const [sidebarWidth, setSidebarWidth] = useState11(width ?? DEFAULT_SIDEBAR_WIDTH);
3771
3758
  const widthToCss = (w) => {
3772
3759
  return typeof w === "number" ? `${w}px` : w;
@@ -3777,7 +3764,7 @@ function CopilotSidebarView({ header, width, ...props }) {
3777
3764
  }
3778
3765
  return w;
3779
3766
  };
3780
- useEffect15(() => {
3767
+ useEffect14(() => {
3781
3768
  if (width !== void 0) {
3782
3769
  return;
3783
3770
  }
@@ -3856,7 +3843,7 @@ function CopilotSidebarView({ header, width, ...props }) {
3856
3843
  CopilotSidebarView.displayName = "CopilotSidebarView";
3857
3844
 
3858
3845
  // src/components/chat/CopilotPopupView.tsx
3859
- import { useEffect as useEffect16, useMemo as useMemo11, useRef as useRef9, useState as useState12 } from "react";
3846
+ import { useEffect as useEffect15, useMemo as useMemo11, useRef as useRef8, useState as useState12 } from "react";
3860
3847
  import { Fragment as Fragment8, jsx as jsx23, jsxs as jsxs14 } from "react/jsx-runtime";
3861
3848
  var DEFAULT_POPUP_WIDTH = 420;
3862
3849
  var DEFAULT_POPUP_HEIGHT = 560;
@@ -3881,10 +3868,10 @@ function CopilotPopupView({
3881
3868
  const isPopupOpen = configuration?.isModalOpen ?? false;
3882
3869
  const setModalOpen = configuration?.setModalOpen;
3883
3870
  const labels = configuration?.labels ?? CopilotChatDefaultLabels;
3884
- const containerRef = useRef9(null);
3871
+ const containerRef = useRef8(null);
3885
3872
  const [isRendered, setIsRendered] = useState12(isPopupOpen);
3886
3873
  const [isAnimatingOut, setIsAnimatingOut] = useState12(false);
3887
- useEffect16(() => {
3874
+ useEffect15(() => {
3888
3875
  if (isPopupOpen) {
3889
3876
  setIsRendered(true);
3890
3877
  setIsAnimatingOut(false);
@@ -3900,7 +3887,7 @@ function CopilotPopupView({
3900
3887
  }, 200);
3901
3888
  return () => clearTimeout(timeout);
3902
3889
  }, [isPopupOpen, isRendered]);
3903
- useEffect16(() => {
3890
+ useEffect15(() => {
3904
3891
  if (!isPopupOpen) {
3905
3892
  return;
3906
3893
  }
@@ -3916,7 +3903,7 @@ function CopilotPopupView({
3916
3903
  window.addEventListener("keydown", handleKeyDown);
3917
3904
  return () => window.removeEventListener("keydown", handleKeyDown);
3918
3905
  }, [isPopupOpen, setModalOpen]);
3919
- useEffect16(() => {
3906
+ useEffect15(() => {
3920
3907
  if (!isPopupOpen) {
3921
3908
  return;
3922
3909
  }
@@ -3925,7 +3912,7 @@ function CopilotPopupView({
3925
3912
  }, 200);
3926
3913
  return () => clearTimeout(focusTimer);
3927
3914
  }, [isPopupOpen]);
3928
- useEffect16(() => {
3915
+ useEffect15(() => {
3929
3916
  if (!isPopupOpen || !clickOutsideToClose) {
3930
3917
  return;
3931
3918
  }