diff --git a/packages/libro-jupyter/src/utils/index.ts b/packages/libro-jupyter/src/utils/index.ts index 1b33a8222..c4d91253f 100644 --- a/packages/libro-jupyter/src/utils/index.ts +++ b/packages/libro-jupyter/src/utils/index.ts @@ -1,17 +1,15 @@ +import { l10n } from '@difizen/libro-common/l10n'; import type { CellModel } from '@difizen/libro-core'; import type { ServerManager } from '@difizen/libro-kernel'; -import { l10n } from '@difizen/libro-common/l10n'; import { duration } from 'moment'; import { LibroJupyterModel } from '../libro-jupyter-model.js'; -import type { - ExecutedWithKernelCellModel, - ServerStatus, -} from '../libro-jupyter-protocol.js'; +import type { ServerStatus } from '../libro-jupyter-protocol.js'; import { jupyterServiceStatus, kernelStatus, statusToColor, + ExecutedWithKernelCellModel, } from '../libro-jupyter-protocol.js'; export const EXECUTE_INPUT = 'to_execute'; // 用户点击执行按钮的时间 @@ -100,7 +98,18 @@ export const getServiceStatusInfo = ( }; } - return kernelStatus[libroModel.kernelConnection.status]; + let status = libroModel.kernelConnection.status; + + if (status === 'unknown') { + const hasRunningCell = libroModel.cells.some((cell) => { + return ExecutedWithKernelCellModel.is(cell.model) && cell.model.kernelExecuting; + }); + if (hasRunningCell) { + status = 'busy'; + } + } + + return kernelStatus[status]; }; // 判断服务未启动、kernel正在连接 -> return false