How to close the left sidebar in a jupyterlab extension

Hi, I am new to the jupyterlab extension development, I am trying to open/close the left sidebar (the file browser) pragmatically. Could you please give me some hint on how to implement that in a jupyterlab extension? I have been searching through the jupyterlab repo but doesn’t seem to find anything for that.

The command application:toggle-left-area will do what is says on the tin:

app.commands.execute('application:toggle-left-area');

The above link also shows how one might ensure that it only opens, by looking at app.shell.leftCollapsed.

Thanks a lot! It works!