Async Widget.restoreState?

I want to prevent the IDE from opening new shells when restoring terminals in the UI. I want to know how to handle async events in the restoreState method, or if there is a way to prevent a widget from being restored even before based on some async test?

[original thread by Paul Maréchal]

Could you share how async restoreState would look like?

Could you avoid storing state in the first place?

for example like here: https://github.com/eclipse-theia/theia/blob/a551e6d91ce3c1a7fae83e76a0c51834caae237e/packages/plugin-ext/src/hosted/browser/hosted-plugin.ts#L174-L187

If an empty object is stored as state then a widget gets disposed during restoring

To be fair I didn’t really know how the async restoreState would work, but essentially the issue is that state should be stored, but when about to recreate the widget (before or while restoring) we need to asynchronously check that the state is also valid on the backend (for terminals, this means not recreating terminals if the remote process doesn’t exist anymore, maybe the backend restarted). Thanks for the pointers.

it does not seem that async restoreState is necessary, it can trigger async operation without awaiting to check whether terminal exist and if it does not then dispose the widget or do something else. It could that you need a guard that recreation does not happen.

Yes, does such a “re-creation guard” hook already exists?

I don’t know, please have a look at TerminalWidget. I don’t think we need a generic one for widgets.