import { createContext, useContext, useMemo, type JSX, type PropsWithChildren } from "react"; import type { AgentVisibleErrorOverrides, AgentVisibleErrorPresentationScope } from "../agentEnv/agentErrorPresentation"; interface AgentVisibleErrorPresentationContextValue { overrides: AgentVisibleErrorOverrides | null; scope: AgentVisibleErrorPresentationScope; } const AgentVisibleErrorPresentationContext = createContext({ overrides: null, scope: "local_owner" }); export function AgentVisibleErrorPresentationProvider({ children, scope = "local_owner", value }: PropsWithChildren<{ scope?: AgentVisibleErrorPresentationScope; value?: AgentVisibleErrorOverrides | null; }>): JSX.Element { const contextValue = useMemo( () => ({ overrides: value ?? null, scope }), [scope, value] ); return ( {children} ); } export function useAgentVisibleErrorPresentation(): AgentVisibleErrorPresentationContextValue { return useContext(AgentVisibleErrorPresentationContext); }