@copilotkitnext/react 0.0.21-alpha.0 → 0.0.22-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1910,30 +1910,22 @@ var import_react10 = require("react");
1910
1910
  var import_react11 = __toESM(require("react"));
1911
1911
  function useHumanInTheLoop(tool) {
1912
1912
  const { copilotkit } = useCopilotKit();
1913
- const [status, setStatus] = (0, import_react10.useState)(
1914
- "inProgress"
1915
- );
1916
- const statusRef = (0, import_react10.useRef)(status);
1917
1913
  const resolvePromiseRef = (0, import_react10.useRef)(null);
1918
- statusRef.current = status;
1919
1914
  const respond = (0, import_react10.useCallback)(async (result) => {
1920
1915
  if (resolvePromiseRef.current) {
1921
1916
  resolvePromiseRef.current(result);
1922
- setStatus("complete");
1923
1917
  resolvePromiseRef.current = null;
1924
1918
  }
1925
1919
  }, []);
1926
1920
  const handler = (0, import_react10.useCallback)(async () => {
1927
1921
  return new Promise((resolve) => {
1928
- setStatus("executing");
1929
1922
  resolvePromiseRef.current = resolve;
1930
1923
  });
1931
1924
  }, []);
1932
1925
  const RenderComponent = (0, import_react10.useCallback)(
1933
1926
  (props) => {
1934
1927
  const ToolComponent = tool.render;
1935
- const currentStatus = statusRef.current;
1936
- if (currentStatus === "inProgress" && props.status === "inProgress") {
1928
+ if (props.status === "inProgress") {
1937
1929
  const enhancedProps = {
1938
1930
  ...props,
1939
1931
  name: tool.name,
@@ -1941,7 +1933,7 @@ function useHumanInTheLoop(tool) {
1941
1933
  respond: void 0
1942
1934
  };
1943
1935
  return import_react11.default.createElement(ToolComponent, enhancedProps);
1944
- } else if (currentStatus === "executing" && props.status === "executing") {
1936
+ } else if (props.status === "executing") {
1945
1937
  const enhancedProps = {
1946
1938
  ...props,
1947
1939
  name: tool.name,
@@ -1949,7 +1941,7 @@ function useHumanInTheLoop(tool) {
1949
1941
  respond
1950
1942
  };
1951
1943
  return import_react11.default.createElement(ToolComponent, enhancedProps);
1952
- } else if (currentStatus === "complete" && props.status === "complete") {
1944
+ } else if (props.status === "complete") {
1953
1945
  const enhancedProps = {
1954
1946
  ...props,
1955
1947
  name: tool.name,