- 
                Notifications
    
You must be signed in to change notification settings  - Fork 3
 
Description
The second table in the dialog does not get updated when the kernel state changes
jupyterlab-launchpad/src/dialogs.tsx
Lines 292 to 313 in 5ba3fee
| {runningKernelsItems.length > 0 ? ( | |
| <> | |
| <h3 className="jp-KernelSelector-Section"> | |
| {this.trans.__('Connect to a running kernel')} | |
| </h3> | |
| <KernelTable | |
| trans={this.trans} | |
| commands={this.commands} | |
| items={runningKernelsItems} | |
| settings={this._settings} | |
| query="" | |
| showSearchBox={false} | |
| onClick={item => { | |
| this._selection = item; | |
| this.options.acceptDialog(); | |
| }} | |
| hideColumns={['last-used', 'star']} | |
| favouritesChanged={this._favoritesDatabase.changed} | |
| lastUsedChanged={this._lastUsedDatabase.changed} | |
| /> | |
| </> | |
| ) : null} | 
Because it includes things like "state: starting" it needs to be dynamically updated. We need to trigger forceUpdate when item metadata changes, and for that we need to pass through another signal, like with lastUsedChanged:
jupyterlab-launchpad/src/components/table.tsx
Lines 103 to 117 in 5ba3fee
| // Hoisted to avoid "Rendered fewer hooks than expected" error on toggling the Star column | |
| const [, forceUpdate] = React.useReducer(x => x + 1, 0); | |
| React.useEffect(() => { | |
| props.favouritesChanged.connect(forceUpdate); | |
| return () => { | |
| props.favouritesChanged.disconnect(forceUpdate); | |
| }; | |
| }); | |
| React.useEffect(() => { | |
| props.lastUsedChanged.connect(forceUpdate); | |
| return () => { | |
| props.lastUsedChanged.disconnect(forceUpdate); | |
| }; | |
| }); | 
We derive the items from the sessions object passed in options:
jupyterlab-launchpad/src/dialogs.tsx
Line 239 in 5ba3fee
| for (const model of this.options.data.sessions!) { | 
and we fetch the sessions when creating the dialog:
jupyterlab-launchpad/src/dialogs.tsx
Lines 75 to 80 in 5ba3fee
| body: new KernelSelector({ | |
| data: { | |
| specs: sessionContext.specsManager.specs, | |
| sessions: sessionContext.sessionManager.running(), | |
| preference: sessionContext.kernelPreference | |
| }, | 
The SessionManager emits runningChanged signal which we could use.