I have found a working ui_template that does not enter a feedback loop like my template does but I am not sure if the observed behaviour is correct.
Here is a flow to demonstrate:
[{"id":"9ea17f7a.df536","type":"tab","label":"Flow 7","disabled":false,"info":""},{"id":"6aeef412.e50ccc","type":"inject","z":"9ea17f7a.df536","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"State 1","payloadType":"str","x":190,"y":80,"wires":[["91a4ce0c.b2c85"]]},{"id":"91a4ce0c.b2c85","type":"ui_template","z":"9ea17f7a.df536","group":"eb14755f.a52328","name":"00","order":2,"width":"3","height":1,"format":"\n<div class=\"blocktitle blue\" ng-bind-html=\"msg.payload\"></div>","storeOutMessages":false,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":390,"y":140,"wires":[["549220ba.d65f2"]]},{"id":"8613b2fb.2dd71","type":"ui_template","z":"9ea17f7a.df536","group":"eb14755f.a52328","name":"Title CSS","order":13,"width":0,"height":0,"format":"<style>\n .blocktitle{\n font-weight: bold;\n background-color: inherit;\n padding: 6px;\n text-align: center;\n }\n .blocktitle.blue{\n background-color: blue;\n \n }\n .blocktitle.red{\n background-color: red;\n }\n</style>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"global","x":400,"y":40,"wires":[["549220ba.d65f2"]]},{"id":"dd380195.41b53","type":"ui_template","z":"9ea17f7a.df536","group":"eb14755f.a52328","name":"11","order":8,"width":"3","height":1,"format":"\n<div class=\"blocktitle red\" ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":390,"y":380,"wires":[["549220ba.d65f2"]]},{"id":"549220ba.d65f2","type":"debug","z":"9ea17f7a.df536","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":620,"y":200,"wires":[]},{"id":"e7570f96.7c2d3","type":"ui_template","z":"9ea17f7a.df536","group":"eb14755f.a52328","name":"10","order":6,"width":"3","height":1,"format":"\n<div class=\"blocktitle blue\" ng-bind-html=\"msg.payload\"></div>","storeOutMessages":true,"fwdInMessages":true,"resendOnRefresh":false,"templateScope":"local","x":390,"y":300,"wires":[[]]},{"id":"ce508c0d.9d32b","type":"ui_template","z":"9ea17f7a.df536","group":"eb14755f.a52328","name":"01","order":4,"width":"3","height":1,"format":"\n<div class=\"blocktitle red\" ng-bind-html=\"msg.payload\"></div>","storeOutMessages":false,"fwdInMessages":true,"resendOnRefresh":true,"templateScope":"local","x":390,"y":220,"wires":[[]]},{"id":"a87ee7bd.c3d7a8","type":"ui_text","z":"9ea17f7a.df536","group":"eb14755f.a52328","order":1,"width":"4","height":"1","name":"","label":"False and False","format":"{{msg.payload}}","layout":"row-spread","x":420,"y":100,"wires":[]},{"id":"e4d0db50.3756a8","type":"ui_text","z":"9ea17f7a.df536","group":"eb14755f.a52328","order":5,"width":"4","height":"1","name":"","label":"True and False","format":"{{msg.payload}}","layout":"row-spread","x":420,"y":260,"wires":[]},{"id":"ca0b4efc.50059","type":"ui_text","z":"9ea17f7a.df536","group":"eb14755f.a52328","order":3,"width":"3","height":"1","name":"","label":"False and True","format":"{{msg.payload}}","layout":"row-spread","x":420,"y":180,"wires":[]},{"id":"30757de8.844782","type":"ui_text","z":"9ea17f7a.df536","group":"eb14755f.a52328","order":7,"width":"4","height":"1","name":"","label":"True and True","format":"{{msg.payload}}","layout":"row-spread","x":420,"y":340,"wires":[]},{"id":"94d3c556.406b68","type":"inject","z":"9ea17f7a.df536","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"State 1","payloadType":"str","x":190,"y":160,"wires":[["ce508c0d.9d32b"]]},{"id":"c65941a4.e906e","type":"inject","z":"9ea17f7a.df536","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"State 1","payloadType":"str","x":190,"y":240,"wires":[["e7570f96.7c2d3"]]},{"id":"c5e4e506.fb8d38","type":"inject","z":"9ea17f7a.df536","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"State 1","payloadType":"str","x":190,"y":320,"wires":[["dd380195.41b53"]]},{"id":"7722d8fc.365c88","type":"inject","z":"9ea17f7a.df536","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"State 2","payloadType":"str","x":190,"y":120,"wires":[["91a4ce0c.b2c85"]]},{"id":"9211739.260e99","type":"inject","z":"9ea17f7a.df536","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"State 2","payloadType":"str","x":190,"y":200,"wires":[["ce508c0d.9d32b"]]},{"id":"1ddd7c1e.82ba74","type":"inject","z":"9ea17f7a.df536","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"State 2","payloadType":"str","x":190,"y":280,"wires":[["e7570f96.7c2d3"]]},{"id":"f224c5cd.bf2458","type":"inject","z":"9ea17f7a.df536","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"State 2","payloadType":"str","x":190,"y":360,"wires":[["dd380195.41b53"]]},{"id":"eb14755f.a52328","type":"ui_group","z":"","name":"Store and Restore State","tab":"c88be1ab.5033b","order":1,"disp":true,"width":"4","collapse":false},{"id":"c88be1ab.5033b","type":"ui_tab","z":"","name":"Persistence","icon":"dashboard","disabled":false,"hidden":false}]
From a cold start I get:
Injecting State 1 into each node and then doing a browser refresh
Which is OK I think.
If I now edit the ui_templates and set them all to False False and redeploy
Which I think is not OK. I have to restart node-red for it to forget stored state.
Also if I set a ui_template to disabled like the clock toolbar it also remains after redeploy and requires node-red restart.