Actions performed after the execution of an asynchronous task are not working correctly

Hello there! I’ve developed a wizard that includes an asynchronous task execution using asyncio. While the initial execution works smoothly, an issue arises afterward. The buttons for the subsequent steps are rendered, but unfortunately, they become unresponsive. Upon pressing any button, the entire async task restarts, and only after completing it for the second time does the originally intended action of the button take effect.

I have reproduced the problem in a simpler example. Here is the relevant code and the corresponding repository: [github].

import streamlit as st
import asyncio

async def async_job():
    st.text("Async job is running...")

    batches = 3
    for i in range(batches):
        await asyncio.sleep(1)
        st.text(f"Executing batch {i+1}/{batches}...")
    st.text("Async job is finished!")

def main():
    st.title("Async Streamlit App")

    if st.button("Next Step"):
        st.title("Next Step Screen")
        st.text("You pressed the 'Next Step' button!")

if __name__ == "__main__":

You can run the example here:

Any help would be highly appreciated.