-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Add checkbox to skip showing the kernel restart dialog #16265
base: main
Are you sure you want to change the base?
Add checkbox to skip showing the kernel restart dialog #16265
Conversation
Thanks for making a pull request to jupyterlab! |
c920b96
to
6a8cb71
Compare
6a8cb71
to
1c940f0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @NexVeridian
Would you feel comfortable implementing option (c) - never display the dialog through a setting instead of per session that cannot be undone?
To achieve that you will need to extend ISessionContext.IDialogsOptions
to accept the ISettingRegistry
token. And then you'll be able to do something like there:
jupyterlab/packages/docmanager-extension/src/index.tsx
Lines 905 to 942 in 82051a9
const result = await InputDialog.getText({ | |
title: trans.__('Rename file'), | |
okLabel: trans.__('Rename'), | |
placeholder: trans.__('File name'), | |
text: oldName, | |
selectionRange: oldName.length - PathExt.extname(oldName).length, | |
checkbox: { | |
label: trans.__('Do not ask me again.'), | |
caption: trans.__( | |
'If checked, you will not be asked to rename future untitled files when saving them.' | |
) | |
} | |
}); | |
if (result.button.accept) { | |
newName = result.value ?? oldName; | |
(widget as IDocumentWidget).isUntitled = false; | |
if (typeof result.isChecked === 'boolean') { | |
const currentSetting = ( | |
await settingRegistry.get( | |
docManagerPluginId, | |
'renameUntitledFileOnSave' | |
) | |
).composite as boolean; | |
if (result.isChecked === currentSetting) { | |
settingRegistry | |
.set( | |
docManagerPluginId, | |
'renameUntitledFileOnSave', | |
!result.isChecked | |
) | |
.catch(reason => { | |
console.error( | |
`Fail to set 'renameUntitledFileOnSave:\n${reason}` | |
); | |
}); | |
} | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice @NexVeridian you are on the right path.
The dialogs plugin is defined there:
jupyterlab/packages/apputils-extension/src/index.ts
Lines 574 to 585 in 59acb33
const sessionDialogs: JupyterFrontEndPlugin<ISessionContextDialogs> = { | |
id: '@jupyterlab/apputils-extension:sessionDialogs', | |
description: 'Provides the session context dialogs.', | |
provides: ISessionContextDialogs, | |
optional: [ITranslator], | |
autoStart: true, | |
activate: async (app: JupyterFrontEnd, translator: ITranslator | null) => { | |
return new SessionContextDialogs({ | |
translator: translator ?? nullTranslator | |
}); | |
} | |
}; |
So you will have to add ISettingRegistry
as additional optional
dependency. Then you'll be able to pass it to SessionContextDialogs
.
This also answers the question about the settings plugin. It should be @jupyterlab/apputils-extension:sessionDialogs
. That implies you need to create in packages/apputils-extension/schema
directory a new file named sessionDialogs.json
(naming is important). That contains
{
"title": "Kernel dialogs",
"description": "Kernel dialogs settings.",
"additionalProperties": false,
"properties": {
"skipKernelRestartDialog": {
"title": "...", # I let you add a short description here
"description": "...", # I let you add a long description here
"type": "boolean",
"default": false
},
},
"type": "object"
}
9d477b1
to
f220e29
Compare
@@ -1319,6 +1322,7 @@ export namespace SessionContext { | |||
export class SessionContextDialogs implements ISessionContext.IDialogs { | |||
constructor(options: ISessionContext.IDialogsOptions = {}) { | |||
this._translator = options.translator ?? nullTranslator; | |||
this._settingRegistry = options.settingRegistry || null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
using the setting page works now, but checkbox dialog linked to the setting doesn't
this._settingRegistry = options.settingRegistry || null;
is undefined, when the setting is unset
so I think this need to be nullSettingRegistry which I can't find
f6ce669
to
f8e1aad
Compare
@fcollonval just for awareness, from a quick straw poll on #6420 it seems that option (b) may be preferred by a number of users. I think the consensus is that we should allow for both (b) and (c), but maybe the checkbox should be connected to (b)? |
7e0c6a6
to
90bbf2f
Compare
Everything should be working now, by doing this
Or if you want to checkbox to be linked to c, then you could revert the last commit and fix this
|
5ff4578
to
90bbf2f
Compare
References
closes #8021 and closes #6420
Code changes
Add checkbox to skip showing the kernel restart dialog see #8021 (comment)
User-facing changes
2024-04-29.15-21-54.mp4
Backwards-incompatible changes
none
Thing that might need to be added
#6420 (comment)
this pr does option b, hiding the dialogs is per file, and is reset every session
to convert to option c, the checkbox value would need to be persisted and added to settings like
Automatically Start Preferred Kernel
is, I don't think I'm going to able to implement that though, this is might good enough for now