28 lines
695 B
TypeScript
28 lines
695 B
TypeScript
"use client";
|
|
|
|
import type { ExportedMessageRepository } from "@assistant-ui/core";
|
|
import { createContext, useContext } from "react";
|
|
|
|
type ClawSessionReplayContextValue = {
|
|
replaySession: (
|
|
sessionId: string,
|
|
repository: ExportedMessageRepository,
|
|
) => void;
|
|
clearSession: () => void;
|
|
};
|
|
|
|
const ClawSessionReplayContext =
|
|
createContext<ClawSessionReplayContextValue | null>(null);
|
|
|
|
export const ClawSessionReplayProvider = ClawSessionReplayContext.Provider;
|
|
|
|
export function useClawSessionReplay() {
|
|
const value = useContext(ClawSessionReplayContext);
|
|
if (!value) {
|
|
throw new Error(
|
|
"useClawSessionReplay must be used within ClawSessionReplayProvider",
|
|
);
|
|
}
|
|
return value;
|
|
}
|