# Adding Main Area widget when Lab reloads

**URL:** <https://discourse.jupyter.org/t/adding-main-area-widget-when-lab-reloads/28038>\
**Category:** extensions\
**Tags:** help-wanted\
**Created:** [September 2, 2024, 8:40am UTC](https://discourse.jupyter.org/t/adding-main-area-widget-when-lab-reloads/28038 "2024-09-02T08:40:19Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![anushkav](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/anushkav/32/14673_2.png) [@anushkav](https://discourse.jupyter.org/u/anushkav)\
**Post date:** [September 2, 2024, 8:40am UTC](https://discourse.jupyter.org/t/adding-main-area-widget-when-lab-reloads/28038/1 "2024-09-02T08:40:19Z")

</div>

Hi all, I’m trying to add a main area widget which should open whenever JupyterLab reloads:

```auto
export const ExtensionName: JupyterFrontEndPlugin<void> = {
    id: extensionID,
    autoStart: true,
    activate: (app: JupyterFrontEnd) => {
        app.commands.addCommand(COMMAND, {
            execute: () => {
                const content = new MyComponent();
                const widget = new MainAreaWidget({content});
                widget.title.label = someLabel;
                app.shell.add(widget, 'main');
                app.shell.activateById(widget.id);
            }
        });
        app.restored.then(async () => {
            app.commands.execute(COMMAND);
        });
    }
};

```

This works fine when there are no previous notebooks open.  
But if a previous notebook is open, lab opens the widget after reloading and navigates back to the previously open notebook in a second or so. I was able to overcome this by setting a timeout before `app.commands.execute(COMMAND);`, but I’m looking for a better solution to prevent the tab-switching between the widget and the previously open file.
