@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.
@@ -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
- ...(step.links === undefined
237
- ? {}
238
- : { links: step.links.slice(0, LONG_TASK_LINK_MAX) }),
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
- : [...(current.history ?? []), historyRow].slice(-LONG_TASK_HISTORY_MAX);
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.list.entry': 'Long tasks {n}',
1036
- 'longTask.list.title': 'All long tasks',
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.list.entry': '长任务 {n}',
1030
- 'longTask.list.title': '全部长任务',
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': '需要登录',