Streamlit-aggrid not saving updates to table

Hello -

I’m trying to create an aggrid table that will retain its values in an st.session_state variable. However, every other value I enter into the table doesn’t save effectively. It reverts to the prior value. Can someone take a look at the simplified code below and let me know what might be happening?

import streamlit as st
import pandas as pd
from st_aggrid import AgGrid, GridUpdateMode

# Initial dataframe
initial_data = {
    "Values": ["Value A", "Value B", "Value C"],
    "Types": ["Type 1", "Type 2", "Type 3"],
    "Categories": ["Category 1", "Category 2", "Category 3"],
}

# Convert to DataFrame
df = pd.DataFrame(initial_data)

# Initialize session_state if not already initialized
if "Saved Table" not in st.session_state:
    st.session_state["Saved Table"] = df.copy()


# Grid options
grid_options = {
    "columnDefs": [
        {"headerName": "Values", "field": "Values", "editable": True},
        {"headerName": "Types", "field": "Types", "editable": True},
        {"headerName": "Categories", "field": "Categories", "editable": True},
    ],
}

# AgGrid display
grid_response = AgGrid(
    st.session_state["Saved Table"],  # Use session_state for persistent data
    gridOptions=grid_options,
    theme="streamlit",
)

# Convert DataFrames to have the same index and column labels before comparing
grid_data = pd.DataFrame(grid_response["data"])
st.session_state["Saved Table"] = grid_data