Adding button to chat window gets confused by multiple chats

Hi, I’m trying make a plugin that will add a button to the ChatRoom window. I tried using the example from the sparkplug window, but it doesnt seem to like multiple chat windows.

What will happen is that the button will disapear (or appear) on either one or the other tab, although not necessarily the first one I have added it to.

Is the example in the docs the right one to use?

Sam.