i have handle_repo_url function. this function is tightly coupled with session_state and main function. how can i remove these coupling from the function.
...

def handle_repo_url(repo_url):
    if not repo_url:
        return False
    
    if repo_url != st.session_state.app.repo_url:
        repo_path = f"cloned_repos/{repo_url.split('/')[-1]}"
        st.session_state.app.update_and_reset(repo_url=repo_url)
        st.session_state.app.update(repo_path=repo_path)
    else:
        repo_path = st.session_state.app.repo_path

    if os.path.isdir(repo_path):
        st.session_state.app.repo_cloned = True 
        return True
    
    if (
        "username" not in st.session_state
        and "password" not in st.session_state
    ):
        stc.get_username_password()
    else:
        clone_output = clone_repository(
            repo_url,
            repo_path,
            st.session_state.username,
            st.session_state.password,
        )
        if clone_output:
            st.session_state.app.repo_cloned = True
            logger.info("Repository Cloning : Success !")
            return True
        else:
            logger.error("Repository Cloning : Error !")
            stc.toast("Repository Cloning : Error !", type="error")
            return False
        
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:
                st.session_state.app = start_code_generation(data=st.session_state.app)
    elif components[-1] == "verify_io_user_input":
        with scenarios_col:
            st.session_state.app = display_chat_interface(data=st.session_state.app)
    elif components[-1] == "user_input":
        with scenarios_col:
            st.session_state.app = display_chat_interface(data=st.session_state.app)
    elif "scenarios_section" in st.session_state.app.components:
        with scenarios_col:
            st.session_state.app = display_test_scenarios(data=st.session_state.app)

    if "code_section" in st.session_state.app.components:
        st.session_state.app = display_code(data=st.session_state.app)

    if "results_section" in st.session_state.app.components :
        st.session_state.app = display_results(data=st.session_state.app)

if __name__ == "__main__":
    main()