@dsh-workbench/shared 1.5.4-beta.0 → 1.5.4-beta.2
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.
- package/dist/components/card/ApprovalDetail.d.ts +1 -0
- package/dist/components/card/ApprovalDetail.js +16 -2
- package/dist/components/card/LongTaskRow.css +24 -6
- package/dist/components/card/LongTaskRow.d.ts +2 -0
- package/dist/components/card/LongTaskRow.js +27 -16
- package/dist/contract/long-task.d.ts +4 -0
- package/dist/host/flow/step.d.ts +2 -1
- package/dist/host/flow/step.js +13 -8
- package/dist/host/unit/long-task.js +17 -6
- package/dist/i18n/en.js +4 -2
- package/dist/i18n/index.d.ts +5 -3
- package/dist/i18n/zh.d.ts +4 -2
- package/dist/i18n/zh.js +4 -2
- package/package.json +1 -1
- package/src/components/card/ApprovalDetail.tsx +16 -2
- package/src/components/card/LongTaskRow.css +24 -6
- package/src/components/card/LongTaskRow.tsx +93 -49
- package/src/components/card/__tests__/long-task-row.test.ts +68 -16
- package/src/contract/long-task.ts +4 -0
- package/src/host/flow/__tests__/step.test.ts +29 -5
- package/src/host/flow/step.ts +13 -9
- package/src/host/unit/__tests__/long-task.test.ts +58 -0
- package/src/host/unit/long-task.ts +24 -6
- package/src/i18n/en.ts +4 -2
- package/src/i18n/zh.ts +4 -2
|
@@ -16,6 +16,18 @@ function isLiveStatus(status: LongTaskStatus): boolean {
|
|
|
16
16
|
|
|
17
17
|
const RECENT_MS = 10 * 60 * 1000;
|
|
18
18
|
|
|
19
|
+
function mergeStepRow(
|
|
20
|
+
rows: readonly LongTaskStepRow[],
|
|
21
|
+
row: LongTaskStepRow,
|
|
22
|
+
): LongTaskStepRow[] {
|
|
23
|
+
if (row.stepId === undefined) return [...rows, row].slice(-LONG_TASK_HISTORY_MAX);
|
|
24
|
+
const at = rows.findIndex((one) => one.stepId === row.stepId);
|
|
25
|
+
if (at === -1) return [...rows, row].slice(-LONG_TASK_HISTORY_MAX);
|
|
26
|
+
const next = [...rows];
|
|
27
|
+
next[at] = row;
|
|
28
|
+
return next;
|
|
29
|
+
}
|
|
30
|
+
|
|
19
31
|
export interface LongTaskBase {
|
|
20
32
|
readonly id: string;
|
|
21
33
|
readonly workspace: string;
|
|
@@ -224,22 +236,28 @@ export function createLongTaskRegistry<S extends LongTaskBase>(deps: LongTaskDep
|
|
|
224
236
|
const onStep = (step: LongTaskStep): void => {
|
|
225
237
|
const current = live(id);
|
|
226
238
|
if (current === null) return;
|
|
227
|
-
const line = `${step.kind === 'fail' ? '✗ ' : ''}${step.text}`;
|
|
228
239
|
const repeated =
|
|
229
240
|
current.step === step.text &&
|
|
230
241
|
step.intervention !== undefined &&
|
|
231
242
|
current.intervention?.title === step.intervention.title;
|
|
232
|
-
const steps = repeated ? current.steps : [...current.steps, line].slice(-LONG_TASK_HISTORY_MAX);
|
|
233
243
|
const historyRow: LongTaskStepRow = {
|
|
234
244
|
kind: step.kind,
|
|
235
245
|
text: step.text,
|
|
236
|
-
...(
|
|
237
|
-
|
|
238
|
-
|
|
246
|
+
...pickDefined(
|
|
247
|
+
{
|
|
248
|
+
stepId: step.stepId,
|
|
249
|
+
attempt: step.attempt,
|
|
250
|
+
links: step.links?.slice(0, LONG_TASK_LINK_MAX),
|
|
251
|
+
},
|
|
252
|
+
['stepId', 'attempt', 'links'],
|
|
253
|
+
),
|
|
239
254
|
};
|
|
240
255
|
const history = repeated
|
|
241
256
|
? current.history ?? []
|
|
242
|
-
:
|
|
257
|
+
: mergeStepRow(current.history ?? [], historyRow);
|
|
258
|
+
const steps = history.map(
|
|
259
|
+
(row) => `${row.kind === 'fail' ? '✗ ' : ''}${row.text}`,
|
|
260
|
+
);
|
|
243
261
|
const extra = bound.step?.(step, current) ?? {};
|
|
244
262
|
if (step.intervention !== undefined) {
|
|
245
263
|
patch(
|
package/src/i18n/en.ts
CHANGED
|
@@ -1032,8 +1032,10 @@ export const en: Record<keyof WorkbenchMessages, string> = {
|
|
|
1032
1032
|
'longTask.stopConfirm': 'Confirm stop',
|
|
1033
1033
|
'longTask.stopArmed': 'Click again to stop',
|
|
1034
1034
|
'longTask.stopPending': 'Stop requested; waiting for the module',
|
|
1035
|
-
'longTask.
|
|
1036
|
-
'longTask.list.
|
|
1035
|
+
'longTask.attempt': 'Attempt {attempt}',
|
|
1036
|
+
'longTask.list.entry': 'Workbench tasks {n}',
|
|
1037
|
+
'longTask.list.count': '{n}',
|
|
1038
|
+
'longTask.list.title': 'Workbench tasks',
|
|
1037
1039
|
'longTask.state.running': 'Running',
|
|
1038
1040
|
'longTask.state.needsHuman': 'Waiting for you',
|
|
1039
1041
|
'longTask.state.needsLogin': 'Needs sign-in',
|
package/src/i18n/zh.ts
CHANGED
|
@@ -1026,8 +1026,10 @@ export const zh = {
|
|
|
1026
1026
|
'longTask.stopConfirm': '确认停止',
|
|
1027
1027
|
'longTask.stopArmed': '再次点击确认停止',
|
|
1028
1028
|
'longTask.stopPending': '已请求停止,等模块确认',
|
|
1029
|
-
'longTask.
|
|
1030
|
-
'longTask.list.
|
|
1029
|
+
'longTask.attempt': '第 {attempt} 次',
|
|
1030
|
+
'longTask.list.entry': '工作台任务 {n}',
|
|
1031
|
+
'longTask.list.count': '{n} 个',
|
|
1032
|
+
'longTask.list.title': '工作台任务',
|
|
1031
1033
|
'longTask.state.running': '运行中',
|
|
1032
1034
|
'longTask.state.needsHuman': '等你处理',
|
|
1033
1035
|
'longTask.state.needsLogin': '需要登录',
|