How can I customize the outline entries based on the different parts' labels?

So, stumbled upon this and gave it a go and oddly enough the numbering goes all wonky here, it seems like the counter is getting updated somehow when you wouldn’t expect it to?

Screenshot from 2025-05-23 21-14-25