Currently, if you save the notebook after using
Collapse All Code, it reopens with that same code collapsed. I just tested it in JupyterLab >= 1.0 launched from here and here by collapsing it in one session, saving the notebook and opening in another session. It should work for individual cells if you want that, too.
You can view the state in the meta data by right-clicking on the notebooks in the JupyterLab file browser and opening the notebooks with
Open with >
Editor and seeing
"source_hidden": true for cells.
Or are you asking if you can enforce this for notebooks where this wasn’t previously set?
That probably can be done by reading in a notebook with nbformat and designating the output be adjusted to have that attribute by combining the process outlined here to open a notebook and step through cells with details here to adjust the meta-data in the output.