Skip to content

Commit f3d4e09

Browse files
committed
fix(libro-jupyter): 修复未知内核状态时未正确返回忙碌状态的问题
1 parent 4034054 commit f3d4e09

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

  • packages/libro-jupyter/src/utils

packages/libro-jupyter/src/utils/index.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
1+
import { l10n } from '@difizen/libro-common/l10n';
12
import type { CellModel } from '@difizen/libro-core';
23
import type { ServerManager } from '@difizen/libro-kernel';
3-
import { l10n } from '@difizen/libro-common/l10n';
44
import { duration } from 'moment';
55

66
import { LibroJupyterModel } from '../libro-jupyter-model.js';
7-
import type {
8-
ExecutedWithKernelCellModel,
9-
ServerStatus,
10-
} from '../libro-jupyter-protocol.js';
7+
import type { ServerStatus } from '../libro-jupyter-protocol.js';
118
import {
129
jupyterServiceStatus,
1310
kernelStatus,
1411
statusToColor,
12+
ExecutedWithKernelCellModel,
1513
} from '../libro-jupyter-protocol.js';
1614

1715
export const EXECUTE_INPUT = 'to_execute'; // 用户点击执行按钮的时间
@@ -100,7 +98,18 @@ export const getServiceStatusInfo = (
10098
};
10199
}
102100

103-
return kernelStatus[libroModel.kernelConnection.status];
101+
let status = libroModel.kernelConnection.status;
102+
103+
if (status === 'unknown') {
104+
const hasRunningCell = libroModel.cells.some((cell) => {
105+
return ExecutedWithKernelCellModel.is(cell.model) && cell.model.kernelExecuting;
106+
});
107+
if (hasRunningCell) {
108+
status = 'busy';
109+
}
110+
}
111+
112+
return kernelStatus[status];
104113
};
105114

106115
// 判断服务未启动、kernel正在连接 -> return false

0 commit comments

Comments
 (0)