Panel Selector Expand Not Working After Restarting Server

Consider app.py:

class A(pm.Parameterized):
    a = pm.Number()

class B(pm.Parameterized):
    a = pm.Selector()

a = A()
B.param['a'].objects = [a]
b = B(a=a)
app = pn.panel(b).servable()

If I serve the above with:

panel serve app.py --autoreload

Then the expand button works fine.

But if I kill the server (C-c) and run again:

panel serve app.py --autoreload

Then the expand button no longer works.

panel==1.2.2
param==1.13.0
Python 3.10.12

I think I fixed it using instantiate=True:

class B(pm.Parameterized):
    a = pm.Selector(instantiate=True)

This worked for a while. But now I’m having the bug again.

Maybe this?

import panel as pn
import param as pm

class A(pm.Parameterized):
    a = pm.Number()

class B(pm.Parameterized):
    a = pm.ObjectSelector()

a = A()
B.param['a'].objects = [a]
b = B(a=a)
app = pn.panel(b).servable()

But I’m a bit confused on what this is trying to do. Is it trying to get the instantiated A?

I want to be able to use the expand button to see the contents of a while looking at b as a panel.

The expand button is not working.

I could do:

app = pn.panel(b, expand=True).servable()

To force the toggle open, but I want to be able to use the toggle button in the browser on the a field on b as a panel.

The problem seems to be with --autoreload. When I remove that flag the app is working as expected.