def METHOD_NAME(metadata: WidgetMetadata[Any]) -> None:
    """Save a widget's metadata to a thread-local callstack, so the widget
    can be registered again when that widget is replayed.
    """
    CACHE_DATA_MESSAGE_REPLAY_CTX.METHOD_NAME(metadata)
    CACHE_RESOURCE_MESSAGE_REPLAY_CTX.METHOD_NAME(metadata)