@jupyterlite/apputils-extension 0.8.0 → 0.9.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import type { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ import type { ISessionContext } from '@jupyterlab/apputils';
2
3
  import { ReactWidget } from '@jupyterlab/apputils';
3
- import type { Kernel } from '@jupyterlab/services';
4
4
  import type { ISignal } from '@lumino/signaling';
5
5
  import { ITranslator } from '@jupyterlab/translation';
6
6
  /**
@@ -8,21 +8,28 @@ import { ITranslator } from '@jupyterlab/translation';
8
8
  */
9
9
  export declare class KernelStatus {
10
10
  /**
11
- * Current execution status of the kernel.
11
+ * Current display status of the kernel.
12
12
  */
13
- get status(): Kernel.Status;
13
+ get status(): ISessionContext.KernelDisplayStatus;
14
14
  /**
15
- * Signal emitted when the kernel status changes.
15
+ * Whether the session currently has no kernel (e.g. after a shutdown).
16
+ *
17
+ * This is tracked separately from the status because a session reports the
18
+ * 'unknown' status both while a kernel is starting up (a kernel is present
19
+ * but has not reported its status yet) and when there is no kernel at all.
16
20
  */
17
- get statusChanged(): ISignal<this, Kernel.Status>;
21
+ get hasNoKernel(): boolean;
18
22
  /**
19
- * Set the current execution status.
20
- *
21
- * @param status - The new status
23
+ * Signal emitted when the status or kernel presence changes.
24
+ */
25
+ get changed(): ISignal<this, void>;
26
+ /**
27
+ * Set the current display status and whether a kernel is present.
22
28
  */
23
- setStatus(status: Kernel.Status): void;
29
+ setStatus(status: ISessionContext.KernelDisplayStatus, hasNoKernel: boolean): void;
24
30
  private _status;
25
- private _statusChanged;
31
+ private _hasNoKernel;
32
+ private _changed;
26
33
  }
27
34
  /**
28
35
  * A widget displaying the kernel status.
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
3
  import { IToolbarWidgetRegistry, ReactWidget } from '@jupyterlab/apputils';
4
+ import { circleEmptyIcon } from '@jupyterlab/ui-components';
4
5
  import { ILoggerRegistry } from '@jupyterlab/logconsole';
5
6
  import { Signal } from '@lumino/signaling';
6
7
  import React, { useState, useEffect } from 'react';
@@ -10,55 +11,76 @@ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
10
11
  */
11
12
  export class KernelStatus {
12
13
  constructor() {
13
- this._status = 'idle';
14
- this._statusChanged = new Signal(this);
14
+ this._status = 'unknown';
15
+ this._hasNoKernel = true;
16
+ this._changed = new Signal(this);
15
17
  }
16
18
  /**
17
- * Current execution status of the kernel.
19
+ * Current display status of the kernel.
18
20
  */
19
21
  get status() {
20
22
  return this._status;
21
23
  }
22
24
  /**
23
- * Signal emitted when the kernel status changes.
25
+ * Whether the session currently has no kernel (e.g. after a shutdown).
26
+ *
27
+ * This is tracked separately from the status because a session reports the
28
+ * 'unknown' status both while a kernel is starting up (a kernel is present
29
+ * but has not reported its status yet) and when there is no kernel at all.
24
30
  */
25
- get statusChanged() {
26
- return this._statusChanged;
31
+ get hasNoKernel() {
32
+ return this._hasNoKernel;
27
33
  }
28
34
  /**
29
- * Set the current execution status.
30
- *
31
- * @param status - The new status
35
+ * Signal emitted when the status or kernel presence changes.
36
+ */
37
+ get changed() {
38
+ return this._changed;
39
+ }
40
+ /**
41
+ * Set the current display status and whether a kernel is present.
32
42
  */
33
- setStatus(status) {
34
- if (this._status === status) {
43
+ setStatus(status, hasNoKernel) {
44
+ if (this._status === status && this._hasNoKernel === hasNoKernel) {
35
45
  return;
36
46
  }
37
47
  this._status = status;
38
- this._statusChanged.emit(status);
48
+ this._hasNoKernel = hasNoKernel;
49
+ this._changed.emit();
39
50
  }
40
51
  }
41
52
  /**
42
53
  * A React component for displaying kernel status.
43
54
  */
44
55
  function KernelStatusComponent(props) {
45
- const [status, setStatus] = useState(props.model.status);
56
+ const [, forceUpdate] = useState({});
46
57
  const trans = props.translator.load('jupyterlite');
47
58
  useEffect(() => {
48
- const onChange = (_, newStatus) => {
49
- setStatus(newStatus);
59
+ const onChange = () => {
60
+ forceUpdate({});
50
61
  };
51
- props.model.statusChanged.connect(onChange);
62
+ props.model.changed.connect(onChange);
52
63
  return () => {
53
- props.model.statusChanged.disconnect(onChange);
64
+ props.model.changed.disconnect(onChange);
54
65
  };
55
66
  }, [props.model]);
56
- const isError = status === 'dead';
57
- const isIdle = status === 'idle';
58
- const isBusy = !isError && !isIdle;
67
+ const status = props.model.status;
68
+ // When there is no kernel (e.g. after a shutdown) show a neutral, muted icon
69
+ // rather than the spinner, the idle checkmark or the error cross. The display
70
+ // status is also 'unknown' in that case, so it cannot be distinguished by the
71
+ // status alone, hence relying on `hasNoKernel`. This takes precedence over the
72
+ // other states so the indicator never reserves an empty, icon-less gap.
73
+ const isNoKernel = props.model.hasNoKernel;
74
+ const isError = !isNoKernel && status === 'dead';
75
+ const isIdle = !isNoKernel && status === 'idle';
76
+ // Show the loading spinner while a kernel is present (or starting up) and not
77
+ // yet idle or dead.
78
+ const isBusy = !isNoKernel && !isError && !isIdle;
59
79
  // Return the appropriate icon and text based on status
60
80
  return (React.createElement("div", { className: 'jp-KernelStatus', onClick: props.onClick, style: { cursor: 'pointer' }, title: trans.__('Click to open kernel logs') },
61
81
  React.createElement("div", { className: "jp-KernelStatus-icon-container" },
82
+ isNoKernel && (React.createElement("div", { className: "jp-KernelStatus-none" },
83
+ React.createElement(circleEmptyIcon.react, { tag: null }))),
62
84
  isBusy && (React.createElement("div", { className: "jp-KernelStatus-spinner" },
63
85
  React.createElement("svg", { viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" },
64
86
  React.createElement("circle", { className: "jp-KernelStatus-spinner-track", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
@@ -120,10 +142,18 @@ export const kernelStatusPlugin = {
120
142
  // Create the kernel status model
121
143
  const kernelStatus = new KernelStatus();
122
144
  const sessionContext = panel.sessionContext;
123
- // Update status when kernel status changes
124
- sessionContext.statusChanged.connect((_, status) => {
125
- kernelStatus.setStatus(status);
126
- });
145
+ // Reflect the session's display status together with whether a kernel
146
+ // is present. The display status is recomputed on any signal that can
147
+ // affect it (mirroring the execution indicator), and `hasNoKernel`
148
+ // tells a starting kernel (spinner) apart from no kernel (no spinner),
149
+ // since both report the 'unknown' status.
150
+ const updateStatus = () => {
151
+ kernelStatus.setStatus(sessionContext.kernelDisplayStatus, sessionContext.hasNoKernel);
152
+ };
153
+ sessionContext.statusChanged.connect(updateStatus);
154
+ sessionContext.connectionStatusChanged.connect(updateStatus);
155
+ sessionContext.kernelChanged.connect(updateStatus);
156
+ updateStatus();
127
157
  if (loggerRegistry) {
128
158
  const path = panel.context.path;
129
159
  const logger = loggerRegistry.getLogger(path);
@@ -135,11 +165,11 @@ export const kernelStatusPlugin = {
135
165
  const level = latestMessage.level;
136
166
  // rely on kernels properly reporting a critical state
137
167
  if (level === 'critical') {
138
- kernelStatus.setStatus('dead');
168
+ kernelStatus.setStatus('dead', sessionContext.hasNoKernel);
139
169
  }
140
170
  else if (level !== 'metadata') {
141
171
  // if new messages are logged, set the status back to busy
142
- kernelStatus.setStatus('busy');
172
+ kernelStatus.setStatus('busy', sessionContext.hasNoKernel);
143
173
  }
144
174
  }
145
175
  });
@@ -1 +1 @@
1
- {"version":3,"file":"kernelstatus.js","sourceRoot":"","sources":["../src/kernelstatus.tsx"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,2DAA2D;AAI3D,OAAO,EAAE,sBAAsB,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAK3E,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAKzD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;GAEG;AACH,MAAM,OAAO,YAAY;IAAz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9C,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE;wBACzC,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC;wBAC7C,IAAI,IAAI,KAAK,QAAQ,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;4BACpC,yBAAyB;4BACzB,MAAM,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,GAAG,CAC9C,MAAM,GAAG,CAAC,CACQ,CAAC;4BACrB,MAAM,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC;4BAClC,sDAAsD;4BACtD,IAAI,KAAK,KAAK,UAAU,EAAE,CAAC;gCACzB,YAAY,CAAC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;4BAC7D,CAAC;iCAAM,IAAI,KAAK,KAAK,UAAU,EAAE,CAAC;gCAChC,0DAA0D;gCAC1D,YAAY,CAAC,SAAS,CAAC,MAAM,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;4BAC7D,CAAC;wBACH,CAAC;oBACH,CAAC,CAAC,CAAC;gBACL,CAAC;gBAED,OAAO,IAAI,kBAAkB,CAAC;oBAC5B,KAAK,EAAE,YAAY;oBACnB,OAAO,EAAE,GAAG,EAAE;wBACZ,QAAQ,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;oBACtC,CAAC;oBACD,UAAU;iBACX,CAAC,CAAC;YACL,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlite/apputils-extension",
3
- "version": "0.8.0",
3
+ "version": "0.9.0-alpha.0",
4
4
  "description": "JupyterLite - Application Utilities Extension",
5
5
  "homepage": "https://github.com/jupyterlite/jupyterlite",
6
6
  "bugs": {
@@ -38,14 +38,14 @@
38
38
  "watch": "tsc -b --watch"
39
39
  },
40
40
  "dependencies": {
41
- "@jupyterlab/application": "~4.6.0",
42
- "@jupyterlab/apputils": "~4.7.0",
43
- "@jupyterlab/logconsole": "~4.6.0",
44
- "@jupyterlab/pluginmanager": "~4.6.0",
45
- "@jupyterlab/translation": "~4.6.0",
46
- "@jupyterlab/ui-components": "~4.6.0",
47
- "@jupyterlite/application": "^0.8.0",
48
- "@jupyterlite/apputils": "^0.8.0"
41
+ "@jupyterlab/application": "~4.7.0-alpha.0",
42
+ "@jupyterlab/apputils": "~4.8.0-alpha.0",
43
+ "@jupyterlab/logconsole": "~4.7.0-alpha.0",
44
+ "@jupyterlab/pluginmanager": "~4.7.0-alpha.0",
45
+ "@jupyterlab/translation": "~4.7.0-alpha.0",
46
+ "@jupyterlab/ui-components": "~4.7.0-alpha.0",
47
+ "@jupyterlite/application": "^0.9.0-alpha.0",
48
+ "@jupyterlite/apputils": "^0.9.0-alpha.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "rimraf": "~5.0.1",
@@ -3,15 +3,16 @@
3
3
 
4
4
  import type { JupyterFrontEnd, JupyterFrontEndPlugin } from '@jupyterlab/application';
5
5
 
6
+ import type { ISessionContext } from '@jupyterlab/apputils';
6
7
  import { IToolbarWidgetRegistry, ReactWidget } from '@jupyterlab/apputils';
7
8
 
9
+ import { circleEmptyIcon } from '@jupyterlab/ui-components';
10
+
8
11
  import type { NotebookPanel } from '@jupyterlab/notebook';
9
12
 
10
13
  import type { ILogOutputModel } from '@jupyterlab/logconsole';
11
14
  import { ILoggerRegistry } from '@jupyterlab/logconsole';
12
15
 
13
- import type { Kernel } from '@jupyterlab/services';
14
-
15
16
  import type { ISignal } from '@lumino/signaling';
16
17
  import { Signal } from '@lumino/signaling';
17
18
 
@@ -23,34 +24,45 @@ import { ITranslator, nullTranslator } from '@jupyterlab/translation';
23
24
  */
24
25
  export class KernelStatus {
25
26
  /**
26
- * Current execution status of the kernel.
27
+ * Current display status of the kernel.
27
28
  */
28
- get status(): Kernel.Status {
29
+ get status(): ISessionContext.KernelDisplayStatus {
29
30
  return this._status;
30
31
  }
31
32
 
32
33
  /**
33
- * Signal emitted when the kernel status changes.
34
+ * Whether the session currently has no kernel (e.g. after a shutdown).
35
+ *
36
+ * This is tracked separately from the status because a session reports the
37
+ * 'unknown' status both while a kernel is starting up (a kernel is present
38
+ * but has not reported its status yet) and when there is no kernel at all.
34
39
  */
35
- get statusChanged(): ISignal<this, Kernel.Status> {
36
- return this._statusChanged;
40
+ get hasNoKernel(): boolean {
41
+ return this._hasNoKernel;
37
42
  }
38
43
 
39
44
  /**
40
- * Set the current execution status.
41
- *
42
- * @param status - The new status
45
+ * Signal emitted when the status or kernel presence changes.
46
+ */
47
+ get changed(): ISignal<this, void> {
48
+ return this._changed;
49
+ }
50
+
51
+ /**
52
+ * Set the current display status and whether a kernel is present.
43
53
  */
44
- setStatus(status: Kernel.Status): void {
45
- if (this._status === status) {
54
+ setStatus(status: ISessionContext.KernelDisplayStatus, hasNoKernel: boolean): void {
55
+ if (this._status === status && this._hasNoKernel === hasNoKernel) {
46
56
  return;
47
57
  }
48
58
  this._status = status;
49
- this._statusChanged.emit(status);
59
+ this._hasNoKernel = hasNoKernel;
60
+ this._changed.emit();
50
61
  }
51
62
 
52
- private _status: Kernel.Status = 'idle';
53
- private _statusChanged = new Signal<this, Kernel.Status>(this);
63
+ private _status: ISessionContext.KernelDisplayStatus = 'unknown';
64
+ private _hasNoKernel = true;
65
+ private _changed = new Signal<this, void>(this);
54
66
  }
55
67
 
56
68
  /**
@@ -61,23 +73,32 @@ function KernelStatusComponent(props: {
61
73
  onClick?: () => void;
62
74
  translator: ITranslator;
63
75
  }): JSX.Element {
64
- const [status, setStatus] = useState<Kernel.Status>(props.model.status);
76
+ const [, forceUpdate] = useState({});
65
77
  const trans = props.translator.load('jupyterlite');
66
78
  useEffect(() => {
67
- const onChange = (_: any, newStatus: Kernel.Status) => {
68
- setStatus(newStatus);
79
+ const onChange = () => {
80
+ forceUpdate({});
69
81
  };
70
82
 
71
- props.model.statusChanged.connect(onChange);
83
+ props.model.changed.connect(onChange);
72
84
 
73
85
  return () => {
74
- props.model.statusChanged.disconnect(onChange);
86
+ props.model.changed.disconnect(onChange);
75
87
  };
76
88
  }, [props.model]);
77
89
 
78
- const isError = status === 'dead';
79
- const isIdle = status === 'idle';
80
- const isBusy = !isError && !isIdle;
90
+ const status = props.model.status;
91
+ // When there is no kernel (e.g. after a shutdown) show a neutral, muted icon
92
+ // rather than the spinner, the idle checkmark or the error cross. The display
93
+ // status is also 'unknown' in that case, so it cannot be distinguished by the
94
+ // status alone, hence relying on `hasNoKernel`. This takes precedence over the
95
+ // other states so the indicator never reserves an empty, icon-less gap.
96
+ const isNoKernel = props.model.hasNoKernel;
97
+ const isError = !isNoKernel && status === 'dead';
98
+ const isIdle = !isNoKernel && status === 'idle';
99
+ // Show the loading spinner while a kernel is present (or starting up) and not
100
+ // yet idle or dead.
101
+ const isBusy = !isNoKernel && !isError && !isIdle;
81
102
 
82
103
  // Return the appropriate icon and text based on status
83
104
  return (
@@ -88,6 +109,16 @@ function KernelStatusComponent(props: {
88
109
  title={trans.__('Click to open kernel logs')}
89
110
  >
90
111
  <div className="jp-KernelStatus-icon-container">
112
+ {isNoKernel && (
113
+ <div className="jp-KernelStatus-none">
114
+ {/* Reuse JupyterLab's empty-circle icon: it already renders a muted,
115
+ theme-aware ring (via its `jp-icon3` class) for this neutral,
116
+ inactive state. `tag={null}` returns the bare <svg>, matching the
117
+ structure of the sibling state icons. */}
118
+ <circleEmptyIcon.react tag={null} />
119
+ </div>
120
+ )}
121
+
91
122
  {isBusy && (
92
123
  <div className="jp-KernelStatus-spinner">
93
124
  <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
@@ -247,10 +278,21 @@ export const kernelStatusPlugin: JupyterFrontEndPlugin<void> = {
247
278
 
248
279
  const sessionContext = panel.sessionContext;
249
280
 
250
- // Update status when kernel status changes
251
- sessionContext.statusChanged.connect((_, status) => {
252
- kernelStatus.setStatus(status as Kernel.Status);
253
- });
281
+ // Reflect the session's display status together with whether a kernel
282
+ // is present. The display status is recomputed on any signal that can
283
+ // affect it (mirroring the execution indicator), and `hasNoKernel`
284
+ // tells a starting kernel (spinner) apart from no kernel (no spinner),
285
+ // since both report the 'unknown' status.
286
+ const updateStatus = () => {
287
+ kernelStatus.setStatus(
288
+ sessionContext.kernelDisplayStatus,
289
+ sessionContext.hasNoKernel,
290
+ );
291
+ };
292
+ sessionContext.statusChanged.connect(updateStatus);
293
+ sessionContext.connectionStatusChanged.connect(updateStatus);
294
+ sessionContext.kernelChanged.connect(updateStatus);
295
+ updateStatus();
254
296
 
255
297
  if (loggerRegistry) {
256
298
  const path = panel.context.path;
@@ -265,10 +307,10 @@ export const kernelStatusPlugin: JupyterFrontEndPlugin<void> = {
265
307
  const level = latestMessage.level;
266
308
  // rely on kernels properly reporting a critical state
267
309
  if (level === 'critical') {
268
- kernelStatus.setStatus('dead');
310
+ kernelStatus.setStatus('dead', sessionContext.hasNoKernel);
269
311
  } else if (level !== 'metadata') {
270
312
  // if new messages are logged, set the status back to busy
271
- kernelStatus.setStatus('busy');
313
+ kernelStatus.setStatus('busy', sessionContext.hasNoKernel);
272
314
  }
273
315
  }
274
316
  });
package/style/base.css CHANGED
@@ -19,6 +19,7 @@
19
19
  .jp-KernelStatus-spinner,
20
20
  .jp-KernelStatus-success,
21
21
  .jp-KernelStatus-error,
22
+ .jp-KernelStatus-none,
22
23
  .jp-KernelStatus svg {
23
24
  width: 16px;
24
25
  height: 16px;
@@ -58,6 +59,10 @@
58
59
  color: var(--jp-error-color1);
59
60
  }
60
61
 
62
+ /* No kernel state (e.g. after a shutdown) uses JupyterLab's circleEmptyIcon,
63
+ which is already a muted, theme-aware ring (via its `jp-icon3` class), so no
64
+ color override is needed here. */
65
+
61
66
  /* Busy state */
62
67
  .jp-KernelStatus-busy {
63
68
  display: flex;