From 21028f88e87c58677505ab7e48b707a2559345e6 Mon Sep 17 00:00:00 2001 From: HellowVirgil <1135895008@qq.com> Date: Thu, 22 Jan 2026 21:05:33 +0800 Subject: [PATCH] =?UTF-8?q?fix(libro-jupyter):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=9C=AA=E7=9F=A5=E5=86=85=E6=A0=B8=E7=8A=B6=E6=80=81=E6=97=B6?= =?UTF-8?q?=E6=9C=AA=E6=AD=A3=E7=A1=AE=E8=BF=94=E5=9B=9E=E5=BF=99=E7=A2=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/libro-jupyter/src/utils/index.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) 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