#19863·jupyterlab

Reload shows the first tab when the active tab is not restored

Author: krassowskiCreated Sep 27, 2026Updated Sep 27, 2026
Labelsbugstatus:Needs Triage

Description

On a page reload, when the tab that was active is not (yet) restored, the tab bar shows the first tab of the main area. A Launcher is such a tab, and so is a tab that an extension adds without a restorer. The status bar and the file browser show the file of another tab.

Reproduce

  1. Open a notebook and then a Python file from the file browser, for example Untitled.ipynb and helper.py.
  2. Close the Launcher tab.
  3. Select File → New Launcher. The tabs are Untitled.ipynb, helper.py and Launcher, with Launcher active.
  4. Reload the page.

The tab bar shows Untitled.ipynb, the first tab. The status bar shows Ln 1, Col 1, Spaces: 4 and helper.py, and the file browser selects helper.py. shell.currentWidget is helper.py, although its tab is not selected.

Expected behavior

helper.py, the tab before the Launcher, is shown and is the current widget.

Possible solution

The layout restorer saves currentIndex counted among all tabs, but it saves only the tabs that have a restore name:

https://github.com/jupyterlab/jupyterlab/blob/a62365d745fee48f7d59c60bda377a2ed14415a8/packages/application/src/layoutrestorer.ts#L789-L796

On restore, an index past the end of the saved tabs resets to 0:

https://github.com/jupyterlab/jupyterlab/blob/a62365d745fee48f7d59c60bda377a2ed14415a8/packages/application/src/layoutrestorer.ts#L866-L869

When the current tab has no restore name, the restorer does not save a current widget, and restoreLayout then does not activate a tab:

https://github.com/jupyterlab/jupyterlab/blob/a62365d745fee48f7d59c60bda377a2ed14415a8/packages/application/src/shell.ts#L1306-L1308

The layout restorer counts the current index among the tabs that it saves, and saves the nearest tab with a restore name as the current widget. When a saved tab does not come back, the restore selects the nearest tab that does.

Context

  • Operating System and version: Linux
  • Browser and version: Chromium 149
  • JupyterLab version: 4.6.4 and 4.7.0a2