def redraw()

in UI/nl2sqlstudio_ui.py [0:0]


def redraw() -> None:
    """
    Trigger the re-rendering of the UI
    """
    cntr = 0
    msg_container = st.session_state.mc

    with msg_container:
        for message in st.session_state.messages:
            logger.info(f"message is: {message}")
            cntr += 1

            with st.chat_message(message["role"]):
                st.markdown(message["content"], unsafe_allow_html=True)

                if message["dataframe"] is not None:
                    visualise_modal = st.session_state.get(
                        f'visualise_modal_{cntr}',
                        Modal("Plot Results", key=f"vm_{cntr}")
                    )
                    st.session_state[f'visualise_modal_{cntr}'] = \
                        visualise_modal

                    cols = st.columns([1, 1, 1, 7])
                    with cols[0]:
                        open_modal = st.button("Default Plotting",
                                               key=f"vr_key_{cntr}")
                    with cols[1]:
                        open_modal_new = st.button(
                            "Custom Plotting", key=f"vru_key_{cntr}")

                    with cols[2]:
                        open_modal_lk = st.button(
                            "Looker Plotting", key=f"vrlk_key_{cntr}")

                    if open_modal or open_modal_new or open_modal_lk:
                        st.session_state[
                            f'v_c_{cntr}'] = (
                                'n' if open_modal else (
                                    'cp' if open_modal_new else 'clk'
                                    )
                                )
                        visualise_modal.open()

                    sql_exec_flag = st.session_state.execution
                    if visualise_modal.is_open() and sql_exec_flag:
                        with visualise_modal.container():
                            if st.session_state.get(f'v_c_{cntr}') == 'n':
                                try:
                                    run_visualization(
                                        message["dataframe"],
                                        False, cntr)
                                except Exception as e:
                                    st.write(
                                        f"Error Loading Plot \
                                        due to error: {str(e)}")
                            elif st.session_state.get(f'v_c_{cntr}') == 'cp':
                                try:
                                    run_visualization(message["dataframe"],
                                                      True, cntr)
                                except Exception as e:
                                    st.write(
                                        f"Error Loading Plot\
                                            due to error: {str(e)}")
                            elif st.session_state.get(f'v_c_{cntr}') == 'clk':
                                try:
                                    look, base_url = create_look_ui()
                                    new_look_id = look.id
                                    embed_url = (f"{base_url}/embed/looks/"
                                                 f"{new_look_id}"
                                                 "?refresh=true")
                                    st.components.v1.iframe(embed_url,
                                                            height=500)
                                except Exception as e:
                                    st.write(
                                        f"Error Loading Plot\
                                            due to error: {str(e)}")
                            if st.button("Close Modal",
                                         key=f"close_vm_key_{cntr}"):
                                st.session_state[
                                    f'v_c_{cntr}'] = None
                                visualise_modal.close()