Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
import { createContext, useContext, useEffect, type ReactNode } from "react";
import type { ReplyPlaybackSession } from "@akeru/client-runtime/reply-playback";
import { useWebReplyPlaybackSession } from "~/lib/replyPlaybackSession";
const ReplyPlaybackContext = createContext<ReplyPlaybackSession | null>(null);
export function ReplyPlaybackProvider({ children }: { readonly children: ReactNode }) {
const session = useWebReplyPlaybackSession();
useEffect(() => {
void session.preference.load();
return () => session.dispose();
}, [session]);
return <ReplyPlaybackContext value={session}>{children}</ReplyPlaybackContext>;
}
export function useReplyPlayback() {
const session = useContext(ReplyPlaybackContext);
if (!session) throw new Error("Reply playback must be inside ReplyPlaybackProvider.");
return session;
}
export function useOptionalReplyPlayback() {
return useContext(ReplyPlaybackContext);
}