Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2270c04

Browse files
authored
Update browser tab favicon on kernel busy (#6980)
1 parentfe4799a commit2270c04

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

‎packages/notebook-extension/src/index.ts‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,51 @@ const notebookToolsWidget: JupyterFrontEndPlugin<void> = {
402402
},
403403
};
404404

405+
/**
406+
* A plugin to update the tab icon based on the kernel status.
407+
*/
408+
consttabIcon:JupyterFrontEndPlugin<void>={
409+
id:'@jupyter-notebook/notebook-extension:tab-icon',
410+
autoStart:true,
411+
requires:[INotebookTracker],
412+
activate:(app:JupyterFrontEnd,tracker:INotebookTracker)=>{
413+
// the favicons are provided by Jupyter Server
414+
constnotebookIcon=' /static/favicons/favicon-notebook.ico';
415+
constbusyIcon=' /static/favicons/favicon-busy-1.ico';
416+
417+
constupdateBrowserFavicon=(
418+
status:ISessionContext.KernelDisplayStatus
419+
)=>{
420+
constlink=document.querySelector(
421+
"link[rel*='icon']"
422+
)asHTMLLinkElement;
423+
switch(status){
424+
case'busy':
425+
link.href=busyIcon;
426+
break;
427+
case'idle':
428+
link.href=notebookIcon;
429+
break;
430+
}
431+
};
432+
433+
constonChange=async()=>{
434+
constcurrent=tracker.currentWidget;
435+
constsessionContext=current?.sessionContext;
436+
if(!sessionContext){
437+
return;
438+
}
439+
440+
sessionContext.statusChanged.connect(()=>{
441+
conststatus=sessionContext.kernelDisplayStatus;
442+
updateBrowserFavicon(status);
443+
});
444+
};
445+
446+
tracker.currentChanged.connect(onChange);
447+
},
448+
};
449+
405450
/**
406451
* A plugin that adds a Trusted indicator to the menu area
407452
*/
@@ -441,8 +486,9 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
441486
closeTab,
442487
kernelLogo,
443488
kernelStatus,
444-
scrollOutput,
445489
notebookToolsWidget,
490+
scrollOutput,
491+
tabIcon,
446492
trusted,
447493
];
448494

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp