i have display_test_scenarios which displays a streamlit widget that allows the user to select test scenarios. this function is tightly coupled with session_state and main function. how can i remove these coupling from the function?
...

def display_test_scenarios():
    stc.markdown("Test scenarios", font_size="25px", font_weight="bold")
    with st.container(height=400, border=False):
        selected_scenarios = stc.multiselect(
            title="select test cases",
            options=st.session_state.app.test_cases,
            default=st.session_state.app.selected_scenarios,
        )
    codes_button = stc.st_button("Generate test codes", "codes_button", "right")
    if codes_button:
        st.session_state.app.update(selected_scenarios=selected_scenarios)
        with stc.LottieAnimation("assets/Animation-1724036221793.json", "Generating Code"):
            st.session_state.app.generate_results(step="code_generation")
        st.rerun()
        
def main():
    
    if "app" not in st.session_state:
        st.session_state.app = AppManager()
        
    inputs_col, scenarios_col = st.columns(2, gap="large", vertical_alignment="top")

    with inputs_col:
        repo_url_col, lanuage_col = st.columns([0.7, 0.3], gap="small")
        repo_url = repo_url_col.text_input("Enter BitBucket repo link here:", value=st.session_state.app.repo_url)
        language = lanuage_col.selectbox("Language", options=["Python", "Java"], index=0)
        repo_cloned = handle_repo_url(repo_url)
            
        file_selection_col, method_selection_col = st.columns([0.5, 0.5], gap="small")

        if repo_cloned:
            repo_tree_data = make_repo_tree_structure(st.session_state.app.repo_path)
            disabled_treeview = False
            search_visible = True
        else:
            repo_tree_data = []
            disabled_treeview = True
            search_visible = False
            
        with file_selection_col:
            stc.markdown(
                "Select the file you want to test :", font_size="14px", font_color="#454545"
            )

            file_path = st_ant_tree(
                treeData=repo_tree_data,
                key="file_select",
                multiple=False,
                placeholder="Choose a File",
                showSearch=search_visible,
                treeCheckable=False,
                disabled=disabled_treeview,
            )
        
        if file_path is not None:
            file_name, packages, complete_methods = handle_file_path (file_path)

        if file_path and not disabled_treeview:
            function_tree_data = transform_module_to_tree(st.session_state.app.complete_methods)
            disabled_treeview = False
            search_visible = True
        else:
            function_tree_data = []
            disabled_treeview = True
            search_visible = False
            
        with method_selection_col:
            stc.markdown(
                "Select the method/function you want to test:", font_size="14px", font_color="#454545",
            )
            method_name = st_ant_tree(
                treeData=function_tree_data,
                key="method_name",
                multiple=False,
                placeholder="Choose a method/function",
                showSearch=search_visible,
                treeCheckable=False,
                disabled=disabled_treeview,
            )

        handle_method_name(method_name)
            
        objective = st.text_area("Provide additional info of the method (optional)")
        sample_data = st.text_area("Provide sample data for the method (optional)")
        st.session_state.app.update(objective=objective, sample_data=sample_data)
        scenario_button = stc.st_button("Generate Test Scenarios", "scenario_button")

    components = st.session_state.app.components

    if len(components) == 0:
        if scenario_button:
            with scenarios_col:
                start_code_generation()
    
    elif components[-1] == "verify_io_user_input":
        with scenarios_col:
            display_chat_interface(components)
        
    elif components[-1] == "user_input":
        with scenarios_col:
            display_chat_interface(components)
        
    elif "scenarios_section" in components:
        with scenarios_col:
            display_test_scenarios()

    if "code_section" in components:
        display_code()
            

    if "results_section" in components :
        display_results()


if __name__ == "__main__":
    main()


def display_test_scenarios(data):
    stc.markdown("Test scenarios", font_size="25px", font_weight="bold")
    with st.container(height=400, border=False):
        selected_scenarios = stc.multiselect(
            title="select test cases",
            options=data.test_cases,
            default=data.selected_scenarios,
        )
    codes_button = stc.st_button("Generate test codes", "codes_button", "right")
    if codes_button:
        data.update(selected_scenarios=selected_scenarios)
        with stc.LottieAnimation("assets/Animation-1724036221793.json", "Generating Code"):
            data.generate_results(step="code_generation")
        return data