I'm adding an extra column to zotero-items-columns-header to display BBTs citekey in an overlay:
<treecols id="zotero-items-columns-header">
<treecol
id="zotero-items-column-citekey" primary="true"
label="Citekey"
flex="1"
insertafter="zotero-items-column-title"
zotero-persist="width ordinal hidden sortActive sortDirection"
/>
</treecols>
this works nicely, but when BBT is uninstalled, the data remains persisted in extensions.zotero.pane.persist as the column is still available at shutdown, so Zotero.serializePersist will store it. The problem I have is at startup after uninstall, all columns in the reference list are selected, and I have no idea why. During uninstall (an event that happens well before shutdown) I remove the "persist" attribute from that column so that Zotero.serializePersist will not see it.
The weird thing is that a) I can't see Zotero.serializePersist being called (I've wrapped it in a monkey-patch for the occasion so I can see if it's being called), and b) looking at the code of Zotero.unserializePersist it skips any columns it cannot find a corresponding element for, so even if I didn't strip the value, it should just ignore it, and c) even though I can't see Zotero.serializePersist being called, I can see that extensions.zotero.pane.persist is set at shutdown *including* zotero-items-column-citekey through a prefs observer I have set.
I really want to leave Zotero in a clean state when BBT is installed, but I can't seem to get this bit right. It's reproducible by just putting
user_pref("extensions.zotero.pane.persist", '{"zotero-collections-pane":{},"zotero-tags-splitter":{},"zotero-tag-selector":{"height":"0"},"zotero-collections-splitter":{},"zotero-layout-switcher":{"orient":"horizontal"},"zotero-items-pane":{},"zotero-items-tree":{"current-view-group":"default"},"zotero-items-column-title":{"ordinal":"1","hidden":"false"},"zotero-items-column-firstCreator":{"ordinal":"3","hidden":"false"},"zotero-items-column-itemType":{"width":"40","ordinal":"5","hidden":"true"},"zotero-items-column-date":{"ordinal":"7","hidden":"true"},"zotero-items-column-year":{"ordinal":"9","hidden":"true"},"zotero-items-column-publisher":{"ordinal":"11","hidden":"true"},"zotero-items-column-publicationTitle":{"ordinal":"13","hidden":"true"},"zotero-items-column-journalAbbreviation":{"ordinal":"15","hidden":"true"},"zotero-items-column-language":{"ordinal":"17","hidden":"true"},"zotero-items-column-accessDate":{"ordinal":"19","hidden":"true"},"zotero-items-column-libraryCatalog":{"ordinal":"21","hidden":"true"},"zotero-items-column-callNumber":{"ordinal":"23","hidden":"true"},"zotero-items-column-rights":{"ordinal":"25","hidden":"true"},"zotero-items-column-dateAdded":{"ordinal":"27","hidden":"true"},"zotero-items-column-dateModified":{"ordinal":"29","hidden":"true"},"zotero-items-column-archive":{"ordinal":"31","hidden":"true"},"zotero-items-column-archiveLocation":{"ordinal":"33","hidden":"true"},"zotero-items-column-place":{"ordinal":"35","hidden":"true"},"zotero-items-column-volume":{"ordinal":"37","hidden":"true"},"zotero-items-column-edition":{"ordinal":"39","hidden":"true"},"zotero-items-column-pages":{"ordinal":"41","hidden":"true"},"zotero-items-column-issue":{"ordinal":"43","hidden":"true"},"zotero-items-column-series":{"ordinal":"45","hidden":"true"},"zotero-items-column-seriesTitle":{"ordinal":"47","hidden":"true"},"zotero-items-column-court":{"ordinal":"49","hidden":"true"},"zotero-items-column-medium":{"ordinal":"51","hidden":"true"},"zotero-items-column-genre":{"ordinal":"53","hidden":"true"},"zotero-items-column-system":{"ordinal":"55","hidden":"true"},"zotero-items-column-extra":{"ordinal":"57","hidden":"true"},"zotero-items-column-hasAttachment":{"ordinal":"59","hidden":"false"},"zotero-items-column-numNotes":{"ordinal":"61","hidden":"true"},"zotero-items-splitter":{"orient":"horizontal"},"zotero-item-pane":{}}');
in prefs.js before start when BBT is not installed.