Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State in the table for running kernels does not get updated #68

Open
krassowski opened this issue Aug 23, 2024 · 0 comments
Open

State in the table for running kernels does not get updated #68

krassowski opened this issue Aug 23, 2024 · 0 comments
Labels

Comments

@krassowski
Copy link
Member

The second table in the dialog does not get updated when the kernel state changes

{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:

// 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:

for (const model of this.options.data.sessions!) {

and we fetch the sessions when creating the dialog:

body: new KernelSelector({
data: {
specs: sessionContext.specsManager.specs,
sessions: sessionContext.sessionManager.running(),
preference: sessionContext.kernelPreference
},

The SessionManager emits runningChanged signal which we could use.

@krassowski krassowski added the bug label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant