Jslink end of player to number of tabs

tabs = pn.Tabs('a', 'b')
player = pn.widgets.Player(end=len(tabs) - 1)
player.jslink(tabs, value='active', bidirectional=True)
pn.Column(tabs, player)

I was able to successfully link the value to active, but now if I append to tabs, I want the player end to match it too.

I think it’s something like:
player.jslink(tabs, code={'end': 'target.end = length(source)'})
but I don’t think it’s working.

This works, but it watches active, not number of tabs

tabs = pn.Tabs('a', 'b')
player = pn.widgets.Player(end=len(tabs) - 1)
player.jslink(tabs, value='active', bidirectional=True)
tabs.jslink(player, code={'active': 'target.end = source.tabs.length - 1'})
tabs.append('a')
pn.Column(tabs, player)