How to find the active (visible) notebook within Jupyter lab

I’m trying to write an extension for Jupyter lab. I’ve based it off of the kernel-output example. In the example at line 54 of panel.ts It pops up the select Kernel dialog. I want to instead just use the active notebook.
I looked through the entries in this._sessionContext.sessionManager._sessionConnections in the debugger but I can’t see any attribute that indicates if it is visible.