@assistant-ui/react
Version:
Open-source TypeScript/React library for building production-grade AI chat experiences
37 lines (32 loc) • 938 B
text/typescript
"use client";
import { useCallback } from "react";
import { useComposerResume as useComposerResumeBehavior } from "@assistant-ui/core/react";
import {
createActionButton,
type ActionButtonElement,
type ActionButtonProps,
} from "../../utils/createActionButton";
const useComposerResume = () => {
const { disabled, resume } = useComposerResumeBehavior();
const callback = useCallback(() => resume(), [resume]);
if (disabled) return null;
return callback;
};
export namespace ComposerPrimitiveResume {
export type Element = ActionButtonElement;
export type Props = ActionButtonProps<typeof useComposerResume>;
}
/**
* Resumes an interrupted run when its adapter explicitly reports a checkpoint.
*
* @example
* ```tsx
* <ComposerPrimitive.Resume>
* Resume
* </ComposerPrimitive.Resume>
* ```
*/
export const ComposerPrimitiveResume = createActionButton(
"ComposerPrimitive.Resume",
useComposerResume,
);