App doesn't work correctly when using pn.serve / app.show instead of panel serve

Hello, I am using panel to display a simulation hosted on a server. I usually run this command to start the interface:

panel serve interface.py
#interface.py
from panel_app import WindowManager

# Serve the app to launch the interface
wm = WindowManager()
wm.app.servable(title="app_title")

But I would need to run this interface without using command line, so the best option seems to encapsulate it in a function to use it in other modules of my project.

I tried to run the interface like this :

python3 test.py
#test.py
import panel as pn
from panel_app import WindowManager

def serve_app():
    # Initialize WindowManager
    wm = WindowManager()
    pn.serve(wm.app, title="Vivarium")

if __name__ == "__main__":
    serve_app()

The interface starts and plot the first frame of the simulation. Then, using buttons on the interface seems to work because I can start / stop the simulation (I get this notification on my server, and I can check that the simulation state has changed), but can’t see the plot of the simulation being updated.

I tried to debug this myself and also used “wp.app.show(threaded=True)” instead of pn.serve but got the same result.

Did I do something wrong ?

I can provide more information if it is needed to solve the problem.

Thanks in advance !
Corentin

I’m only familiar with using pn.serve (and I do it a lot) with a dictionary that has the route at the template/app function to be called in it as the first parameter. Here is the documentation, to try other examples:
Serving multiple applications — Panel v1.5.4