dsh-uitest 2.1.4 → 2.3.0

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/client.js CHANGED
@@ -43,6 +43,11 @@ window.__ModuleLoader__.load({
43
43
  if (!Number.isFinite(n) || n < 0) return '—';
44
44
  if (n < 1000) return Math.round(n) + 'ms';
45
45
  if (n < 60000) return (n / 1000).toFixed(n < 10000 ? 1 : 0) + 's';
46
+ if (n >= 3600000) {
47
+ const h = Math.floor(n / 3600000);
48
+ const m = Math.floor((n % 3600000) / 60000);
49
+ return h + 'h' + (m < 10 ? '0' : '') + m + 'm';
50
+ }
46
51
  const m = Math.floor(n / 60000);
47
52
  const s = Math.round((n % 60000) / 1000);
48
53
  return m + 'm' + (s < 10 ? '0' : '') + s + 's';
@@ -93,32 +98,99 @@ window.__ModuleLoader__.load({
93
98
  return parts[parts.length - 1] || String(projectPath || '');
94
99
  }
95
100
 
101
+ /** 运行状态是同一个领域概念:标签、色调、是否进行中、是否已判定,全站只从这里取。 */
102
+ const RUN_STATES = {
103
+ untested: { label: '未执行', tone: 'muted' },
104
+ pending: { label: '待执行', tone: 'muted' },
105
+ queued: { label: '排队中', tone: 'muted' },
106
+ preparing: { label: '准备中', tone: 'business', live: true },
107
+ running: { label: '执行中', tone: 'business', live: true },
108
+ passed: { label: '通过', tone: 'success', done: true },
109
+ partial: { label: '部分通过', tone: 'warn', done: true },
110
+ failed: { label: '失败', tone: 'danger', done: true },
111
+ blocked: { label: '阻塞', tone: 'warn', done: true },
112
+ stopped: { label: '已停止', tone: 'warn', done: true },
113
+ done: { label: '已完成', tone: 'success', done: true },
114
+ skipped: { label: '已跳过', tone: 'muted', done: true },
115
+ failed_batch: { label: '失败', tone: 'danger', done: true },
116
+ };
117
+
118
+ function runState(status) {
119
+ return RUN_STATES[status] || { label: status || '未执行', tone: 'muted' };
120
+ }
121
+
96
122
  function statusLabel(status) {
97
- return ({ passed: '通过', partial: '部分通过', failed: '失败', blocked: '阻塞', untested: '未执行', running: '执行中', queued: '排队中', pending: '待执行', done: '完成', stopped: '已停止', failed_batch: '失败' })[status] || status || '未执行';
123
+ return runState(status).label;
98
124
  }
99
125
 
100
126
  function statusTone(status) {
101
- if (status === 'passed') return 'success';
102
- if (status === 'failed') return 'danger';
103
- if (status === 'blocked') return 'warn';
104
- if (status === 'partial') return 'warn';
105
- if (status === 'running') return 'business';
106
- if (status === 'done') return 'success';
107
- if (status === 'stopped') return 'warn';
108
- if (status === 'queued' || status === 'pending') return 'muted';
109
- return 'muted';
127
+ return runState(status).tone;
110
128
  }
111
129
 
112
130
  function modeLabel(mode) {
113
131
  return ({ flow: '流程', agent: 'Agent', manual: '人工', blocked: '阻塞' })[mode] || mode || '—';
114
132
  }
115
133
 
116
- function batchPercent(batch) {
117
- if (!batch) return 0;
118
- const s = batch.summary || {};
119
- const done = (s.passed || 0) + (s.partial || 0) + (s.failed || 0) + (s.blocked || 0);
120
- const total = s.total || batch.cases?.length || 0;
121
- return total ? Math.round((done / total) * 100) : 0;
134
+ function batchProgress(batch) {
135
+ const s = (batch && batch.summary) || {};
136
+ const runs = asArray(batch && batch.cases);
137
+ const total = Number(s.total) || runs.length || 0;
138
+ const passed = Number(s.passed) || 0;
139
+ const partial = Number(s.partial) || 0;
140
+ const failed = Number(s.failed) || 0;
141
+ const blocked = Number(s.blocked) || 0;
142
+ const done = Number.isFinite(Number(s.done)) ? Number(s.done) : passed + partial + failed + blocked;
143
+ const runningRuns = runs.filter((run) => run.status === 'running' || run.queue?.state === 'running');
144
+ const queuedRuns = runs.filter((run) => run.status === 'queued' || run.queue?.state === 'queued');
145
+ const untested = Number(s.untested) || 0;
146
+ const stopped = Number(s.stopped) || 0;
147
+ const current = runningRuns[0] || null;
148
+ const stages = batch ? batchStageList(batch) : [];
149
+ const runningStage = stages.find((stage) => stage.status === 'running')
150
+ || stages.find((stage) => stage.status === 'failed')
151
+ || stages.find((stage) => stage.status === 'pending')
152
+ || stages[stages.length - 1]
153
+ || null;
154
+ const status = batch ? String(batch.status || '') : '';
155
+ const active = ['running', 'preparing', 'queued'].includes(status) || runningRuns.length > 0;
156
+ const startedAt = batch && (batch.startedAt || batch.createdAt);
157
+ const endedAt = batch && batch.endedAt;
158
+ const elapsedMs = startedAt
159
+ ? Math.max(0, (endedAt ? new Date(endedAt).getTime() : Date.now()) - new Date(startedAt).getTime())
160
+ : 0;
161
+ return {
162
+ total,
163
+ done,
164
+ passed,
165
+ partial,
166
+ failed,
167
+ blocked,
168
+ stopped,
169
+ queued: queuedRuns.length || Number(s.queued) || 0,
170
+ untested,
171
+ pending: (queuedRuns.length || Number(s.queued) || 0) + untested,
172
+ running: runningRuns.length,
173
+ // 还有未判定用例时最多 99%,避免 241/242 四舍五入成 100%。
174
+ percent: total ? (done >= total ? 100 : Math.min(99, Math.floor((done / total) * 100))) : 0,
175
+ current,
176
+ queuedRuns,
177
+ stage: runningStage,
178
+ active,
179
+ status,
180
+ elapsedMs,
181
+ startedAt,
182
+ };
183
+ }
184
+
185
+ function useElapsed(startedAt, active) {
186
+ const [now, setNow] = useState(() => Date.now());
187
+ useEffect(() => {
188
+ if (!active) return undefined;
189
+ const timer = setInterval(() => setNow(Date.now()), 1000);
190
+ return () => clearInterval(timer);
191
+ }, [active]);
192
+ const start = startedAt ? new Date(startedAt).getTime() : NaN;
193
+ return Number.isFinite(start) ? Math.max(0, now - start) : 0;
122
194
  }
123
195
 
124
196
  function readFileBase64(file) {
@@ -144,7 +216,7 @@ window.__ModuleLoader__.load({
144
216
  return String(value || '')
145
217
  .normalize('NFKC')
146
218
  .trim()
147
- .replace(/\.(md|markdown|txt|xlsx|json)$/i, '')
219
+ .replace(/\.(md|markdown|txt|xlsx|csv|json)$/i, '')
148
220
  .replace(/\s+/g, '')
149
221
  .toLowerCase();
150
222
  }
@@ -222,8 +294,11 @@ window.__ModuleLoader__.load({
222
294
  }
223
295
 
224
296
  function StatusBadge(props) {
225
- const status = props.status;
226
- return h('span', { className: cx('studio-status', 'tone-' + statusTone(status)) }, h('span', { className: 'studio-status-dot' }), statusLabel(status));
297
+ const state = runState(props.status);
298
+ return h('span', {
299
+ className: cx('studio-status', 'tone-' + state.tone, state.live ? 'is-live' : ''),
300
+ title: props.title || '',
301
+ }, h('span', { className: 'studio-status-dot' }), props.label || state.label);
227
302
  }
228
303
 
229
304
  function ModeBadge(props) {
@@ -242,14 +317,14 @@ window.__ModuleLoader__.load({
242
317
 
243
318
  function Progress(props) {
244
319
  const percent = Math.max(0, Math.min(100, Number(props.percent) || 0));
245
- return h('div', { className: cx('studio-progress', props.className) },
246
- h('div', { className: 'studio-progress-fill', style: { width: percent + '%' } }),
320
+ return h('div', { className: cx('studio-progress', props.tone ? 'is-' + props.tone : '', props.live ? 'is-live' : '', props.indeterminate ? 'is-indeterminate' : '', props.className) },
321
+ h('div', { className: 'studio-progress-fill', style: { width: (props.indeterminate ? 36 : percent) + '%' } }),
247
322
  props.label ? h('span', { className: 'studio-progress-label' }, props.label) : null
248
323
  );
249
324
  }
250
325
 
251
326
  function Spinner(props) {
252
- return h('span', { className: cx('studio-spinner', props.className) });
327
+ return h('span', { className: cx('studio-spinner', props.className), style: props.style });
253
328
  }
254
329
 
255
330
  function Empty(props) {
@@ -271,6 +346,207 @@ window.__ModuleLoader__.load({
271
346
  );
272
347
  }
273
348
 
349
+ function PageHeader(props) {
350
+ return h('div', { className: 'studio-page-head' },
351
+ h('div', null,
352
+ props.kicker ? h('div', { className: 'studio-page-kicker' }, props.icon ? h(Icon, { name: props.icon, size: 13 }) : null, props.kicker) : null,
353
+ h('h1', { className: 'studio-page-title' }, props.title),
354
+ props.desc ? h('p', { className: 'studio-page-desc' }, props.desc) : null,
355
+ props.meta ? h('div', { className: 'studio-page-meta' }, props.meta) : null
356
+ ),
357
+ props.actions ? h('div', { className: 'studio-page-actions' }, props.actions) : null
358
+ );
359
+ }
360
+
361
+ function MenuButton(props) {
362
+ const [open, setOpen] = useState(false);
363
+ const ref = useRef(null);
364
+ useEffect(() => {
365
+ if (!open) return undefined;
366
+ const close = (event) => { if (ref.current && !ref.current.contains(event.target)) setOpen(false); };
367
+ const escape = (event) => { if (event.key === 'Escape') setOpen(false); };
368
+ document.addEventListener('mousedown', close);
369
+ document.addEventListener('keydown', escape);
370
+ return () => {
371
+ document.removeEventListener('mousedown', close);
372
+ document.removeEventListener('keydown', escape);
373
+ };
374
+ }, [open]);
375
+ return h('div', { className: 'studio-menu', ref },
376
+ h('button', {
377
+ type: 'button',
378
+ className: cx('studio-btn', props.primary ? 'studio-btn-primary' : ''),
379
+ disabled: props.disabled,
380
+ onClick: () => setOpen((value) => !value),
381
+ 'aria-expanded': open,
382
+ }, props.icon ? h(Icon, { name: props.icon, size: 14 }) : null, props.label, h(Icon, { name: 'chevron', size: 12, className: 'studio-menu-caret' })),
383
+ open ? h('div', { className: 'studio-menu-pop', onClick: () => setOpen(false) }, props.children) : null
384
+ );
385
+ }
386
+
387
+ /**
388
+ * 固定行高的窗口列表:只渲染视口内与少量缓冲行,长列表滚动不再随行数变慢。
389
+ * 行高由调用方给出,行内容必须能在一行高度内裁切。
390
+ */
391
+ function VirtualList(props) {
392
+ const items = props.items || [];
393
+ const rowHeight = Number(props.rowHeight) || 72;
394
+ const overscan = props.overscan === undefined ? 6 : Number(props.overscan);
395
+ const ref = useRef(null);
396
+ const [scrollTop, setScrollTop] = useState(0);
397
+ const [viewport, setViewport] = useState(0);
398
+ useEffect(() => {
399
+ const element = ref.current;
400
+ if (!element) return undefined;
401
+ const update = () => setViewport(element.clientHeight);
402
+ update();
403
+ if (typeof ResizeObserver === 'undefined') {
404
+ window.addEventListener('resize', update);
405
+ return () => window.removeEventListener('resize', update);
406
+ }
407
+ const observer = new ResizeObserver(update);
408
+ observer.observe(element);
409
+ return () => observer.disconnect();
410
+ }, []);
411
+ useEffect(() => {
412
+ const element = ref.current;
413
+ if (!element) return;
414
+ element.scrollTop = 0;
415
+ setScrollTop(0);
416
+ }, [props.resetKey]);
417
+ if (!items.length) return props.empty || null;
418
+ const first = Math.floor(scrollTop / rowHeight);
419
+ const start = Math.max(0, Math.min(first, items.length - 1) - overscan);
420
+ const end = Math.min(items.length, Math.ceil((scrollTop + (viewport || rowHeight * 10)) / rowHeight) + overscan);
421
+ const visible = items.slice(start, end);
422
+ return h('div', {
423
+ ref,
424
+ className: cx('studio-virtual', props.className),
425
+ onScroll: (event) => setScrollTop(event.currentTarget.scrollTop),
426
+ role: 'list',
427
+ 'aria-label': props.ariaLabel || '',
428
+ },
429
+ h('div', { className: 'studio-virtual-inner', style: { height: items.length * rowHeight } },
430
+ visible.map((item, index) => {
431
+ const position = start + index;
432
+ const key = props.keyFor ? props.keyFor(item, position) : (item?.tcId || item?.caseId || item?.id || position);
433
+ return h('div', {
434
+ key,
435
+ className: 'studio-virtual-row',
436
+ style: { top: position * rowHeight, height: rowHeight },
437
+ role: 'listitem',
438
+ }, props.renderRow(item, position));
439
+ })
440
+ )
441
+ );
442
+ }
443
+
444
+ function StageStrip(props) {
445
+ const stages = props.stages || batchStageList(props.batch || {});
446
+ if (!stages.length) return null;
447
+ return h('div', { className: 'studio-stage-strip' },
448
+ stages.map((stage) => h('div', { key: stage.id, className: cx('studio-stage-item', 'is-' + stage.status) },
449
+ h('span', { className: 'studio-stage-dot' }, stage.status === 'done' ? h(Icon, { name: 'check', size: 10 }) : stage.status === 'running' ? h(Spinner, { style: { width: 9, height: 9, borderWidth: 1.5 } }) : null),
450
+ h('div', { className: 'studio-stage-body' },
451
+ h('div', { className: 'studio-stage-label' }, stage.label),
452
+ h('div', { className: 'studio-stage-meta' }, stage.status === 'running' ? '进行中…' : stage.meta || statusLabel(stage.status))
453
+ )
454
+ ))
455
+ );
456
+ }
457
+
458
+ function ExecutionBanner(props) {
459
+ const batch = props.batch;
460
+ const progress = props.progress || batchProgress(batch);
461
+ const state = runState(batch.status === 'preparing' ? 'preparing' : batch.status);
462
+ const liveElapsed = useElapsed(progress.startedAt, progress.active);
463
+ const elapsed = progress.active ? liveElapsed : progress.elapsedMs;
464
+ const current = progress.current;
465
+ const title = current ? (current.title || current.caseId) : '';
466
+ const note = current ? (current.note || current.agentLive?.note || '') : '';
467
+ const queuedAhead = current?.queue?.ahead ?? progress.queuedRuns[0]?.queue?.ahead;
468
+ const currentLabel = current
469
+ ? (current.status === 'running' ? '正在执行' : '准备执行')
470
+ : progress.active && progress.queued
471
+ ? '等待调度 · 队列 ' + progress.queued + ' 条'
472
+ : progress.active
473
+ ? '批次运行中'
474
+ : progress.done >= progress.total && progress.total
475
+ ? '本批次已结束'
476
+ : '等待开始';
477
+ return h('div', { className: cx('studio-execution', 'tone-' + state.tone, props.compact ? 'is-compact' : '') },
478
+ h('div', { className: 'studio-execution-inner' },
479
+ h('div', { className: 'studio-execution-top' },
480
+ h('div', { style: { minWidth: 0 } },
481
+ h('div', { className: 'studio-execution-title' }, batch.name || batch.id),
482
+ h('div', { className: 'studio-execution-sub' },
483
+ h(StatusBadge, { status: batch.status === 'preparing' ? 'preparing' : batch.status }),
484
+ progress.stage ? h('span', null, '阶段:' + progress.stage.label) : null,
485
+ progress.startedAt ? h('span', null, (progress.active ? '已用时 ' : '用时 ') + formatDuration(elapsed)) : null,
486
+ batch.options?.concurrency && !props.compact ? h('span', null, '并发 ' + batch.options.concurrency) : null,
487
+ progress.total && !props.compact ? h('span', null, progress.total + ' 条用例') : null
488
+ )
489
+ ),
490
+ props.actions ? h('div', { className: 'studio-execution-side' }, props.actions) : null
491
+ ),
492
+ h('div', { className: 'studio-execution-progress' },
493
+ h('div', { className: 'studio-execution-progress-head' },
494
+ h('span', { className: 'studio-execution-percent' }, progress.percent + '%'),
495
+ h('span', { className: 'studio-execution-count' },
496
+ progress.done + ' / ' + progress.total + ' 已判定 · 执行中 ' + progress.running + ' · 排队 ' + progress.queued
497
+ )
498
+ ),
499
+ h(Progress, {
500
+ percent: progress.percent,
501
+ tone: progress.failed ? 'danger' : progress.active ? 'business' : 'success',
502
+ live: progress.active,
503
+ })
504
+ ),
505
+ props.compact ? null : h('div', { className: 'studio-execution-metrics' },
506
+ h('div', { className: 'studio-metric' }, h('div', { className: 'studio-metric-value tone-success' }, progress.passed), h('div', { className: 'studio-metric-label' }, '通过' + (progress.partial ? ' +' + progress.partial + ' 部分' : ''))),
507
+ h('div', { className: 'studio-metric' }, h('div', { className: 'studio-metric-value tone-danger' }, progress.failed), h('div', { className: 'studio-metric-label' }, '失败')),
508
+ h('div', { className: 'studio-metric' }, h('div', { className: 'studio-metric-value tone-warn' }, progress.blocked), h('div', { className: 'studio-metric-label' }, '阻塞')),
509
+ h('div', { className: 'studio-metric' }, h('div', { className: 'studio-metric-value' }, progress.pending), h('div', { className: 'studio-metric-label' }, '待执行')),
510
+ progress.stopped ? h('div', { className: 'studio-metric' }, h('div', { className: 'studio-metric-value tone-warn' }, progress.stopped), h('div', { className: 'studio-metric-label' }, '已停止')) : null
511
+ ),
512
+ h('div', { className: cx('studio-execution-current', progress.active && current ? 'is-live' : '') },
513
+ h('span', { className: 'studio-execution-current-icon' },
514
+ progress.active ? h(Spinner) : h(Icon, { name: state.done ? 'check' : 'clock', size: 14 })
515
+ ),
516
+ h('div', { className: 'studio-execution-current-main' },
517
+ h('div', { className: 'studio-execution-current-title' }, current ? currentLabel + ' · ' + title : currentLabel),
518
+ note ? h('div', { className: 'studio-execution-current-note' }, note) : null
519
+ ),
520
+ queuedAhead !== undefined && queuedAhead !== null && progress.active && (!current || current.status !== 'running')
521
+ ? h('span', { className: 'studio-execution-current-meta' }, '前方 ' + queuedAhead + ' 条')
522
+ : null
523
+ ),
524
+ props.compact || props.showStages === false ? null : h(StageStrip, { stages: batchStageList(batch) })
525
+ )
526
+ );
527
+ }
528
+
529
+ function OperationProgress(props) {
530
+ const elapsed = useElapsed(props.startedAt, props.active !== false);
531
+ return h('div', { className: 'studio-op', role: 'status', 'aria-live': 'polite' },
532
+ h('div', { className: 'studio-op-head' },
533
+ h(Spinner),
534
+ h('span', { className: 'studio-op-title' }, props.label || '正在处理'),
535
+ h('span', { className: 'studio-op-time' }, formatDuration(elapsed))
536
+ ),
537
+ props.detail ? h('div', { className: 'studio-op-detail' }, props.detail) : null,
538
+ props.steps && props.steps.length
539
+ ? h('div', { className: 'studio-op-steps' },
540
+ props.steps.map((step, index) => h('span', {
541
+ key: index,
542
+ className: cx('studio-op-step', step.status === 'done' ? 'is-done' : step.status === 'active' ? 'is-active' : ''),
543
+ }, h('span', { className: 'studio-op-step-dot' }), step.label))
544
+ )
545
+ : null,
546
+ h('div', { className: 'studio-op-bar' }, h(Progress, { indeterminate: true, tone: 'business' }))
547
+ );
548
+ }
549
+
274
550
  function Field(props) {
275
551
  return h('label', { className: 'studio-field' },
276
552
  h('span', { className: 'studio-field-label' }, props.label),
@@ -294,13 +570,18 @@ window.__ModuleLoader__.load({
294
570
  return () => window.removeEventListener('keydown', onKey);
295
571
  }, [props.onClose]);
296
572
  return h('div', { className: 'studio-modal-overlay', onMouseDown: (e) => { if (e.target === e.currentTarget) props.onClose(); } },
297
- h('div', { className: cx('studio-modal', props.wide ? 'studio-modal-wide' : '') },
573
+ h('div', {
574
+ className: cx('studio-modal', props.wide ? 'studio-modal-wide' : ''),
575
+ role: 'dialog',
576
+ 'aria-modal': 'true',
577
+ 'aria-label': props.title || '对话框',
578
+ },
298
579
  h('div', { className: 'studio-modal-head' },
299
580
  h('div', null,
300
581
  h('h3', { className: 'studio-modal-title' }, props.title),
301
582
  props.desc ? h('p', { className: 'studio-modal-desc' }, props.desc) : null
302
583
  ),
303
- h('button', { className: 'studio-icon-btn', onClick: props.onClose, title: '关闭' }, h(Icon, { name: 'x', size: 16 }))
584
+ h('button', { className: 'studio-icon-btn', onClick: props.onClose, title: '关闭', 'aria-label': '关闭对话框' }, h(Icon, { name: 'x', size: 16 }))
304
585
  ),
305
586
  h('div', { className: 'studio-modal-body' }, props.children),
306
587
  props.footer ? h('div', { className: 'studio-modal-foot' }, props.footer) : null
@@ -352,282 +633,513 @@ window.__ModuleLoader__.load({
352
633
  /* ------------------------------------------------------------------ */
353
634
 
354
635
  const CSS = [
355
- '.studio-root{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;height:100%;overflow:hidden;position:relative;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.5}',
356
- '.studio-topbar{flex:none;display:flex;align-items:center;gap:12px;padding:12px 18px;border-bottom:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}',
357
- '.studio-brand{display:flex;align-items:center;gap:10px;min-width:0}',
358
- '.studio-logo{width:30px;height:30px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-inverted);flex:none}',
359
- '.studio-brand-title{font-size:15px;font-weight:650;letter-spacing:.2px;line-height:1.2}',
360
- '.studio-brand-sub{font-size:11px;color:var(--dsw-alias-label-tertiary);line-height:1.3}',
636
+ /* ---------- 设计令牌:一处定义,全站复用 ---------- */
637
+ '.studio-root{--ui-bg:var(--dsw-alias-bg-base,#f6f7f9);--ui-surface:var(--dsw-alias-bg-layer-1,#ffffff);--ui-surface-2:var(--dsw-alias-bg-layer-2,#f1f3f5);--ui-text:var(--dsw-alias-label-primary,#1f2329);--ui-text-2:var(--dsw-alias-label-secondary,#4e5969);--ui-text-3:var(--dsw-alias-label-tertiary,#86909c);--ui-border:var(--dsw-alias-border-l1,#e5e6eb);--ui-accent:var(--dsw-alias-link,#1f6feb);--ui-accent-fill:var(--dsw-alias-button-primary-fill,#1f6feb);--ui-accent-hover:var(--dsw-alias-button-primary-hover,#1a5fc7);--ui-accent-soft:color-mix(in srgb,var(--dsw-alias-link,#1f6feb) 10%,transparent);--ui-success:var(--dsw-alias-state-success-primary,#12a150);--ui-danger:var(--dsw-alias-state-error-primary,#d92d20);--ui-warn:var(--dsw-alias-state-warn-primary,#d97706);--ui-business:var(--dsw-alias-state-business-primary,#7c3aed);--ui-hover:var(--dsw-alias-interactive-bg-hover,#f2f3f5);--ui-active:var(--dsw-alias-interactive-bg-active,#e8f0fe);--ui-radius:12px;--ui-radius-sm:8px;--ui-shadow:0 1px 2px color-mix(in srgb,var(--ui-bg) 55%,transparent);--ui-shadow-lg:0 18px 44px color-mix(in srgb,var(--ui-bg) 52%,transparent);--ui-mono:"JetBrains Mono",ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;--ui-font:"Inter","IBM Plex Sans",-apple-system,BlinkMacSystemFont,"Segoe UI","PingFang SC","Microsoft YaHei",sans-serif}',
638
+ '.studio-root{display:flex;flex-direction:column;flex:1;min-width:0;min-height:0;height:100%;overflow:hidden;position:relative;background:var(--ui-bg);color:var(--ui-text);font-family:var(--ui-font);font-size:13.5px;line-height:1.55;-webkit-font-smoothing:antialiased}',
639
+ '.studio-root *{box-sizing:border-box}',
640
+ '.studio-root ::selection{background:color-mix(in srgb,var(--ui-accent) 22%,transparent)}',
641
+ '.studio-root button:focus-visible,.studio-root input:focus-visible,.studio-root select:focus-visible,.studio-root textarea:focus-visible,.studio-root [role=button]:focus-visible{outline:2px solid var(--ui-accent);outline-offset:2px}',
642
+ '.studio-root ::-webkit-scrollbar{width:10px;height:10px}',
643
+ '.studio-root ::-webkit-scrollbar-thumb{background:color-mix(in srgb,var(--ui-text-3) 34%,transparent);border-radius:999px;border:2px solid transparent;background-clip:padding-box}',
644
+ '.studio-root ::-webkit-scrollbar-track{background:transparent}',
645
+
646
+ /* ---------- 顶栏 ---------- */
647
+ '.studio-topbar{flex:none;display:flex;align-items:center;gap:10px;min-height:56px;padding:0 18px;border-bottom:1px solid var(--ui-border);background:var(--ui-surface);position:relative;z-index:20}',
648
+ '.studio-brand{display:flex;align-items:center;gap:10px;min-width:0;flex:none}',
649
+ '.studio-logo{width:30px;height:30px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;background:linear-gradient(145deg,var(--ui-accent-fill),color-mix(in srgb,var(--ui-accent-fill) 70%,var(--ui-business)));color:var(--dsw-alias-label-primary-inverted,#fff);flex:none;box-shadow:0 2px 6px color-mix(in srgb,var(--ui-accent) 24%,transparent)}',
650
+ '.studio-brand-title{font-size:14.5px;font-weight:680;letter-spacing:-.1px;line-height:1.2}',
651
+ '.studio-brand-sub{font-size:10.5px;color:var(--ui-text-3);line-height:1.3;margin-top:1px}',
361
652
  '.studio-topbar-spacer{flex:1 1 auto;min-width:8px}',
362
- '.studio-env{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}',
363
- '.studio-env-dot{width:7px;height:7px;border-radius:50%;background:var(--dsw-alias-state-success-primary);flex:none}',
364
- '.studio-env-dot.is-warn{background:var(--dsw-alias-state-warn-primary)}',
365
- '.studio-env-dot.is-fail{background:var(--dsw-alias-state-error-primary)}',
366
- '.studio-select{height:28px;padding:0 8px;border-radius:6px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-size:12px;font-family:inherit;outline:none;max-width:200px}',
367
- '.studio-input,.studio-textarea{box-sizing:border-box;width:100%;height:30px;padding:0 9px;border-radius:7px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-size:12px;font-family:inherit;outline:none}',
368
- '.studio-textarea{height:auto;min-height:80px;padding:7px 9px;resize:vertical;line-height:1.55}',
369
- '.studio-input:focus,.studio-textarea:focus{border-color:var(--dsw-alias-link)}',
370
- '.studio-btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;height:29px;padding:0 11px;border-radius:7px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary);font-size:12px;font-family:inherit;cursor:pointer;white-space:nowrap;transition:background .12s ease,opacity .12s ease}',
371
- '.studio-btn-icon{padding-left:8px;padding-right:8px}',
372
- '.studio-folder-icon{flex:none;display:inline-flex;align-items:center;color:var(--dsw-alias-label-secondary)}',
373
- '.studio-workspace-row{display:flex;align-items:center;gap:8px;width:100%;padding:9px 11px;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;cursor:pointer;text-align:left}',
374
- '.studio-workspace-row:hover{background:var(--dsw-alias-interactive-bg-hover)}',
375
- '.studio-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover)}',
653
+ '.studio-env{display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 9px;border-radius:999px;border:1px solid var(--ui-border);background:var(--ui-surface-2);font-size:10.5px;color:var(--ui-text-2);white-space:nowrap;max-width:230px;overflow:hidden;text-overflow:ellipsis}',
654
+ '.studio-topbar-live{display:inline-flex;align-items:center;gap:7px;height:28px;padding:0 10px;border-radius:999px;border:1px solid color-mix(in srgb,var(--ui-business) 34%,var(--ui-border));background:color-mix(in srgb,var(--ui-business) 8%,var(--ui-surface));color:var(--ui-text);font:inherit;font-size:11px;cursor:pointer;white-space:nowrap;flex:none}',
655
+ '.studio-topbar-live:hover{background:color-mix(in srgb,var(--ui-business) 14%,var(--ui-surface))}',
656
+ '.studio-topbar-live-label{color:var(--ui-business);font-weight:650}',
657
+ '.studio-topbar-live-num{font-variant-numeric:tabular-nums;font-weight:650}',
658
+ '.studio-topbar-live-sub{color:var(--ui-text-3);font-variant-numeric:tabular-nums}',
659
+ '.studio-nav-live{width:6px;height:6px;border-radius:50%;background:var(--ui-business);flex:none;animation:studio-pulse 1.15s ease-in-out infinite}',
660
+ '.studio-env-dot{width:6px;height:6px;border-radius:50%;background:var(--ui-success);flex:none}',
661
+ '.studio-env-dot.is-warn{background:var(--ui-warn)}',
662
+ '.studio-env-dot.is-fail{background:var(--ui-danger)}',
663
+ '.studio-select{height:28px;padding:0 26px 0 9px;border-radius:7px;border:1px solid var(--ui-border);background:var(--ui-surface-2);color:var(--ui-text);font-size:11.5px;font-family:inherit;outline:none;max-width:220px;appearance:none;background-image:linear-gradient(45deg,transparent 50%,var(--ui-text-3) 50%),linear-gradient(135deg,var(--ui-text-3) 50%,transparent 50%);background-position:calc(100% - 13px) 12px,calc(100% - 9px) 12px;background-size:4px 4px,4px 4px;background-repeat:no-repeat;cursor:pointer}',
664
+ '.studio-select:hover{border-color:color-mix(in srgb,var(--ui-text-3) 42%,var(--ui-border))}',
665
+
666
+ /* ---------- 基础控件 ---------- */
667
+ '.studio-input,.studio-textarea{width:100%;height:32px;padding:0 10px;border-radius:8px;border:1px solid var(--ui-border);background:var(--ui-surface);color:var(--ui-text);font-size:12.5px;font-family:inherit;outline:none;transition:border-color .15s ease,box-shadow .15s ease}',
668
+ '.studio-textarea{height:auto;min-height:84px;padding:8px 10px;resize:vertical;line-height:1.6}',
669
+ '.studio-input:hover,.studio-textarea:hover{border-color:color-mix(in srgb,var(--ui-text-3) 42%,var(--ui-border))}',
670
+ '.studio-input:focus,.studio-textarea:focus{border-color:var(--ui-accent);box-shadow:0 0 0 3px var(--ui-accent-soft)}',
671
+ '.studio-input::placeholder,.studio-textarea::placeholder{color:var(--ui-text-3)}',
672
+ '.studio-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;height:30px;padding:0 12px;border-radius:8px;border:1px solid var(--ui-border);background:var(--ui-surface);color:var(--ui-text);font-size:12px;font-weight:550;font-family:inherit;cursor:pointer;white-space:nowrap;transition:background .14s ease,border-color .14s ease,transform .06s ease}',
673
+ '.studio-btn:hover:not(:disabled){background:var(--ui-hover);border-color:color-mix(in srgb,var(--ui-text-3) 36%,var(--ui-border))}',
674
+ '.studio-btn:active:not(:disabled){transform:translateY(1px)}',
376
675
  '.studio-btn:disabled{opacity:.45;cursor:not-allowed}',
377
- '.studio-btn-primary{border-color:transparent;background:var(--dsw-alias-button-primary-fill);color:var(--dsw-alias-label-primary-inverted)}',
378
- '.studio-btn-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-hover)}',
379
- '.studio-btn-danger{color:var(--dsw-alias-state-error-primary);background:transparent}',
380
- '.studio-btn-sm{height:24px;padding:0 8px;font-size:11px;border-radius:6px}',
381
- '.studio-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:26px;height:26px;border-radius:6px;border:0;background:transparent;color:var(--dsw-alias-label-tertiary);cursor:pointer}',
382
- '.studio-icon-btn:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}',
676
+ '.studio-btn-primary{border-color:transparent;background:var(--ui-accent-fill);color:var(--dsw-alias-label-primary-inverted,#fff);box-shadow:0 1px 2px color-mix(in srgb,var(--ui-accent) 28%,transparent)}',
677
+ '.studio-btn-primary:hover:not(:disabled){background:var(--ui-accent-hover);border-color:transparent}',
678
+ '.studio-btn-danger{color:var(--ui-danger);background:transparent;border-color:color-mix(in srgb,var(--ui-danger) 26%,var(--ui-border))}',
679
+ '.studio-btn-danger:hover:not(:disabled){background:color-mix(in srgb,var(--ui-danger) 8%,transparent);border-color:color-mix(in srgb,var(--ui-danger) 42%,var(--ui-border))}',
680
+ '.studio-btn-sm{height:25px;padding:0 9px;font-size:11px;border-radius:7px}',
681
+ '.studio-btn-icon{padding-left:8px;padding-right:8px}',
682
+ '.studio-icon-btn{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border-radius:7px;border:0;background:transparent;color:var(--ui-text-3);cursor:pointer;transition:background .12s ease,color .12s ease}',
683
+ '.studio-icon-btn:hover{background:var(--ui-hover);color:var(--ui-text)}',
684
+ '.studio-menu{position:relative;display:inline-flex}',
685
+ '.studio-menu-caret{transform:rotate(90deg);opacity:.65;margin-left:1px}',
686
+ '.studio-menu-pop{position:absolute;right:0;top:calc(100% + 6px);z-index:60;min-width:190px;padding:5px;border:1px solid var(--ui-border);border-radius:10px;background:var(--ui-surface);box-shadow:var(--ui-shadow-lg)}',
687
+ '.studio-menu-pop .studio-btn{width:100%;justify-content:flex-start;border:0;background:transparent;box-shadow:none;height:31px;font-weight:500}',
688
+ '.studio-menu-pop .studio-btn:hover:not(:disabled){background:var(--ui-hover)}',
689
+ '.studio-folder-icon{flex:none;display:inline-flex;align-items:center;color:var(--ui-text-2)}',
690
+ '.studio-workspace-row{display:flex;align-items:center;gap:9px;width:100%;padding:10px 11px;border:1px solid var(--ui-border);border-radius:9px;background:var(--ui-surface);color:var(--ui-text);font:inherit;cursor:pointer;text-align:left;transition:background .12s ease,border-color .12s ease}',
691
+ '.studio-workspace-row:hover{background:var(--ui-hover);border-color:color-mix(in srgb,var(--ui-text-3) 36%,var(--ui-border))}',
692
+
693
+ /* ---------- 骨架与侧栏 ---------- */
383
694
  '.studio-body{display:flex;flex:1;min-height:0;overflow:hidden}',
384
- '.studio-rail{width:208px;flex:none;display:flex;flex-direction:column;gap:4px;padding:12px 10px;border-right:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}',
385
- '.studio-rail-group{font-size:10px;letter-spacing:.8px;text-transform:uppercase;color:var(--dsw-alias-label-tertiary);padding:8px 10px 4px}',
386
- '.studio-nav{display:flex;align-items:center;gap:9px;height:34px;padding:0 10px;border-radius:8px;border:0;background:transparent;color:var(--dsw-alias-label-secondary);font-size:12.5px;font-family:inherit;cursor:pointer;text-align:left;width:100%}',
387
- '.studio-nav:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}',
388
- '.studio-nav.is-active{background:var(--dsw-alias-interactive-bg-active);color:var(--dsw-alias-label-primary);font-weight:600}',
389
- '.studio-nav-icon{display:inline-flex;color:var(--dsw-alias-label-tertiary)}',
390
- '.studio-nav.is-active .studio-nav-icon{color:var(--dsw-alias-link)}',
391
- '.studio-nav-badge{margin-left:auto;font-size:10px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}',
392
- '.studio-rail-foot{margin-top:auto;padding:10px;border-top:1px solid var(--dsw-alias-border-l1);font-size:11px;color:var(--dsw-alias-label-tertiary)}',
393
- '.studio-main{flex:1;min-width:0;overflow-y:auto;overflow-x:hidden;scroll-behavior:smooth}',
394
- '.studio-content{max-width:1120px;margin:0 auto;padding:22px 28px 56px}',
395
- '.studio-page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:18px}',
396
- '.studio-page-title{font-size:20px;font-weight:650;letter-spacing:.2px;margin:0}',
397
- '.studio-page-desc{margin:5px 0 0;color:var(--dsw-alias-label-secondary);font-size:12.5px;max-width:680px}',
398
- '.studio-page-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end}',
399
- '.studio-card{border:1px solid var(--dsw-alias-border-l1);border-radius:12px;background:var(--dsw-alias-bg-layer-1);padding:16px 18px}',
400
- '.studio-card + .studio-card{margin-top:14px}',
401
- '.studio-hero{position:relative;overflow:hidden;border:1px solid var(--dsw-alias-border-l1);border-radius:16px;background:var(--dsw-alias-bg-layer-1);padding:26px 28px 22px}',
402
- '.studio-hero:after{content:"";position:absolute;right:-60px;top:-80px;width:260px;height:260px;border-radius:50%;background:radial-gradient(circle,var(--dsw-alias-interactive-bg-hover),transparent 68%);pointer-events:none}',
403
- '.studio-hero-kicker{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dsw-alias-link);letter-spacing:.4px;text-transform:uppercase;margin-bottom:10px}',
404
- '.studio-hero-title{margin:0;font-size:25px;line-height:1.3;font-weight:680;letter-spacing:.2px;max-width:720px}',
405
- '.studio-hero-desc{margin:9px 0 0;color:var(--dsw-alias-label-secondary);font-size:13px;max-width:720px}',
406
- '.studio-hero-actions{display:flex;gap:9px;flex-wrap:wrap;margin-top:18px}',
407
- '.studio-pipeline{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:8px;margin-top:22px;position:relative;z-index:1}',
408
- '.studio-pipe{display:flex;flex-direction:column;gap:6px;padding:10px 10px 9px;border-radius:10px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);min-width:0}',
695
+ '.studio-rail{width:176px;flex:none;display:flex;flex-direction:column;gap:3px;padding:14px 8px 10px;border-right:1px solid var(--ui-border);background:var(--ui-surface);overflow-y:auto}',
696
+ '.studio-rail-group{font-size:10.5px;letter-spacing:.2px;color:var(--ui-text-3);padding:6px 9px 6px;font-weight:600}',
697
+ '.studio-nav{position:relative;display:flex;align-items:center;gap:9px;height:36px;padding:0 9px;border-radius:8px;border:0;background:transparent;color:var(--ui-text-2);font-size:12.5px;font-weight:500;font-family:inherit;cursor:pointer;text-align:left;width:100%;transition:background .12s ease,color .12s ease}',
698
+ '.studio-nav:hover{background:var(--ui-hover);color:var(--ui-text)}',
699
+ '.studio-nav.is-active{background:var(--ui-active);color:var(--ui-text);font-weight:650}',
700
+ '.studio-nav.is-active:before{content:"";position:absolute;left:0;top:9px;bottom:9px;width:3px;border-radius:0 3px 3px 0;background:var(--ui-accent)}',
701
+ '.studio-nav-icon{display:inline-flex;color:var(--ui-text-3);flex:none}',
702
+ '.studio-nav.is-active .studio-nav-icon{color:var(--ui-accent)}',
703
+ '.studio-nav-badge{margin-left:auto;font-size:10.5px;color:var(--ui-text-3);font-variant-numeric:tabular-nums;background:var(--ui-surface-2);border-radius:999px;padding:0 6px;line-height:18px;min-width:20px;text-align:center}',
704
+ '.studio-rail-foot{margin-top:auto;padding:12px 9px 4px;border-top:1px solid var(--ui-border);font-size:10.5px;color:var(--ui-text-3);line-height:1.7}',
705
+ '.studio-rail-foot .studio-code{font-size:10px}',
706
+ '.studio-main{flex:1;min-width:0;overflow-y:auto;overflow-x:hidden;scroll-behavior:smooth;scrollbar-gutter:stable}',
707
+ '.studio-content{width:100%;max-width:1680px;margin:0 auto;padding:26px 32px 72px}',
708
+
709
+ /* ---------- 页头 ---------- */
710
+ '.studio-page-head{display:flex;align-items:flex-start;justify-content:space-between;gap:20px;margin-bottom:18px;flex-wrap:wrap}',
711
+ '.studio-page-head>div:first-child{min-width:0;flex:1 1 320px}',
712
+ '.studio-page-kicker{display:inline-flex;align-items:center;gap:6px;font-size:11px;font-weight:600;color:var(--ui-accent);margin-bottom:5px}',
713
+ '.studio-page-title{font-size:22px;font-weight:700;letter-spacing:-.3px;line-height:1.28;margin:0}',
714
+ '.studio-page-desc{margin:6px 0 0;color:var(--ui-text-2);font-size:12.5px;line-height:1.6;max-width:760px}',
715
+ '.studio-page-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:10px}',
716
+ '.studio-page-actions{display:flex;gap:8px;flex-wrap:wrap;justify-content:flex-end;align-items:center;flex:0 1 auto}',
717
+
718
+ /* ---------- 容器 ---------- */
719
+ '.studio-card{border:1px solid var(--ui-border);border-radius:var(--ui-radius);background:var(--ui-surface);padding:16px 18px;box-shadow:var(--ui-shadow)}',
720
+ '.studio-card + .studio-card{margin-top:12px}',
721
+ '.studio-card-flush{padding:10px}',
722
+ '.studio-card-flush .studio-list-head{padding:2px 4px 0}',
723
+ '.studio-empty-wrap{padding:24px 16px;border:1px dashed var(--ui-border);border-radius:10px;background:var(--ui-surface)}',
724
+ '.studio-backbar{display:flex;align-items:center;gap:8px;margin-bottom:10px;flex-wrap:wrap}',
725
+ '.studio-meta-strip{display:flex;align-items:center;gap:6px 16px;flex-wrap:wrap;font-size:11px;color:var(--ui-text-3);margin:10px 0 0;font-variant-numeric:tabular-nums}',
726
+ '.studio-meta-strip .studio-code{max-width:320px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;display:inline-block;vertical-align:middle}',
727
+ '.studio-results-head{display:flex;align-items:flex-end;justify-content:space-between;gap:12px;margin:18px 0 10px;flex-wrap:wrap}',
728
+ '.studio-results-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}',
729
+ '.studio-loading{display:flex;align-items:center;gap:9px;padding:16px 2px;color:var(--ui-text-3);font-size:11.5px}',
730
+ '.studio-central-metrics{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:0;margin-top:12px;border-top:1px solid var(--ui-border);padding-top:11px}',
731
+ '.studio-central-metric{display:flex;flex-direction:column;gap:2px;padding:0 14px;border-left:1px solid var(--ui-border);min-width:0}',
732
+ '.studio-central-metric:first-child{padding-left:0;border-left:0}',
733
+ '.studio-central-metric-value{font-size:17px;font-weight:680;font-variant-numeric:tabular-nums;line-height:1.25;letter-spacing:-.2px}',
734
+ '.studio-central-metric-label{font-size:10px;color:var(--ui-text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
735
+ '.studio-virtual .studio-result-row,.studio-virtual .studio-case{height:100%}',
736
+ '.studio-virtual .studio-result-main{gap:2px}',
737
+ '.studio-virtual .studio-result-summary{-webkit-line-clamp:1;line-clamp:1}',
738
+ '.studio-hero{position:relative;overflow:hidden;border:1px solid var(--ui-border);border-radius:16px;background:var(--ui-surface);padding:24px 26px 22px;box-shadow:var(--ui-shadow)}',
739
+ '.studio-hero:before{content:"";position:absolute;left:0;top:0;right:0;height:3px;background:linear-gradient(90deg,var(--ui-accent),color-mix(in srgb,var(--ui-business) 70%,var(--ui-accent)))}',
740
+ '.studio-hero-grid{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(280px,.85fr);gap:26px;align-items:start}',
741
+ '.studio-hero-kicker{display:inline-flex;align-items:center;gap:6px;font-size:11px;font-weight:650;color:var(--ui-accent);margin-bottom:8px}',
742
+ '.studio-hero-title{margin:0;font-size:27px;line-height:1.25;font-weight:720;letter-spacing:-.6px;max-width:640px}',
743
+ '.studio-hero-desc{margin:10px 0 0;color:var(--ui-text-2);font-size:12.5px;line-height:1.7;max-width:640px}',
744
+ '.studio-hero-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:18px}',
745
+ '.studio-pipeline{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:0;margin-top:22px;border:1px solid var(--ui-border);border-radius:11px;overflow:hidden;background:var(--ui-surface-2)}',
746
+ '.studio-pipe{display:flex;flex-direction:column;gap:5px;padding:11px 12px 10px;background:var(--ui-surface);border-top:2px solid transparent;min-width:0;position:relative}',
747
+ '.studio-pipe + .studio-pipe{border-left:1px solid var(--ui-border)}',
748
+ '.studio-pipe.is-active{border-top-color:var(--ui-business);background:color-mix(in srgb,var(--ui-business) 5%,var(--ui-surface))}',
749
+ '.studio-pipe.is-done{border-top-color:var(--ui-success)}',
750
+ '.studio-pipe.is-blocked{border-top-color:var(--ui-warn)}',
409
751
  '.studio-pipe-top{display:flex;align-items:center;justify-content:space-between;gap:6px}',
410
- '.studio-pipe-index{font-size:10px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}',
411
- '.studio-pipe-icon{display:inline-flex;color:var(--dsw-alias-link)}',
752
+ '.studio-pipe-index{font-size:9.5px;color:var(--ui-text-3);font-variant-numeric:tabular-nums;font-family:var(--ui-mono)}',
753
+ '.studio-pipe-icon{display:inline-flex;color:var(--ui-accent)}',
412
754
  '.studio-pipe-name{font-size:11.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
413
- '.studio-pipe-value{font-size:18px;font-weight:650;line-height:1.1;font-variant-numeric:tabular-nums}',
414
- '.studio-pipe-hint{font-size:10px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
415
- '.studio-stat-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px;margin-top:16px}',
416
- '.studio-stat{border:1px solid var(--dsw-alias-border-l1);border-radius:12px;background:var(--dsw-alias-bg-layer-1);padding:13px 15px;min-width:0}',
417
- '.studio-stat-label{font-size:11px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
418
- '.studio-stat-value{font-size:24px;font-weight:660;line-height:1.25;font-variant-numeric:tabular-nums}',
419
- '.studio-stat-hint{font-size:10.5px;color:var(--dsw-alias-label-tertiary);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
420
- '.studio-grid-2{display:grid;grid-template-columns:minmax(0,1.35fr) minmax(0,1fr);gap:16px;margin-top:16px;align-items:start}',
755
+ '.studio-pipe-value{font-size:18px;font-weight:680;line-height:1.15;font-variant-numeric:tabular-nums;letter-spacing:-.3px}',
756
+ '.studio-pipe-hint{font-size:9.5px;color:var(--ui-text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
757
+ '.studio-stat-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));margin-top:16px;border:1px solid var(--ui-border);border-radius:var(--ui-radius);background:var(--ui-surface);overflow:hidden;box-shadow:var(--ui-shadow)}',
758
+ '.studio-stat{padding:13px 16px;min-width:0;border-left:1px solid var(--ui-border)}',
759
+ '.studio-stat:first-child{border-left:0}',
760
+ '.studio-stat-label{font-size:11px;color:var(--ui-text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
761
+ '.studio-stat-value{font-size:24px;font-weight:700;line-height:1.2;font-variant-numeric:tabular-nums;letter-spacing:-.5px;margin-top:2px}',
762
+ '.studio-stat-hint{font-size:10.5px;color:var(--ui-text-3);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
763
+ '.studio-grid-2{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(0,1fr);gap:18px;margin-top:18px;align-items:start}',
421
764
  '.studio-section-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;margin:22px 0 10px}',
422
- '.studio-section-title{font-size:14px;font-weight:650;margin:0;letter-spacing:.2px}',
423
- '.studio-section-desc{margin:3px 0 0;font-size:11.5px;color:var(--dsw-alias-label-tertiary)}',
424
- '.studio-list{display:flex;flex-direction:column;gap:8px}',
425
- '.studio-row{display:flex;align-items:center;gap:10px;padding:10px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1);min-width:0;cursor:pointer;transition:background .12s ease}',
426
- '.studio-row:hover{background:var(--dsw-alias-interactive-bg-hover)}',
427
- '.studio-row-main{flex:1;min-width:0}',
428
- '.studio-row-title{font-size:12.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
429
- '.studio-row-sub{font-size:11px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px}',
430
- '.studio-row-side{display:flex;align-items:center;gap:8px;flex:none}',
431
- '.studio-badge{display:inline-flex;align-items:center;justify-content:center;height:20px;padding:0 7px;border-radius:999px;border:1px solid var(--dsw-alias-border-l1);font-size:10.5px;font-weight:600;white-space:nowrap;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2)}',
432
- '.studio-status{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;white-space:nowrap;color:var(--dsw-alias-label-secondary)}',
433
- '.studio-status-dot{width:6px;height:6px;border-radius:50%;background:currentColor;flex:none}',
434
- '.tone-success{color:var(--dsw-alias-state-success-primary)}',
435
- '.tone-danger{color:var(--dsw-alias-state-error-primary)}',
436
- '.tone-warn{color:var(--dsw-alias-state-warn-primary)}',
437
- '.tone-business{color:var(--dsw-alias-state-business-primary)}',
438
- '.tone-link{color:var(--dsw-alias-link)}',
439
- '.tone-muted{color:var(--dsw-alias-label-tertiary)}',
440
- '.studio-badge.tone-success{color:var(--dsw-alias-state-success-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-success-primary) 28%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-success-primary) 10%,transparent)}',
441
- '.studio-badge.tone-danger{color:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 28%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-error-primary) 10%,transparent)}',
442
- '.studio-badge.tone-warn{color:var(--dsw-alias-state-warn-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 28%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 10%,transparent)}',
443
- '.studio-badge.tone-business{color:var(--dsw-alias-state-business-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-business-primary) 28%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-business-primary) 10%,transparent)}',
444
- '.studio-badge.tone-link{color:var(--dsw-alias-link);border-color:color-mix(in srgb,var(--dsw-alias-link) 28%,transparent);background:color-mix(in srgb,var(--dsw-alias-link) 9%,transparent)}',
445
- '.studio-progress{position:relative;height:6px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);overflow:hidden}',
446
- '.studio-progress-fill{position:absolute;left:0;top:0;bottom:0;border-radius:999px;background:var(--dsw-alias-button-primary-fill);transition:width .3s ease}',
447
- '.studio-progress-label{position:absolute;right:0;top:-16px;font-size:10px;color:var(--dsw-alias-label-tertiary)}',
765
+ '.studio-section-title{font-size:14px;font-weight:680;margin:0;letter-spacing:-.1px}',
766
+ '.studio-section-desc{margin:3px 0 0;font-size:11.5px;color:var(--ui-text-3);line-height:1.55}',
767
+
768
+ /* ---------- 执行状态:全站统一语言 ---------- */
769
+ '.studio-execution{border:1px solid var(--ui-border);border-radius:var(--ui-radius);background:var(--ui-surface);box-shadow:var(--ui-shadow);overflow:visible;position:relative}',
770
+ '.studio-execution:before{content:"";position:absolute;left:0;top:0;bottom:0;width:3px;background:var(--ui-text-3);border-radius:calc(var(--ui-radius) - 1px) 0 0 calc(var(--ui-radius) - 1px)}',
771
+ '.studio-execution.tone-business:before{background:var(--ui-business)}',
772
+ '.studio-execution.tone-success:before{background:var(--ui-success)}',
773
+ '.studio-execution.tone-danger:before{background:var(--ui-danger)}',
774
+ '.studio-execution.tone-warn:before{background:var(--ui-warn)}',
775
+ '.studio-execution-inner{padding:15px 18px 15px 20px}',
776
+ '.studio-execution-top{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;flex-wrap:wrap}',
777
+ '.studio-execution-title{font-size:14px;font-weight:680;line-height:1.4;min-width:0;word-break:break-word}',
778
+ '.studio-execution-sub{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:6px;font-size:11px;color:var(--ui-text-3)}',
779
+ '.studio-execution-side{display:flex;align-items:center;gap:7px;flex-wrap:wrap;justify-content:flex-end}',
780
+ '.studio-execution-progress{margin-top:13px}',
781
+ '.studio-execution-progress-head{display:flex;align-items:baseline;justify-content:space-between;gap:10px;margin-bottom:7px}',
782
+ '.studio-execution-percent{font-size:22px;font-weight:720;line-height:1;font-variant-numeric:tabular-nums;letter-spacing:-.6px}',
783
+ '.studio-execution-count{font-size:11px;color:var(--ui-text-3);font-variant-numeric:tabular-nums}',
784
+ '.studio-execution-metrics{display:flex;gap:0;flex-wrap:wrap;margin-top:13px;border-top:1px solid var(--ui-border);padding-top:11px}',
785
+ '.studio-metric{min-width:74px;padding-right:16px;margin-right:16px;border-right:1px solid var(--ui-border)}',
786
+ '.studio-metric:last-child{border-right:0;margin-right:0;padding-right:0}',
787
+ '.studio-metric-value{font-size:16px;font-weight:680;line-height:1.2;font-variant-numeric:tabular-nums}',
788
+ '.studio-metric-label{font-size:10px;color:var(--ui-text-3);margin-top:2px;white-space:nowrap}',
789
+ '.studio-execution-current{display:flex;align-items:flex-start;gap:9px;margin-top:12px;padding:9px 11px;border-radius:9px;background:var(--ui-surface-2);border:1px solid var(--ui-border);min-width:0}',
790
+ '.studio-execution-current.is-live{background:color-mix(in srgb,var(--ui-business) 7%,var(--ui-surface));border-color:color-mix(in srgb,var(--ui-business) 24%,var(--ui-border))}',
791
+ '.studio-execution-current-icon{flex:none;color:var(--ui-business);display:inline-flex;margin-top:1px}',
792
+ '.studio-execution-current-main{flex:1;min-width:0}',
793
+ '.studio-execution-current-title{font-size:11.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
794
+ '.studio-execution-current-note{font-size:11px;color:var(--ui-text-2);margin-top:2px;line-height:1.5;word-break:break-word;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}',
795
+ '.studio-execution-current-meta{flex:none;font-size:10.5px;color:var(--ui-text-3);font-variant-numeric:tabular-nums}',
796
+ '.studio-execution.is-compact .studio-execution-inner{padding:13px 15px 13px 17px}',
797
+ '.studio-execution.is-compact .studio-execution-title{font-size:13px}',
798
+ '.studio-execution.is-compact .studio-execution-percent{font-size:20px}',
799
+ '.studio-execution.is-compact .studio-execution-metrics{display:none}',
800
+ '.studio-batch-row{align-items:stretch}',
801
+ '.studio-batch-percent{font-size:17px;font-weight:700;font-variant-numeric:tabular-nums;letter-spacing:-.4px;margin-left:auto}',
802
+ '.studio-stage-strip{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px;margin-top:13px}',
803
+ '.studio-stage-item{display:flex;align-items:flex-start;gap:7px;padding:8px 9px;border-radius:8px;background:var(--ui-surface-2);border:1px solid transparent;min-width:0}',
804
+ '.studio-stage-item.is-running{background:color-mix(in srgb,var(--ui-business) 9%,var(--ui-surface));border-color:color-mix(in srgb,var(--ui-business) 28%,transparent)}',
805
+ '.studio-stage-item.is-done{background:color-mix(in srgb,var(--ui-success) 6%,var(--ui-surface))}',
806
+ '.studio-stage-item.is-failed{background:color-mix(in srgb,var(--ui-danger) 8%,var(--ui-surface));border-color:color-mix(in srgb,var(--ui-danger) 24%,transparent)}',
807
+ '.studio-stage-dot{width:16px;height:16px;border-radius:50%;flex:none;display:flex;align-items:center;justify-content:center;margin-top:1px;background:var(--ui-surface);border:1px solid var(--ui-border);color:var(--ui-text-3);font-size:9px;font-weight:700}',
808
+ '.studio-stage-item.is-done .studio-stage-dot{background:var(--ui-success);border-color:transparent;color:var(--dsw-alias-label-primary-inverted,#fff)}',
809
+ '.studio-stage-item.is-running .studio-stage-dot{background:var(--ui-business);border-color:transparent;color:var(--dsw-alias-label-primary-inverted,#fff)}',
810
+ '.studio-stage-item.is-failed .studio-stage-dot{background:var(--ui-danger);border-color:transparent;color:var(--dsw-alias-label-primary-inverted,#fff)}',
811
+ '.studio-stage-body{min-width:0}',
812
+ '.studio-stage-label{font-size:10.5px;font-weight:650;white-space:nowrap}',
813
+ '.studio-stage-meta{font-size:9.5px;color:var(--ui-text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:1px}',
814
+ '.studio-op{border:1px solid color-mix(in srgb,var(--ui-business) 26%,var(--ui-border));border-radius:var(--ui-radius);background:color-mix(in srgb,var(--ui-business) 5%,var(--ui-surface));padding:12px 14px;margin:0 0 12px}',
815
+ '.studio-op-head{display:flex;align-items:center;gap:9px;flex-wrap:wrap}',
816
+ '.studio-op-title{font-size:12px;font-weight:650;color:var(--ui-text)}',
817
+ '.studio-op-time{font-size:10.5px;color:var(--ui-text-3);font-variant-numeric:tabular-nums;margin-left:auto}',
818
+ '.studio-op-detail{font-size:11px;color:var(--ui-text-2);margin-top:5px;line-height:1.55}',
819
+ '.studio-op-steps{display:flex;gap:6px;flex-wrap:wrap;margin-top:9px}',
820
+ '.studio-op-step{display:inline-flex;align-items:center;gap:5px;height:23px;padding:0 8px;border-radius:999px;background:var(--ui-surface);border:1px solid var(--ui-border);font-size:10.5px;color:var(--ui-text-3);white-space:nowrap}',
821
+ '.studio-op-step.is-active{color:var(--ui-business);border-color:color-mix(in srgb,var(--ui-business) 34%,var(--ui-border))}',
822
+ '.studio-op-step.is-done{color:var(--ui-success)}',
823
+ '.studio-op-step-dot{width:5px;height:5px;border-radius:50%;background:currentColor;flex:none}',
824
+ '.studio-op-bar{margin-top:10px}',
825
+
826
+ /* ---------- 进度条 ---------- */
827
+ '.studio-progress{position:relative;height:7px;border-radius:999px;background:var(--ui-surface-2);overflow:hidden;border:1px solid color-mix(in srgb,var(--ui-border) 70%,transparent)}',
828
+ '.studio-progress-fill{position:absolute;left:0;top:0;bottom:0;border-radius:999px;background:var(--ui-accent-fill);transition:width .35s ease}',
829
+ '.studio-progress.is-success .studio-progress-fill{background:var(--ui-success)}',
830
+ '.studio-progress.is-danger .studio-progress-fill{background:var(--ui-danger)}',
831
+ '.studio-progress.is-warn .studio-progress-fill{background:var(--ui-warn)}',
832
+ '.studio-progress.is-business .studio-progress-fill{background:var(--ui-business)}',
833
+ '.studio-progress.is-live .studio-progress-fill{background-image:linear-gradient(90deg,transparent 0,color-mix(in srgb,#fff 38%,transparent) 50%,transparent 100%);background-size:220px 100%;background-repeat:no-repeat;animation:studio-shimmer 1.6s linear infinite}',
834
+ '.studio-progress.is-indeterminate .studio-progress-fill{width:36%!important;animation:studio-indeterminate 1.35s ease-in-out infinite}',
835
+ '.studio-progress-label{position:absolute;right:0;top:-17px;font-size:10px;color:var(--ui-text-3);font-variant-numeric:tabular-nums}',
836
+ '@keyframes studio-shimmer{0%{background-position:-220px 0}100%{background-position:calc(100% + 220px) 0}}',
837
+ '@keyframes studio-indeterminate{0%{left:-36%}100%{left:100%}}',
448
838
  '.studio-stepper{display:flex;gap:0;overflow-x:auto;padding:4px 0 2px}',
449
839
  '.studio-step{flex:1;min-width:110px;display:flex;gap:8px}',
450
840
  '.studio-step-rail{display:flex;flex-direction:column;align-items:center;flex:none}',
451
- '.studio-step-dot{width:22px;height:22px;border-radius:50%;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-tertiary);display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600}',
452
- '.studio-step.is-done .studio-step-dot{border-color:transparent;background:var(--dsw-alias-state-success-primary);color:var(--dsw-alias-label-primary-inverted)}',
453
- '.studio-step.is-running .studio-step-dot{border-color:transparent;background:var(--dsw-alias-state-business-primary);color:var(--dsw-alias-label-primary-inverted)}',
454
- '.studio-step.is-failed .studio-step-dot{border-color:transparent;background:var(--dsw-alias-state-error-primary);color:var(--dsw-alias-label-primary-inverted)}',
841
+ '.studio-step-dot{width:22px;height:22px;border-radius:50%;border:1px solid var(--ui-border);background:var(--ui-surface-2);color:var(--ui-text-3);display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600}',
842
+ '.studio-step.is-done .studio-step-dot{border-color:transparent;background:var(--ui-success);color:var(--dsw-alias-label-primary-inverted,#fff)}',
843
+ '.studio-step.is-running .studio-step-dot{border-color:transparent;background:var(--ui-business);color:var(--dsw-alias-label-primary-inverted,#fff)}',
844
+ '.studio-step.is-failed .studio-step-dot{border-color:transparent;background:var(--ui-danger);color:var(--dsw-alias-label-primary-inverted,#fff)}',
455
845
  '.studio-step.is-skipped .studio-step-dot{opacity:.55}',
456
- '.studio-step-line{width:1px;flex:1;min-height:16px;background:var(--dsw-alias-border-l1);margin:3px 0}',
846
+ '.studio-step-line{width:1px;flex:1;min-height:16px;background:var(--ui-border);margin:3px 0}',
457
847
  '.studio-step-body{padding:2px 8px 0 0;min-width:0}',
458
848
  '.studio-step-title{font-size:11.5px;font-weight:600;white-space:nowrap}',
459
- '.studio-step-meta{font-size:10px;color:var(--dsw-alias-label-tertiary);margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
849
+ '.studio-step-meta{font-size:10px;color:var(--ui-text-3);margin-top:1px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
850
+
851
+ /* ---------- 列表与行 ---------- */
852
+ '.studio-list{display:flex;flex-direction:column;gap:8px}',
853
+ '.studio-list-head{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:8px;flex-wrap:wrap}',
854
+ '.studio-row{display:flex;align-items:center;gap:11px;padding:11px 13px;border:1px solid var(--ui-border);border-radius:10px;background:var(--ui-surface);min-width:0;cursor:pointer;transition:background .12s ease,border-color .12s ease}',
855
+ '.studio-row:hover{background:var(--ui-hover)}',
856
+ '.studio-row-main{flex:1;min-width:0}',
857
+ '.studio-row-title{font-size:12.5px;font-weight:620;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
858
+ '.studio-row-sub{font-size:11px;color:var(--ui-text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:2px;line-height:1.5}',
859
+ '.studio-row-side{display:flex;align-items:center;gap:8px;flex:none}',
860
+ '.studio-row-actions{display:flex;align-items:center;gap:5px;flex:none;opacity:.6;transition:opacity .12s ease}',
861
+ '.studio-result-row:hover .studio-row-actions,.studio-result-row:focus-within .studio-row-actions{opacity:1}',
862
+ '.studio-result-row:focus-visible{outline:2px solid var(--ui-accent);outline-offset:1px}',
863
+ '.studio-virtual{overflow-y:auto;overscroll-behavior:contain;position:relative;scrollbar-gutter:stable}',
864
+ '.studio-virtual-inner{position:relative;width:100%}',
865
+ '.studio-virtual-row{position:absolute;left:0;right:0;padding-bottom:7px}',
866
+
867
+ /* ---------- 徽标与状态 ---------- */
868
+ '.studio-badge{display:inline-flex;align-items:center;justify-content:center;height:21px;padding:0 8px;border-radius:999px;border:1px solid var(--ui-border);font-size:10.5px;font-weight:600;white-space:nowrap;color:var(--ui-text-2);background:var(--ui-surface-2);letter-spacing:.1px}',
869
+ '.studio-status{display:inline-flex;align-items:center;gap:5px;height:21px;padding:0 7px;border-radius:999px;border:1px solid transparent;font-size:10.5px;font-weight:650;white-space:nowrap;color:var(--ui-text-2);background:var(--ui-surface-2)}',
870
+ '.studio-status.tone-success{color:var(--ui-success);background:color-mix(in srgb,var(--ui-success) 9%,var(--ui-surface))}',
871
+ '.studio-status.tone-danger{color:var(--ui-danger);background:color-mix(in srgb,var(--ui-danger) 9%,var(--ui-surface))}',
872
+ '.studio-status.tone-warn{color:var(--ui-warn);background:color-mix(in srgb,var(--ui-warn) 10%,var(--ui-surface))}',
873
+ '.studio-status.tone-business{color:var(--ui-business);background:color-mix(in srgb,var(--ui-business) 10%,var(--ui-surface))}',
874
+ '.studio-status.tone-link{color:var(--ui-accent);background:var(--ui-accent-soft)}',
875
+ '.studio-status-dot{width:6px;height:6px;border-radius:50%;background:currentColor;flex:none}',
876
+ '.studio-status.is-live .studio-status-dot{animation:studio-pulse 1.15s ease-in-out infinite}',
877
+ '.tone-success{color:var(--ui-success)}',
878
+ '.tone-danger{color:var(--ui-danger)}',
879
+ '.tone-warn{color:var(--ui-warn)}',
880
+ '.tone-business{color:var(--ui-business)}',
881
+ '.tone-link{color:var(--ui-accent)}',
882
+ '.tone-muted{color:var(--ui-text-3)}',
883
+ '.studio-badge.tone-success{color:var(--ui-success);border-color:color-mix(in srgb,var(--ui-success) 28%,transparent);background:color-mix(in srgb,var(--ui-success) 10%,transparent)}',
884
+ '.studio-badge.tone-danger{color:var(--ui-danger);border-color:color-mix(in srgb,var(--ui-danger) 28%,transparent);background:color-mix(in srgb,var(--ui-danger) 10%,transparent)}',
885
+ '.studio-badge.tone-warn{color:var(--ui-warn);border-color:color-mix(in srgb,var(--ui-warn) 28%,transparent);background:color-mix(in srgb,var(--ui-warn) 10%,transparent)}',
886
+ '.studio-badge.tone-business{color:var(--ui-business);border-color:color-mix(in srgb,var(--ui-business) 28%,transparent);background:color-mix(in srgb,var(--ui-business) 10%,transparent)}',
887
+ '.studio-badge.tone-link{color:var(--ui-accent);border-color:color-mix(in srgb,var(--ui-accent) 28%,transparent);background:color-mix(in srgb,var(--ui-accent) 9%,transparent)}',
888
+ '.studio-queue-badge{display:inline-flex;flex-direction:column;align-items:flex-end;gap:2px;min-width:0}',
889
+ '.studio-queue-hint{font-size:9.5px;color:var(--ui-text-3);white-space:nowrap}',
890
+
891
+ /* ---------- 工具条与筛选 ---------- */
460
892
  '.studio-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin:0 0 12px}',
461
- '.studio-search{position:relative;flex:1 1 220px;min-width:160px}',
462
- '.studio-search .studio-input{padding-left:30px}',
463
- '.studio-search-icon{position:absolute;left:9px;top:7px;color:var(--dsw-alias-label-tertiary);pointer-events:none}',
464
- '.studio-chip{display:inline-flex;align-items:center;height:24px;padding:0 9px;border-radius:999px;border:1px solid var(--dsw-alias-border-l1);background:transparent;color:var(--dsw-alias-label-secondary);font-size:11px;font-family:inherit;cursor:pointer;white-space:nowrap}',
465
- '.studio-chip.is-active{border-color:transparent;background:var(--dsw-alias-interactive-bg-active);color:var(--dsw-alias-label-primary);font-weight:600}',
893
+ '.studio-search{position:relative;flex:1 1 240px;min-width:170px}',
894
+ '.studio-search .studio-input{padding-left:31px;background:var(--ui-surface)}',
895
+ '.studio-search-icon{position:absolute;left:9px;top:8px;color:var(--ui-text-3);pointer-events:none}',
896
+ '.studio-filter-bar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;padding:3px;border:1px solid var(--ui-border);border-radius:9px;background:var(--ui-surface-2)}',
897
+ '.studio-chip{display:inline-flex;align-items:center;gap:5px;height:25px;padding:0 9px;border-radius:7px;border:1px solid transparent;background:transparent;color:var(--ui-text-2);font-size:11px;font-family:inherit;cursor:pointer;white-space:nowrap;transition:background .12s ease,color .12s ease}',
898
+ '.studio-chip:hover{background:var(--ui-hover);color:var(--ui-text)}',
899
+ '.studio-chip.is-active{background:var(--ui-surface);color:var(--ui-text);font-weight:650;border-color:var(--ui-border);box-shadow:var(--ui-shadow)}',
900
+ '.studio-chip-count{font-size:10px;color:var(--ui-text-3);font-variant-numeric:tabular-nums}',
901
+
902
+ /* ---------- 用例列表 ---------- */
466
903
  '.studio-case-list{display:flex;flex-direction:column;gap:7px}',
467
- '.studio-case{display:flex;gap:10px;padding:11px 12px;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-1);cursor:pointer;min-width:0;transition:background .12s ease,border-color .12s ease}',
468
- '.studio-case:hover{background:var(--dsw-alias-interactive-bg-hover)}',
469
- '.studio-case.is-active{border-color:var(--dsw-alias-link);background:var(--dsw-alias-interactive-bg-active)}',
470
- '.studio-case-check{margin-top:2px;flex:none}',
471
- '.studio-case-main{flex:1;min-width:0}',
904
+ '.studio-case{display:flex;gap:10px;padding:10px 12px;border:1px solid var(--ui-border);border-radius:10px;background:var(--ui-surface);cursor:pointer;min-width:0;height:100%;transition:background .12s ease,border-color .12s ease,box-shadow .12s ease;position:relative}',
905
+ '.studio-case:hover{background:var(--ui-hover);border-color:color-mix(in srgb,var(--ui-text-3) 34%,var(--ui-border))}',
906
+ '.studio-case.is-active{border-color:var(--ui-accent);background:var(--ui-accent-soft);box-shadow:0 0 0 1px color-mix(in srgb,var(--ui-accent) 22%,transparent)}',
907
+ '.studio-case.is-active:before{content:"";position:absolute;left:-1px;top:9px;bottom:9px;width:3px;border-radius:0 3px 3px 0;background:var(--ui-accent)}',
908
+ '.studio-case.is-live{border-color:color-mix(in srgb,var(--ui-business) 32%,var(--ui-border))}',
909
+ '.studio-case.is-child{margin-left:24px;border-left:3px solid color-mix(in srgb,var(--ui-accent) 24%,var(--ui-border))}',
910
+ '.studio-case.is-child.is-active{border-left-color:var(--ui-accent)}',
911
+ '.studio-case-seq{flex:none;min-width:30px;height:22px;padding:0 5px;display:inline-flex;align-items:center;justify-content:center;border-radius:6px;background:var(--ui-surface-2);color:var(--ui-text-3);font-family:var(--ui-mono);font-size:10.5px;font-variant-numeric:tabular-nums}',
912
+ '.studio-case.is-active .studio-case-seq{background:color-mix(in srgb,var(--ui-accent) 14%,var(--ui-surface));color:var(--ui-accent)}',
913
+ '.studio-case-check{margin-top:2px;flex:none;display:flex;align-items:center}',
914
+ '.studio-case-main{flex:1;min-width:0;display:flex;flex-direction:column;justify-content:center}',
472
915
  '.studio-case-top{display:flex;align-items:center;gap:7px;min-width:0}',
473
- '.studio-case-title{font-size:12.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}',
474
- '.studio-case-id{font-size:10.5px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;white-space:nowrap}',
475
- '.studio-case-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap;font-size:10.5px;color:var(--dsw-alias-label-tertiary);margin-top:4px}',
476
- '.studio-case-side{display:flex;flex-direction:column;align-items:flex-end;gap:5px;flex:none}',
477
- '.studio-detail{position:sticky;top:16px;border:1px solid var(--dsw-alias-border-l1);border-radius:14px;background:var(--dsw-alias-bg-layer-1);overflow:hidden}',
478
- '.studio-detail-head{padding:15px 16px 12px;border-bottom:1px solid var(--dsw-alias-border-l1)}',
479
- '.studio-detail-title{font-size:15px;font-weight:650;margin:0;line-height:1.35}',
480
- '.studio-detail-meta{display:flex;gap:8px;flex-wrap:wrap;margin-top:7px}',
481
- '.studio-detail-body{padding:14px 16px 18px;max-height:calc(100vh - 260px);overflow-y:auto}',
482
- '.studio-detail-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}',
916
+ '.studio-case-title{font-size:12.5px;font-weight:620;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}',
917
+ '.studio-case-id{font-size:10px;color:var(--ui-text-3);font-family:var(--ui-mono);white-space:nowrap}',
918
+ '.studio-case-meta{display:flex;align-items:center;gap:8px;flex-wrap:nowrap;overflow:hidden;font-size:10.5px;color:var(--ui-text-3);margin-top:4px;white-space:nowrap}',
919
+ '.studio-case-meta>span{flex:none}',
920
+ '.studio-case-meta>span:last-child{overflow:hidden;text-overflow:ellipsis;flex:0 1 auto}',
921
+ '.studio-case-side{display:flex;flex-direction:column;align-items:flex-end;justify-content:center;gap:3px;flex:none}',
922
+ '.studio-case-status-mobile{display:none}',
923
+ '.studio-case-scroll{max-height:clamp(320px,calc(100vh - 330px),760px);border-radius:10px}',
924
+ '.studio-picker-group{display:flex;flex-direction:column;gap:6px;margin-bottom:10px}',
925
+ '.studio-picker-doc{height:auto;cursor:default;padding:8px 10px}',
926
+ '.studio-picker-doc .studio-doc-hint{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
927
+
928
+ /* ---------- 文档行 ---------- */
929
+ '.studio-doc-row{display:flex;align-items:center;gap:9px;padding:9px 12px;border:1px solid var(--ui-border);border-radius:10px;background:var(--ui-surface-2);cursor:pointer;height:100%;min-width:0;overflow:hidden;transition:background .12s ease,border-color .12s ease}',
930
+ '.studio-doc-row:hover{background:var(--ui-hover);border-color:color-mix(in srgb,var(--ui-text-3) 32%,var(--ui-border))}',
931
+ '.studio-doc-row.is-unassigned{background:color-mix(in srgb,var(--ui-warn) 5%,var(--ui-surface));border-style:dashed}',
932
+ '.studio-doc-chevron{width:20px;height:20px;flex:none;display:inline-flex;align-items:center;justify-content:center;border:0;border-radius:6px;background:transparent;color:var(--ui-text-3);cursor:pointer;padding:0;transition:transform .12s ease,background .12s ease}',
933
+ '.studio-doc-row.is-expanded .studio-doc-chevron{transform:rotate(90deg)}',
934
+ '.studio-doc-chevron:hover{background:var(--ui-hover);color:var(--ui-text)}',
935
+ '.studio-doc-main{flex:1;min-width:0;display:flex;flex-direction:column;justify-content:center;gap:3px}',
936
+ '.studio-doc-top{display:flex;align-items:center;gap:7px;min-width:0;flex-wrap:nowrap}',
937
+ '.studio-doc-name{font-size:12.5px;font-weight:650;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex:0 1 auto}',
938
+ '.studio-doc-kind{flex:none}',
939
+ '.studio-doc-count,.studio-doc-version{font-size:10.5px;color:var(--ui-text-3);white-space:nowrap;flex:none;font-variant-numeric:tabular-nums}',
940
+ '.studio-doc-source{flex:none;display:inline-flex}',
941
+ '.studio-doc-sub{display:flex;align-items:center;gap:9px;min-width:0;font-size:10.5px;color:var(--ui-text-3);white-space:nowrap;overflow:hidden}',
942
+ '.studio-doc-sub>span{flex:none}',
943
+ '.studio-doc-hint{overflow:hidden;text-overflow:ellipsis;flex:0 1 auto!important}',
944
+ '.studio-doc-rollup{display:inline-flex;gap:7px;min-width:0;overflow:hidden}',
945
+ '.studio-doc-writeback,.studio-doc-mode,.studio-doc-action,.studio-doc-more{flex:none}',
946
+ '.studio-doc-row.is-archived{opacity:.78}',
947
+ '.studio-doc-archived{flex:none}',
948
+ '.studio-doc-more{width:24px;height:24px}',
949
+ '.studio-archived-toggle{flex:none;margin-left:auto;white-space:nowrap}',
950
+ '.studio-doc-action-list{display:grid;gap:6px}',
951
+ '.studio-doc-action-row{width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer}',
952
+ '.studio-doc-action-row.is-danger .studio-row-title{color:var(--ui-danger)}',
953
+ '.studio-doc-action-desc{font-size:11px;color:var(--ui-text-3);line-height:1.55;white-space:normal}',
954
+ '.studio-doc-action-icon{flex:none;width:28px;height:28px;display:inline-flex;align-items:center;justify-content:center;border-radius:8px;border:1px solid var(--ui-border);background:var(--ui-surface);color:var(--ui-text-2)}',
955
+ '.studio-doc-action-row.is-danger .studio-doc-action-icon{color:var(--ui-danger);border-color:color-mix(in srgb,var(--ui-danger) 35%,var(--ui-border))}',
956
+ '.studio-doc-meta{display:flex;flex-wrap:wrap;align-items:center;gap:6px;margin-top:6px}',
957
+
958
+ /* ---------- 用例所属文档 ---------- */
959
+ '.studio-doc-link{display:flex;align-items:center;gap:5px;margin-top:8px;font-size:11px;color:var(--ui-text-3);min-width:0;flex-wrap:wrap}',
960
+ '.studio-doc-link-name{color:var(--ui-text-2);font-weight:600;overflow:hidden;text-overflow:ellipsis}',
961
+ '.studio-doc-link-meta{font-size:10.5px;color:var(--ui-text-3)}',
962
+ '.studio-doc-link.is-unassigned{color:var(--ui-warn)}',
963
+ '.studio-mono-break{font-family:var(--ui-mono);font-size:10.5px;word-break:break-all}',
964
+
965
+ /* ---------- 用例详情 ---------- */
966
+ '.studio-detail{position:sticky;top:16px;border:1px solid var(--ui-border);border-radius:14px;background:var(--ui-surface);overflow:hidden;box-shadow:var(--ui-shadow);max-height:calc(100vh - 120px);display:flex;flex-direction:column}',
967
+ '.studio-detail-head{padding:15px 16px 12px;border-bottom:1px solid var(--ui-border);flex:none}',
968
+ '.studio-detail-title{font-size:15px;font-weight:680;margin:0;line-height:1.4;letter-spacing:-.1px}',
969
+ '.studio-detail-meta{display:flex;gap:7px;flex-wrap:wrap;margin-top:7px}',
970
+ '.studio-detail-body{padding:14px 16px 20px;overflow-y:auto;min-height:0}',
971
+ '.studio-detail-actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:12px}',
972
+ '.studio-detail-live{margin-top:10px;padding:8px 10px;border-radius:8px;background:color-mix(in srgb,var(--ui-business) 7%,var(--ui-surface));border:1px solid color-mix(in srgb,var(--ui-business) 22%,var(--ui-border));font-size:10.5px;color:var(--ui-text-2);line-height:1.5}',
483
973
  '.studio-nl{display:flex;flex-direction:column;gap:14px}',
484
- '.studio-nl-block{border-left:2px solid var(--dsw-alias-border-l1);padding-left:12px}',
485
- '.studio-nl-label{font-size:10.5px;letter-spacing:.6px;text-transform:uppercase;color:var(--dsw-alias-label-tertiary);margin-bottom:5px}',
486
- '.studio-nl-list{margin:0;padding-left:18px;color:var(--dsw-alias-label-secondary);font-size:12px;line-height:1.7}',
487
- '.studio-nl-list li{margin:1px 0}',
488
- '.studio-note{white-space:pre-wrap;word-break:break-word;color:var(--dsw-alias-label-secondary);font-size:11.5px;line-height:1.6}',
974
+ '.studio-nl-block{border-left:2px solid var(--ui-border);padding-left:12px}',
975
+ '.studio-nl-label{font-size:10.5px;font-weight:650;color:var(--ui-text-3);margin-bottom:5px;letter-spacing:.1px}',
976
+ '.studio-nl-list{margin:0;padding-left:18px;color:var(--ui-text-2);font-size:12px;line-height:1.75}',
977
+ '.studio-nl-list li{margin:2px 0}',
978
+ '.studio-definition{display:flex;flex-direction:column;gap:14px}',
979
+ '.studio-definition.is-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:12px;align-items:start}',
980
+ '.studio-note{white-space:pre-wrap;word-break:break-word;color:var(--ui-text-2);font-size:11.5px;line-height:1.65}',
489
981
  '.studio-evidence{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}',
490
982
  '.studio-evidence-item{display:flex;flex-direction:column;gap:4px;min-width:0}',
491
- '.studio-evidence img{width:100%;height:92px;object-fit:cover;border-radius:8px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);cursor:zoom-in}',
492
- '.studio-evidence-cap{font-size:10px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
493
- '.studio-case-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}',
494
- '.studio-run-card{border:1px solid var(--dsw-alias-border-l1);border-radius:11px;background:var(--dsw-alias-bg-layer-1);padding:12px 13px;min-width:0}',
495
- '.studio-run-card.is-running{border-color:var(--dsw-alias-state-business-primary)}',
496
- '.studio-result-list{display:flex;flex-direction:column;gap:8px}',
497
- '.studio-result-row{display:flex;align-items:flex-start;gap:12px;width:100%;padding:11px 13px;border:1px solid var(--dsw-alias-border-l1);border-radius:11px;background:var(--dsw-alias-bg-layer-1);color:inherit;font:inherit;text-align:left;cursor:pointer;min-width:0}',
498
- '.studio-result-row:hover{background:var(--dsw-alias-interactive-bg-hover)}',
499
- '.studio-result-main{flex:1;min-width:0;display:grid;gap:4px}',
500
- '.studio-result-title{font-size:12px;font-weight:600;line-height:1.45;word-break:break-word}',
501
- '.studio-result-summary{font-size:11px;line-height:1.55;color:var(--dsw-alias-label-secondary);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
502
- '.studio-result-side{display:flex;align-items:center;gap:7px;flex:none;color:var(--dsw-alias-label-tertiary)}',
503
- '.studio-drawer-overlay{position:absolute;inset:0;z-index:80;display:flex;justify-content:flex-end;background:color-mix(in srgb,var(--dsw-alias-bg-base) 55%,transparent)}',
504
- '.studio-drawer{width:min(780px,100%);height:100%;display:flex;flex-direction:column;background:var(--dsw-alias-bg-layer-1);border-left:1px solid var(--dsw-alias-border-l1);box-shadow:-24px 0 60px color-mix(in srgb,var(--dsw-alias-bg-base) 45%,transparent)}',
505
- '.studio-drawer-body{flex:1;overflow-y:auto;padding:14px 18px 24px}',
506
- '.studio-feedback{margin-top:10px;padding-top:10px;border-top:1px dashed var(--dsw-alias-border-l1)}',
507
- '.studio-feedback-head{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin-bottom:7px}',
508
- '.studio-feedback-title{font-size:11.5px;font-weight:650;color:var(--dsw-alias-label-primary)}',
509
- '.studio-feedback-actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:7px}',
510
- '.studio-feedback-used{font-size:11px;line-height:1.55;color:var(--dsw-alias-label-secondary);white-space:pre-wrap;word-break:break-word;margin-bottom:6px}',
511
- '.studio-correction{padding:7px 9px;border-radius:8px;background:var(--dsw-alias-bg-layer-2);font-size:11px;line-height:1.55;color:var(--dsw-alias-label-secondary);word-break:break-word}',
512
- '.studio-knowledge-deposit{margin-top:9px;padding:8px 10px;border:1px solid var(--dsw-alias-border-l1);border-radius:9px;background:var(--dsw-alias-bg-layer-1)}',
513
- '.studio-knowledge-deposit summary{cursor:pointer;list-style:none;display:flex;align-items:center;gap:6px;flex-wrap:wrap}',
514
- '.studio-knowledge-chips{display:flex;gap:5px;flex-wrap:wrap;margin-top:6px}',
515
- '.studio-knowledge-item{padding:5px 0;border-top:1px dashed var(--dsw-alias-border-l1);font-size:11px;line-height:1.55;color:var(--dsw-alias-label-secondary);word-break:break-word}',
983
+ '.studio-evidence img{width:100%;height:92px;object-fit:cover;border-radius:8px;border:1px solid var(--ui-border);background:var(--ui-surface-2);cursor:zoom-in}',
984
+ '.studio-evidence-cap{font-size:10px;color:var(--ui-text-3);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}',
985
+ '.studio-evidence-missing{height:92px;display:flex;align-items:center;justify-content:center;border:1px dashed var(--ui-border);border-radius:8px;color:var(--ui-text-3);font-size:10.5px;background:var(--ui-surface-2)}',
516
986
  '.studio-lifecycle{display:flex;gap:6px;flex-wrap:wrap;margin-top:12px}',
517
- '.studio-lifecycle-item{flex:1 1 118px;min-width:0;display:flex;align-items:flex-start;gap:6px;padding:7px 9px;border:0;border-radius:8px;background:var(--dsw-alias-bg-layer-2);color:inherit;font:inherit;text-align:left;cursor:pointer}',
518
- '.studio-lifecycle-item:hover{background:var(--dsw-alias-interactive-bg-hover)}',
519
- '.studio-lifecycle-dot{flex:none;width:7px;height:7px;margin-top:5px;border-radius:50%;background:var(--dsw-alias-label-tertiary)}',
520
- '.studio-lifecycle-label{font-size:11px;font-weight:650;color:var(--dsw-alias-label-primary)}',
521
- '.studio-lifecycle-detail{font-size:10.5px;line-height:1.45;color:var(--dsw-alias-label-secondary);word-break:break-word}',
522
- '.studio-lifecycle-dot.tone-success{background:var(--dsw-alias-state-success-primary)}',
523
- '.studio-lifecycle-dot.tone-danger{background:var(--dsw-alias-state-error-primary)}',
524
- '.studio-lifecycle-dot.tone-warn{background:var(--dsw-alias-state-warn-primary)}',
525
- '.studio-lifecycle-dot.tone-business{background:var(--dsw-alias-state-business-primary)}',
987
+ '.studio-lifecycle-item{flex:1 1 118px;min-width:0;display:flex;align-items:flex-start;gap:6px;padding:7px 9px;border:1px solid transparent;border-radius:8px;background:var(--ui-surface-2);color:inherit;font:inherit;text-align:left;cursor:pointer;transition:background .12s ease,border-color .12s ease}',
988
+ '.studio-lifecycle-item:hover{background:var(--ui-hover);border-color:var(--ui-border)}',
989
+ '.studio-lifecycle-item.is-active{background:var(--ui-active);border-color:color-mix(in srgb,var(--ui-accent) 38%,var(--ui-border))}',
990
+ '.studio-lifecycle-item.is-active .studio-lifecycle-label{color:var(--ui-accent)}',
991
+ '.studio-lifecycle-dot{flex:none;width:7px;height:7px;margin-top:5px;border-radius:50%;background:var(--ui-text-3)}',
992
+ '.studio-lifecycle-label{font-size:11px;font-weight:650;color:var(--ui-text)}',
993
+ '.studio-lifecycle-detail{font-size:10.5px;line-height:1.45;color:var(--ui-text-2);word-break:break-word}',
994
+ '.studio-lifecycle-dot.tone-success{background:var(--ui-success)}',
995
+ '.studio-lifecycle-dot.tone-danger{background:var(--ui-danger)}',
996
+ '.studio-lifecycle-dot.tone-warn{background:var(--ui-warn)}',
997
+ '.studio-lifecycle-dot.tone-business{background:var(--ui-business)}',
998
+
999
+ /* ---------- 批次结果 ---------- */
1000
+ '.studio-result-row{display:flex;align-items:flex-start;gap:12px;width:100%;padding:11px 13px;border:1px solid var(--ui-border);border-radius:10px;background:var(--ui-surface);color:inherit;font:inherit;text-align:left;cursor:pointer;min-width:0;height:100%;transition:background .12s ease,border-color .12s ease}',
1001
+ '.studio-result-row:hover{background:var(--ui-hover)}',
1002
+ '.studio-result-row.is-live{border-color:color-mix(in srgb,var(--ui-business) 32%,var(--ui-border));background:color-mix(in srgb,var(--ui-business) 4%,var(--ui-surface))}',
1003
+ '.studio-result-row.is-selected{border-color:var(--ui-accent);background:var(--ui-accent-soft)}',
1004
+ '.studio-bulk-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding:8px 10px;border:1px solid color-mix(in srgb,var(--ui-accent) 30%,var(--ui-border));border-radius:9px;background:var(--ui-accent-soft);font-size:11.5px}',
1005
+ '.studio-bulk-bar .studio-row-sub{margin:0}',
1006
+ '.studio-run-tools{display:flex;align-items:center;gap:8px;flex-wrap:wrap}',
1007
+ '.studio-result-main{flex:1;min-width:0;display:grid;gap:4px}',
1008
+ '.studio-result-title{font-size:12px;font-weight:620;line-height:1.45;word-break:break-word;display:-webkit-box;-webkit-line-clamp:1;-webkit-box-orient:vertical;overflow:hidden}',
1009
+ '.studio-result-summary{font-size:11px;line-height:1.5;color:var(--ui-text-2);display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
1010
+ '.studio-result-side{display:flex;align-items:center;gap:7px;flex:none;color:var(--ui-text-3);flex-wrap:wrap;justify-content:flex-end;max-width:46%}',
1011
+ '.studio-result-scroll{max-height:clamp(260px,calc(100vh - 560px),560px);border-radius:10px}',
1012
+ '.studio-run-card{border:1px solid var(--ui-border);border-radius:11px;background:var(--ui-surface);padding:12px 13px;min-width:0}',
1013
+ '.studio-run-card.is-running{border-color:var(--ui-business);box-shadow:0 0 0 1px color-mix(in srgb,var(--ui-business) 20%,transparent)}',
526
1014
  '.studio-run-top{display:flex;align-items:flex-start;justify-content:space-between;gap:8px}',
527
1015
  '.studio-run-title{font-size:12px;font-weight:600;line-height:1.4;min-width:0;word-break:break-word}',
528
- '.studio-run-meta{display:flex;gap:8px;flex-wrap:wrap;font-size:10.5px;color:var(--dsw-alias-label-tertiary);margin-top:5px;font-variant-numeric:tabular-nums}',
529
- '.studio-run-note{font-size:11px;color:var(--dsw-alias-label-secondary);margin-top:7px;line-height:1.55;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden;word-break:break-word}',
530
- '.studio-run-summary{margin-top:8px;padding:8px 10px;border-radius:8px;background:var(--dsw-alias-bg-layer-2);display:grid;gap:5px}',
531
- '.studio-run-summary-title{font-size:10.5px;letter-spacing:.5px;text-transform:uppercase;color:var(--dsw-alias-label-tertiary)}',
1016
+ '.studio-run-meta{display:flex;gap:8px;flex-wrap:wrap;font-size:10.5px;color:var(--ui-text-3);margin-top:5px;font-variant-numeric:tabular-nums}',
1017
+ '.studio-run-summary{margin-top:8px;padding:8px 10px;border-radius:8px;background:var(--ui-surface-2);display:grid;gap:5px}',
1018
+ '.studio-run-summary-title{font-size:10.5px;font-weight:650;color:var(--ui-text-3)}',
532
1019
  '.studio-summary{display:grid;gap:6px}',
533
- '.studio-summary p{margin:0;max-width:76ch;font-size:11.5px;line-height:1.65;color:var(--dsw-alias-label-secondary);word-break:break-word}',
534
- '.studio-summary ul{margin:0;padding-left:18px;max-width:76ch;font-size:11.5px;line-height:1.65;color:var(--dsw-alias-label-secondary)}',
1020
+ '.studio-summary p{margin:0;max-width:76ch;font-size:11.5px;line-height:1.65;color:var(--ui-text-2);word-break:break-word}',
1021
+ '.studio-summary ul{margin:0;padding-left:18px;max-width:76ch;font-size:11.5px;line-height:1.65;color:var(--ui-text-2)}',
535
1022
  '.studio-summary li{margin:1px 0;word-break:break-word}',
536
1023
  '.studio-summary-issues{display:grid;gap:4px;margin-top:2px}',
537
- '.studio-summary-list{margin:0;padding-left:18px;max-width:76ch;font-size:11.5px;line-height:1.65;color:var(--dsw-alias-label-secondary)}',
538
- '.studio-summary-label{font-size:10.5px;letter-spacing:.5px;text-transform:uppercase;color:var(--dsw-alias-label-tertiary)}',
539
- '.studio-summary-toggle{align-self:flex-start;border:0;background:transparent;padding:0;color:var(--dsw-alias-link);font:inherit;font-size:11px;cursor:pointer}',
1024
+ '.studio-summary-list{margin:0;padding-left:18px;max-width:76ch;font-size:11.5px;line-height:1.65;color:var(--ui-text-2)}',
1025
+ '.studio-summary-label{font-size:10.5px;font-weight:650;color:var(--ui-text-3)}',
1026
+ '.studio-summary-toggle{align-self:flex-start;border:0;background:transparent;padding:0;color:var(--ui-accent);font:inherit;font-size:11px;cursor:pointer}',
540
1027
  '.studio-summary-toggle:hover{text-decoration:underline}',
541
- '.studio-details{margin-top:2px;font-size:11px;color:var(--dsw-alias-label-tertiary)}',
1028
+ '.studio-details{margin-top:2px;font-size:11px;color:var(--ui-text-3)}',
542
1029
  '.studio-details summary{cursor:pointer}',
543
- '.studio-details pre{margin:6px 0 0;max-height:200px;overflow:auto;white-space:pre-wrap;word-break:break-word;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:10.5px;line-height:1.55;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-1);border:1px solid var(--dsw-alias-border-l1);border-radius:6px;padding:8px}',
544
- '.studio-failure-card{display:grid;gap:6px;padding:10px 12px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-error-primary) 30%,var(--dsw-alias-border-l1));border-radius:9px;background:var(--dsw-alias-bg-layer-2)}',
545
- '.studio-failure-head{display:flex;align-items:center;gap:6px;font-size:11.5px;font-weight:650;color:var(--dsw-alias-state-error-primary)}',
546
- '.studio-queue-badge{display:inline-flex;flex-direction:column;align-items:flex-end;gap:2px;min-width:0}',
547
- '.studio-queue-hint{font-size:10px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}',
548
- '.studio-row-actions{display:flex;align-items:center;gap:6px;flex:none;opacity:.55;transition:opacity .12s ease}',
549
- '.studio-result-row:hover .studio-row-actions,.studio-result-row:focus-within .studio-row-actions{opacity:1}',
550
- '.studio-result-row:focus-visible{outline:2px solid var(--dsw-alias-link);outline-offset:1px}',
1030
+ '.studio-details pre{margin:6px 0 0;max-height:200px;overflow:auto;white-space:pre-wrap;word-break:break-word;font-family:var(--ui-mono);font-size:10.5px;line-height:1.55;color:var(--ui-text-2);background:var(--ui-surface);border:1px solid var(--ui-border);border-radius:6px;padding:8px}',
1031
+ '.studio-failure-card{display:grid;gap:6px;padding:10px 12px;border:1px solid color-mix(in srgb,var(--ui-danger) 30%,var(--ui-border));border-radius:9px;background:color-mix(in srgb,var(--ui-danger) 4%,var(--ui-surface))}',
1032
+ '.studio-failure-head{display:flex;align-items:center;gap:6px;font-size:11.5px;font-weight:650;color:var(--ui-danger)}',
1033
+
1034
+ /* ---------- 步骤时间线 ---------- */
551
1035
  '.studio-step-list{display:flex;flex-direction:column;min-width:0}',
552
- '.studio-step-row{display:flex;align-items:flex-start;gap:9px;padding:9px 0;border-top:1px dashed var(--dsw-alias-border-l1);min-width:0}',
1036
+ '.studio-step-row{display:flex;align-items:flex-start;gap:9px;padding:9px 0;border-top:1px dashed var(--ui-border);min-width:0}',
553
1037
  '.studio-step-row:first-child{border-top:0}',
554
- '.studio-step-seq{flex:none;width:20px;text-align:right;font-size:10.5px;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-tertiary);padding-top:2px}',
555
- '.studio-step-status{flex:none;width:7px;height:7px;border-radius:50%;margin-top:6px;background:var(--dsw-alias-label-tertiary)}',
556
- '.studio-step-status.tone-success{background:var(--dsw-alias-state-success-primary)}',
557
- '.studio-step-status.tone-danger{background:var(--dsw-alias-state-error-primary)}',
558
- '.studio-step-status.tone-business{background:var(--dsw-alias-state-business-primary)}',
1038
+ '.studio-step-seq{flex:none;width:20px;text-align:right;font-size:10.5px;font-variant-numeric:tabular-nums;color:var(--ui-text-3);padding-top:2px;font-family:var(--ui-mono)}',
1039
+ '.studio-step-status{flex:none;width:7px;height:7px;border-radius:50%;margin-top:6px;background:var(--ui-text-3)}',
1040
+ '.studio-step-status.tone-success{background:var(--ui-success)}',
1041
+ '.studio-step-status.tone-danger{background:var(--ui-danger)}',
1042
+ '.studio-step-status.tone-business{background:var(--ui-business);animation:studio-pulse 1.2s ease-in-out infinite}',
559
1043
  '.studio-step-content{flex:1;min-width:0;display:grid;gap:2px}',
560
- '.studio-step-name{font-size:11.5px;font-weight:600;line-height:1.5;color:var(--dsw-alias-label-primary);word-break:break-word}',
561
- '.studio-step-info{display:flex;gap:7px;flex-wrap:wrap;font-size:10.5px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}',
562
- '.studio-step-thumb{width:96px;height:56px;flex:none;object-fit:cover;border-radius:8px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2);cursor:zoom-in;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary);padding:0}',
1044
+ '.studio-step-name{font-size:11.5px;font-weight:600;line-height:1.5;color:var(--ui-text);word-break:break-word}',
1045
+ '.studio-step-info{display:flex;gap:7px;flex-wrap:wrap;font-size:10.5px;color:var(--ui-text-3);font-variant-numeric:tabular-nums}',
1046
+ '.studio-step-thumb{width:96px;height:56px;flex:none;object-fit:cover;border-radius:8px;border:1px solid var(--ui-border);background:var(--ui-surface-2);cursor:zoom-in;display:inline-flex;align-items:center;justify-content:center;color:var(--ui-text-3);padding:0}',
563
1047
  '.studio-step-thumb.is-empty{cursor:default;border-style:dashed}',
564
- '.studio-evidence-missing{height:92px;display:flex;align-items:center;justify-content:center;border:1px dashed var(--dsw-alias-border-l1);border-radius:8px;color:var(--dsw-alias-label-tertiary);font-size:10.5px;background:var(--dsw-alias-bg-layer-2)}',
565
- '.studio-empty{padding:38px 18px;text-align:center;border:1px dashed var(--dsw-alias-border-l1);border-radius:12px;color:var(--dsw-alias-label-tertiary)}',
566
- '.studio-empty-icon{display:flex;justify-content:center;color:var(--dsw-alias-label-tertiary);margin-bottom:8px}',
567
- '.studio-empty-title{font-size:12.5px;font-weight:600;color:var(--dsw-alias-label-secondary)}',
568
- '.studio-empty-desc{font-size:11.5px;margin-top:4px;max-width:420px;margin-left:auto;margin-right:auto;line-height:1.6}',
569
- '.studio-modal-overlay{position:absolute;inset:0;z-index:80;display:flex;align-items:center;justify-content:center;padding:24px;background:color-mix(in srgb,var(--dsw-alias-bg-base) 62%,transparent);backdrop-filter:blur(3px)}',
570
- '.studio-modal{width:min(560px,100%);max-height:88vh;display:flex;flex-direction:column;border:1px solid var(--dsw-alias-border-l1);border-radius:16px;background:var(--dsw-alias-bg-layer-1);box-shadow:0 22px 60px color-mix(in srgb,var(--dsw-alias-bg-base) 55%,transparent);overflow:hidden}',
1048
+
1049
+ /* ---------- 反馈与知识沉淀 ---------- */
1050
+ '.studio-feedback{margin-top:10px;padding-top:10px;border-top:1px dashed var(--ui-border)}',
1051
+ '.studio-feedback-head{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin-bottom:7px}',
1052
+ '.studio-feedback-title{font-size:11.5px;font-weight:650;color:var(--ui-text)}',
1053
+ '.studio-feedback-actions{display:flex;gap:7px;flex-wrap:wrap;margin-top:7px}',
1054
+ '.studio-feedback-used{font-size:11px;line-height:1.55;color:var(--ui-text-2);white-space:pre-wrap;word-break:break-word;margin-bottom:6px}',
1055
+ '.studio-correction{padding:7px 9px;border-radius:8px;background:var(--ui-surface-2);font-size:11px;line-height:1.55;color:var(--ui-text-2);word-break:break-word}',
1056
+ '.studio-knowledge-deposit{margin-top:9px;padding:9px 11px;border:1px solid var(--ui-border);border-radius:9px;background:var(--ui-surface)}',
1057
+ '.studio-knowledge-deposit summary{cursor:pointer;list-style:none;display:flex;align-items:center;gap:6px;flex-wrap:wrap}',
1058
+ '.studio-knowledge-chips{display:flex;gap:5px;flex-wrap:wrap;margin-top:6px}',
1059
+ '.studio-knowledge-item{padding:6px 0;border-top:1px dashed var(--ui-border);font-size:11px;line-height:1.6;color:var(--ui-text-2);word-break:break-word}',
1060
+
1061
+ /* ---------- 空态与加载 ---------- */
1062
+ '.studio-empty{padding:36px 18px;text-align:center;border:1px dashed var(--ui-border);border-radius:12px;color:var(--ui-text-3);background:color-mix(in srgb,var(--ui-surface) 60%,transparent)}',
1063
+ '.studio-empty-icon{display:flex;justify-content:center;color:var(--ui-text-3);margin-bottom:8px}',
1064
+ '.studio-empty-title{font-size:12.5px;font-weight:650;color:var(--ui-text-2)}',
1065
+ '.studio-empty-desc{font-size:11.5px;margin-top:4px;max-width:430px;margin-left:auto;margin-right:auto;line-height:1.65}',
1066
+ '.studio-spinner{width:14px;height:14px;border-radius:50%;border:2px solid color-mix(in srgb,var(--ui-text-3) 30%,transparent);border-top-color:var(--ui-accent);display:inline-block;animation:studio-spin .7s linear infinite;flex:none}',
1067
+ '@keyframes studio-spin{to{transform:rotate(360deg)}}',
1068
+ '@keyframes studio-pulse{0%,100%{opacity:.4}50%{opacity:1}}',
1069
+ '.studio-pulse{animation:studio-pulse 1.6s ease-in-out infinite}',
1070
+
1071
+ /* ---------- 弹层 ---------- */
1072
+ '.studio-modal-overlay{position:absolute;inset:0;z-index:80;display:flex;align-items:center;justify-content:center;padding:24px;background:color-mix(in srgb,var(--ui-bg) 62%,transparent);backdrop-filter:blur(4px)}',
1073
+ '.studio-modal{width:min(560px,100%);max-height:88vh;display:flex;flex-direction:column;border:1px solid var(--ui-border);border-radius:16px;background:var(--ui-surface);box-shadow:var(--ui-shadow-lg);overflow:hidden}',
571
1074
  '.studio-modal-wide{width:min(900px,100%)}',
572
- '.studio-modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:16px 18px 12px;border-bottom:1px solid var(--dsw-alias-border-l1)}',
573
- '.studio-modal-title{font-size:15px;font-weight:650;margin:0}',
574
- '.studio-modal-desc{margin:4px 0 0;font-size:11.5px;color:var(--dsw-alias-label-tertiary);line-height:1.5}',
575
- '.studio-modal-body{padding:16px 18px;overflow-y:auto}',
576
- '.studio-modal-foot{display:flex;justify-content:flex-end;gap:8px;padding:12px 18px;border-top:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-2)}',
577
- '.studio-form{display:flex;flex-direction:column;gap:12px}',
1075
+ '.studio-modal-head{display:flex;align-items:flex-start;justify-content:space-between;gap:12px;padding:16px 18px 13px;border-bottom:1px solid var(--ui-border);flex:none}',
1076
+ '.studio-modal-title{font-size:15px;font-weight:680;margin:0;letter-spacing:-.1px}',
1077
+ '.studio-modal-desc{margin:4px 0 0;font-size:11.5px;color:var(--ui-text-3);line-height:1.55}',
1078
+ '.studio-modal-body{padding:16px 18px;overflow-y:auto;min-height:0}',
1079
+ '.studio-modal-foot{display:flex;justify-content:flex-end;align-items:center;gap:8px;padding:12px 18px;border-top:1px solid var(--ui-border);background:var(--ui-surface-2);flex:none}',
1080
+ '.studio-drawer-overlay{position:absolute;inset:0;z-index:80;display:flex;justify-content:flex-end;background:color-mix(in srgb,var(--ui-bg) 55%,transparent);backdrop-filter:blur(2px)}',
1081
+ '.studio-drawer{width:min(1120px,100%);height:100%;display:flex;flex-direction:column;background:var(--ui-surface);border-left:1px solid var(--ui-border);box-shadow:var(--ui-shadow-lg)}',
1082
+ '.studio-drawer-body{flex:1;overflow-y:auto;padding:14px 18px 24px;min-height:0}',
1083
+ '.studio-form{display:flex;flex-direction:column;gap:13px}',
578
1084
  '.studio-field{display:flex;flex-direction:column;gap:5px}',
579
- '.studio-field-label{font-size:11px;font-weight:600;color:var(--dsw-alias-label-secondary)}',
580
- '.studio-field-hint{font-size:10.5px;color:var(--dsw-alias-label-tertiary)}',
581
- '.studio-toggle{display:inline-flex;align-items:center;gap:8px;cursor:pointer;font-size:12px;color:var(--dsw-alias-label-secondary)}',
1085
+ '.studio-field-label{font-size:11px;font-weight:650;color:var(--ui-text-2)}',
1086
+ '.studio-field-hint{font-size:10.5px;color:var(--ui-text-3);line-height:1.5}',
1087
+ '.studio-toggle{display:inline-flex;align-items:center;gap:9px;cursor:pointer;font-size:12px;color:var(--ui-text-2)}',
582
1088
  '.studio-toggle input{position:absolute;opacity:0;pointer-events:none}',
583
- '.studio-toggle-track{width:32px;height:18px;border-radius:999px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);position:relative;flex:none;transition:background .15s ease}',
584
- '.studio-toggle-thumb{position:absolute;left:2px;top:2px;width:12px;height:12px;border-radius:50%;background:var(--dsw-alias-label-tertiary);transition:transform .15s ease,background .15s ease}',
585
- '.studio-toggle input:checked + .studio-toggle-track{background:var(--dsw-alias-button-primary-fill);border-color:transparent}',
586
- '.studio-toggle input:checked + .studio-toggle-track .studio-toggle-thumb{transform:translateX(14px);background:var(--dsw-alias-label-primary-inverted)}',
587
- '.studio-check{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dsw-alias-label-secondary);cursor:pointer}',
588
- '.studio-check input{accent-color:var(--dsw-alias-link)}',
589
- '.studio-tabs{display:flex;gap:4px;border-bottom:1px solid var(--dsw-alias-border-l1);margin:14px 0}',
590
- '.studio-tab{display:inline-flex;align-items:center;gap:5px;height:32px;padding:0 10px;border:0;border-bottom:2px solid transparent;background:transparent;color:var(--dsw-alias-label-tertiary);font-size:12px;font-family:inherit;cursor:pointer}',
591
- '.studio-tab.is-active{color:var(--dsw-alias-label-primary);border-bottom-color:var(--dsw-alias-link);font-weight:600}',
592
- '.studio-tab-count{font-size:10px;background:var(--dsw-alias-bg-layer-2);border-radius:999px;padding:0 5px;color:var(--dsw-alias-label-tertiary)}',
593
- '.studio-kv{display:grid;grid-template-columns:120px minmax(0,1fr);gap:6px 10px;font-size:11.5px}',
594
- '.studio-kv-key{color:var(--dsw-alias-label-tertiary)}',
595
- '.studio-kv-val{color:var(--dsw-alias-label-secondary);min-width:0;word-break:break-word}',
596
- '.studio-code{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:10.5px;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:6px;padding:1px 5px;color:var(--dsw-alias-label-secondary);word-break:break-all}',
597
- '.studio-log{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:10.5px;line-height:1.6;white-space:pre-wrap;background:var(--dsw-alias-bg-layer-2);border:1px solid var(--dsw-alias-border-l1);border-radius:8px;padding:10px;max-height:220px;overflow:auto;color:var(--dsw-alias-label-secondary)}',
598
- '.studio-toast{position:fixed;left:50%;bottom:26px;transform:translateX(-50%);z-index:120;display:flex;align-items:center;gap:8px;padding:9px 14px;border-radius:10px;border:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1);box-shadow:0 12px 32px color-mix(in srgb,var(--dsw-alias-bg-base) 45%,transparent);font-size:12px;color:var(--dsw-alias-label-primary);max-width:min(560px,90vw)}',
599
- '.studio-toast.is-error{color:var(--dsw-alias-state-error-primary);border-color:color-mix(in srgb,var(--dsw-alias-state-error-primary) 35%,transparent)}',
600
- '.studio-spinner{width:14px;height:14px;border-radius:50%;border:2px solid var(--dsw-alias-border-l1);border-top-color:var(--dsw-alias-link);display:inline-block;animation:studio-spin .7s linear infinite;flex:none}',
601
- '@keyframes studio-spin{to{transform:rotate(360deg)}}',
602
- '@keyframes studio-pulse{0%,100%{opacity:.45}50%{opacity:1}}',
603
- '.studio-pulse{animation:studio-pulse 1.2s ease-in-out infinite}',
604
- '.studio-lightbox{position:absolute;inset:0;z-index:140;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dsw-alias-bg-base) 78%,transparent);padding:28px}',
605
- '.studio-lightbox img{max-width:92%;max-height:88%;border-radius:10px;box-shadow:0 20px 60px color-mix(in srgb,var(--dsw-alias-bg-base) 60%,transparent)}',
1089
+ '.studio-toggle-track{width:34px;height:19px;border-radius:999px;background:var(--ui-surface-2);border:1px solid var(--ui-border);position:relative;flex:none;transition:background .15s ease}',
1090
+ '.studio-toggle-thumb{position:absolute;left:2px;top:2px;width:13px;height:13px;border-radius:50%;background:var(--ui-text-3);transition:transform .15s ease,background .15s ease}',
1091
+ '.studio-toggle input:checked + .studio-toggle-track{background:var(--ui-accent-fill);border-color:transparent}',
1092
+ '.studio-toggle input:checked + .studio-toggle-track .studio-toggle-thumb{transform:translateX(15px);background:var(--dsw-alias-label-primary-inverted,#fff)}',
1093
+ '.studio-check{display:inline-flex;align-items:center;gap:6px;font-size:11.5px;color:var(--ui-text-2);cursor:pointer}',
1094
+ '.studio-check input{accent-color:var(--ui-accent)}',
1095
+ '.studio-tabs{display:flex;gap:2px;border-bottom:1px solid var(--ui-border);margin:14px 0;overflow-x:auto}',
1096
+ '.studio-tab{display:inline-flex;align-items:center;gap:5px;height:34px;padding:0 11px;border:0;border-bottom:2px solid transparent;background:transparent;color:var(--ui-text-3);font-size:12px;font-family:inherit;cursor:pointer;white-space:nowrap;transition:color .12s ease,border-color .12s ease}',
1097
+ '.studio-tab:hover{color:var(--ui-text)}',
1098
+ '.studio-tab.is-active{color:var(--ui-text);border-bottom-color:var(--ui-accent);font-weight:650}',
1099
+ '.studio-tab-count{font-size:10px;background:var(--ui-surface-2);border-radius:999px;padding:0 5px;color:var(--ui-text-3);line-height:17px}',
1100
+ '.studio-kv{display:grid;grid-template-columns:120px minmax(0,1fr);gap:7px 12px;font-size:11.5px}',
1101
+ '.studio-kv-key{color:var(--ui-text-3)}',
1102
+ '.studio-kv-val{color:var(--ui-text-2);min-width:0;word-break:break-word}',
1103
+ '.studio-code{font-family:var(--ui-mono);font-size:10.5px;background:var(--ui-surface-2);border:1px solid var(--ui-border);border-radius:5px;padding:1px 5px;color:var(--ui-text-2);word-break:break-all}',
1104
+ '.studio-log{font-family:var(--ui-mono);font-size:10.5px;line-height:1.65;white-space:pre-wrap;background:var(--ui-surface-2);border:1px solid var(--ui-border);border-radius:8px;padding:10px;max-height:240px;overflow:auto;color:var(--ui-text-2)}',
1105
+ '.studio-toast{position:fixed;left:50%;bottom:26px;transform:translateX(-50%);z-index:120;display:flex;align-items:center;gap:8px;padding:10px 15px;border-radius:10px;border:1px solid var(--ui-border);background:var(--ui-surface);box-shadow:var(--ui-shadow-lg);font-size:12px;color:var(--ui-text);max-width:min(560px,90vw)}',
1106
+ '.studio-toast.is-error{color:var(--ui-danger);border-color:color-mix(in srgb,var(--ui-danger) 35%,transparent)}',
1107
+ '.studio-lightbox{position:absolute;inset:0;z-index:140;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--ui-bg) 82%,transparent);padding:28px}',
1108
+ '.studio-lightbox img{max-width:92%;max-height:88%;border-radius:10px;box-shadow:var(--ui-shadow-lg)}',
606
1109
  '.studio-lightbox-close{position:absolute;top:18px;right:18px}',
607
1110
  '.studio-sidebar-icon{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px}',
1111
+ '.studio-rotate-180{transform:rotate(180deg)}',
1112
+
1113
+ /* ---------- 实时与 Agent ---------- */
608
1114
  '.studio-account-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}',
1115
+ '.studio-account-card{min-width:0}',
609
1116
  '.studio-live-panel{margin-top:14px;padding:14px 16px}',
610
1117
  '.studio-live-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}',
611
- '.studio-live-tile{display:flex;flex-direction:column;gap:6px;min-width:0;border:1px solid var(--dsw-alias-border-l1);border-radius:10px;background:var(--dsw-alias-bg-layer-2);padding:8px}',
1118
+ '.studio-live-tile{display:flex;flex-direction:column;gap:6px;min-width:0;border:1px solid var(--ui-border);border-radius:10px;background:var(--ui-surface-2);padding:8px}',
612
1119
  '.studio-live-head{display:flex;align-items:center;gap:7px;min-width:0}',
613
1120
  '.studio-live-title{font-size:11.5px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0;flex:1}',
614
- '.studio-live-status{display:inline-flex;align-items:center;gap:4px;font-size:10px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}',
615
- '.studio-live-status.is-live{color:var(--dsw-alias-state-success-primary)}',
1121
+ '.studio-live-status{display:inline-flex;align-items:center;gap:4px;font-size:10px;color:var(--ui-text-3);white-space:nowrap}',
1122
+ '.studio-live-status.is-live{color:var(--ui-success)}',
616
1123
  '.studio-live-status.is-live .studio-status-dot{animation:studio-pulse 1.2s ease-in-out infinite}',
617
- '.studio-live-frames{font-size:9.5px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;font-variant-numeric:tabular-nums}',
618
- '.studio-live-frame{display:block;width:100%;aspect-ratio:16/10;object-fit:contain;border-radius:7px;background:var(--dsw-alias-bg-base);border:1px solid var(--dsw-alias-border-l1);cursor:zoom-in}',
619
- '.studio-live-empty{display:flex;align-items:center;justify-content:center;width:100%;aspect-ratio:16/10;border-radius:7px;background:var(--dsw-alias-bg-base);color:var(--dsw-alias-label-tertiary);font-size:11px;text-align:center;padding:12px}',
620
- '.studio-live-empty-panel{padding:22px 12px;text-align:center;color:var(--dsw-alias-label-tertiary);font-size:11.5px;border:1px dashed var(--dsw-alias-border-l1);border-radius:8px}',
1124
+ '.studio-live-frames{font-size:9.5px;color:var(--ui-text-3);white-space:nowrap;font-variant-numeric:tabular-nums}',
1125
+ '.studio-live-frame{display:block;width:100%;aspect-ratio:16/10;object-fit:contain;border-radius:7px;background:var(--ui-bg);border:1px solid var(--ui-border);cursor:zoom-in}',
1126
+ '.studio-live-empty{display:flex;align-items:center;justify-content:center;width:100%;aspect-ratio:16/10;border-radius:7px;background:var(--ui-bg);color:var(--ui-text-3);font-size:11px;text-align:center;padding:12px}',
1127
+ '.studio-live-empty-panel{padding:22px 12px;text-align:center;color:var(--ui-text-3);font-size:11.5px;border:1px dashed var(--ui-border);border-radius:8px}',
621
1128
  '.studio-monitor-grid{display:grid;grid-template-columns:minmax(0,1.1fr) minmax(0,1fr);gap:12px;align-items:start;margin-bottom:12px}',
622
1129
  '.studio-agent-view{padding:14px 16px;min-height:260px}',
623
- '.studio-agent-events{display:flex;flex-direction:column;gap:6px;max-height:360px;overflow-y:auto;padding-right:4px}',
624
- '.studio-agent-event-kind{font-size:9.5px;letter-spacing:.4px;text-transform:uppercase;color:var(--dsw-alias-label-tertiary);font-weight:600}',
625
- '.studio-agent-empty{padding:24px 10px;text-align:center;color:var(--dsw-alias-label-tertiary);font-size:11.5px;border:1px dashed var(--dsw-alias-border-l1);border-radius:8px}',
626
- '.studio-live-error{font-size:10px;color:var(--dsw-alias-state-warn-primary);line-height:1.4}',
627
- '.studio-account-card{min-width:0}',
628
- '.studio-rotate-180{transform:rotate(180deg)}',
629
- '@media (max-width:900px){.studio-account-grid{grid-template-columns:1fr}.studio-monitor-grid{grid-template-columns:1fr}.studio-live-grid{grid-template-columns:1fr}.studio-pipeline{grid-template-columns:repeat(3,minmax(0,1fr))}.studio-stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-grid-2{grid-template-columns:1fr}.studio-detail{position:static}.studio-case-grid{grid-template-columns:1fr}}',
630
- '@media (max-width:720px){.studio-topbar{flex-wrap:wrap;padding:10px 12px}.studio-brand-sub{display:none}.studio-rail{position:fixed;left:0;right:0;bottom:0;z-index:30;width:auto;flex-direction:row;gap:2px;padding:6px 8px;border-right:0;border-top:1px solid var(--dsw-alias-border-l1);overflow-x:auto}.studio-rail-group,.studio-rail-foot{display:none}.studio-nav{flex-direction:column;gap:2px;height:48px;justify-content:center;padding:0 6px;font-size:9.5px;min-width:56px}.studio-nav-icon{display:flex}.studio-nav-badge{display:none}.studio-body{padding-bottom:58px}.studio-content{padding:16px 14px 40px}.studio-hero{padding:18px 16px}.studio-hero-title{font-size:20px}.studio-pipeline{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-page-head{flex-direction:column}.studio-page-actions{justify-content:flex-start}.studio-evidence{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-case-side{display:none}.studio-kv{grid-template-columns:90px minmax(0,1fr)}.studio-step-thumb{width:72px;height:44px}.studio-row-actions{opacity:1}}',
1130
+ '.studio-agent-events{display:flex;flex-direction:column;gap:6px;max-height:380px;overflow-y:auto;padding-right:4px}',
1131
+ '.studio-agent-event-kind{font-size:9.5px;letter-spacing:.2px;color:var(--ui-text-3);font-weight:650}',
1132
+ '.studio-agent-empty{padding:24px 10px;text-align:center;color:var(--ui-text-3);font-size:11.5px;border:1px dashed var(--ui-border);border-radius:8px}',
1133
+ '.studio-live-error{font-size:10px;color:var(--ui-warn);line-height:1.4}',
1134
+ '.studio-flow-chips{display:flex;gap:5px;flex-wrap:wrap}',
1135
+ '.studio-import-mode{display:flex;gap:6px;flex-wrap:wrap}',
1136
+
1137
+ /* ---------- 响应式 ---------- */
1138
+ '@media (max-width:1240px){.studio-brand-sub{display:none}.studio-env{max-width:180px}.studio-content{padding:22px 24px 56px}.studio-hero{padding:22px 22px 20px}.studio-hero-grid{grid-template-columns:minmax(0,1.3fr) minmax(260px,.9fr);gap:20px}.studio-hero-title{font-size:24px}.studio-grid-2{grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);gap:14px}.studio-case-scroll{max-height:clamp(300px,calc(100vh - 320px),720px)}.studio-doc-mode{display:none}}',
1139
+ '@media (max-width:1080px){.studio-env{display:none}.studio-topbar{gap:8px}.studio-select{max-width:180px}.studio-hero-grid{grid-template-columns:1fr}.studio-pipeline{grid-template-columns:repeat(3,minmax(0,1fr))}.studio-pipe:nth-child(4){border-left:0;border-top:1px solid var(--ui-border)}.studio-pipe:nth-child(n+4){border-top:1px solid var(--ui-border)}.studio-stat-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-stat:nth-child(3){border-left:0;border-top:1px solid var(--ui-border)}.studio-stat:nth-child(4){border-top:1px solid var(--ui-border)}.studio-grid-2{grid-template-columns:1fr}.studio-detail{position:static;max-height:none}.studio-case-scroll{max-height:520px}.studio-result-scroll{max-height:480px}.studio-stage-strip{grid-template-columns:repeat(3,minmax(0,1fr))}}',
1140
+ '@media (max-width:900px){.studio-account-grid{grid-template-columns:1fr}.studio-monitor-grid{grid-template-columns:1fr}.studio-live-grid{grid-template-columns:1fr}.studio-result-side{max-width:52%}.studio-doc-writeback{display:none}}',
1141
+ '@media (max-width:720px){.studio-topbar{flex-wrap:wrap;padding:9px 12px;min-height:auto;gap:8px}.studio-brand-sub{display:none}.studio-topbar-spacer{display:none}.studio-topbar .studio-btn{padding:0 9px}.studio-rail{position:fixed;left:0;right:0;bottom:0;z-index:30;width:auto;flex-direction:row;gap:2px;padding:6px 8px;border-right:0;border-top:1px solid var(--ui-border);overflow-x:auto}.studio-rail-group,.studio-rail-foot{display:none}.studio-nav{flex-direction:column;gap:2px;height:48px;justify-content:center;padding:0 6px;font-size:9.5px;min-width:56px}.studio-nav.is-active:before{display:none}.studio-nav-icon{display:flex}.studio-nav-badge{display:none}.studio-body{padding-bottom:58px}.studio-content{padding:16px 14px 44px}.studio-hero{padding:18px 16px}.studio-hero-title{font-size:21px}.studio-pipeline{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-page-head{flex-direction:column;justify-content:flex-start;gap:12px}.studio-page-head>div:first-child{flex:0 1 auto;width:100%}.studio-page-actions{justify-content:flex-start}.studio-evidence{grid-template-columns:repeat(2,minmax(0,1fr))}.studio-case-side{display:none}.studio-case-status-mobile{display:inline-flex}.studio-kv{grid-template-columns:90px minmax(0,1fr)}.studio-step-thumb{width:72px;height:44px}.studio-row-actions{opacity:1}.studio-stat-grid{grid-template-columns:1fr 1fr}.studio-execution-metrics{gap:8px 0}.studio-metric{min-width:64px;padding-right:10px;margin-right:10px}.studio-result-side{display:none}.studio-filter-bar{width:100%;overflow-x:auto;flex-wrap:nowrap}.studio-doc-row{padding:8px 9px;gap:6px}.studio-doc-sub{gap:6px}.studio-doc-kind,.studio-doc-version,.studio-doc-writeback,.studio-doc-mode,.studio-doc-action-label{display:none}.studio-doc-action{padding:0 6px}}',
1142
+ '@media (prefers-reduced-motion:reduce){.studio-root *{animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important;scroll-behavior:auto!important}}',
631
1143
  ].join('\n');
632
1144
 
633
1145
  /* ------------------------------------------------------------------ */
@@ -797,6 +1309,32 @@ window.__ModuleLoader__.load({
797
1309
  .map((item) => item.run);
798
1310
  }
799
1311
 
1312
+ function runIsActive(run) {
1313
+ return ['running', 'preparing', 'queued', 'pending'].includes(run?.status)
1314
+ || ['running', 'queued'].includes(run?.queue?.state);
1315
+ }
1316
+
1317
+ function runMatchesQuery(run, query) {
1318
+ if (!query) return true;
1319
+ const text = [
1320
+ run.title,
1321
+ run.caseId,
1322
+ run.note,
1323
+ run.review?.summary,
1324
+ asArray(run.review?.issues).join(' '),
1325
+ run.queue?.hint,
1326
+ run.mode,
1327
+ ].filter(Boolean).join(' ').toLowerCase();
1328
+ return text.includes(query);
1329
+ }
1330
+
1331
+ const RUN_SORTS = [
1332
+ { id: 'active', label: '执行优先' },
1333
+ { id: 'seq', label: '序号' },
1334
+ { id: 'started', label: '开始时间' },
1335
+ { id: 'duration', label: '执行时长' },
1336
+ ];
1337
+
800
1338
  function QueueBadge(props) {
801
1339
  const info = queueDisplay(props.run);
802
1340
  if (!info) return null;
@@ -1148,6 +1686,8 @@ window.__ModuleLoader__.load({
1148
1686
  const recent = readRecentProjects().filter((item) => !workspaces.some((workspace) => workspace.path === item));
1149
1687
  const hasCurrent = workspaces.some((item) => item.path === current) || recent.includes(current);
1150
1688
  const envTone = env.agentBrowser === '不可用' ? 'is-fail' : env.stateReady ? '' : 'is-warn';
1689
+ const activeBatch = snapshot?.activeBatch || null;
1690
+ const activeProgress = activeBatch ? batchProgress(activeBatch) : null;
1151
1691
  return h('header', { className: 'studio-topbar' },
1152
1692
  h('div', { className: 'studio-brand' },
1153
1693
  h(Logo),
@@ -1157,6 +1697,16 @@ window.__ModuleLoader__.load({
1157
1697
  )
1158
1698
  ),
1159
1699
  h('div', { className: 'studio-topbar-spacer' }),
1700
+ activeBatch && activeProgress ? h('button', {
1701
+ className: 'studio-topbar-live',
1702
+ onClick: () => props.onNavigate && props.onNavigate('batches'),
1703
+ title: '打开执行中的批次:' + (activeBatch.name || activeBatch.id),
1704
+ },
1705
+ h(Spinner, { style: { width: 10, height: 10, borderWidth: 1.5 } }),
1706
+ h('span', { className: 'studio-topbar-live-label' }, activeProgress.active ? '执行中' : statusLabel(activeBatch.status)),
1707
+ h('span', { className: 'studio-topbar-live-num' }, activeProgress.percent + '%'),
1708
+ h('span', { className: 'studio-topbar-live-sub' }, activeProgress.done + '/' + activeProgress.total)
1709
+ ) : null,
1160
1710
  h('span', { className: cx('studio-env', 'studio-pulse') }, h('span', { className: cx('studio-env-dot', envTone) }), text(env.baseUrl || snapshot?.config?.baseUrl || '未配置环境')),
1161
1711
  h('select', {
1162
1712
  className: 'studio-select',
@@ -1200,6 +1750,7 @@ window.__ModuleLoader__.load({
1200
1750
  const snapshot = props.snapshot;
1201
1751
  const counts = snapshot?.counts || {};
1202
1752
  const knowledge = snapshot?.knowledge?.summary || {};
1753
+ const activeBatch = snapshot?.activeBatch || null;
1203
1754
  const badge = {
1204
1755
  cases: counts.total,
1205
1756
  batches: snapshot?.batches?.length,
@@ -1216,6 +1767,7 @@ window.__ModuleLoader__.load({
1216
1767
  },
1217
1768
  h('span', { className: 'studio-nav-icon' }, h(Icon, { name: item.icon, size: 16 })),
1218
1769
  h('span', null, item.label),
1770
+ item.id === 'batches' && activeBatch ? h('span', { className: 'studio-nav-live', title: '批次执行中' }) : null,
1219
1771
  badge[item.id] !== undefined && badge[item.id] !== null ? h('span', { className: 'studio-nav-badge' }, badge[item.id]) : null
1220
1772
  )),
1221
1773
  h('div', { className: 'studio-rail-foot' },
@@ -1231,7 +1783,7 @@ window.__ModuleLoader__.load({
1231
1783
  /* ------------------------------------------------------------------ */
1232
1784
 
1233
1785
  function PipelineCard(props) {
1234
- return h('div', { className: 'studio-pipe' },
1786
+ return h('div', { className: cx('studio-pipe', props.state ? 'is-' + props.state : '') },
1235
1787
  h('div', { className: 'studio-pipe-top' },
1236
1788
  h('span', { className: 'studio-pipe-icon' }, h(Icon, { name: props.icon, size: 14 })),
1237
1789
  h('span', { className: 'studio-pipe-index' }, props.index)
@@ -1244,22 +1796,49 @@ window.__ModuleLoader__.load({
1244
1796
 
1245
1797
  function BatchRow(props) {
1246
1798
  const batch = props.batch;
1247
- const percent = batchPercent(batch);
1248
- return h('div', { className: 'studio-row', onClick: () => props.onOpen(batch.id), role: 'button', tabIndex: 0 },
1799
+ const progress = batchProgress(batch);
1800
+ const current = progress.current;
1801
+ const liveElapsed = useElapsed(progress.startedAt, progress.active);
1802
+ const open = () => props.onOpen(batch.id);
1803
+ return h('div', {
1804
+ className: 'studio-row studio-batch-row',
1805
+ onClick: open,
1806
+ role: 'button',
1807
+ tabIndex: 0,
1808
+ onKeyDown: (event) => {
1809
+ if (event.target !== event.currentTarget) return;
1810
+ if (event.key !== 'Enter' && event.key !== ' ') return;
1811
+ event.preventDefault();
1812
+ open();
1813
+ },
1814
+ },
1249
1815
  h('div', { className: 'studio-row-main' },
1250
- h('div', { className: 'studio-row-title' }, batch.name || batch.id),
1816
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, minWidth: 0 } },
1817
+ h(StatusBadge, { status: batch.status === 'preparing' ? 'preparing' : batch.status }),
1818
+ h('div', { className: 'studio-row-title', style: { flex: 1 } }, batch.name || batch.id),
1819
+ h('span', { className: 'studio-batch-percent' }, progress.percent + '%')
1820
+ ),
1251
1821
  h('div', { className: 'studio-row-sub' },
1252
1822
  formatTime(batch.createdAt || batch.startedAt),
1253
1823
  ' · ',
1254
- (batch.summary?.passed || 0) + ' 通过 / ' + (batch.summary?.total || 0) + ' 条',
1824
+ progress.done + '/' + progress.total + ' 已判定',
1825
+ ' · 通过 ' + progress.passed,
1826
+ progress.failed ? ' · 失败 ' + progress.failed : '',
1827
+ progress.active ? ' · 已用时 ' + formatDuration(progress.active ? liveElapsed : progress.elapsedMs) : '',
1255
1828
  batch.options?.allowWrites ? ' · 已放行写操作' : ''
1256
1829
  ),
1257
- h('div', { style: { marginTop: 7 } }, h(Progress, { percent }))
1830
+ h('div', { style: { marginTop: 7 } }, h(Progress, {
1831
+ percent: progress.percent,
1832
+ tone: progress.failed ? 'danger' : progress.active ? 'business' : 'success',
1833
+ live: progress.active,
1834
+ })),
1835
+ current
1836
+ ? h('div', { className: 'studio-row-sub tone-business', style: { marginTop: 5 } }, '执行中 · ' + (current.title || current.caseId))
1837
+ : progress.active && progress.queued
1838
+ ? h('div', { className: 'studio-row-sub', style: { marginTop: 5 } }, '队列 ' + progress.queued + ' 条待执行')
1839
+ : null
1258
1840
  ),
1259
- h('div', { className: 'studio-row-side' },
1260
- h(StatusBadge, { status: batch.status === 'preparing' ? 'running' : batch.status }),
1261
- h(Icon, { name: 'chevron', size: 14 })
1262
- )
1841
+ h('div', { className: 'studio-row-side' }, h(Icon, { name: 'chevron', size: 14 }))
1263
1842
  );
1264
1843
  }
1265
1844
 
@@ -1281,71 +1860,92 @@ window.__ModuleLoader__.load({
1281
1860
  const batches = asArray(snapshot.batches);
1282
1861
  const active = snapshot.activeBatch;
1283
1862
  const latest = batches[0];
1284
- const activePercent = active ? batchPercent(active) : 0;
1285
- const ran = (counts.passed || 0) + (counts.failed || 0) + (counts.blocked || 0);
1286
- const passRate = ran ? Math.round(((counts.passed || 0) / ran) * 100) : 0;
1863
+ const activeProgress = active ? batchProgress(active) : null;
1864
+ const latestProgress = latest ? batchProgress(latest) : null;
1865
+ const judged = (counts.passed || 0) + (counts.partial || 0) + (counts.failed || 0) + (counts.blocked || 0);
1866
+ const ran = judged + (counts.stopped || 0);
1867
+ const passRate = judged ? Math.round((((counts.passed || 0) + (counts.partial || 0)) / judged) * 100) : 0;
1287
1868
  const nextActions = [];
1288
- if (!counts.total) nextActions.push({ icon: 'import', title: '导入第一份用例文档', desc: '支持 Markdown、文本、xlsx 或目录;导入后自动生成自然语言用例', onClick: props.onImport });
1869
+ if (!counts.total) nextActions.push({ icon: 'import', title: '导入第一份用例文档', desc: '支持 Markdown、文本、xlsx、CSV;导入后自动生成自然语言用例', onClick: props.onImport });
1289
1870
  if (counts.total && !batches.length) nextActions.push({ icon: 'play', title: '创建第一个执行批次', desc: 'flow 与 Agent 两条泳道并发,前置造数自动执行', onClick: props.onNewBatch });
1290
- if (active) nextActions.push({ icon: 'clock', title: '继续查看执行中的批次', desc: active.name + ' · ' + activePercent + '% 完成', onClick: () => props.onOpenBatch(active.id) });
1871
+ if (active) nextActions.push({ icon: 'clock', title: '继续查看执行中的批次', desc: active.name + ' · ' + activeProgress.percent + '% 完成' + (activeProgress.current ? ' · ' + (activeProgress.current.title || activeProgress.current.caseId) : ''), onClick: () => props.onOpenBatch(active.id) });
1291
1872
  if (latest && latest.status === 'done' && !latest.writeback) nextActions.push({ icon: 'file', title: '回写用例文档', desc: '批次已结束;按批次一次写回,避免并发覆盖', onClick: () => props.onOpenBatch(latest.id) });
1292
1873
  if (knowledge.pages) nextActions.push({ icon: 'knowledge', title: '查看本轮页面知识', desc: knowledge.pages + ' 个页面 · ' + knowledge.learnings + ' 条学习记录', onClick: () => props.onNavigate('knowledge') });
1293
1874
  if (!nextActions.length) nextActions.push({ icon: 'batch', title: '再跑一个批次', desc: '选择用例、设置并发,结果与证据自动归档', onClick: props.onNewBatch });
1294
1875
 
1295
1876
  return h('div', null,
1296
1877
  h('section', { className: 'studio-hero' },
1297
- h('div', { className: 'studio-hero-kicker' }, h(Icon, { name: 'spark', size: 13 }), 'Test Studio'),
1298
- h('h1', { className: 'studio-hero-title' }, '把一份用例文档,变成可复跑的测试资产'),
1299
- h('p', { className: 'studio-hero-desc' }, '导入文档后,先得到带前置条件、测试过程与预期结果的自然语言用例;Agent 负责造数与执行,批次结束后统一归档、回写,并把通过轨迹沉淀成 flow。'),
1300
- h('div', { className: 'studio-hero-actions' },
1301
- h('button', { className: 'studio-btn studio-btn-primary', onClick: props.onNewBatch }, h(Icon, { name: 'play', size: 14 }), '新建测试批次'),
1302
- h('button', { className: 'studio-btn', onClick: props.onImport }, h(Icon, { name: 'import', size: 14 }), '导入用例文档'),
1303
- h('button', { className: 'studio-btn', onClick: () => props.onNavigate('cases') }, h(Icon, { name: 'cases', size: 14 }), '浏览用例')
1878
+ h('div', { className: 'studio-hero-grid' },
1879
+ h('div', null,
1880
+ h('div', { className: 'studio-hero-kicker' }, h(Icon, { name: 'spark', size: 13 }), 'TEST STUDIO'),
1881
+ h('h1', { className: 'studio-hero-title' }, '把一份用例文档,变成可复跑的测试资产'),
1882
+ h('p', { className: 'studio-hero-desc' }, '导入文档后得到带前置条件、测试过程与预期结果的自然语言用例;Agent 负责造数与执行,批次结束后统一归档、回写,并把通过轨迹沉淀成 flow。'),
1883
+ h('div', { className: 'studio-hero-actions' },
1884
+ h('button', { className: 'studio-btn studio-btn-primary', onClick: props.onNewBatch }, h(Icon, { name: 'play', size: 14 }), '新建测试批次'),
1885
+ h('button', { className: 'studio-btn', onClick: props.onImport }, h(Icon, { name: 'import', size: 14 }), '导入用例文档'),
1886
+ h('button', { className: 'studio-btn', onClick: () => props.onNavigate('cases') }, h(Icon, { name: 'cases', size: 14 }), '浏览用例')
1887
+ )
1888
+ ),
1889
+ active
1890
+ ? h(ExecutionBanner, {
1891
+ batch: active,
1892
+ progress: activeProgress,
1893
+ compact: true,
1894
+ actions: h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onOpenBatch(active.id) }, '查看详情', h(Icon, { name: 'chevron', size: 12 })),
1895
+ })
1896
+ : latest
1897
+ ? h('div', { className: 'studio-card', style: { margin: 0 } },
1898
+ h('div', { className: 'studio-row-sub' }, '最近批次'),
1899
+ h('div', { className: 'studio-row-title', style: { marginTop: 4, whiteSpace: 'normal', fontSize: 13.5 } }, latest.name || latest.id),
1900
+ h('div', { className: 'studio-run-meta', style: { alignItems: 'center' } },
1901
+ h('span', null, formatTime(latest.createdAt)),
1902
+ h(StatusBadge, { status: latest.status }),
1903
+ h('span', null, latestProgress.passed + ' 通过 / ' + latestProgress.total + ' 条')
1904
+ ),
1905
+ h('div', { style: { marginTop: 11 } }, h(Progress, {
1906
+ percent: latestProgress.percent,
1907
+ tone: latestProgress.failed ? 'danger' : 'success',
1908
+ })),
1909
+ h('div', { className: 'studio-detail-actions' },
1910
+ h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onOpenBatch(latest.id) }, '查看批次', h(Icon, { name: 'chevron', size: 12 }))
1911
+ )
1912
+ )
1913
+ : h('div', { className: 'studio-card', style: { margin: 0 } },
1914
+ h('div', { className: 'studio-row-title' }, '还没有执行批次'),
1915
+ h('p', { className: 'studio-row-sub', style: { whiteSpace: 'normal', marginTop: 6, lineHeight: 1.6 } }, '导入用例后,新建一个批次,把前置造数、执行、归档与回写串起来。'),
1916
+ h('div', { className: 'studio-detail-actions' },
1917
+ h('button', { className: 'studio-btn studio-btn-primary studio-btn-sm', onClick: props.onNewBatch }, h(Icon, { name: 'play', size: 12 }), '新建批次')
1918
+ )
1919
+ )
1304
1920
  ),
1305
1921
  h('div', { className: 'studio-pipeline' },
1306
- h(PipelineCard, { index: '01', icon: 'file', name: '文档', value: asArray(snapshot.docs).length, hint: '已导入来源' }),
1307
- h(PipelineCard, { index: '02', icon: 'cases', name: '用例', value: counts.total || 0, hint: '自然语言用例' }),
1308
- h(PipelineCard, { index: '03', icon: 'layers', name: '造数', value: counts.agent || 0, hint: 'Agent / 配方前置' }),
1309
- h(PipelineCard, { index: '04', icon: 'play', name: '执行', value: active ? activePercent + '%' : batches.length, hint: active ? '当前批次进度' : '历史批次数' }),
1310
- h(PipelineCard, { index: '05', icon: 'file', name: '回写', value: latest?.writeback ? '已回写' : '待批次', hint: latest ? formatTime(latest.createdAt) : '尚无批次' }),
1311
- h(PipelineCard, { index: '06', icon: 'knowledge', name: '沉淀', value: knowledge.pages || 0, hint: '页面知识条目' })
1922
+ h(PipelineCard, { index: '01', icon: 'file', name: '文档', value: asArray(snapshot.docs).length, hint: '已导入来源', state: asArray(snapshot.docs).length ? 'done' : '' }),
1923
+ h(PipelineCard, { index: '02', icon: 'cases', name: '用例', value: counts.total || 0, hint: '自然语言用例', state: counts.total ? 'done' : '' }),
1924
+ h(PipelineCard, { index: '03', icon: 'layers', name: '造数', value: counts.agent || 0, hint: 'Agent / 配方前置', state: counts.agent ? 'done' : '' }),
1925
+ h(PipelineCard, { index: '04', icon: 'play', name: '执行', value: active ? activeProgress.percent + '%' : batches.length, hint: active ? '正在进行 · ' + (activeProgress.current ? (activeProgress.current.title || activeProgress.current.caseId) : '等待调度') : '历史批次数', state: active ? 'active' : batches.length ? 'done' : '' }),
1926
+ h(PipelineCard, { index: '05', icon: 'file', name: '回写', value: latest?.writeback ? '已回写' : latest?.status === 'done' ? '待回写' : '待批次', hint: latest ? formatTime(latest.createdAt) : '尚无批次', state: latest?.writeback ? 'done' : latest?.status === 'done' ? 'blocked' : '' }),
1927
+ h(PipelineCard, { index: '06', icon: 'knowledge', name: '沉淀', value: knowledge.pages || 0, hint: '页面知识条目', state: knowledge.pages ? 'done' : '' })
1312
1928
  )
1313
1929
  ),
1314
1930
 
1315
1931
  h('div', { className: 'studio-stat-grid' },
1316
1932
  h(Stat, { label: '用例总数', value: counts.total || 0, hint: (counts.flow || 0) + ' 条有 flow · ' + (counts.agent || 0) + ' 条走 Agent' }),
1317
- h(Stat, { label: '已执行', value: ran, tone: counts.failed ? 'danger' : 'success', hint: '通过 ' + (counts.passed || 0) + ' · 失败 ' + (counts.failed || 0) }),
1933
+ h(Stat, { label: '已执行', value: ran, tone: counts.failed ? 'danger' : 'success', hint: '通过 ' + (counts.passed || 0) + ' · 部分 ' + (counts.partial || 0) + ' · 失败 ' + (counts.failed || 0) }),
1318
1934
  h(Stat, { label: '通过率', value: passRate + '%', tone: passRate >= 80 ? 'success' : passRate >= 50 ? 'warn' : 'danger', hint: '仅统计已判定用例' }),
1319
1935
  h(Stat, { label: '知识资产', value: knowledge.pages || 0, hint: (knowledge.processes || 0) + ' 个流程 · ' + (knowledge.learnings || 0) + ' 条学习' })
1320
1936
  ),
1321
1937
 
1322
1938
  h('div', { className: 'studio-grid-2' },
1323
1939
  h('div', null,
1324
- h(SectionHead, { title: active ? '进行中的批次' : '最近批次', desc: active ? '每 1.6 秒自动刷新执行状态' : '批次是归档与回写的最小单位' }),
1325
- active
1326
- ? h('div', { className: 'studio-card' },
1327
- h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, marginBottom: 10 } },
1328
- h(StatusBadge, { status: 'running' }),
1329
- h('div', { style: { flex: 1, minWidth: 0 } },
1330
- h('div', { className: 'studio-row-title' }, active.name),
1331
- h('div', { className: 'studio-row-sub' }, active.summary?.passed + ' 通过 · ' + active.summary?.failed + ' 失败 · ' + active.summary?.blocked + ' 阻塞')
1332
- ),
1333
- h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onOpenBatch(active.id) }, '查看详情')
1334
- ),
1335
- h(Progress, { percent: activePercent }),
1336
- h('div', { className: 'studio-run-meta', style: { marginTop: 10 } },
1337
- h('span', null, '并发 ' + (active.options?.concurrency || Math.max(active.options?.workers || 0, active.options?.agentWorkers || 0) || '-')),
1338
- h('span', null, '已用时 ' + formatDuration(Date.now() - new Date(active.startedAt || active.createdAt).getTime()))
1339
- )
1340
- )
1341
- : batches.length
1342
- ? h('div', { className: 'studio-list' }, batches.slice(0, 5).map((batch) => h(BatchRow, { key: batch.id, batch, onOpen: props.onOpenBatch })))
1343
- : h(Empty, { icon: 'batch', title: '还没有执行批次', desc: '导入用例后,新建一个批次把前置造数、执行、归档与回写串起来。', action: h('button', { className: 'studio-btn studio-btn-primary', onClick: props.onNewBatch, style: { marginTop: 12 } }, '新建批次') })
1940
+ h(SectionHead, { title: active ? '批次动态' : '最近批次', desc: active ? '执行中批次置顶,每 1.6 秒刷新状态' : '批次是归档与回写的最小单位' }),
1941
+ batches.length
1942
+ ? h('div', { className: 'studio-list' }, batches.slice(0, 6).map((batch) => h(BatchRow, { key: batch.id, batch, onOpen: props.onOpenBatch })))
1943
+ : h(Empty, { icon: 'batch', title: '还没有执行批次', desc: '导入用例后,新建一个批次把前置造数、执行、归档与回写串起来。', action: h('button', { className: 'studio-btn studio-btn-primary', onClick: props.onNewBatch, style: { marginTop: 12 } }, '新建批次') })
1344
1944
  ),
1345
1945
  h('div', null,
1346
1946
  h(SectionHead, { title: '下一步', desc: '按当前项目状态给出建议' }),
1347
1947
  h('div', { className: 'studio-list' },
1348
- nextActions.map((item, index) => h(NextAction, { key: index, ...item }))
1948
+ nextActions.slice(0, 4).map((item, index) => h(NextAction, { key: index, ...item }))
1349
1949
  ),
1350
1950
  latest ? h('div', { className: 'studio-card', style: { marginTop: 14 } },
1351
1951
  h('div', { className: 'studio-row-title' }, '最近一次批次'),
@@ -1370,6 +1970,7 @@ window.__ModuleLoader__.load({
1370
1970
 
1371
1971
  const CASE_FILTERS = [
1372
1972
  { id: 'all', label: '全部' },
1973
+ { id: 'live', label: '进行中' },
1373
1974
  { id: 'flow', label: '有流程' },
1374
1975
  { id: 'agent', label: 'Agent' },
1375
1976
  { id: 'manual', label: '人工' },
@@ -1377,48 +1978,242 @@ window.__ModuleLoader__.load({
1377
1978
  { id: 'untested', label: '未执行' },
1378
1979
  ];
1379
1980
 
1380
- function caseMatches(item, query, filter) {
1981
+ function caseMatches(item, query, filter, live) {
1982
+ if (filter === 'live') return Boolean(live);
1381
1983
  if (filter === 'flow' && item.mode !== 'flow') return false;
1382
1984
  if (filter === 'agent' && item.mode !== 'agent') return false;
1383
1985
  if (filter === 'manual' && item.mode !== 'manual') return false;
1384
1986
  if (filter === 'failed' && item.status !== 'failed' && item.status !== 'blocked') return false;
1385
- if (filter === 'untested' && item.status !== 'untested') return false;
1987
+ if (filter === 'untested' && (item.status !== 'untested' || live)) return false;
1386
1988
  if (!query) return true;
1387
1989
  const needle = query.toLowerCase();
1388
1990
  return [item.tcId, item.title, item.module, item.precondition, item.steps, item.expected, item.flow?.name]
1389
1991
  .join(' ').toLowerCase().includes(needle);
1390
1992
  }
1391
1993
 
1392
- function CaseListItem(props) {
1994
+ function caseSignature(item) {
1995
+ if (!item) return '';
1996
+ return [item.tcId, item.title, item.status, item.mode, item.module, item.priority, item.lastRun?.at, asArray(item.dataNeeds).join(',')].join('|');
1997
+ }
1998
+
1999
+ function sameLiveState(a, b) {
2000
+ if (a === b) return true;
2001
+ if (!a || !b) return false;
2002
+ return a.status === b.status && a.note === b.note && a.position === b.position && a.ahead === b.ahead;
2003
+ }
2004
+
2005
+ function docKindLabel(kind) {
2006
+ return ({ xlsx: 'Excel', csv: 'CSV', markdown: 'Markdown', json: 'JSON', text: '文本' })[kind] || kind || '文档';
2007
+ }
2008
+
2009
+ function docKindTone(kind) {
2010
+ return kind === 'xlsx' || kind === 'csv' ? 'success' : kind === 'markdown' ? 'link' : kind === 'json' ? 'warn' : 'muted';
2011
+ }
2012
+
2013
+ function docCaseFileLabel(state) {
2014
+ return ({ ready: '可用', missing: '缺失', pending: '待生成' })[state] || state || '未知';
2015
+ }
2016
+
2017
+ function docModeLabel(mode) {
2018
+ return mode === 'overwrite' ? '覆盖导入' : '合并导入';
2019
+ }
2020
+
2021
+ const DOC_STATUS_PARTS = [
2022
+ ['passed', '通过', 'success'],
2023
+ ['partial', '部分', 'warn'],
2024
+ ['failed', '失败', 'danger'],
2025
+ ['blocked', '阻塞', 'warn'],
2026
+ ['running', '执行中', 'business'],
2027
+ ['queued', '排队', 'muted'],
2028
+ ['stopped', '已停', 'warn'],
2029
+ ['untested', '未执行', 'muted'],
2030
+ ];
2031
+
2032
+ function docRollup(doc) {
2033
+ const counts = doc?.statusCounts || {};
2034
+ return DOC_STATUS_PARTS
2035
+ .filter(([key]) => Number(counts[key]) > 0)
2036
+ .map(([key, label, tone]) => ({ key, label: label + ' ' + counts[key], tone }));
2037
+ }
2038
+
2039
+ function diffText(diff) {
2040
+ if (!diff) return '—';
2041
+ const parts = [
2042
+ '新增 ' + (diff.added || 0),
2043
+ '更新 ' + (diff.updated || 0),
2044
+ '未变 ' + (diff.unchanged || 0),
2045
+ '移除 ' + (diff.removed || 0),
2046
+ ];
2047
+ if (diff.missing) parts.push('缺失 ' + diff.missing);
2048
+ if (diff.hidden) parts.push('隐藏 ' + diff.hidden);
2049
+ return parts.join(' · ');
2050
+ }
2051
+
2052
+ function SelectCheckbox(props) {
2053
+ const ref = useRef(null);
2054
+ useEffect(() => {
2055
+ if (ref.current) ref.current.indeterminate = Boolean(props.mixed) && !props.checked;
2056
+ }, [props.mixed, props.checked]);
2057
+ return h('label', { className: 'studio-case-check', onClick: (event) => event.stopPropagation() },
2058
+ h('input', {
2059
+ ref,
2060
+ type: 'checkbox',
2061
+ checked: Boolean(props.checked),
2062
+ disabled: Boolean(props.disabled),
2063
+ onChange: () => props.onChange(!props.checked),
2064
+ 'aria-label': props.label || '选择',
2065
+ })
2066
+ );
2067
+ }
2068
+
2069
+ /**
2070
+ * 文档层的一行:标题、归属用例数、源文件状态、执行汇总与重新导读入口。
2071
+ * 用例行和文档行共用同一套固定行高,滚动窗口才能准确定位。
2072
+ */
2073
+ const CaseDocHeader = React.memo(function CaseDocHeader(props) {
2074
+ const doc = props.doc || null;
2075
+ const isUnassigned = !doc;
2076
+ const collapseKey = isUnassigned ? '__unassigned__' : doc.id;
2077
+ const cases = asArray(props.cases);
2078
+ const ids = cases.map((item) => item.tcId);
2079
+ const selected = ids.length > 0 && ids.every((caseId) => props.selectedIds.includes(caseId));
2080
+ const mixed = !selected && ids.some((caseId) => props.selectedIds.includes(caseId));
2081
+ const expanded = props.expanded;
2082
+ const rollup = doc ? docRollup(doc) : [];
2083
+ const total = doc ? Number(doc.visibleCount) || 0 : Number(props.total) || 0;
2084
+ const toggle = () => props.onToggleCollapse(collapseKey);
2085
+ return h('div', {
2086
+ className: cx('studio-doc-row', isUnassigned ? 'is-unassigned' : '', expanded ? 'is-expanded' : '', doc?.archived ? 'is-archived' : ''),
2087
+ role: 'button',
2088
+ tabIndex: 0,
2089
+ onClick: toggle,
2090
+ onKeyDown: (event) => {
2091
+ if (event.target !== event.currentTarget) return;
2092
+ if (event.key !== 'Enter' && event.key !== ' ') return;
2093
+ event.preventDefault();
2094
+ toggle();
2095
+ },
2096
+ 'aria-expanded': expanded,
2097
+ },
2098
+ h('button', {
2099
+ type: 'button',
2100
+ className: 'studio-doc-chevron',
2101
+ title: expanded ? '收起该文档下的用例' : '展开该文档下的用例',
2102
+ onClick: (event) => { event.stopPropagation(); toggle(); },
2103
+ }, h(Icon, { name: 'chevron', size: 13 })),
2104
+ h(SelectCheckbox, {
2105
+ checked: selected,
2106
+ mixed,
2107
+ disabled: !ids.length,
2108
+ label: isUnassigned ? '选择未归属用例' : '选择该文档下的用例',
2109
+ onChange: (next) => props.onToggleCases(ids, next),
2110
+ }),
2111
+ h('div', { className: 'studio-doc-main' },
2112
+ h('div', { className: 'studio-doc-top' },
2113
+ h('span', { className: 'studio-doc-name', title: doc?.name || '未归属文档' }, doc?.name || '未归属文档'),
2114
+ doc ? h(Badge, { tone: docKindTone(doc.kind), className: 'studio-doc-kind' }, docKindLabel(doc.kind)) : null,
2115
+ doc?.archived ? h(Badge, { tone: 'muted', className: 'studio-doc-archived' }, '已归档') : null,
2116
+ h('span', { className: 'studio-doc-count' },
2117
+ total + ' 条',
2118
+ props.filtering && cases.length !== total
2119
+ ? ' · 命中 ' + cases.length
2120
+ : !props.filtering && props.truncated && doc && cases.length < total
2121
+ ? ' · 已载入 ' + cases.length
2122
+ : ''
2123
+ ),
2124
+ doc ? h('span', { className: 'studio-doc-version' }, 'v' + (doc.version || 1)) : null,
2125
+ doc
2126
+ ? h('span', { className: 'studio-doc-source', title: doc.sourcePath || '' },
2127
+ h(Badge, { tone: doc.sourceState === 'missing' ? 'danger' : 'success' },
2128
+ doc.sourceState === 'missing' ? '源缺失' : '源就绪'))
2129
+ : h(Badge, { tone: 'warn' }, '未关联文档')
2130
+ ),
2131
+ h('div', { className: 'studio-doc-sub' },
2132
+ isUnassigned
2133
+ ? h('span', { className: 'studio-doc-hint' }, '这些用例没有关联到导入文档,回写时按独立用例处理')
2134
+ : h(React.Fragment, null,
2135
+ h('span', { className: 'studio-doc-rollup' },
2136
+ rollup.length
2137
+ ? rollup.map((part) => h('span', { key: part.key, className: cx('tone-' + part.tone) }, part.label))
2138
+ : total
2139
+ ? '暂无执行结果'
2140
+ : '暂无用例,可重新导读或重新关联源文件'
2141
+ ),
2142
+ h('span', { className: 'studio-doc-writeback' },
2143
+ doc.writeback?.at ? '回写 ' + relativeTime(doc.writeback.at) : '未回写'),
2144
+ h('span', { className: 'studio-doc-mode' }, docModeLabel(doc.mode))
2145
+ )
2146
+ )
2147
+ ),
2148
+ doc ? h('button', {
2149
+ type: 'button',
2150
+ className: 'studio-btn studio-btn-sm studio-doc-action',
2151
+ title: '重新读取源文档并更新该文档下的用例',
2152
+ onClick: (event) => { event.stopPropagation(); props.onReRead(doc); },
2153
+ }, h(Icon, { name: 'refresh', size: 12 }), h('span', { className: 'studio-doc-action-label' }, '重新导读')) : null,
2154
+ doc ? h('button', {
2155
+ type: 'button',
2156
+ className: 'studio-icon-btn studio-doc-more',
2157
+ title: '更多文档操作',
2158
+ 'aria-label': '更多文档操作:' + (doc.name || doc.id),
2159
+ onClick: (event) => { event.stopPropagation(); props.onActions(doc); },
2160
+ }, h(Icon, { name: 'more', size: 15 })) : null
2161
+ );
2162
+ });
2163
+
2164
+ const CaseListItem = React.memo(function CaseListItem(props) {
1393
2165
  const item = props.item;
1394
- const selected = props.selected;
2166
+ const live = props.live || null;
1395
2167
  return h('div', {
1396
- className: cx('studio-case', props.active ? 'is-active' : ''),
1397
- onClick: props.onClick,
2168
+ className: cx('studio-case', props.indent ? 'is-child' : '', props.active ? 'is-active' : '', live ? 'is-live' : ''),
2169
+ onClick: () => props.onSelect(item.tcId),
1398
2170
  role: 'button',
1399
2171
  tabIndex: 0,
2172
+ onKeyDown: (event) => {
2173
+ if (event.target !== event.currentTarget) return;
2174
+ if (event.key !== 'Enter' && event.key !== ' ') return;
2175
+ event.preventDefault();
2176
+ props.onSelect(item.tcId);
2177
+ },
1400
2178
  },
1401
2179
  h('label', { className: 'studio-case-check', onClick: (event) => event.stopPropagation() },
1402
- h('input', { type: 'checkbox', checked: selected, onChange: () => props.onToggle(item.tcId), 'aria-label': '选择用例' })
2180
+ h('input', { type: 'checkbox', checked: props.selected, onChange: () => props.onToggle(item.tcId), 'aria-label': '选择用例' })
1403
2181
  ),
1404
2182
  h('div', { className: 'studio-case-main' },
1405
2183
  h('div', { className: 'studio-case-top' },
2184
+ props.seq ? h('span', { className: 'studio-case-seq', title: '文档内序号' }, '#' + props.seq) : null,
1406
2185
  h('span', { className: 'studio-case-title' }, item.title || item.tcId),
1407
2186
  h('span', { className: 'studio-case-id' }, item.tcId)
1408
2187
  ),
1409
2188
  h('div', { className: 'studio-case-meta' },
1410
2189
  h(ModeBadge, { mode: item.mode }),
1411
- item.module ? h('span', null, item.module) : null,
1412
- item.priority ? h('span', null, item.priority) : null,
1413
- item.mode === 'flow' && asArray(item.dataNeeds).length ? h('span', null, '数据提示:' + item.dataNeeds.join('、')) : null
1414
- )
1415
- ),
2190
+ live
2191
+ ? h('span', { className: 'tone-business' },
2192
+ live.status === 'running'
2193
+ ? (live.note || '正在执行')
2194
+ : live.status === 'preparing'
2195
+ ? '准备执行'
2196
+ : '排队' + (live.position ? ' #' + live.position : '') + (live.ahead > 0 ? ' · 前方 ' + live.ahead : '')
2197
+ )
2198
+ : h(React.Fragment, null,
2199
+ item.module ? h('span', { key: 'module' }, item.module) : null,
2200
+ item.priority ? h('span', { key: 'priority' }, item.priority) : null,
2201
+ item.mode === 'flow' && asArray(item.dataNeeds).length ? h('span', { key: 'data' }, '数据提示:' + item.dataNeeds.join('、')) : null,
2202
+ ),
2203
+ h('span', { className: 'studio-case-status-mobile' }, h(StatusBadge, { status: live ? live.status : item.status }))
2204
+ )
2205
+ ),
1416
2206
  h('div', { className: 'studio-case-side' },
1417
- h(StatusBadge, { status: item.status }),
2207
+ h(StatusBadge, { status: live ? live.status : item.status }),
1418
2208
  item.lastRun ? h('span', { className: 'studio-case-id' }, relativeTime(item.lastRun.at)) : null
1419
2209
  )
1420
2210
  );
1421
- }
2211
+ }, (prev, next) => prev.active === next.active
2212
+ && prev.selected === next.selected
2213
+ && prev.seq === next.seq
2214
+ && prev.indent === next.indent
2215
+ && sameLiveState(prev.live, next.live)
2216
+ && caseSignature(prev.item) === caseSignature(next.item));
1422
2217
 
1423
2218
  function EvidenceImage(props) {
1424
2219
  const [failed, setFailed] = useState(false);
@@ -1431,13 +2226,29 @@ window.__ModuleLoader__.load({
1431
2226
  });
1432
2227
  }
1433
2228
 
2229
+ /** 用例定义的三段自然语言内容;详情与执行抽屉共用同一数据形状。 */
2230
+ function CaseDefinition(props) {
2231
+ const nl = props.nl || {};
2232
+ const blocks = [
2233
+ { key: 'preconditions', label: '前置条件', items: asArray(nl.preconditions), empty: '无特殊前置,按用例步骤直接执行。' },
2234
+ { key: 'steps', label: '测试过程', items: asArray(nl.steps), empty: '未提供步骤;执行时由 Agent 按用例描述完成并记录页面状态。' },
2235
+ { key: 'expected', label: '预期结果', items: asArray(nl.expected), empty: '未提供明确预期;执行时记录实际结果与判定依据。' },
2236
+ ];
2237
+ return h('div', { className: cx('studio-definition', props.grid ? 'is-grid' : '') },
2238
+ blocks.map((block) => h('div', { key: block.key, className: 'studio-nl-block' },
2239
+ h('div', { className: 'studio-nl-label' }, block.label),
2240
+ block.items.length
2241
+ ? h('ol', { className: 'studio-nl-list' }, block.items.map((line, index) => h('li', { key: index }, line)))
2242
+ : h('div', { className: 'studio-note' }, block.empty)
2243
+ ))
2244
+ );
2245
+ }
2246
+
1434
2247
  function CaseDetail(props) {
1435
2248
  const item = props.item;
1436
2249
  const [tab, setTab] = useState(item?.lastRun ? 'run' : 'nl');
1437
- const [feedbackRequest, setFeedbackRequest] = useState(0);
1438
2250
  useEffect(() => {
1439
2251
  setTab(item?.lastRun ? 'run' : 'nl');
1440
- setFeedbackRequest(0);
1441
2252
  }, [item?.tcId, item?.lastRun?.batchId]);
1442
2253
  if (!item) return h(Empty, { icon: 'cases', title: '选择一条用例', desc: '查看自然语言用例、关联流程和执行历史。' });
1443
2254
  const nl = item.nl || { preconditions: [], steps: [], expected: [] };
@@ -1449,6 +2260,35 @@ window.__ModuleLoader__.load({
1449
2260
  ...entry,
1450
2261
  url: entry.url || (entry.file ? API + '/shot?project=' + encodeURIComponent(props.project || '') + '&file=' + encodeURIComponent(entry.file) : ''),
1451
2262
  }));
2263
+ const liveRun = props.liveRun || null;
2264
+ const caseDoc = props.doc || null;
2265
+ const caseDocId = item.docId || item.source?.docId || '';
2266
+ const caseDocName = caseDoc?.name || item.docName || '';
2267
+ const caseDocKind = caseDoc?.kind || item.docKind || '';
2268
+ const flowCount = (item.flow ? 1 : 0) + asArray(item.preconditionFlows).length;
2269
+ const tabs = [
2270
+ { id: 'nl', label: '用例定义', detail: '前置 / 步骤 / 预期' + (flowCount ? ' · ' + flowCount + ' 个流程' : ''), tone: 'success' },
2271
+ { id: 'run', label: '最近执行', detail: item.lastRun ? statusLabel(item.lastRun.status) + ' · ' + relativeTime(item.lastRun.at) : '尚未执行', tone: runTone },
2272
+ { id: 'feedback', label: '执行反馈', detail: item.lastFeedback ? '已记录 · 下一轮可带入' : '执行后可填写', tone: item.lastFeedback ? 'success' : 'muted' },
2273
+ { id: 'knowledge', label: '知识沉淀', detail: knowledge ? knowledgePages + ' 页 · ' + knowledgeCorrections + ' 条纠错' : '执行后生成', tone: knowledge ? 'business' : 'muted' },
2274
+ ];
2275
+ const feedbackBox = (defaultOpen) => h(RunFeedbackBox, {
2276
+ caseId: item.tcId,
2277
+ batchId: item.lastRun.batchId,
2278
+ runStatus: item.lastRun.status,
2279
+ project: props.project,
2280
+ latestFeedback: item.lastFeedback || null,
2281
+ usedFeedback: item.lastFeedback && item.lastRun.batchId && item.lastFeedback.batchId === item.lastRun.batchId ? item.lastFeedback : null,
2282
+ defaultOpen,
2283
+ rerunDisabled: !props.hasBaseUrl,
2284
+ onToast: props.onToast,
2285
+ onOpenBatch: (batchId) => props.onCaseRunBatch ? props.onCaseRunBatch(batchId, item.tcId) : props.onOpenBatch(batchId),
2286
+ onRequeued: (payload) => {
2287
+ const batchId = payload?.batch?.id || item.lastRun.batchId;
2288
+ if (props.onCaseRunBatch) props.onCaseRunBatch(batchId, item.tcId);
2289
+ else if (batchId) props.onOpenBatch(batchId);
2290
+ },
2291
+ });
1452
2292
  return h('div', { className: 'studio-detail' },
1453
2293
  h('div', { className: 'studio-detail-head' },
1454
2294
  h('div', { style: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 8 } },
@@ -1456,19 +2296,31 @@ window.__ModuleLoader__.load({
1456
2296
  h('h3', { className: 'studio-detail-title' }, item.title || item.tcId),
1457
2297
  h('div', { className: 'studio-detail-meta' },
1458
2298
  h(ModeBadge, { mode: item.mode }),
1459
- h(StatusBadge, { status: item.status }),
2299
+ h(StatusBadge, { status: liveRun ? liveRun.status : item.status }),
1460
2300
  item.module ? h(Badge, { tone: 'muted' }, item.module) : null,
1461
2301
  item.priority ? h(Badge, { tone: 'muted' }, item.priority) : null
2302
+ ),
2303
+ h('div', { className: cx('studio-doc-link', caseDocName ? '' : 'is-unassigned'), title: caseDoc?.sourcePath || '' },
2304
+ h(Icon, { name: 'folder', size: 12 }),
2305
+ h('span', null, '所属文档:', h('span', { className: 'studio-doc-link-name' }, caseDocName || '未归属文档')),
2306
+ caseDoc
2307
+ ? h('span', { className: cx('studio-doc-link-meta', caseDoc.sourceState === 'missing' ? 'tone-danger' : '') },
2308
+ docKindLabel(caseDoc.kind) + ' · v' + (caseDoc.version || 1) + ' · ' + (caseDoc.sourceState === 'missing' ? '源文件缺失' : '源文件可用'))
2309
+ : caseDocKind
2310
+ ? h('span', { className: 'studio-doc-link-meta' }, docKindLabel(caseDocKind))
2311
+ : caseDocId
2312
+ ? h('span', { className: 'studio-doc-link-meta' }, '文档记录不可用')
2313
+ : null
1462
2314
  )
1463
2315
  ),
1464
2316
  h('button', { className: 'studio-icon-btn', onClick: props.onClose, title: '收起' }, h(Icon, { name: 'x', size: 15 }))
1465
2317
  ),
1466
2318
  h('div', { className: 'studio-detail-actions' },
1467
2319
  item.lastRun && ['failed', 'partial', 'blocked'].includes(item.lastRun.status)
1468
- ? h('button', { className: 'studio-btn studio-btn-primary studio-btn-sm', disabled: !props.hasBaseUrl, title: props.hasBaseUrl ? '不填写反馈,直接用 Agent 重跑' : '请先配置被测地址', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'play', size: 12 }), '直接重跑')
1469
- : h('button', { className: 'studio-btn studio-btn-primary studio-btn-sm', disabled: !props.hasBaseUrl, title: props.hasBaseUrl ? '' : '请先配置被测地址', onClick: () => props.onRun(item) }, h(Icon, { name: 'play', size: 12 }), item.lastRun ? '再执行一次' : '执行用例'),
1470
- item.lastRun ? h('button', { className: 'studio-btn studio-btn-sm', onClick: () => { setTab('run'); setFeedbackRequest((value) => value + 1); } }, h(Icon, { name: 'file', size: 12 }), '填写反馈') : null,
1471
- (!item.lastRun || !['failed', 'partial', 'blocked'].includes(item.lastRun.status)) && (item.flow || asArray(item.preconditionFlows).length) ? h('button', { className: 'studio-btn studio-btn-sm', disabled: !props.hasBaseUrl, title: props.hasBaseUrl ? '' : '请先配置被测地址', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 重跑') : null,
2320
+ ? h('button', { className: 'studio-btn studio-btn-primary studio-btn-sm', disabled: !props.hasBaseUrl || Boolean(liveRun), title: liveRun ? '该用例正在批次中执行' : props.hasBaseUrl ? '不填写反馈,直接用 Agent 重跑' : '请先配置被测地址', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'play', size: 12 }), '直接重跑')
2321
+ : h('button', { className: 'studio-btn studio-btn-primary studio-btn-sm', disabled: !props.hasBaseUrl || Boolean(liveRun), title: liveRun ? '该用例正在批次中执行' : props.hasBaseUrl ? '' : '请先配置被测地址', onClick: () => props.onRun(item) }, h(Icon, { name: 'play', size: 12 }), liveRun ? '执行中' : item.lastRun ? '再执行一次' : '执行用例'),
2322
+ item.lastRun ? h('button', { className: 'studio-btn studio-btn-sm', onClick: () => setTab('feedback') }, h(Icon, { name: 'file', size: 12 }), '填写反馈') : null,
2323
+ (!item.lastRun || !['failed', 'partial', 'blocked'].includes(item.lastRun.status)) && (item.flow || asArray(item.preconditionFlows).length) ? h('button', { className: 'studio-btn studio-btn-sm', disabled: !props.hasBaseUrl || Boolean(liveRun), title: liveRun ? '该用例正在批次中执行' : props.hasBaseUrl ? '' : '请先配置被测地址', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 重跑') : null,
1472
2324
  item.lastRun?.batchId ? h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onOpenBatch(item.lastRun.batchId) }, h(Icon, { name: 'batch', size: 12 }), '打开批次') : null,
1473
2325
  h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onAdd(item.tcId) }, h(Icon, { name: 'plus', size: 12 }), '加入批次'),
1474
2326
  h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onEdit(item) }, '编辑'),
@@ -1479,13 +2331,28 @@ window.__ModuleLoader__.load({
1479
2331
  h(Icon, { name: 'alert', size: 13 }), '当前工作区未配置被测地址 baseUrl;执行前请先去设置页填写。',
1480
2332
  h('button', { className: 'studio-btn studio-btn-sm', onClick: props.onOpenSettings }, '去设置')
1481
2333
  ) : null,
1482
- h('div', { className: 'studio-lifecycle' },
1483
- [
1484
- { key: 'define', label: '用例定义', detail: '前置 / 步骤 / 预期', tone: 'success', tab: 'nl' },
1485
- { key: 'run', label: '最近执行', detail: item.lastRun ? statusLabel(item.lastRun.status) + ' · ' + relativeTime(item.lastRun.at) : '尚未执行', tone: runTone, tab: 'run' },
1486
- { key: 'feedback', label: '执行反馈', detail: item.lastFeedback ? '已记录 · 下一轮可带入' : '执行后可填写', tone: item.lastFeedback ? 'success' : 'muted', tab: 'run' },
1487
- { key: 'knowledge', label: '知识沉淀', detail: knowledge ? knowledgePages + ' 页 · ' + knowledgeCorrections + ' 条纠错' : '执行后生成', tone: knowledge ? 'business' : 'muted', tab: 'run' },
1488
- ].map((step) => h('button', { key: step.key, type: 'button', className: 'studio-lifecycle-item', onClick: () => setTab(step.tab) },
2334
+ liveRun ? h('div', { className: 'studio-detail-live' },
2335
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 6, flexWrap: 'wrap' } },
2336
+ h(StatusBadge, { status: liveRun.status }),
2337
+ h('span', null,
2338
+ liveRun.status === 'running'
2339
+ ? '当前批次正在执行这条用例'
2340
+ : liveRun.status === 'preparing'
2341
+ ? '正在准备执行环境'
2342
+ : '排队第 ' + (liveRun.queue?.position || '?') + ' 位' + (liveRun.queue?.ahead > 0 ? ' · 前方 ' + liveRun.queue.ahead + ' 条' : '')
2343
+ )
2344
+ ),
2345
+ liveRun.note ? h('div', { style: { marginTop: 5, color: 'var(--ui-text-2)' } }, liveRun.note) : null
2346
+ ) : null,
2347
+ h('div', { className: 'studio-lifecycle', role: 'tablist', 'aria-label': '用例详情' },
2348
+ tabs.map((step) => h('button', {
2349
+ key: step.id,
2350
+ type: 'button',
2351
+ role: 'tab',
2352
+ 'aria-selected': tab === step.id,
2353
+ className: cx('studio-lifecycle-item', tab === step.id ? 'is-active' : ''),
2354
+ onClick: () => setTab(step.id),
2355
+ },
1489
2356
  h('span', { className: cx('studio-lifecycle-dot', 'tone-' + step.tone) }),
1490
2357
  h('div', { style: { minWidth: 0 } },
1491
2358
  h('div', { className: 'studio-lifecycle-label' }, step.label),
@@ -1494,45 +2361,58 @@ window.__ModuleLoader__.load({
1494
2361
  ))
1495
2362
  ),
1496
2363
  h('div', { className: 'studio-detail-body' },
1497
- h(TabBar, {
1498
- tabs: [
1499
- { id: 'run', label: '执行与反馈', count: item.lastRun ? 1 : 0 },
1500
- { id: 'nl', label: '用例定义' },
1501
- { id: 'flow', label: '关联流程', count: (item.flow ? 1 : 0) + asArray(item.preconditionFlows).length },
1502
- ],
1503
- active: tab,
1504
- onChange: setTab,
1505
- }),
1506
2364
  tab === 'nl' ? h('div', { className: 'studio-nl' },
1507
- item.source ? h('div', { className: 'studio-note', style: { marginBottom: 8 } },
2365
+ item.source ? h('div', { className: 'studio-note' },
1508
2366
  '来源:' + (item.source.docName || item.source.doc || item.source.file || '—')
1509
2367
  + (item.source.sheet ? ' · ' + item.source.sheet : '')
1510
2368
  + (item.source.rowNumber ? ' · 第 ' + item.source.rowNumber + ' 行' : '')
1511
2369
  + (item.source.kind ? '(' + item.source.kind + ')' : '')
1512
2370
  ) : null,
1513
- h('div', { className: 'studio-nl-block' },
1514
- h('div', { className: 'studio-nl-label' }, '前置条件'),
1515
- nl.preconditions.length
1516
- ? h('ol', { className: 'studio-nl-list' }, nl.preconditions.map((line, index) => h('li', { key: index }, line)))
1517
- : h('div', { className: 'studio-note' }, '无特殊前置,按用例步骤直接执行。')
1518
- ),
1519
- h('div', { className: 'studio-nl-block' },
1520
- h('div', { className: 'studio-nl-label' }, '测试过程'),
1521
- nl.steps.length
1522
- ? h('ol', { className: 'studio-nl-list' }, nl.steps.map((line, index) => h('li', { key: index }, line)))
1523
- : h('div', { className: 'studio-note' }, '未提供步骤;执行时由 Agent 按用例描述完成并记录页面状态。')
1524
- ),
1525
- h('div', { className: 'studio-nl-block' },
1526
- h('div', { className: 'studio-nl-label' }, '预期结果'),
1527
- nl.expected.length
1528
- ? h('ol', { className: 'studio-nl-list' }, nl.expected.map((line, index) => h('li', { key: index }, line)))
1529
- : h('div', { className: 'studio-note' }, '未提供明确预期;执行时记录实际结果与判定依据。')
1530
- ),
1531
- item.mode === 'flow' && asArray(item.dataNeeds).length ? h('div', { className: 'studio-note', style: { marginTop: 4 } }, '数据提示(从用例文本推断,不是文档参数字段):' + item.dataNeeds.join('、') + '。') : null,
2371
+ h(CaseDefinition, { nl }),
2372
+ item.mode === 'flow' && asArray(item.dataNeeds).length ? h('div', { className: 'studio-note' }, '数据提示(从用例文本推断,不是文档参数字段):' + item.dataNeeds.join('、') + '。') : null,
1532
2373
  item.remark ? h('div', { className: 'studio-nl-block' },
1533
2374
  h('div', { className: 'studio-nl-label' }, '备注'),
1534
2375
  h('div', { className: 'studio-note' }, item.remark)
1535
- ) : null
2376
+ ) : null,
2377
+ h('div', { className: 'studio-nl-block' },
2378
+ h('div', { className: 'studio-nl-label' }, '关联流程(' + flowCount + ')'),
2379
+ item.flow ? h('div', null,
2380
+ h('div', { className: 'studio-kv' },
2381
+ h('span', { className: 'studio-kv-key' }, '流程名'),
2382
+ h('span', { className: 'studio-kv-val' }, h('span', { className: 'studio-code' }, item.flow.name)),
2383
+ h('span', { className: 'studio-kv-key' }, '标题'),
2384
+ h('span', { className: 'studio-kv-val' }, item.flow.title || '—'),
2385
+ h('span', { className: 'studio-kv-key' }, '标签'),
2386
+ h('span', { className: 'studio-kv-val' }, asArray(item.flow.tags).join('、') || '—'),
2387
+ h('span', { className: 'studio-kv-key' }, '文件'),
2388
+ h('span', { className: 'studio-kv-val' }, item.flow.file || '—')
2389
+ ),
2390
+ h('div', { className: 'studio-note', style: { marginTop: 10 } }, '有 flow 的用例优先走 flow 泳道;需要重新探索时可用 Agent 重跑,或删除关联 flow 后回到 Agent 泳道。'),
2391
+ h('div', { className: 'studio-detail-actions' },
2392
+ h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 重跑'),
2393
+ h('button', { className: 'studio-btn studio-btn-sm studio-btn-danger', onClick: () => props.onDeleteFlow(item.flow, item) }, '删除关联流程')
2394
+ )
2395
+ ) : null,
2396
+ asArray(item.preconditionFlows).length ? h('div', null,
2397
+ h('div', { className: 'studio-nl-label', style: { marginTop: item.flow ? 16 : 0 } }, '前置条件流程'),
2398
+ asArray(item.preconditionFlows).map((flow) => h('div', { key: flow.name, className: 'studio-card', style: { padding: '11px 12px', marginTop: 8, background: 'var(--dsw-alias-bg-layer-2)' } },
2399
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 7, flexWrap: 'wrap' } },
2400
+ h('span', { className: 'studio-row-title' }, flow.title || flow.name),
2401
+ h(Badge, { tone: 'muted' }, '前置'),
2402
+ h('span', { className: 'studio-code' }, flow.name)
2403
+ ),
2404
+ h('div', { className: 'studio-row-sub', style: { marginTop: 5 } }, '提供:' + (asArray(flow.provides).join('、') || '—')),
2405
+ h('div', { className: 'studio-detail-actions' },
2406
+ h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 执行(含前置造数)'),
2407
+ h('button', { className: 'studio-btn studio-btn-sm studio-btn-danger', onClick: () => props.onDeleteFlow(flow, item) }, '删除前置流程')
2408
+ )
2409
+ )),
2410
+ h('div', { className: 'studio-note', style: { marginTop: 8 } }, 'Agent 执行会从头准备前置数据,并在 Agent 视图显示造数思考与操作过程。')
2411
+ ) : null,
2412
+ !item.flow && !asArray(item.preconditionFlows).length
2413
+ ? h('div', { className: 'studio-note' }, '还没有关联流程。Agent 执行通过后会自动把轨迹沉淀成 flows/agent-<caseId>.json。')
2414
+ : null
2415
+ )
1536
2416
  ) : null,
1537
2417
  tab === 'run' ? (item.lastRun
1538
2418
  ? h('div', { className: 'studio-nl' },
@@ -1554,70 +2434,26 @@ window.__ModuleLoader__.load({
1554
2434
  issues: item.lastRun.review?.issues,
1555
2435
  technicalError: item.lastRun.technicalError,
1556
2436
  }),
1557
- evidence.length ? h('div', { className: 'studio-evidence', style: { marginTop: 12 } },
2437
+ evidence.length ? h('div', { className: 'studio-evidence' },
1558
2438
  evidence.slice(0, 6).map((entry, index) => h('div', { key: index, className: 'studio-evidence-item' },
1559
2439
  /\.(png|jpe?g|webp)$/i.test(entry.file || '') ? h(EvidenceImage, { src: entry.url, alt: entry.caption || '证据', onClick: () => props.onShot({ src: entry.url, alt: entry.caption }) }) : h('div', { className: 'studio-note' }, entry.caption || entry.file),
1560
2440
  h('span', { className: 'studio-evidence-cap' }, entry.caption || '')
1561
2441
  ))
1562
2442
  ) : null,
1563
- h(KnowledgeDeposit, { knowledge: item.lastRun.knowledge || null }),
1564
- h('div', { className: 'studio-note', style: { marginTop: 8 } }, '反馈可选:填写后会保存并带入下一轮;留空可以直接再次 Agent 运行。'),
1565
- h(RunFeedbackBox, {
1566
- caseId: item.tcId,
1567
- batchId: item.lastRun.batchId,
1568
- runStatus: item.lastRun.status,
1569
- project: props.project,
1570
- latestFeedback: item.lastFeedback || null,
1571
- usedFeedback: item.lastFeedback && item.lastRun.batchId && item.lastFeedback.batchId === item.lastRun.batchId ? item.lastFeedback : null,
1572
- defaultOpen: feedbackRequest > 0,
1573
- focusToken: feedbackRequest,
1574
- rerunDisabled: !props.hasBaseUrl,
1575
- onToast: props.onToast,
1576
- onOpenBatch: (batchId) => props.onCaseRunBatch ? props.onCaseRunBatch(batchId, item.tcId) : props.onOpenBatch(batchId),
1577
- onRequeued: (payload) => {
1578
- const batchId = payload?.batch?.id || item.lastRun.batchId;
1579
- if (props.onCaseRunBatch) props.onCaseRunBatch(batchId, item.tcId);
1580
- else if (batchId) props.onOpenBatch(batchId);
1581
- },
1582
- })
2443
+ h('div', { className: 'studio-note' }, '执行反馈与知识沉淀分别在对应页签中维护;填写反馈后可带入下一轮。')
1583
2444
  )
1584
2445
  : h(Empty, { icon: 'clock', title: '还没有执行记录', desc: props.hasBaseUrl ? '执行后,结果、证据、知识沉淀和反馈会集中显示在这里。' : '请先在设置页配置被测地址,再执行这条用例。', action: h('button', { className: 'studio-btn studio-btn-primary', style: { marginTop: 12 }, disabled: !props.hasBaseUrl, onClick: () => props.onRun(item) }, h(Icon, { name: 'play', size: 13 }), props.hasBaseUrl ? '执行这条用例' : '先配置被测地址') })
1585
2446
  ) : null,
1586
- tab === 'flow' ? h('div', { className: 'studio-nl' },
1587
- item.flow ? h('div', null,
1588
- h('div', { className: 'studio-kv' },
1589
- h('span', { className: 'studio-kv-key' }, '流程名'),
1590
- h('span', { className: 'studio-kv-val' }, h('span', { className: 'studio-code' }, item.flow.name)),
1591
- h('span', { className: 'studio-kv-key' }, '标题'),
1592
- h('span', { className: 'studio-kv-val' }, item.flow.title || '—'),
1593
- h('span', { className: 'studio-kv-key' }, '标签'),
1594
- h('span', { className: 'studio-kv-val' }, asArray(item.flow.tags).join('、') || '—'),
1595
- h('span', { className: 'studio-kv-key' }, '文件'),
1596
- h('span', { className: 'studio-kv-val' }, item.flow.file || '—')
1597
- ),
1598
- h('div', { className: 'studio-note', style: { marginTop: 10 } }, '有 flow 的用例优先走 flow 泳道;需要重新探索时可用 Agent 重跑,或删除关联 flow 后回到 Agent 泳道。'),
1599
- h('div', { className: 'studio-detail-actions' },
1600
- h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 重跑'),
1601
- h('button', { className: 'studio-btn studio-btn-sm studio-btn-danger', onClick: () => props.onDeleteFlow(item.flow, item) }, '删除关联流程')
2447
+ tab === 'feedback' ? (item.lastRun
2448
+ ? h('div', { className: 'studio-nl' },
2449
+ h('div', { className: 'studio-note' }, '反馈可选:填写后会保存并带入下一轮;留空可以直接再次 Agent 运行。'),
2450
+ feedbackBox(true)
1602
2451
  )
1603
- ) : null,
1604
- asArray(item.preconditionFlows).length ? h('div', null,
1605
- h('div', { className: 'studio-nl-label', style: { marginTop: item.flow ? 16 : 0 } }, '前置条件流程'),
1606
- asArray(item.preconditionFlows).map((flow) => h('div', { key: flow.name, className: 'studio-card', style: { padding: '11px 12px', marginTop: 8, background: 'var(--dsw-alias-bg-layer-2)' } },
1607
- h('div', { style: { display: 'flex', alignItems: 'center', gap: 7, flexWrap: 'wrap' } },
1608
- h('span', { className: 'studio-row-title' }, flow.title || flow.name),
1609
- h(Badge, { tone: 'muted' }, '前置'),
1610
- h('span', { className: 'studio-code' }, flow.name)
1611
- ),
1612
- h('div', { className: 'studio-row-sub', style: { marginTop: 5 } }, '提供:' + (asArray(flow.provides).join('、') || '—')),
1613
- h('div', { className: 'studio-detail-actions' },
1614
- h('button', { className: 'studio-btn studio-btn-sm', onClick: () => props.onRunAgent(item) }, h(Icon, { name: 'spark', size: 12 }), '用 Agent 执行(含前置造数)'),
1615
- h('button', { className: 'studio-btn studio-btn-sm studio-btn-danger', onClick: () => props.onDeleteFlow(flow, item) }, '删除前置流程')
1616
- )
1617
- )),
1618
- h('div', { className: 'studio-note', style: { marginTop: 8 } }, 'Agent 执行会从头准备前置数据,并在 Agent 视图显示造数思考与操作过程。')
1619
- ) : null,
1620
- !item.flow && !asArray(item.preconditionFlows).length ? h(Empty, { icon: 'flow', title: '还没有关联流程', desc: 'Agent 执行通过后会自动把轨迹沉淀成 flows/agent-<caseId>.json。' }) : null
2452
+ : h(Empty, { icon: 'file', title: '执行后可以填写反馈', desc: '最近一次执行结束并给出判定后,反馈会保存在这里。' })
2453
+ ) : null,
2454
+ tab === 'knowledge' ? (knowledge
2455
+ ? h('div', { className: 'studio-nl' }, h(KnowledgeDeposit, { knowledge, open: true }))
2456
+ : h(Empty, { icon: 'knowledge', title: '还没有知识沉淀', desc: '执行结束后,页面、动作、流程与纠错经验会汇总在这里。' })
1621
2457
  ) : null
1622
2458
  )
1623
2459
  );
@@ -1893,6 +2729,325 @@ window.__ModuleLoader__.load({
1893
2729
  );
1894
2730
  }
1895
2731
 
2732
+ function ReReadDialog(props) {
2733
+ const doc = props.doc;
2734
+ const [mode, setMode] = useState(doc?.mode === 'overwrite' ? 'overwrite' : 'merge');
2735
+ const [busy, setBusy] = useState(false);
2736
+ const [error, setError] = useState('');
2737
+ const [result, setResult] = useState(null);
2738
+ const sourceMissing = doc?.sourceState === 'missing';
2739
+ const current = result?.doc || doc;
2740
+ // 重新导读返回的是文档记录而不是视图,源状态回落到打开对话框时的快照。
2741
+ const sourceState = current?.sourceState || doc?.sourceState || 'missing';
2742
+ const lastRead = current?.lastRead || doc?.lastRead || null;
2743
+ // 首次导入后还没有 lastRead:退回到导入时间和那次导入的差异,别让对话框看起来像没有历史。
2744
+ const lastImportAt = current?.updatedAt || current?.importedAt || '';
2745
+ const lastDiff = lastRead?.diff || current?.diff || null;
2746
+ const diff = result?.diffSummary || result?.diff || lastRead?.diff || null;
2747
+ const submit = async () => {
2748
+ if (!props.onReRead) {
2749
+ setError('当前环境没有连接测试工作室 Host,无法重新导读。');
2750
+ return;
2751
+ }
2752
+ setBusy(true);
2753
+ setError('');
2754
+ setResult(null);
2755
+ try {
2756
+ const payload = await props.onReRead({ docId: doc.id, mode });
2757
+ setResult(payload);
2758
+ if (props.onDone) props.onDone(payload);
2759
+ } catch (err) {
2760
+ setError(err.message);
2761
+ } finally {
2762
+ setBusy(false);
2763
+ }
2764
+ };
2765
+ return h(Modal, {
2766
+ title: '重新导读文档',
2767
+ desc: '重新读取源文件并更新该文档下的用例;源文件只读,不会被改动。',
2768
+ onClose: props.onClose,
2769
+ footer: h(React.Fragment, null,
2770
+ h('button', { className: 'studio-btn', onClick: props.onClose }, result ? '完成' : '取消'),
2771
+ result || sourceMissing ? null : h('button', { className: 'studio-btn studio-btn-primary', onClick: submit, disabled: busy },
2772
+ busy ? h(Spinner) : h(Icon, { name: 'refresh', size: 14 }), busy ? '正在导读…' : '开始重新导读')
2773
+ ),
2774
+ },
2775
+ h('div', { className: 'studio-form' },
2776
+ h('div', { className: 'studio-kv' },
2777
+ h('span', { className: 'studio-kv-key' }, '文档'),
2778
+ h('span', { className: 'studio-kv-val' }, current?.name || '—'),
2779
+ h('span', { className: 'studio-kv-key' }, '类型'),
2780
+ h('span', { className: 'studio-kv-val' }, docKindLabel(current?.kind)),
2781
+ h('span', { className: 'studio-kv-key' }, '当前版本'),
2782
+ h('span', { className: 'studio-kv-val' }, 'v' + (current?.version || 1)),
2783
+ h('span', { className: 'studio-kv-key' }, '源文件'),
2784
+ h('span', { className: 'studio-kv-val studio-mono-break' }, current?.sourcePath || '—'),
2785
+ h('span', { className: 'studio-kv-key' }, '源文件状态'),
2786
+ h('span', { className: 'studio-kv-val' },
2787
+ h(Badge, { tone: sourceState === 'missing' ? 'danger' : 'success' },
2788
+ sourceState === 'missing' ? '源文件缺失' : '源文件可用')),
2789
+ h('span', { className: 'studio-kv-key' }, '上次导读'),
2790
+ h('span', { className: 'studio-kv-val' }, lastRead?.at
2791
+ ? relativeTime(lastRead.at) + ' · v' + (lastRead.version || 1)
2792
+ : lastImportAt
2793
+ ? '尚未重新导读 · 上次导入 ' + relativeTime(lastImportAt) + ' · v' + (current?.version || 1)
2794
+ : '尚未重新导读'),
2795
+ h('span', { className: 'studio-kv-key' }, '上次回写'),
2796
+ h('span', { className: 'studio-kv-val' }, current?.writeback?.at
2797
+ ? relativeTime(current.writeback.at) + (current.writeback.targetPath ? ' · ' + current.writeback.targetPath : '')
2798
+ : '尚未回写')
2799
+ ),
2800
+ lastDiff ? h('div', { className: 'studio-note' }, (lastRead?.diff ? '上次导读差异:' : '上次导入差异:') + diffText(lastDiff)) : null,
2801
+ sourceMissing ? h('div', { className: 'studio-note tone-danger', style: { display: 'flex', gap: 7, alignItems: 'flex-start' } },
2802
+ h(Icon, { name: 'alert', size: 14 }),
2803
+ h('span', null, '源文件已不存在,无法重新导读:', current?.sourcePath || doc?.sourcePath || '—')
2804
+ ) : null,
2805
+ h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
2806
+ h('div', { className: 'studio-nl-label' }, '导读方式'),
2807
+ h('label', { className: 'studio-check', style: { padding: '4px 0' } },
2808
+ h('input', { type: 'radio', name: 'studio-reread-mode', checked: mode === 'merge', onChange: () => setMode('merge') }),
2809
+ '合并更新'
2810
+ ),
2811
+ h('div', { className: 'studio-note', style: { marginLeft: 22 } }, '新增用例并更新同编号用例;源文档中已删除的旧用例保留。'),
2812
+ h('label', { className: 'studio-check', style: { padding: '4px 0', marginTop: 6 } },
2813
+ h('input', { type: 'radio', name: 'studio-reread-mode', checked: mode === 'overwrite', onChange: () => setMode('overwrite') }),
2814
+ '覆盖同名文档'
2815
+ ),
2816
+ h('div', { className: 'studio-note', style: { marginLeft: 22 } }, '以源文档为准,删除该文档上次导入、本次已不存在的用例;同编号用例按文档内容更新。')
2817
+ ),
2818
+ h('div', { className: 'studio-note' }, '导读完成后会尝试把该文档上一次的执行结果回写到新的用例文件;源文件只读,不会被修改。'),
2819
+ error ? h('div', { className: 'studio-note tone-danger' }, error) : null,
2820
+ result ? h('div', { className: 'studio-nl' },
2821
+ h('div', { className: 'studio-kv' },
2822
+ h('span', { className: 'studio-kv-key' }, '识别用例'),
2823
+ h('span', { className: 'studio-kv-val', style: { fontWeight: 600 } }, result.caseCount ?? asArray(result.cases).length),
2824
+ h('span', { className: 'studio-kv-key' }, '文档版本'),
2825
+ h('span', { className: 'studio-kv-val' }, 'v' + (result.doc?.version || current?.version || 1)),
2826
+ h('span', { className: 'studio-kv-key' }, '本次差异'),
2827
+ h('span', { className: 'studio-kv-val' }, diffText(diff)),
2828
+ h('span', { className: 'studio-kv-key' }, '结果回写'),
2829
+ h('span', { className: 'studio-kv-val' }, result.resultReapplied ? '已随导读重新回写上次结果' : '没有可重放的历史结果')
2830
+ ),
2831
+ asArray(result.warnings).length
2832
+ ? h('div', { className: 'studio-note tone-warn' }, asArray(result.warnings).map((warning) => warning.message || warning.code || String(warning)).join(';'))
2833
+ : null
2834
+ ) : null
2835
+ )
2836
+ );
2837
+ }
2838
+
2839
+ function DocActionsDialog(props) {
2840
+ const doc = props.doc;
2841
+ const archived = doc.archived === true;
2842
+ const caseFile = doc.caseFile || doc.generatedPath || doc.writeback?.targetPath || '';
2843
+ const caseFileState = doc.caseFileState || 'missing';
2844
+ const actions = [
2845
+ { key: 'reread', icon: 'refresh', title: '重新导读', desc: '重新读取源文件,新增或更新该文档下的用例;源文件只读。', run: () => props.onReRead(doc) },
2846
+ { key: 'writeback', icon: 'check', title: '回写执行结果', desc: '把该文档下用例的最近执行结果写回用例文件;xlsx 生成执行副本,CSV 写入生成的 Markdown 镜像。', run: () => props.onWriteback(doc) },
2847
+ { key: 'reassociate', icon: 'import', title: '重新关联源文件', desc: '选择新的本地文件或服务器路径;文档 id、名称和已有用例归属保留。', run: () => props.onReassociate(doc) },
2848
+ { key: 'archive', icon: archived ? 'refresh' : 'folder', title: archived ? '恢复文档' : '归档文档', desc: archived ? '恢复后该文档和用例回到默认列表。' : '从默认用例列表隐藏该文档;用例与文件都保留,可随时恢复。', run: () => props.onArchive(doc, !archived) },
2849
+ { key: 'delete', icon: 'trash', title: '删除文档记录', desc: '只删除文档记录。用例保留并转为未归属;源文件和用例文件不会被删除。', danger: true, run: () => props.onDelete(doc) },
2850
+ ];
2851
+ return h(Modal, {
2852
+ title: '文档操作',
2853
+ desc: doc.name || doc.id,
2854
+ onClose: props.onClose,
2855
+ footer: h('button', { className: 'studio-btn', onClick: props.onClose }, '关闭'),
2856
+ },
2857
+ h('div', { className: 'studio-form' },
2858
+ h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
2859
+ h('div', { className: 'studio-doc-meta' },
2860
+ h(Badge, { tone: docKindTone(doc.kind) }, docKindLabel(doc.kind)),
2861
+ h(Badge, { tone: archived ? 'muted' : 'success' }, archived ? '已归档' : '使用中'),
2862
+ h(Badge, { tone: doc.sourceState === 'missing' ? 'danger' : 'success' }, doc.sourceState === 'missing' ? '源缺失' : '源就绪'),
2863
+ h(Badge, { tone: caseFileState === 'ready' ? 'success' : caseFileState === 'pending' ? 'muted' : 'danger' }, '用例文件' + docCaseFileLabel(caseFileState)),
2864
+ h('span', { className: 'studio-row-sub' },
2865
+ 'v' + (doc.version || 1) + ' · ' + (Number(doc.visibleCount) || 0) + ' 条用例'
2866
+ + (Number(doc.ownedCount) > Number(doc.visibleCount) ? ' / 账本 ' + doc.ownedCount : '')
2867
+ )
2868
+ ),
2869
+ h('div', { className: 'studio-kv', style: { marginTop: 8 } },
2870
+ h('span', { className: 'studio-kv-key' }, '源文件'),
2871
+ h('span', { className: 'studio-kv-val studio-mono-break' }, doc.sourcePath || '—'),
2872
+ h('span', { className: 'studio-kv-key' }, '用例文件'),
2873
+ h('span', { className: 'studio-kv-val studio-mono-break' }, caseFile || '—'),
2874
+ h('span', { className: 'studio-kv-key' }, '最近执行'),
2875
+ h('span', { className: 'studio-kv-val' }, doc.lastRun?.at ? relativeTime(doc.lastRun.at) : '暂无执行结果'),
2876
+ h('span', { className: 'studio-kv-key' }, '上次回写'),
2877
+ h('span', { className: 'studio-kv-val' }, doc.writeback?.at ? relativeTime(doc.writeback.at) : '尚未回写')
2878
+ ),
2879
+ Number(doc.tombstonedCount) || Number(doc.staleCount)
2880
+ ? h('div', { className: 'studio-note', style: { marginTop: 6 } },
2881
+ '登记用例中已删除 ' + (Number(doc.tombstonedCount) || 0) + ' 条,来源中缺失 ' + (Number(doc.staleCount) || 0) + ' 条。')
2882
+ : null
2883
+ ),
2884
+ h('div', { className: 'studio-doc-action-list' },
2885
+ actions.map((action) => h('button', {
2886
+ key: action.key,
2887
+ type: 'button',
2888
+ className: cx('studio-row', 'studio-doc-action-row', action.danger ? 'is-danger' : ''),
2889
+ onClick: () => { props.onClose(); action.run(); },
2890
+ },
2891
+ h('span', { className: 'studio-doc-action-icon' }, h(Icon, { name: action.icon, size: 15 })),
2892
+ h('div', { className: 'studio-row-main' },
2893
+ h('div', { className: 'studio-row-title' }, action.title),
2894
+ h('div', { className: 'studio-doc-action-desc' }, action.desc)
2895
+ ),
2896
+ h(Icon, { name: 'chevron', size: 13 })
2897
+ ))
2898
+ )
2899
+ )
2900
+ );
2901
+ }
2902
+
2903
+ function DocWritebackDialog(props) {
2904
+ const [preview, setPreview] = useState(null);
2905
+ const [loadingPreview, setLoadingPreview] = useState(true);
2906
+ const [applying, setApplying] = useState(false);
2907
+ const [error, setError] = useState('');
2908
+ const [done, setDone] = useState(null);
2909
+ useEffect(() => {
2910
+ let cancelled = false;
2911
+ setLoadingPreview(true);
2912
+ props.onWriteback({ docId: props.doc.id, dryRun: true })
2913
+ .then((payload) => { if (!cancelled) setPreview(payload); })
2914
+ .catch((err) => { if (!cancelled) setError(err.message); })
2915
+ .finally(() => { if (!cancelled) setLoadingPreview(false); });
2916
+ return () => { cancelled = true; };
2917
+ }, [props.doc.id]);
2918
+ const data = done || preview;
2919
+ const summary = data?.writeback || null;
2920
+ const results = Number(data?.results) || 0;
2921
+ // xlsx 的未写入清单在 writeback.skippedCaseIds 里,markdown 另有 skipped 计数。
2922
+ const skippedCount = (payload) => {
2923
+ const writeback = payload?.writeback || null;
2924
+ return Number(writeback?.markdown?.skipped) || asArray(writeback?.skippedCaseIds).length || 0;
2925
+ };
2926
+ const skipped = skippedCount(data);
2927
+ const caseRows = asArray(data?.cases).filter((item) => item.status);
2928
+ const target = summary?.targetPath || '';
2929
+ const apply = async () => {
2930
+ setApplying(true);
2931
+ setError('');
2932
+ try {
2933
+ const payload = await props.onWriteback({ docId: props.doc.id });
2934
+ setDone(payload);
2935
+ if (props.onToast) {
2936
+ const missed = skippedCount(payload);
2937
+ props.onToast({
2938
+ kind: 'success',
2939
+ text: '已回写 ' + (payload?.results || 0) + ' 条结果'
2940
+ + (missed ? ';' + missed + ' 条在目标文件中未找到对应行,未写入' : '')
2941
+ + (payload?.writeback?.targetPath ? ':' + payload.writeback.targetPath : ''),
2942
+ });
2943
+ }
2944
+ } catch (err) {
2945
+ setError(err.message);
2946
+ } finally {
2947
+ setApplying(false);
2948
+ }
2949
+ };
2950
+ return h(Modal, {
2951
+ title: '回写文档执行结果',
2952
+ desc: '使用该文档下用例的最近一次执行结果;没有结果的用例会跳过。',
2953
+ onClose: props.onClose,
2954
+ footer: h(React.Fragment, null,
2955
+ h('button', { className: 'studio-btn', onClick: props.onClose }, done ? '完成' : '取消'),
2956
+ done ? null : h('button', {
2957
+ className: 'studio-btn studio-btn-primary',
2958
+ disabled: loadingPreview || applying || !preview || !results,
2959
+ onClick: apply,
2960
+ }, applying ? h(Spinner) : h(Icon, { name: 'check', size: 14 }), applying ? '回写中…' : '确认回写')
2961
+ ),
2962
+ },
2963
+ h('div', { className: 'studio-form' },
2964
+ h('div', { className: 'studio-kv' },
2965
+ h('span', { className: 'studio-kv-key' }, '文档'),
2966
+ h('span', { className: 'studio-kv-val' }, props.doc.name || props.doc.id),
2967
+ h('span', { className: 'studio-kv-key' }, '类型'),
2968
+ h('span', { className: 'studio-kv-val' }, docKindLabel(props.doc.kind)),
2969
+ h('span', { className: 'studio-kv-key' }, '结果条数'),
2970
+ h('span', { className: 'studio-kv-val', style: { fontWeight: 600 } }, loadingPreview && !data ? '…' : results),
2971
+ h('span', { className: 'studio-kv-key' }, '回写目标'),
2972
+ h('span', { className: 'studio-kv-val studio-mono-break' }, target || (loadingPreview ? '…' : '—')),
2973
+ h('span', { className: 'studio-kv-key' }, '回写方式'),
2974
+ h('span', { className: 'studio-kv-val' }, props.doc.kind === 'xlsx'
2975
+ ? '生成执行结果副本,不修改源工作簿'
2976
+ : '在生成的用例文件中插入或替换结果块'),
2977
+ h('span', { className: 'studio-kv-key' }, '结果来源'),
2978
+ h('span', { className: 'studio-kv-val' }, summary?.mode === 'batch' || summary?.batchId
2979
+ ? '批次 ' + (summary.batchId || summary.sourceBatchIds?.[0] || '')
2980
+ : '最近结果(跨批次)')
2981
+ ),
2982
+ loadingPreview && !data ? h('div', { className: 'studio-note' }, h(Spinner), ' 正在计算结果范围…') : null,
2983
+ !loadingPreview && !error && preview && !results
2984
+ ? h('div', { className: 'studio-note tone-warn' }, '该文档下还没有可回写的执行结果。先在「批次」中执行用例,再回来回写。')
2985
+ : null,
2986
+ caseRows.length ? h('div', { className: 'studio-list' },
2987
+ h('div', { className: 'studio-nl-label' }, '本次回写用例(' + caseRows.length + ' 条)'),
2988
+ caseRows.slice(0, 10).map((item) => h('div', { key: item.caseId, className: 'studio-row', style: { cursor: 'default' } },
2989
+ h('div', { className: 'studio-row-main' },
2990
+ h('div', { className: 'studio-row-title' }, item.title || item.caseId),
2991
+ h('div', { className: 'studio-row-sub' }, item.caseId)
2992
+ ),
2993
+ h(StatusBadge, { status: item.status })
2994
+ )),
2995
+ caseRows.length > 10 ? h('div', { className: 'studio-note' }, '还有 ' + (caseRows.length - 10) + ' 条未展示') : null
2996
+ ) : null,
2997
+ error ? h('div', { className: 'studio-note tone-danger' }, error) : null,
2998
+ done ? h('div', { className: 'studio-note tone-success' },
2999
+ '已回写 ' + results + ' 条结果' + (skipped ? ';' + skipped + ' 条在目标文件中未找到对应行,未写入' : '')
3000
+ + (target ? ':' + target : '') + '。重复回写会覆盖同一结果块。'
3001
+ ) : null
3002
+ )
3003
+ );
3004
+ }
3005
+
3006
+ function DocDeleteDialog(props) {
3007
+ const doc = props.doc;
3008
+ const [busy, setBusy] = useState(false);
3009
+ const [error, setError] = useState('');
3010
+ const count = Number(doc.visibleCount) || 0;
3011
+ const submit = async () => {
3012
+ setBusy(true);
3013
+ setError('');
3014
+ try {
3015
+ await props.onDelete(doc);
3016
+ props.onClose();
3017
+ } catch (err) {
3018
+ setError(err.message);
3019
+ } finally {
3020
+ setBusy(false);
3021
+ }
3022
+ };
3023
+ return h(Modal, {
3024
+ title: '删除文档记录',
3025
+ desc: '删除后该文档不再出现在用例库中。',
3026
+ onClose: props.onClose,
3027
+ footer: h(React.Fragment, null,
3028
+ h('button', { className: 'studio-btn', onClick: props.onClose }, '取消'),
3029
+ h('button', { className: 'studio-btn studio-btn-danger', onClick: submit, disabled: busy },
3030
+ busy ? h(Spinner) : h(Icon, { name: 'trash', size: 14 }), busy ? '删除中…' : '删除文档记录')
3031
+ ),
3032
+ },
3033
+ h('div', { className: 'studio-form' },
3034
+ h('div', { className: 'studio-kv' },
3035
+ h('span', { className: 'studio-kv-key' }, '文档'),
3036
+ h('span', { className: 'studio-kv-val' }, doc.name || doc.id),
3037
+ h('span', { className: 'studio-kv-key' }, '类型'),
3038
+ h('span', { className: 'studio-kv-val' }, docKindLabel(doc.kind)),
3039
+ h('span', { className: 'studio-kv-key' }, '用例'),
3040
+ h('span', { className: 'studio-kv-val' }, count + ' 条')
3041
+ ),
3042
+ h('div', { className: 'studio-note' },
3043
+ '只删除文档记录。该文档下的 ' + count + ' 条用例会保留,并转为「未归属文档」;源文件和用例文件都不会被删除。'
3044
+ + ' 重新导入同名文档后,这些用例可以重新关联回来。'
3045
+ ),
3046
+ error ? h('div', { className: 'studio-note tone-danger' }, error) : null
3047
+ )
3048
+ );
3049
+ }
3050
+
1896
3051
  function CasesView(props) {
1897
3052
  const snapshot = props.snapshot;
1898
3053
  const [query, setQuery] = useState('');
@@ -1902,11 +3057,121 @@ window.__ModuleLoader__.load({
1902
3057
  const [deleteTargets, setDeleteTargets] = useState([]);
1903
3058
  const [exportOpen, setExportOpen] = useState(false);
1904
3059
  const [exportKind, setExportKind] = useState('cases');
1905
- const cases = asArray(snapshot.cases).filter((item) => caseMatches(item, query, filter));
1906
- const selectedCase = asArray(snapshot.cases).find((item) => item.tcId === props.selectedCaseId) || null;
3060
+ const [collapsedDocs, setCollapsedDocs] = useState(() => new Set());
3061
+ const [reReadDoc, setReReadDoc] = useState(null);
3062
+ const [docActions, setDocActions] = useState(null);
3063
+ const [docWriteback, setDocWriteback] = useState(null);
3064
+ const [docDelete, setDocDelete] = useState(null);
3065
+ const [showArchived, setShowArchived] = useState(false);
3066
+ const allCases = asArray(snapshot.cases);
3067
+ const truncated = Number(snapshot.counts?.total) > allCases.length;
3068
+ const allDocs = useMemo(() => asArray(snapshot.docs), [snapshot.docs]);
3069
+ const archivedDocs = useMemo(() => allDocs.filter((doc) => doc.archived === true), [allDocs]);
3070
+ const docs = useMemo(() => (showArchived ? allDocs : allDocs.filter((doc) => doc.archived !== true)), [allDocs, showArchived]);
3071
+ const docIds = useMemo(() => new Set(docs.map((doc) => doc.id)), [docs]);
3072
+ const allDocIds = useMemo(() => new Set(allDocs.map((doc) => doc.id)), [allDocs]);
3073
+ const visibleCases = useMemo(() => allCases.filter((item) => {
3074
+ const id = String(item.docId || item.source?.docId || '');
3075
+ return !id || !allDocIds.has(id) || docIds.has(id);
3076
+ }), [allCases, allDocIds, docIds]);
3077
+ // 序号按文档内稳定顺序计算,过滤或折叠后仍然指向同一条用例。
3078
+ const caseSeq = useMemo(() => {
3079
+ const groups = new Map();
3080
+ for (const item of visibleCases) {
3081
+ const key = String(item.docId || item.source?.docId || '__unassigned__');
3082
+ if (!groups.has(key)) groups.set(key, []);
3083
+ groups.get(key).push(item);
3084
+ }
3085
+ const map = new Map();
3086
+ for (const list of groups.values()) list.forEach((item, index) => map.set(item.tcId, index + 1));
3087
+ return map;
3088
+ }, [visibleCases]);
3089
+ // 归档文档被视图隐藏后,其中的用例不能再留在选择和详情里,否则会“看不见却被执行”。
3090
+ useEffect(() => {
3091
+ const visible = new Set(visibleCases.map((item) => item.tcId));
3092
+ const kept = props.selectedIds.filter((id) => visible.has(id));
3093
+ if (kept.length !== props.selectedIds.length) props.onSelectAll(kept);
3094
+ if (props.selectedCaseId && !visible.has(props.selectedCaseId)) props.onSelectCase('');
3095
+ }, [visibleCases, props.selectedIds, props.selectedCaseId]);
3096
+ const activeRuns = useMemo(() => {
3097
+ const map = new Map();
3098
+ for (const run of asArray(snapshot.activeBatch?.cases)) map.set(String(run.caseId), run);
3099
+ return map;
3100
+ }, [snapshot.activeBatch]);
3101
+ const liveFor = (item) => {
3102
+ const run = activeRuns.get(String(item.tcId));
3103
+ if (!run || !['running', 'queued', 'preparing'].includes(run.status)) return null;
3104
+ return {
3105
+ status: run.status,
3106
+ note: run.note || run.agentLive?.note || '',
3107
+ position: run.queue?.position,
3108
+ ahead: run.queue?.ahead,
3109
+ };
3110
+ };
3111
+ const cases = useMemo(() => visibleCases.filter((item) => caseMatches(item, query, filter, liveFor(item))), [visibleCases, query, filter, activeRuns]);
3112
+ const filterCounts = useMemo(() => {
3113
+ const counts = { all: visibleCases.length };
3114
+ for (const entry of CASE_FILTERS) {
3115
+ if (entry.id !== 'all') counts[entry.id] = visibleCases.filter((item) => caseMatches(item, '', entry.id, liveFor(item))).length;
3116
+ }
3117
+ return counts;
3118
+ }, [visibleCases, activeRuns]);
3119
+ const filtering = filter !== 'all' || Boolean(query.trim());
3120
+ const unassignedAll = useMemo(() => allCases.filter((item) => !allDocIds.has(String(item.docId || item.source?.docId || ''))), [allCases, allDocIds]);
3121
+ const rows = useMemo(() => {
3122
+ const byDoc = new Map();
3123
+ const unassigned = [];
3124
+ for (const item of cases) {
3125
+ const id = item.docId || item.source?.docId || '';
3126
+ if (id && allDocIds.has(id)) {
3127
+ if (!docIds.has(id)) continue;
3128
+ if (!byDoc.has(id)) byDoc.set(id, []);
3129
+ byDoc.get(id).push(item);
3130
+ } else {
3131
+ unassigned.push(item);
3132
+ }
3133
+ }
3134
+ const next = [];
3135
+ for (const doc of docs) {
3136
+ const list = byDoc.get(doc.id) || [];
3137
+ if (filtering && !list.length) continue;
3138
+ next.push({ type: 'doc', key: 'doc:' + doc.id, doc, cases: list });
3139
+ if (filtering || !collapsedDocs.has(doc.id)) {
3140
+ for (const item of list) next.push({ type: 'case', key: 'case:' + item.tcId, item });
3141
+ }
3142
+ }
3143
+ if (unassigned.length || (!filtering && unassignedAll.length)) {
3144
+ next.push({ type: 'unassigned', key: 'unassigned', cases: unassigned, total: unassignedAll.length });
3145
+ if (filtering || !collapsedDocs.has('__unassigned__')) {
3146
+ for (const item of unassigned) next.push({ type: 'case', key: 'case:' + item.tcId, item });
3147
+ }
3148
+ }
3149
+ return next;
3150
+ }, [cases, docs, docIds, allDocIds, filtering, unassignedAll, collapsedDocs]);
3151
+ const toggleDocCollapse = useCallback((id) => {
3152
+ setCollapsedDocs((current) => {
3153
+ const next = new Set(current);
3154
+ if (next.has(id)) next.delete(id);
3155
+ else next.add(id);
3156
+ return next;
3157
+ });
3158
+ }, []);
3159
+ const toggleDocCases = useCallback((ids, next) => {
3160
+ const set = new Set(props.selectedIds);
3161
+ for (const id of ids) {
3162
+ if (next) set.add(id);
3163
+ else set.delete(id);
3164
+ }
3165
+ props.onSelectAll([...set]);
3166
+ }, [props.selectedIds, props.onSelectAll]);
3167
+ const selectedCase = allCases.find((item) => item.tcId === props.selectedCaseId) || null;
3168
+ const selectedDoc = selectedCase
3169
+ ? allDocs.find((doc) => doc.id === (selectedCase.docId || selectedCase.source?.docId)) || null
3170
+ : null;
3171
+ const selectedLive = selectedCase ? liveFor(selectedCase) : null;
1907
3172
  const selectedCount = props.selectedIds.length;
1908
3173
  const hasBaseUrl = Boolean(snapshot.config?.baseUrl);
1909
- const selectedCases = asArray(snapshot.cases).filter((item) => props.selectedIds.includes(item.tcId));
3174
+ const selectedCases = allCases.filter((item) => props.selectedIds.includes(item.tcId));
1910
3175
  const selectedFlows = (() => {
1911
3176
  const map = new Map();
1912
3177
  const add = (flow, kind, caseId) => {
@@ -1924,48 +3189,66 @@ window.__ModuleLoader__.load({
1924
3189
  return [...map.values()];
1925
3190
  })();
1926
3191
  return h('div', null,
1927
- h('div', { className: 'studio-page-head' },
1928
- h('div', null,
1929
- h('h1', { className: 'studio-page-title' }, '用例'),
1930
- h('p', { className: 'studio-page-desc' }, '选中用例查看执行、反馈与知识沉淀;可单条执行、加入批次,或批量删除关联流程。')
1931
- ),
1932
- h('div', { className: 'studio-page-actions' },
1933
- selectedCount ? h('span', { className: 'studio-badge tone-link' }, '已选 ' + selectedCount + ' 条') : null,
1934
- h('button', { className: 'studio-btn', onClick: props.onImport }, h(Icon, { name: 'import', size: 14 }), '导入'),
1935
- h('button', { className: 'studio-btn', onClick: () => { setExportKind('cases'); setExportOpen(true); } }, h(Icon, { name: 'file', size: 14 }), '导出用例'),
1936
- h('button', { className: 'studio-btn', onClick: () => { setExportKind('results'); setExportOpen(true); } }, h(Icon, { name: 'file', size: 14 }), '导出结果'),
1937
- h('button', {
1938
- className: 'studio-btn studio-btn-danger',
1939
- onClick: () => { setDeleteTargets(selectedCases); setDeleteCasesOpen(true); },
1940
- disabled: !selectedCount,
1941
- title: selectedCount ? '删除所选用例' : '先选择要删除的用例',
1942
- }, h(Icon, { name: 'trash', size: 14 }), '删除用例' + (selectedCount ? '(' + selectedCount + ')' : '')),
1943
- h('button', { className: 'studio-btn studio-btn-danger', onClick: () => setDeleteFlowsOpen(true), disabled: !selectedFlows.length, title: selectedFlows.length ? '删除所选用例关联的 flow' : '所选用例没有关联 flow' },
1944
- h(Icon, { name: 'trash', size: 14 }), '批量删除关联流程' + (selectedFlows.length ? '(' + selectedFlows.length + ')' : '')
1945
- ),
1946
- h('button', { className: 'studio-btn studio-btn-primary', onClick: () => props.onNewBatch(props.selectedIds), disabled: !cases.length }, h(Icon, { name: 'play', size: 14 }), '执行所选用例')
1947
- )
1948
- ),
1949
- asArray(snapshot.docs).length ? h('div', { className: 'studio-note', style: { marginBottom: 8 } },
1950
- '已导入文档:' + asArray(snapshot.docs).slice(0, 4).map((doc) => doc.name + '(' + (doc.count || 0) + ' 条 · v' + (doc.version || 1) + ')').join('、')
1951
- + (asArray(snapshot.docs).length > 4 ? ' 等 ' + asArray(snapshot.docs).length + ' 个' : '')
1952
- + ';重复导入同名文档可更新对应用例。'
3192
+ h(PageHeader, {
3193
+ kicker: '用例库',
3194
+ icon: 'cases',
3195
+ title: '用例',
3196
+ desc: '选中用例查看执行、反馈与知识沉淀;可单条执行、加入批次,或批量管理。',
3197
+ meta: [
3198
+ h('span', { key: 'total', className: 'studio-badge tone-muted' }, allCases.length + ' 条用例'),
3199
+ snapshot.activeBatch ? h(StatusBadge, { key: 'live', status: 'running', label: '批次执行中' }) : null,
3200
+ ],
3201
+ actions: [
3202
+ selectedCount ? h('span', { key: 'sel', className: 'studio-badge tone-link' }, '已选 ' + selectedCount + ' 条') : null,
3203
+ h('button', { key: 'import', className: 'studio-btn', onClick: props.onImport }, h(Icon, { name: 'import', size: 14 }), '导入'),
3204
+ h(MenuButton, { key: 'export', label: '导出', icon: 'file' }, [
3205
+ h('button', { key: 'cases', className: 'studio-btn', onClick: () => { setExportKind('cases'); setExportOpen(true); } }, '导出用例'),
3206
+ h('button', { key: 'results', className: 'studio-btn', onClick: () => { setExportKind('results'); setExportOpen(true); } }, '导出结果'),
3207
+ ]),
3208
+ h(MenuButton, { key: 'more', label: '批量操作', icon: 'more' }, [
3209
+ h('button', { key: 'delcases', className: 'studio-btn', disabled: !selectedCount, onClick: () => { setDeleteTargets(selectedCases); setDeleteCasesOpen(true); } }, '删除所选用例' + (selectedCount ? '(' + selectedCount + ')' : '')),
3210
+ h('button', { key: 'delflows', className: 'studio-btn', disabled: !selectedFlows.length, onClick: () => setDeleteFlowsOpen(true) }, '删除关联流程' + (selectedFlows.length ? '(' + selectedFlows.length + ')' : '')),
3211
+ ]),
3212
+ h('button', { key: 'run', className: 'studio-btn studio-btn-primary', onClick: () => props.onNewBatch(props.selectedIds), disabled: !cases.length }, h(Icon, { name: 'play', size: 14 }), '执行所选用例'),
3213
+ ],
3214
+ }),
3215
+ snapshot.docsError ? h('div', { className: 'studio-note tone-danger', style: { marginBottom: 8 } },
3216
+ snapshot.docsError.message + ';请修复或移走该文件后重新加载。'
1953
3217
  ) : null,
3218
+ h('div', { className: 'studio-note', style: { marginBottom: 8 } },
3219
+ '用例按导入文档分组展示;执行结果会回写到各自文档的用例文件。'
3220
+ + ' 共 ' + allDocs.length + ' 个文档、' + allCases.length + ' 条用例'
3221
+ + (archivedDocs.length ? '(已归档 ' + archivedDocs.length + ' 个)' : '')
3222
+ + (unassignedAll.length ? ',其中 ' + unassignedAll.length + ' 条未归属文档' : '')
3223
+ + '。'
3224
+ + (Number(snapshot.counts?.total) > allCases.length ? ' 列表只加载了 ' + allCases.length + ' 条用例,统计按完整用例库。' : '')
3225
+ ),
1954
3226
  h('div', { className: 'studio-toolbar' },
1955
3227
  h('div', { className: 'studio-search' },
1956
3228
  h('span', { className: 'studio-search-icon' }, h(Icon, { name: 'search', size: 14 })),
1957
3229
  h('input', { className: 'studio-input', placeholder: '搜索编号、标题、前置条件、步骤…', value: query, onChange: (event) => setQuery(event.target.value) })
1958
3230
  ),
1959
- CASE_FILTERS.map((item) => h('button', {
1960
- key: item.id,
1961
- className: cx('studio-chip', filter === item.id ? 'is-active' : ''),
1962
- onClick: () => setFilter(item.id),
1963
- }, item.label))
3231
+ h('div', { className: 'studio-filter-bar' },
3232
+ CASE_FILTERS.map((item) => h('button', {
3233
+ key: item.id,
3234
+ className: cx('studio-chip', filter === item.id ? 'is-active' : ''),
3235
+ onClick: () => setFilter(item.id),
3236
+ }, item.label, h('span', { className: 'studio-chip-count' }, filterCounts[item.id] ?? 0)))
3237
+ ),
3238
+ archivedDocs.length ? h('label', { className: 'studio-check studio-archived-toggle' },
3239
+ h('input', { type: 'checkbox', checked: showArchived, onChange: (event) => setShowArchived(event.target.checked) }),
3240
+ '显示已归档(' + archivedDocs.length + ')'
3241
+ ) : null
1964
3242
  ),
1965
3243
  h('div', { className: 'studio-grid-2' },
1966
- h('div', null,
1967
- h('div', { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: 8 } },
1968
- h('span', { className: 'studio-row-sub' }, cases.length + ' 条用例'),
3244
+ h('div', { className: 'studio-card studio-card-flush' },
3245
+ h('div', { className: 'studio-list-head' },
3246
+ h('span', { className: 'studio-row-sub' },
3247
+ cases.length + ' 条用例'
3248
+ + (filtering ? ' · 已按文档展开' : ' · ' + docs.length + ' 个文档')
3249
+ + (!showArchived && archivedDocs.length ? ' · 已归档 ' + archivedDocs.length : '')
3250
+ + (!filtering && unassignedAll.length ? ' · 未归属 ' + unassignedAll.length : '')
3251
+ ),
1969
3252
  h('label', { className: 'studio-check' },
1970
3253
  h('input', {
1971
3254
  type: 'checkbox',
@@ -1975,19 +3258,64 @@ window.__ModuleLoader__.load({
1975
3258
  '全选当前结果'
1976
3259
  )
1977
3260
  ),
1978
- cases.length
1979
- ? h('div', { className: 'studio-case-list' }, cases.slice(0, 400).map((item) => h(CaseListItem, {
1980
- key: item.tcId,
1981
- item,
1982
- active: item.tcId === props.selectedCaseId,
1983
- selected: props.selectedIds.includes(item.tcId),
1984
- onClick: () => props.onSelectCase(item.tcId),
1985
- onToggle: props.onToggleCase,
1986
- })))
1987
- : h(Empty, { icon: 'search', title: '没有匹配的用例', desc: '换一个关键词,或先导入新的用例文档。' })
3261
+ rows.length
3262
+ ? h(VirtualList, {
3263
+ items: rows,
3264
+ rowHeight: 74,
3265
+ className: 'studio-case-scroll',
3266
+ keyFor: (row) => row.key,
3267
+ resetKey: filter + '|' + query,
3268
+ ariaLabel: '文档与用例列表',
3269
+ renderRow: (row) => {
3270
+ if (row.type === 'case') {
3271
+ return h(CaseListItem, {
3272
+ item: row.item,
3273
+ active: row.item.tcId === props.selectedCaseId,
3274
+ selected: props.selectedIds.includes(row.item.tcId),
3275
+ live: liveFor(row.item),
3276
+ seq: caseSeq.get(row.item.tcId),
3277
+ indent: true,
3278
+ onSelect: props.onSelectCase,
3279
+ onToggle: props.onToggleCase,
3280
+ });
3281
+ }
3282
+ return h(CaseDocHeader, {
3283
+ doc: row.doc || null,
3284
+ cases: row.cases,
3285
+ total: row.total,
3286
+ expanded: filtering || !collapsedDocs.has(row.doc ? row.doc.id : '__unassigned__'),
3287
+ filtering,
3288
+ truncated,
3289
+ selectedIds: props.selectedIds,
3290
+ onToggleCollapse: toggleDocCollapse,
3291
+ onToggleCases: toggleDocCases,
3292
+ onReRead: setReReadDoc,
3293
+ onActions: setDocActions,
3294
+ });
3295
+ },
3296
+ })
3297
+ : h('div', { className: 'studio-empty-wrap' },
3298
+ !filtering && !allCases.length
3299
+ ? h(Empty, {
3300
+ icon: 'cases',
3301
+ title: '还没有用例',
3302
+ desc: '导入用例文档后,用例会按文档分组显示。',
3303
+ action: h('button', { className: 'studio-btn studio-btn-primary', style: { marginTop: 12 }, onClick: props.onImport }, h(Icon, { name: 'import', size: 14 }), '导入用例文档'),
3304
+ })
3305
+ : !filtering && !docs.length && archivedDocs.length && !unassignedAll.length
3306
+ ? h(Empty, {
3307
+ icon: 'folder',
3308
+ title: '当前文档都已归档',
3309
+ desc: '归档不会删除用例;显示已归档后可以恢复文档。',
3310
+ action: h('button', { className: 'studio-btn', style: { marginTop: 12 }, onClick: () => setShowArchived(true) }, '显示已归档(' + archivedDocs.length + ')'),
3311
+ })
3312
+ : h(Empty, { icon: 'search', title: '没有匹配的用例', desc: '换一个关键词,或先导入新的用例文档。' })
3313
+ )
1988
3314
  ),
1989
3315
  selectedCase ? h(CaseDetail, {
1990
3316
  item: selectedCase,
3317
+ doc: selectedDoc,
3318
+ liveRun: selectedLive,
1991
3319
  project: snapshot.project,
1992
3320
  onClose: () => props.onSelectCase(''),
1993
3321
  onRun: props.onRunCase,
@@ -2024,6 +3352,40 @@ window.__ModuleLoader__.load({
2024
3352
  filteredIds: cases.map((item) => item.tcId),
2025
3353
  onClose: () => setExportOpen(false),
2026
3354
  }) : null,
3355
+ reReadDoc ? h(ReReadDialog, {
3356
+ doc: reReadDoc,
3357
+ onClose: () => setReReadDoc(null),
3358
+ onReRead: props.onReReadDocument,
3359
+ onDone: (payload) => {
3360
+ if (props.onToast) {
3361
+ props.onToast({
3362
+ kind: 'success',
3363
+ text: '已重新导读:' + (payload?.doc?.name || reReadDoc.name)
3364
+ + (payload?.caseCount ? ' · ' + payload.caseCount + ' 条用例' : ''),
3365
+ });
3366
+ }
3367
+ },
3368
+ }) : null,
3369
+ docActions ? h(DocActionsDialog, {
3370
+ doc: docActions,
3371
+ onClose: () => setDocActions(null),
3372
+ onReRead: setReReadDoc,
3373
+ onWriteback: setDocWriteback,
3374
+ onReassociate: (doc) => { setDocActions(null); props.onReassociateDocument(doc); },
3375
+ onArchive: (doc, archived) => { setDocActions(null); props.onArchiveDocument(doc, archived); },
3376
+ onDelete: (doc) => { setDocActions(null); setDocDelete(doc); },
3377
+ }) : null,
3378
+ docWriteback ? h(DocWritebackDialog, {
3379
+ doc: docWriteback,
3380
+ onWriteback: props.onDocsWriteback,
3381
+ onClose: () => setDocWriteback(null),
3382
+ onToast: props.onToast,
3383
+ }) : null,
3384
+ docDelete ? h(DocDeleteDialog, {
3385
+ doc: docDelete,
3386
+ onDelete: props.onDeleteDocument,
3387
+ onClose: () => setDocDelete(null),
3388
+ }) : null,
2027
3389
  props.caseRunBatchId ? h(CaseRunDrawer, {
2028
3390
  batchId: props.caseRunBatchId,
2029
3391
  caseId: props.caseRunCaseId || props.selectedCaseId,
@@ -2067,11 +3429,6 @@ window.__ModuleLoader__.load({
2067
3429
  });
2068
3430
  }
2069
3431
 
2070
- function batchActionStatus(batch) {
2071
- if (batch.status === 'preparing') return 'running';
2072
- return batch.status || 'queued';
2073
- }
2074
-
2075
3432
  function KnowledgeDeposit(props) {
2076
3433
  const knowledge = props.knowledge || null;
2077
3434
  if (!knowledge) return null;
@@ -2289,9 +3646,13 @@ window.__ModuleLoader__.load({
2289
3646
  .finally(() => { if (!cancelled) setBusy(false); });
2290
3647
  return () => { cancelled = true; };
2291
3648
  }, [props.batch.id, props.project]);
3649
+ const previewDocs = preview ? asArray(preview.documents) : [];
3650
+ const previewFiles = preview
3651
+ ? [...new Set([...asArray(preview.files), ...previewDocs.map((item) => item.targetPath).filter(Boolean)])]
3652
+ : [];
2292
3653
  return h(Modal, {
2293
3654
  title: '回写用例文档',
2294
- desc: '整个批次结束后只写一次。Markdown 用例插入结果块与截图;xlsx 生成执行结果副本,不覆盖原文档。',
3655
+ desc: '整个批次结束后只写一次。Markdown 用例插入结果块与截图;xlsx 生成执行结果副本;CSV 写入生成的 Markdown 镜像。',
2295
3656
  onClose: props.onClose,
2296
3657
  wide: false,
2297
3658
  footer: h(React.Fragment, null,
@@ -2325,12 +3686,29 @@ window.__ModuleLoader__.load({
2325
3686
  h('span', { className: 'studio-kv-key' }, '插入 / 替换'),
2326
3687
  h('span', { className: 'studio-kv-val' }, (preview.markdown?.inserted || 0) + ' / ' + (preview.markdown?.replaced || 0)),
2327
3688
  h('span', { className: 'studio-kv-key' }, 'xlsx'),
2328
- h('span', { className: 'studio-kv-val' }, preview.xlsx?.path || (preview.xlsx?.written ? '生成执行结果副本' : '无'))
3689
+ h('span', { className: 'studio-kv-val' }, preview.xlsx?.path
3690
+ || (previewDocs.some((item) => item.kind === 'xlsx' && !item.error) ? '按文档生成执行结果副本' : '无'))
2329
3691
  ),
2330
- asArray(preview.files).length ? h('div', null,
3692
+ previewDocs.length ? h('div', null,
3693
+ h('div', { className: 'studio-nl-label' }, '按文档回写'),
3694
+ h('div', { className: 'studio-nl-list', style: { paddingLeft: 0 } },
3695
+ previewDocs.slice(0, 12).map((item, index) => h('div', {
3696
+ key: item.id || index,
3697
+ className: 'studio-code',
3698
+ style: { marginBottom: 4, display: 'block' },
3699
+ },
3700
+ (item.name || item.id || '')
3701
+ + ' · ' + docKindLabel(item.kind)
3702
+ + ' · ' + (item.results || 0) + ' 条'
3703
+ + (item.targetPath ? ' → ' + item.targetPath : '')
3704
+ + (item.error ? ' · 失败:' + (item.error.message || item.error.code || '') : '')
3705
+ ))
3706
+ )
3707
+ ) : null,
3708
+ previewFiles.length ? h('div', null,
2331
3709
  h('div', { className: 'studio-nl-label' }, '将修改'),
2332
3710
  h('div', { className: 'studio-nl-list', style: { paddingLeft: 0 } },
2333
- preview.files.slice(0, 12).map((file, index) => h('div', { key: index, className: 'studio-code', style: { marginBottom: 4, display: 'block' } }, file))
3711
+ previewFiles.slice(0, 12).map((file, index) => h('div', { key: index, className: 'studio-code', style: { marginBottom: 4, display: 'block' } }, file))
2334
3712
  )
2335
3713
  ) : null
2336
3714
  ) : null
@@ -2342,8 +3720,9 @@ window.__ModuleLoader__.load({
2342
3720
  const summary = summaryPieces(run.note || run.review?.summary || '')[0];
2343
3721
  const evidenceCount = asArray(run.evidence).length;
2344
3722
  const open = () => props.onClick();
3723
+ const live = run.status === 'running' || run.queue?.state === 'running' || run.status === 'preparing';
2345
3724
  return h('div', {
2346
- className: 'studio-result-row',
3725
+ className: cx('studio-result-row', live ? 'is-live' : '', props.selected ? 'is-selected' : ''),
2347
3726
  role: 'button',
2348
3727
  tabIndex: 0,
2349
3728
  onClick: open,
@@ -2354,9 +3733,15 @@ window.__ModuleLoader__.load({
2354
3733
  open();
2355
3734
  },
2356
3735
  },
3736
+ h(SelectCheckbox, {
3737
+ checked: props.selected,
3738
+ label: '选择执行实例',
3739
+ onChange: () => props.onToggleSelection(run.caseId),
3740
+ }),
2357
3741
  h('div', { className: 'studio-result-main' },
2358
3742
  h('div', { className: 'studio-result-title' }, run.title || run.caseId),
2359
3743
  h('div', { className: 'studio-run-meta' },
3744
+ props.seq ? h('span', { className: 'studio-case-seq', title: '批次内序号' }, '#' + props.seq) : null,
2360
3745
  h('span', null, run.caseId),
2361
3746
  h(ModeBadge, { mode: run.mode }),
2362
3747
  run.durationMs ? h('span', null, formatDuration(run.durationMs)) : null,
@@ -2389,6 +3774,21 @@ window.__ModuleLoader__.load({
2389
3774
  const startupFailure = Boolean(run.technicalError || agentLive?.error)
2390
3775
  && !steps.length && !agentLive?.active && !agentSteps.length;
2391
3776
  const technicalError = run.technicalError || agentLive?.error || '';
3777
+ const [fetchedDefinition, setFetchedDefinition] = useState(null);
3778
+ useEffect(() => {
3779
+ if (props.definition || !props.project) return undefined;
3780
+ let cancelled = false;
3781
+ setFetchedDefinition(null);
3782
+ api('/case', { project: props.project, query: { id: run.caseId } })
3783
+ .then((payload) => {
3784
+ if (!cancelled) setFetchedDefinition(payload?.studio || payload?.case || null);
3785
+ })
3786
+ .catch(() => {
3787
+ if (!cancelled) setFetchedDefinition(null);
3788
+ });
3789
+ return () => { cancelled = true; };
3790
+ }, [run.caseId, props.definition, props.project]);
3791
+ const definition = props.definition || fetchedDefinition;
2392
3792
  return h(Drawer, {
2393
3793
  title: run.title || run.caseId,
2394
3794
  desc: [run.caseId, statusLabel(run.status), queue ? queue.label + (queue.hint ? ' · ' + queue.hint : '') : '', run.durationMs ? formatDuration(run.durationMs) : ''].filter(Boolean).join(' · '),
@@ -2400,6 +3800,13 @@ window.__ModuleLoader__.load({
2400
3800
  ),
2401
3801
  },
2402
3802
  h('div', { className: 'studio-nl' },
3803
+ definition
3804
+ ? h('div', { className: 'studio-nl-block' },
3805
+ h('div', { className: 'studio-nl-label' }, '用例定义'),
3806
+ definition.remark ? h('div', { className: 'studio-note', style: { marginBottom: 8 } }, definition.remark) : null,
3807
+ h(CaseDefinition, { nl: definition.nl, grid: true })
3808
+ )
3809
+ : null,
2403
3810
  run.live?.wsUrl && run.live?.active !== false ? h('div', { className: 'studio-card', style: { padding: 10 } },
2404
3811
  h('div', { className: 'studio-row-title', style: { marginBottom: 8 } }, '实时镜像'),
2405
3812
  h(LiveStream, { stream: run.live, title: '实时镜像' })
@@ -2500,10 +3907,58 @@ window.__ModuleLoader__.load({
2500
3907
  const [writebackOpen, setWritebackOpen] = useState(false);
2501
3908
  const [exportOpen, setExportOpen] = useState(false);
2502
3909
  const [liveFocus, setLiveFocus] = useState(null);
2503
- const stages = batchStageList(batch);
2504
- const percent = batchPercent(batch);
2505
- const summary = batch.summary || {};
2506
- const cases = sortRunsForDisplay(batch.cases);
3910
+ const [runFilter, setRunFilter] = useState('all');
3911
+ const [runQuery, setRunQuery] = useState('');
3912
+ const [runSort, setRunSort] = useState('active');
3913
+ const [runSortDir, setRunSortDir] = useState('asc');
3914
+ const [selectedRunIds, setSelectedRunIds] = useState([]);
3915
+ const [bulkBusy, setBulkBusy] = useState('');
3916
+ const [resuming, setResuming] = useState(false);
3917
+ const progress = batchProgress(batch);
3918
+ const rawCases = asArray(batch.cases);
3919
+ const cases = useMemo(() => sortRunsForDisplay(rawCases), [rawCases]);
3920
+ const seqByCase = useMemo(() => new Map(rawCases.map((run, index) => [String(run.caseId), index + 1])), [rawCases]);
3921
+ const runFilterDefs = [
3922
+ { id: 'all', label: '全部', match: () => true },
3923
+ { id: 'live', label: '进行中', match: runIsActive },
3924
+ { id: 'passed', label: '通过', match: (run) => run.status === 'passed' || run.status === 'partial' },
3925
+ { id: 'failed', label: '失败', match: (run) => run.status === 'failed' },
3926
+ { id: 'blocked', label: '阻塞', match: (run) => run.status === 'blocked' },
3927
+ { id: 'rest', label: '未执行', match: (run) => ['untested', 'skipped', 'stopped'].includes(run.status) },
3928
+ ];
3929
+ const runCounts = {};
3930
+ for (const def of runFilterDefs) runCounts[def.id] = def.id === 'all' ? cases.length : cases.filter(def.match).length;
3931
+ const activeFilter = runFilterDefs.find((def) => def.id === runFilter) || runFilterDefs[0];
3932
+ const query = runQuery.trim().toLowerCase();
3933
+ const filteredCases = cases.filter((run) => activeFilter.match(run) && runMatchesQuery(run, query));
3934
+ const sequenceOf = (run) => seqByCase.get(String(run.caseId)) || 0;
3935
+ const sortValue = (run) => {
3936
+ if (runSort === 'seq') return sequenceOf(run);
3937
+ if (runSort === 'started') return run.startedAt ? new Date(run.startedAt).getTime() : 0;
3938
+ return Number(run.durationMs) || 0;
3939
+ };
3940
+ const visibleCases = runSort === 'active'
3941
+ ? filteredCases
3942
+ : filteredCases.slice().sort((a, b) => {
3943
+ const direction = runSortDir === 'asc' ? 1 : -1;
3944
+ return (sortValue(a) - sortValue(b)) * direction || sequenceOf(a) - sequenceOf(b);
3945
+ });
3946
+ const selectedSet = new Set(selectedRunIds.map(String));
3947
+ const selectedRuns = cases.filter((run) => selectedSet.has(String(run.caseId)));
3948
+ const allVisibleSelected = visibleCases.length > 0 && visibleCases.every((run) => selectedSet.has(String(run.caseId)));
3949
+ const someVisibleSelected = visibleCases.some((run) => selectedSet.has(String(run.caseId)));
3950
+ const toggleRunSelection = (id) => setSelectedRunIds((current) => (
3951
+ current.map(String).includes(String(id))
3952
+ ? current.filter((item) => String(item) !== String(id))
3953
+ : [...current.map(String), String(id)]
3954
+ ));
3955
+ const toggleAllVisible = (checked) => {
3956
+ if (!checked) {
3957
+ setSelectedRunIds([]);
3958
+ return;
3959
+ }
3960
+ setSelectedRunIds(visibleCases.map((run) => String(run.caseId)));
3961
+ };
2507
3962
  const stoppable = ['running', 'preparing', 'queued'].includes(String(batch.status || ''));
2508
3963
  const deletable = !['running', 'queued', 'preparing'].includes(String(batch.status || ''));
2509
3964
  const distillStage = String(batch.stages?.distill?.status || '');
@@ -2517,6 +3972,42 @@ window.__ModuleLoader__.load({
2517
3972
  if (payload?.batch) applyBatch(payload.batch);
2518
3973
  else await refreshNow();
2519
3974
  };
3975
+ const bulkAction = async (kind) => {
3976
+ if (!selectedRuns.length || bulkBusy) return;
3977
+ const targets = selectedRuns.filter((run) => (kind === 'stop' ? runIsActive(run) : !runIsActive(run)));
3978
+ if (!targets.length) {
3979
+ props.onToast?.({
3980
+ kind: 'warn',
3981
+ text: kind === 'stop' ? '所选执行实例都不在排队或执行中' : '所选执行实例都在排队或执行中,暂时不能重新执行',
3982
+ });
3983
+ return;
3984
+ }
3985
+ const handler = kind === 'stop' ? props.onStopCase : props.onRequeueCase;
3986
+ if (!handler) return;
3987
+ setBulkBusy(kind);
3988
+ let done = 0;
3989
+ for (const run of targets) {
3990
+ const payload = await handler(batch, run.caseId, run, { silent: true });
3991
+ if (payload) done += 1;
3992
+ }
3993
+ setBulkBusy('');
3994
+ setSelectedRunIds([]);
3995
+ await refreshNow();
3996
+ props.onToast?.({
3997
+ kind: done === targets.length ? 'success' : done ? 'warn' : 'error',
3998
+ text: (kind === 'stop' ? '已请求停止 ' : '已重新排队 ') + done + ' / ' + targets.length + ' 条',
3999
+ });
4000
+ };
4001
+ const resumeBatchNow = async () => {
4002
+ if (resuming || !props.onResumeBatch) return;
4003
+ setResuming(true);
4004
+ try {
4005
+ const payload = await props.onResumeBatch(batch.id);
4006
+ if (payload?.batch) applyBatch(payload.batch);
4007
+ } finally {
4008
+ setResuming(false);
4009
+ }
4010
+ };
2520
4011
  useEffect(() => {
2521
4012
  setCaseId('');
2522
4013
  setDeleteOpen(false);
@@ -2524,6 +4015,12 @@ window.__ModuleLoader__.load({
2524
4015
  setDistillError('');
2525
4016
  setLogOpen(false);
2526
4017
  setArchiveOpen(false);
4018
+ setRunFilter('all');
4019
+ setRunQuery('');
4020
+ setRunSort('active');
4021
+ setRunSortDir('asc');
4022
+ setSelectedRunIds([]);
4023
+ setBulkBusy('');
2527
4024
  }, [batch.id]);
2528
4025
  const distillBatchNow = async () => {
2529
4026
  setDistilling(true);
@@ -2552,89 +4049,151 @@ window.__ModuleLoader__.load({
2552
4049
  }
2553
4050
  };
2554
4051
  return h('div', null,
2555
- h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12 } },
4052
+ h('div', { className: 'studio-backbar' },
2556
4053
  h('button', { className: 'studio-btn studio-btn-sm', onClick: props.onBack }, h(Icon, { name: 'chevron', size: 12, className: 'studio-rotate-180' }), '返回批次'),
2557
- h('span', { className: 'studio-row-sub' }, batch.id)
2558
- ),
2559
- h('div', { className: 'studio-card' },
2560
- h('div', { style: { display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: 14, flexWrap: 'wrap' } },
2561
- h('div', { style: { minWidth: 0 } },
2562
- h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
2563
- h('h1', { className: 'studio-page-title', style: { fontSize: 18 } }, batch.name || batch.id),
2564
- h(StatusBadge, { status: batchActionStatus(batch) }),
2565
- batch.options?.allowWrites ? h(Badge, { tone: 'warn' }, '写操作已放行') : h(Badge, { tone: 'muted' }, '只读')
2566
- ),
2567
- h('div', { className: 'studio-run-meta', style: { marginTop: 7 } },
2568
- h('span', null, '创建 ' + formatTime(batch.createdAt)),
2569
- batch.startedAt ? h('span', null, '开始 ' + formatTime(batch.startedAt)) : null,
2570
- batch.endedAt ? h('span', null, '结束 ' + formatTime(batch.endedAt)) : null,
2571
- h('span', null, '并发 ' + (batch.options?.concurrency || Math.max(batch.options?.workers || 0, batch.options?.agentWorkers || 0) || '-')),
2572
- batch.options?.forceCreateData ? h('span', null, '强制造数') : null
2573
- )
2574
- ),
2575
- h('div', { className: 'studio-page-actions' },
2576
- stoppable ? h('button', { className: 'studio-btn studio-btn-danger', onClick: async () => { await props.onStop(batch.id); refreshNow(); } }, h(Icon, { name: 'stop', size: 13 }), '停止批次') : null,
2577
- !stoppable && (batch.status === 'done' || batch.status === 'stopped') ? h('button', { className: 'studio-btn studio-btn-primary', onClick: () => setWritebackOpen(true) }, h(Icon, { name: 'file', size: 13 }), batch.writeback ? '再次回写' : '回写用例文档') : null,
2578
- h('button', { className: 'studio-btn', onClick: () => setExportOpen(true), disabled: !cases.length, title: cases.length ? '导出本批次测试结果 xlsx' : '批次还没有用例结果' }, h(Icon, { name: 'file', size: 13 }), '导出结果'),
2579
- needsDistill ? h('button', {
2580
- className: 'studio-btn studio-btn-primary',
2581
- disabled: distilling,
2582
- title: '重新学习本批页面与流程并写入中心知识库',
2583
- onClick: distillBatchNow,
2584
- }, distilling ? h(Spinner) : h(Icon, { name: 'knowledge', size: 13 }), distilling ? '沉淀中…' : '重新沉淀') : null,
2585
- h('button', {
2586
- className: 'studio-btn studio-btn-danger',
2587
- disabled: !deletable,
2588
- title: deletable ? '删除批次目录与该批次的结果记录' : '批次正在执行,请先停止批次',
2589
- onClick: () => { setDeleteError(''); setDeleteOpen(true); },
2590
- }, h(Icon, { name: 'trash', size: 13 }), '删除批次'),
2591
- batch.resultDoc ? h('span', { className: 'studio-code', style: { maxWidth: 260, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }, title: batch.resultDoc }, shortPath(batch.resultDoc, 36)) : null
2592
- )
2593
- ),
2594
- h('div', { style: { marginTop: 16 } }, h(Progress, { percent, label: percent + '%' })),
2595
- h('div', { className: 'studio-stepper', style: { marginTop: 18 } },
2596
- stages.map((stage) => h('div', { key: stage.id, className: cx('studio-step', 'is-' + stage.status) },
2597
- h('div', { className: 'studio-step-rail' },
2598
- h('div', { className: 'studio-step-dot' }, stage.status === 'done' ? h(Icon, { name: 'check', size: 11 }) : stage.status === 'running' ? h(Spinner, { className: 'studio-step-spinner' }) : null),
2599
- stage.id !== 'distill' ? h('div', { className: 'studio-step-line' }) : null
2600
- ),
2601
- h('div', { className: 'studio-step-body' },
2602
- h('div', { className: 'studio-step-title' }, stage.label),
2603
- h('div', { className: 'studio-step-meta' }, stage.status === 'running' ? '进行中…' : stage.meta || statusLabel(stage.status))
2604
- )
2605
- ))
2606
- )
2607
- ),
2608
-
2609
- h('div', { className: 'studio-stat-grid', style: { marginTop: 14 } },
2610
- h(Stat, { label: '通过', value: summary.passed || 0, tone: 'success', hint: '含部分通过 ' + (summary.partial || 0) }),
2611
- h(Stat, { label: '失败', value: summary.failed || 0, tone: 'danger', hint: '失败步骤保留截图' }),
2612
- h(Stat, { label: '阻塞', value: summary.blocked || 0, tone: 'warn', hint: '前置数据或环境限制' }),
2613
- h(Stat, { label: '未开始', value: summary.queued || summary.untested || 0, hint: summary.stopped ? '已停止 ' + summary.stopped + ' · 排队中 ' + (summary.queued || 0) : '排队中的用例' })
4054
+ h('span', { className: 'studio-code' }, batch.id)
2614
4055
  ),
4056
+ h(ExecutionBanner, {
4057
+ batch,
4058
+ progress,
4059
+ actions: [
4060
+ stoppable ? h('button', { key: 'stop', className: 'studio-btn studio-btn-danger', onClick: async () => { await props.onStop(batch.id); refreshNow(); } }, h(Icon, { name: 'stop', size: 13 }), '停止批次') : null,
4061
+ !stoppable && batch.status === 'stopped' ? h('button', {
4062
+ key: 'resume',
4063
+ className: 'studio-btn studio-btn-primary',
4064
+ disabled: resuming,
4065
+ title: '把未完成的用例重新排入本批次,已判定的结果保留',
4066
+ onClick: resumeBatchNow,
4067
+ }, resuming ? h(Spinner) : h(Icon, { name: 'play', size: 13 }), resuming ? '继续中…' : '继续执行') : null,
4068
+ !stoppable && (batch.status === 'done' || batch.status === 'stopped') ? h('button', { key: 'writeback', className: 'studio-btn studio-btn-primary', onClick: () => setWritebackOpen(true) }, h(Icon, { name: 'file', size: 13 }), batch.writeback ? '再次回写' : '回写用例文档') : null,
4069
+ needsDistill ? h('button', {
4070
+ key: 'distill',
4071
+ className: 'studio-btn studio-btn-primary',
4072
+ disabled: distilling,
4073
+ title: '重新学习本批页面与流程并写入中心知识库',
4074
+ onClick: distillBatchNow,
4075
+ }, distilling ? h(Spinner) : h(Icon, { name: 'knowledge', size: 13 }), distilling ? '沉淀中…' : '重新沉淀') : null,
4076
+ h(MenuButton, { key: 'more', label: '更多', icon: 'more' }, [
4077
+ h('button', { key: 'export', className: 'studio-btn', disabled: !cases.length, title: cases.length ? '导出本批次测试结果 xlsx' : '批次还没有用例结果', onClick: () => setExportOpen(true) }, h(Icon, { name: 'file', size: 13 }), '导出结果'),
4078
+ h('button', { key: 'log', className: 'studio-btn', onClick: () => setLogOpen(true) }, h(Icon, { name: 'terminal', size: 13 }), '执行日志'),
4079
+ h('button', { key: 'archive', className: 'studio-btn', onClick: () => setArchiveOpen(true) }, h(Icon, { name: 'knowledge', size: 13 }), '归档与沉淀'),
4080
+ h('button', { key: 'delete', className: 'studio-btn studio-btn-danger', disabled: !deletable, title: deletable ? '删除批次目录与该批次的结果记录' : '批次正在执行,请先停止批次', onClick: () => { setDeleteError(''); setDeleteOpen(true); } }, h(Icon, { name: 'trash', size: 13 }), '删除批次'),
4081
+ ]),
4082
+ ],
4083
+ }),
2615
4084
 
4085
+ distilling ? h('div', { style: { marginTop: 12 } }, h(OperationProgress, {
4086
+ label: '正在重新沉淀本批知识',
4087
+ detail: '重新学习本批页面与流程,合并后写入中心知识库。完成后列表会自动刷新。',
4088
+ steps: [{ label: '页面学习', status: 'active' }, { label: '流程知识合并' }, { label: '写入中心知识库' }],
4089
+ })) : null,
2616
4090
  distillError ? h('div', { className: 'studio-note tone-danger', style: { marginTop: 10 } }, '重新沉淀失败:' + distillError) : null,
2617
4091
 
2618
- h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, margin: '16px 0 9px', flexWrap: 'wrap' } },
2619
- h('div', { className: 'studio-row-title' }, '用例结果'),
2620
- h('span', { className: 'studio-row-sub' }, cases.length + ' 条 · 点击用例查看结果、步骤、证据与知识沉淀'),
2621
- h('div', { style: { marginLeft: 'auto', display: 'flex', gap: 6 } },
4092
+ h('div', { className: 'studio-meta-strip' },
4093
+ h('span', null, '创建 ' + formatTime(batch.createdAt)),
4094
+ batch.startedAt ? h('span', null, '开始 ' + formatTime(batch.startedAt)) : null,
4095
+ batch.endedAt ? h('span', null, '结束 ' + formatTime(batch.endedAt)) : null,
4096
+ h('span', null, '并发 ' + (batch.options?.concurrency || Math.max(batch.options?.workers || 0, batch.options?.agentWorkers || 0) || '-')),
4097
+ batch.options?.forceCreateData ? h('span', null, '强制造数') : null,
4098
+ batch.options?.allowWrites ? h('span', { className: 'tone-warn' }, '写操作已放行') : h('span', null, '只读'),
4099
+ batch.resultDoc ? h('span', null, '结果文档 ', h('span', { className: 'studio-code', title: batch.resultDoc }, shortPath(batch.resultDoc, 36))) : null
4100
+ ),
4101
+
4102
+ h('div', { className: 'studio-results-head' },
4103
+ h('div', null,
4104
+ h('div', { className: 'studio-row-title' }, '用例结果'),
4105
+ h('div', { className: 'studio-row-sub' }, cases.length + ' 条 · 点击用例查看结果、步骤、证据与知识沉淀')
4106
+ ),
4107
+ h('div', { className: 'studio-results-actions' },
2622
4108
  h('button', { className: 'studio-btn studio-btn-sm', onClick: () => setLogOpen(true) }, h(Icon, { name: 'file', size: 12 }), '执行日志'),
2623
4109
  h('button', { className: 'studio-btn studio-btn-sm', onClick: () => setArchiveOpen(true) }, h(Icon, { name: 'knowledge', size: 12 }), '归档与沉淀')
2624
4110
  )
2625
4111
  ),
4112
+ h('div', { className: 'studio-toolbar' },
4113
+ h('div', { className: 'studio-search' },
4114
+ h('span', { className: 'studio-search-icon' }, h(Icon, { name: 'search', size: 14 })),
4115
+ h('input', {
4116
+ className: 'studio-input',
4117
+ placeholder: '搜索用例编号、标题、执行结果…',
4118
+ value: runQuery,
4119
+ onChange: (event) => setRunQuery(event.target.value),
4120
+ })
4121
+ ),
4122
+ h('div', { className: 'studio-filter-bar' },
4123
+ runFilterDefs.map((def) => h('button', {
4124
+ key: def.id,
4125
+ className: cx('studio-chip', runFilter === def.id ? 'is-active' : ''),
4126
+ onClick: () => setRunFilter(def.id),
4127
+ }, def.label, h('span', { className: 'studio-chip-count' }, runCounts[def.id])))
4128
+ ),
4129
+ h('div', { className: 'studio-run-tools' },
4130
+ h('span', { className: 'studio-row-sub' }, '排序'),
4131
+ h('select', {
4132
+ className: 'studio-select',
4133
+ value: runSort,
4134
+ onChange: (event) => {
4135
+ const key = event.target.value;
4136
+ setRunSort(key);
4137
+ setRunSortDir(key === 'started' || key === 'duration' ? 'desc' : 'asc');
4138
+ },
4139
+ }, RUN_SORTS.map((item) => h('option', { key: item.id, value: item.id }, item.label))),
4140
+ h('button', {
4141
+ className: 'studio-btn studio-btn-sm',
4142
+ disabled: runSort === 'active',
4143
+ title: runSortDir === 'asc' ? '当前升序,点击切换为降序' : '当前降序,点击切换为升序',
4144
+ onClick: () => setRunSortDir((value) => (value === 'asc' ? 'desc' : 'asc')),
4145
+ }, runSortDir === 'asc' ? '↑ 升序' : '↓ 降序')
4146
+ )
4147
+ ),
4148
+ h('div', { className: 'studio-list-head' },
4149
+ h('label', { className: 'studio-check' },
4150
+ h('input', {
4151
+ type: 'checkbox',
4152
+ checked: allVisibleSelected,
4153
+ disabled: !visibleCases.length,
4154
+ onChange: (event) => toggleAllVisible(event.target.checked),
4155
+ }),
4156
+ '全选当前结果',
4157
+ someVisibleSelected && !allVisibleSelected ? h('span', { className: 'studio-row-sub' }, '部分已选') : null
4158
+ ),
4159
+ h('span', { className: 'studio-row-sub' },
4160
+ (filteredCases.length === cases.length ? '' : filteredCases.length + ' / ') + cases.length + ' 条'
4161
+ + (selectedRuns.length ? ' · 已选 ' + selectedRuns.length : '')
4162
+ )
4163
+ ),
4164
+ selectedRuns.length ? h('div', { className: 'studio-bulk-bar' },
4165
+ h('span', null, '已选 ' + selectedRuns.length + ' 条执行实例'),
4166
+ h('button', { className: 'studio-btn studio-btn-sm', disabled: Boolean(bulkBusy), onClick: () => bulkAction('stop') },
4167
+ bulkBusy === 'stop' ? h(Spinner) : h(Icon, { name: 'stop', size: 12 }), '停止所选'),
4168
+ h('button', { className: 'studio-btn studio-btn-sm', disabled: Boolean(bulkBusy), onClick: () => bulkAction('requeue') },
4169
+ bulkBusy === 'requeue' ? h(Spinner) : h(Icon, { name: 'play', size: 12 }), '重新执行所选'),
4170
+ h('button', { className: 'studio-btn studio-btn-sm', disabled: Boolean(bulkBusy), onClick: () => setSelectedRunIds([]) }, '清除选择')
4171
+ ) : null,
2626
4172
  cases.length
2627
- ? h('div', { className: 'studio-result-list' }, cases.map((run) => h(RunListRow, {
2628
- key: run.caseId,
2629
- run,
2630
- onClick: () => setCaseId(String(run.caseId)),
2631
- onAction: runAction,
2632
- })))
4173
+ ? h(VirtualList, {
4174
+ items: visibleCases,
4175
+ rowHeight: 82,
4176
+ className: 'studio-result-scroll',
4177
+ keyFor: (run) => String(run.caseId),
4178
+ resetKey: runFilter + '|' + runQuery + '|' + runSort + '|' + runSortDir,
4179
+ ariaLabel: '用例结果',
4180
+ empty: h('div', { className: 'studio-empty-wrap' }, h(Empty, { icon: 'search', title: '当前筛选没有结果', desc: '切换到其他状态或清空搜索查看该批次的用例。' })),
4181
+ renderRow: (run) => h(RunListRow, {
4182
+ run,
4183
+ seq: seqByCase.get(String(run.caseId)),
4184
+ selected: selectedSet.has(String(run.caseId)),
4185
+ onToggleSelection: toggleRunSelection,
4186
+ onClick: () => setCaseId(String(run.caseId)),
4187
+ onAction: runAction,
4188
+ }),
4189
+ })
2633
4190
  : h(Empty, { icon: 'batch', title: '批次还没有用例结果', desc: '执行开始后,这里会按用例实时出现状态、说明与截图。' }),
2634
4191
  caseRun ? h(BatchCaseDrawer, {
4192
+ key: caseRun.caseId,
2635
4193
  run: caseRun,
2636
4194
  batch,
2637
4195
  batchId: batch.id,
4196
+ definition: props.caseById?.get(String(caseRun.caseId)) || null,
2638
4197
  project: props.project,
2639
4198
  hasBaseUrl: props.hasBaseUrl,
2640
4199
  onShot: props.onShot,
@@ -2747,6 +4306,8 @@ window.__ModuleLoader__.load({
2747
4306
  const [loading, setLoading] = useState(false);
2748
4307
  const [error, setError] = useState('');
2749
4308
  const selected = props.selectedBatchId;
4309
+ // 批次抽屉的用例定义直接取首页快照;超过快照上限时抽屉再按 id 补取。
4310
+ const caseById = useMemo(() => new Map(asArray(snapshot.cases).map((item) => [String(item.tcId), item])), [snapshot.cases]);
2750
4311
  useEffect(() => {
2751
4312
  if (!selected) { setDetail(null); setError(''); return undefined; }
2752
4313
  let cancelled = false;
@@ -2765,8 +4326,10 @@ window.__ModuleLoader__.load({
2765
4326
  batch: detail,
2766
4327
  project: snapshot.project,
2767
4328
  hasBaseUrl: Boolean(snapshot.config?.baseUrl),
4329
+ caseById,
2768
4330
  onBack: () => props.onSelectBatch(''),
2769
4331
  onStop: props.onStopBatch,
4332
+ onResumeBatch: props.onResumeBatch,
2770
4333
  onWritebackDone: props.onWritebackDone,
2771
4334
  onShot: props.onShot,
2772
4335
  onOpenBatch: props.onOpenBatch,
@@ -2783,16 +4346,23 @@ window.__ModuleLoader__.load({
2783
4346
  );
2784
4347
  }
2785
4348
  const batches = asArray(snapshot.batches);
4349
+ const activeBatch = batches.find((batch) => ['running', 'preparing', 'queued'].includes(String(batch.status || ''))) || null;
4350
+ const finished = batches.filter((batch) => batch.summary?.failed).length;
2786
4351
  return h('div', null,
2787
- h('div', { className: 'studio-page-head' },
2788
- h('div', null,
2789
- h('h1', { className: 'studio-page-title' }, '批次'),
2790
- h('p', { className: 'studio-page-desc' }, '每个批次是一份可审计的执行记录:并发跑 flow 与 Agent,统一归档,最后只回写一次。')
2791
- ),
2792
- h('div', { className: 'studio-page-actions' },
2793
- h('button', { className: 'studio-btn studio-btn-primary', onClick: () => props.onNewBatch([]) }, h(Icon, { name: 'plus', size: 14 }), '新建批次')
2794
- )
2795
- ),
4352
+ h(PageHeader, {
4353
+ kicker: '执行记录',
4354
+ icon: 'batch',
4355
+ title: '批次',
4356
+ desc: '每个批次是一份可审计的执行记录:并发跑 flow 与 Agent,统一归档,最后只回写一次。',
4357
+ meta: [
4358
+ h('span', { key: 'total', className: 'studio-badge tone-muted' }, batches.length + ' 个批次'),
4359
+ activeBatch ? h(StatusBadge, { key: 'live', status: 'running', label: '1 个批次执行中' }) : null,
4360
+ finished ? h('span', { key: 'failed', className: 'studio-badge tone-danger' }, finished + ' 个批次有失败用例') : null,
4361
+ ],
4362
+ actions: [
4363
+ h('button', { key: 'new', className: 'studio-btn studio-btn-primary', onClick: () => props.onNewBatch([]) }, h(Icon, { name: 'plus', size: 14 }), '新建批次'),
4364
+ ],
4365
+ }),
2796
4366
  batches.length ? h('div', { className: 'studio-list' },
2797
4367
  batches.map((batch) => h(BatchRow, { key: batch.id, batch, onOpen: props.onSelectBatch }))
2798
4368
  ) : h(Empty, { icon: 'batch', title: '还没有批次', desc: '新建批次后,执行、证据、归档与回写都在这里。', action: h('button', { className: 'studio-btn studio-btn-primary', onClick: () => props.onNewBatch([]), style: { marginTop: 12 } }, '新建批次') })
@@ -2812,15 +4382,20 @@ window.__ModuleLoader__.load({
2812
4382
  });
2813
4383
  const flowCaseIds = [...new Set(flows.flatMap((flow) => asArray(flow.cases)).filter(Boolean))];
2814
4384
  return h('div', null,
2815
- h('div', { className: 'studio-page-head' },
2816
- h('div', null,
2817
- h('h1', { className: 'studio-page-title' }, '流程'),
2818
- h('p', { className: 'studio-page-desc' }, '通过 Agent 执行并判为通过的自然语言轨迹,会自动去值化沉淀为 flow;下一次同用例优先走 flow,更快、更稳定。')
2819
- ),
2820
- h('div', { className: 'studio-page-actions' },
2821
- h('button', { className: 'studio-btn', onClick: () => props.onNewBatch(flowCaseIds), disabled: !flowCaseIds.length }, h(Icon, { name: 'play', size: 14 }), '用流程跑批次' + (flowCaseIds.length ? '(' + flowCaseIds.length + ' 条用例)' : ''))
2822
- )
2823
- ),
4385
+ h(PageHeader, {
4386
+ kicker: '执行路径',
4387
+ icon: 'flow',
4388
+ title: '流程',
4389
+ desc: '通过 Agent 执行并判为通过的自然语言轨迹,会自动去值化沉淀为 flow;下一次同用例优先走 flow,更快、更稳定。',
4390
+ meta: [
4391
+ h('span', { key: 'total', className: 'studio-badge tone-muted' }, flows.length + ' 个流程'),
4392
+ h('span', { key: 'cases', className: 'studio-badge tone-muted' }, flowCaseIds.length + ' 条关联用例'),
4393
+ flows.some((flow) => flow.generated) ? h('span', { key: 'gen', className: 'studio-badge tone-business' }, flows.filter((flow) => flow.generated).length + ' 个 Agent 沉淀') : null,
4394
+ ],
4395
+ actions: [
4396
+ h('button', { key: 'run', className: 'studio-btn studio-btn-primary', onClick: () => props.onNewBatch(flowCaseIds), disabled: !flowCaseIds.length }, h(Icon, { name: 'play', size: 14 }), '用流程跑批次' + (flowCaseIds.length ? '(' + flowCaseIds.length + ' 条用例)' : '')),
4397
+ ],
4398
+ }),
2824
4399
  h('div', { className: 'studio-toolbar' },
2825
4400
  h('div', { className: 'studio-search' },
2826
4401
  h('span', { className: 'studio-search-icon' }, h(Icon, { name: 'search', size: 14 })),
@@ -3224,6 +4799,86 @@ window.__ModuleLoader__.load({
3224
4799
  );
3225
4800
  }
3226
4801
 
4802
+ const PIPELINE_PHASE_LABELS = {
4803
+ idle: '空闲',
4804
+ extracting: '提取中',
4805
+ indexing: '索引中',
4806
+ backoff: '重试等待',
4807
+ stopped: '已停用',
4808
+ };
4809
+
4810
+ function CentralPipelineCard(props) {
4811
+ const pipeline = props.pipeline;
4812
+ const counts = pipeline && pipeline.counts && typeof pipeline.counts === 'object' ? pipeline.counts : null;
4813
+ const phase = pipeline?.phase || 'idle';
4814
+ const phaseTone = pipeline?.last_error
4815
+ ? 'danger'
4816
+ : phase === 'backoff'
4817
+ ? 'warn'
4818
+ : phase === 'stopped'
4819
+ ? 'warn'
4820
+ : pipeline?.manual
4821
+ ? 'link'
4822
+ : pipeline?.auto === false
4823
+ ? 'muted'
4824
+ : 'success';
4825
+ const sources = counts ? Number(counts.sources) || 0 : 0;
4826
+ const extractPending = counts ? Number(counts.extract_pending) || 0 : 0;
4827
+ const knowledge = counts ? Number(counts.knowledge) || 0 : 0;
4828
+ const indexPending = counts ? Number(counts.index_pending) || 0 : 0;
4829
+ const extracted = Math.max(0, sources - extractPending);
4830
+ const indexed = Math.max(0, knowledge - indexPending);
4831
+ const extractPercent = sources ? Math.round((extracted / sources) * 100) : (extractPending ? 0 : 100);
4832
+ const indexPercent = knowledge ? Math.round((indexed / knowledge) * 100) : (indexPending ? 0 : 100);
4833
+ const lastExtract = pipeline?.last_extract || null;
4834
+ const lastIndex = pipeline?.last_index || null;
4835
+ const engine = String(lastExtract?.engine || '');
4836
+ const activity = lastIndex
4837
+ ? '最近索引 ' + relativeTime(lastIndex.at) + ',本次 ' + (Number(lastIndex.indexed) || 0) + ' 条' + (Number(lastIndex.errors) ? ',错误 ' + lastIndex.errors + ' 条' : '')
4838
+ : lastExtract
4839
+ ? '最近提取 ' + relativeTime(lastExtract.at) + ',扫描 ' + (Number(lastExtract.scanned) || 0) + ' 条,保存 ' + (Number(lastExtract.stored) || 0) + ' 个分类'
4840
+ : '等待首次自动运行';
4841
+ const error = props.error || '';
4842
+ const errorNote = error
4843
+ ? h('div', { className: 'studio-note tone-' + (pipeline ? 'warn' : 'danger'), style: { marginTop: 8 } },
4844
+ pipeline ? '状态刷新失败,显示的是最后一次成功状态:' + error : '状态读取失败:' + error
4845
+ )
4846
+ : null;
4847
+ return h('div', { className: 'studio-card', style: { marginBottom: 12 } },
4848
+ h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
4849
+ h('div', { className: 'studio-row-title' }, '自动管线'),
4850
+ pipeline ? h(Badge, { tone: phaseTone }, PIPELINE_PHASE_LABELS[phase] || phase) : h(Badge, { tone: 'muted' }, props.enabled ? '连接中' : '未启用'),
4851
+ pipeline?.manual ? h('span', { className: 'studio-row-sub' }, '手动补跑') : null,
4852
+ pipeline?.auto === false ? h('span', { className: 'studio-row-sub' }, '自动已关闭') : null,
4853
+ pipeline?.updated_at ? h('span', { className: 'studio-row-sub', style: { marginLeft: 'auto' } }, '更新于 ' + relativeTime(pipeline.updated_at)) : null
4854
+ ),
4855
+ !props.enabled
4856
+ ? h('div', { className: 'studio-note', style: { marginTop: 8 } }, '中心知识库未启用,自动管线不会运行。')
4857
+ : !pipeline
4858
+ ? (errorNote || h('div', { className: 'studio-loading', style: { marginTop: 8 } }, h(Spinner), '正在读取管线状态…'))
4859
+ : h(React.Fragment, null,
4860
+ errorNote,
4861
+ counts
4862
+ ? h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(2,minmax(0,1fr))', gap: '10px 18px', marginTop: 10 } },
4863
+ h('div', null,
4864
+ h('div', { className: 'studio-row-sub' }, '知识提取 ' + extracted + ' / ' + sources),
4865
+ h(Progress, { percent: extractPercent, tone: 'business', label: extractPercent + '%' })
4866
+ ),
4867
+ h('div', null,
4868
+ h('div', { className: 'studio-row-sub' }, '语义索引 ' + indexed + ' / ' + knowledge),
4869
+ h(Progress, { percent: indexPercent, tone: 'success', label: indexPercent + '%' })
4870
+ )
4871
+ )
4872
+ : h('div', { className: 'studio-note tone-warn', style: { marginTop: 8 } }, '计数暂不可用:' + (pipeline.error || '中心库暂时不可达')),
4873
+ h('div', { className: 'studio-row-sub', style: { marginTop: 8 } }, activity),
4874
+ pipeline.last_error ? h('div', { className: 'studio-note tone-danger', style: { marginTop: 6 } }, '最近错误(' + (pipeline.last_error.phase || phase) + '):' + (pipeline.last_error.message || '未知错误') + ' · ' + relativeTime(pipeline.last_error.at)) : null,
4875
+ engine === 'heuristic' || engine === 'llm+heuristic'
4876
+ ? h('div', { className: 'studio-note tone-warn', style: { marginTop: 6 } }, '上次提取使用了规则兜底(engine=' + engine + '),LLM 不可用。')
4877
+ : null
4878
+ )
4879
+ );
4880
+ }
4881
+
3227
4882
  function CentralKnowledgePanel(props) {
3228
4883
  const central = props.central || {};
3229
4884
  const nodeCount = asArray(central.nodes).reduce((sum, item) => sum + (Number(item.count) || 0), 0);
@@ -3255,8 +4910,13 @@ window.__ModuleLoader__.load({
3255
4910
  const [extractionsLoading, setExtractionsLoading] = useState(false);
3256
4911
  const [extractBusy, setExtractBusy] = useState(false);
3257
4912
  const [semanticBusy, setSemanticBusy] = useState(false);
4913
+ const [categorizeBusy, setCategorizeBusy] = useState(false);
4914
+ const [opStartedAt, setOpStartedAt] = useState(null);
3258
4915
  const [extractResult, setExtractResult] = useState(null);
3259
4916
  const [extractError, setExtractError] = useState('');
4917
+ const [pipeline, setPipeline] = useState(null);
4918
+ const [pipelineError, setPipelineError] = useState('');
4919
+ const pipelineRevisionRef = useRef(-1);
3260
4920
  const [importMode, setImportMode] = useState('');
3261
4921
  const seqRef = useRef(0);
3262
4922
 
@@ -3269,7 +4929,6 @@ window.__ModuleLoader__.load({
3269
4929
  if (kind !== 'extract') return undefined;
3270
4930
  let cancelled = false;
3271
4931
  setExtractionsLoading(true);
3272
- setExtractError('');
3273
4932
  api('/knowledge/central/extractions', { project: props.project, query: { limit: 40 } })
3274
4933
  .then((payload) => { if (!cancelled) setExtractions(asArray(payload.items)); })
3275
4934
  .catch((err) => { if (!cancelled) setExtractError(err.message); })
@@ -3277,9 +4936,48 @@ window.__ModuleLoader__.load({
3277
4936
  return () => { cancelled = true; };
3278
4937
  }, [kind, reload, props.project]);
3279
4938
 
4939
+ useEffect(() => {
4940
+ if (!central.enabled) {
4941
+ setPipeline(null);
4942
+ setPipelineError('');
4943
+ return undefined;
4944
+ }
4945
+ let cancelled = false;
4946
+ let timer = null;
4947
+ const poll = async () => {
4948
+ try {
4949
+ const payload = await api('/knowledge/central/pipeline', {
4950
+ project: props.project,
4951
+ query: { groupId: central.groupId || '' },
4952
+ timeoutMs: 20000,
4953
+ });
4954
+ if (!cancelled) {
4955
+ setPipeline(payload);
4956
+ setPipelineError('');
4957
+ }
4958
+ } catch (err) {
4959
+ // 保留上一份状态,由卡片标明它已过期。
4960
+ if (!cancelled) setPipelineError(err?.message || '状态读取失败');
4961
+ }
4962
+ if (!cancelled) timer = setTimeout(poll, 2000);
4963
+ };
4964
+ poll();
4965
+ return () => { cancelled = true; if (timer) clearTimeout(timer); };
4966
+ }, [central.enabled, central.groupId, props.project]);
4967
+
4968
+ useEffect(() => {
4969
+ if (!pipeline) return;
4970
+ const revision = Number(pipeline.revision);
4971
+ if (!Number.isFinite(revision) || revision === pipelineRevisionRef.current) return;
4972
+ const first = pipelineRevisionRef.current < 0;
4973
+ pipelineRevisionRef.current = revision;
4974
+ if (!first && kind === 'extract') setReload((value) => value + 1);
4975
+ }, [pipeline, kind]);
4976
+
3280
4977
  const runExtract = async (force) => {
3281
4978
  if (extractBusy) return;
3282
4979
  setExtractBusy(true);
4980
+ setOpStartedAt(Date.now());
3283
4981
  setExtractError('');
3284
4982
  setExtractResult(null);
3285
4983
  try {
@@ -3295,14 +4993,16 @@ window.__ModuleLoader__.load({
3295
4993
  setExtractError(err.message);
3296
4994
  } finally {
3297
4995
  setExtractBusy(false);
4996
+ setOpStartedAt(null);
3298
4997
  }
3299
4998
  };
3300
4999
 
3301
5000
  const runSemanticIndex = async () => {
3302
5001
  if (semanticBusy) return;
3303
5002
  setSemanticBusy(true);
5003
+ setOpStartedAt(Date.now());
3304
5004
  setExtractError('');
3305
- setCategoryNote('正在把提取结果送入语义索引…');
5005
+ setCategoryNote('');
3306
5006
  try {
3307
5007
  const payload = await api('/knowledge/central/semantic-index', {
3308
5008
  method: 'POST',
@@ -3314,9 +5014,9 @@ window.__ModuleLoader__.load({
3314
5014
  setReload((value) => value + 1);
3315
5015
  } catch (err) {
3316
5016
  setExtractError(err.message);
3317
- setCategoryNote('');
3318
5017
  } finally {
3319
5018
  setSemanticBusy(false);
5019
+ setOpStartedAt(null);
3320
5020
  }
3321
5021
  };
3322
5022
 
@@ -3433,45 +5133,73 @@ window.__ModuleLoader__.load({
3433
5133
  };
3434
5134
 
3435
5135
  const organizeCategories = async () => {
5136
+ if (categorizeBusy) return;
5137
+ setCategorizeBusy(true);
5138
+ setOpStartedAt(Date.now());
3436
5139
  setActionError('');
3437
- setCategoryNote('正在整理分类…');
3438
5140
  try {
3439
5141
  const payload = await api('/knowledge/central/categories', { method: 'POST', project: props.project, body: { force: true }, timeoutMs: 300000 });
3440
5142
  setCategoryNote('分类整理完成:扫描 ' + (payload.scanned || 0) + ' 条,补标记 ' + (payload.updated || 0) + ' 条');
3441
5143
  setReload((value) => value + 1);
3442
5144
  } catch (err) {
3443
5145
  setActionError(err.message);
3444
- setCategoryNote('');
5146
+ } finally {
5147
+ setCategorizeBusy(false);
5148
+ setOpStartedAt(null);
3445
5149
  }
3446
5150
  };
3447
5151
 
3448
5152
  const emptyText = kind === 'episodes' ? '近况' : kind === 'facts' ? '事实' : '实体';
5153
+ const activeOp = extractBusy
5154
+ ? { label: '正在提取知识', detail: '读取已有知识和导入文档,按页面知识、业务流程、操作流程、注意事项、单据流转整理要点。每次处理 20 条未提取数据。', steps: [{ label: '扫描知识' }, { label: '分类提取', status: 'active' }, { label: '写入知识库' }] }
5155
+ : semanticBusy
5156
+ ? { label: '正在建立语义索引', detail: '把已提取的知识送入 Graphiti 语义索引,每次处理 5 条。', steps: [{ label: '读取提取结果' }, { label: '生成索引', status: 'active' }, { label: '写回中心库' }] }
5157
+ : categorizeBusy
5158
+ ? { label: '正在整理分类', detail: '扫描中心知识条目,为缺少分类的条目补标记。', steps: [{ label: '扫描条目' }, { label: '补标记', status: 'active' }] }
5159
+ : null;
3449
5160
  return h('div', null,
3450
5161
  h('div', { className: 'studio-card', style: { marginBottom: 12 } },
3451
5162
  h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
3452
5163
  h('div', { className: 'studio-row-title' }, '中心知识库'),
3453
5164
  h(Badge, { tone: central.ok ? 'success' : central.enabled ? 'danger' : 'warn' }, centralStatusText(central)),
3454
- central.url ? h('span', { className: 'studio-code' }, central.url) : null,
5165
+ central.url ? h('span', { className: 'studio-code', title: central.url }, central.url) : null,
3455
5166
  central.groupId ? h('span', { className: 'studio-badge tone-muted' }, 'group ' + central.groupId) : null,
3456
5167
  h('div', { style: { marginLeft: 'auto', display: 'flex', gap: 6, flexWrap: 'wrap' } },
3457
5168
  h('button', { className: 'studio-btn studio-btn-sm', onClick: refresh, disabled: refreshing }, refreshing ? h(Spinner) : h(Icon, { name: 'refresh', size: 12 }), '刷新'),
3458
- h('button', { className: 'studio-btn studio-btn-sm', onClick: () => setImportMode('files') }, h(Icon, { name: 'file', size: 12 }), '导入文件'),
3459
- h('button', { className: 'studio-btn studio-btn-sm', onClick: () => setImportMode('folder') }, h(Icon, { name: 'folder', size: 12 }), '导入文件夹'),
3460
- h('button', { className: 'studio-btn studio-btn-sm', onClick: organizeCategories }, h(Icon, { name: 'knowledge', size: 12 }), '整理分类'),
3461
- kind === 'docs' ? h('button', { className: 'studio-btn studio-btn-sm', onClick: syncDocs, disabled: docsLoading }, h(Icon, { name: 'refresh', size: 12 }), '同步中心文档') : null,
3462
- h('button', { className: 'studio-btn studio-btn-sm', onClick: props.onOpenSettings }, '配置')
5169
+ h(MenuButton, { label: '导入', icon: 'import' }, [
5170
+ h('button', { key: 'files', className: 'studio-btn', onClick: () => setImportMode('files') }, h(Icon, { name: 'file', size: 13 }), '导入文件'),
5171
+ h('button', { key: 'folder', className: 'studio-btn', onClick: () => setImportMode('folder') }, h(Icon, { name: 'folder', size: 13 }), '导入文件夹'),
5172
+ kind === 'docs' ? h('button', { key: 'sync', className: 'studio-btn', disabled: docsLoading, onClick: syncDocs }, h(Icon, { name: 'refresh', size: 13 }), '同步中心文档') : null,
5173
+ ]),
5174
+ h(MenuButton, { label: '维护', icon: 'settings' }, [
5175
+ h('button', { key: 'cat', className: 'studio-btn', disabled: categorizeBusy, onClick: organizeCategories }, h(Icon, { name: 'knowledge', size: 13 }), categorizeBusy ? '整理中…' : '整理分类'),
5176
+ h('button', { key: 'cfg', className: 'studio-btn', onClick: props.onOpenSettings }, h(Icon, { name: 'settings', size: 13 }), '知识库配置'),
5177
+ ])
3463
5178
  )
3464
5179
  ),
3465
- h('div', { className: 'studio-row-sub', style: { marginTop: 6 } },
3466
- central.ok
3467
- ? 'Neo4j 节点 ' + nodeCount + ' 个 / 关系 ' + edgeCount + ' 条;最后同步 ' + relativeTime(central.at) + '。批次沉淀会增量写入这里。'
3468
- : central.error || '中心知识库未启用;本地缓存页签仍可正常使用。'
3469
- )
5180
+ h('div', { className: 'studio-central-metrics' },
5181
+ h('div', { className: 'studio-central-metric' },
5182
+ h('div', { className: 'studio-central-metric-value' }, nodeCount),
5183
+ h('div', { className: 'studio-central-metric-label' }, '图节点')
5184
+ ),
5185
+ h('div', { className: 'studio-central-metric' },
5186
+ h('div', { className: 'studio-central-metric-value' }, edgeCount),
5187
+ h('div', { className: 'studio-central-metric-label' }, '关系')
5188
+ ),
5189
+ h('div', { className: 'studio-central-metric' },
5190
+ h('div', { className: 'studio-central-metric-value' }, central.at ? relativeTime(central.at) : '—'),
5191
+ h('div', { className: 'studio-central-metric-label' }, '最后同步')
5192
+ )
5193
+ ),
5194
+ !central.ok ? h('div', { className: 'studio-note' + (central.error ? ' tone-danger' : ''), style: { marginTop: 10 } },
5195
+ central.error || '中心知识库未启用;本地缓存页签仍可正常使用。') : null
3470
5196
  ),
5197
+ activeOp ? h(OperationProgress, { label: activeOp.label, detail: activeOp.detail, steps: activeOp.steps, startedAt: opStartedAt, active: true }) : null,
5198
+ h(CentralPipelineCard, { pipeline, error: pipelineError, enabled: central.enabled === true }),
3471
5199
  h(TabBar, {
3472
5200
  tabs: CENTRAL_TABS.map((item) => (item.id === kind ? { ...item, count: items.length } : item)),
3473
5201
  active: kind,
3474
- onChange: setKind,
5202
+ onChange: (value) => { setKind(value); setExtractError(''); },
3475
5203
  }),
3476
5204
  kind === 'episodes' ? h('div', { style: { display: 'flex', gap: 6, flexWrap: 'wrap', margin: '0 0 10px' } },
3477
5205
  KNOWLEDGE_CATEGORY_TABS.map((item) => h('button', {
@@ -3514,12 +5242,12 @@ window.__ModuleLoader__.load({
3514
5242
  h('div', { className: 'studio-card', style: { marginBottom: 12 } },
3515
5243
  h('div', { className: 'studio-row-title' }, '从当前知识库提取知识'),
3516
5244
  h('div', { className: 'studio-row-sub', style: { marginTop: 6 } },
3517
- '读取已有知识和导入文档,按页面知识、业务流程、操作流程、注意事项、单据流转提取要点;每次处理 20 条未提取数据。'
5245
+ '知识提取和语义索引由中心服务自动、持续运行,新知识与导入文档会自动处理。下方按钮只用于补跑、重跑或排查问题。'
3518
5246
  ),
3519
5247
  h('div', { className: 'studio-detail-actions' },
3520
- h('button', { className: 'studio-btn studio-btn-primary', onClick: () => runExtract(false), disabled: extractBusy }, extractBusy ? h(Spinner) : h(Icon, { name: 'knowledge', size: 14 }), extractBusy ? '提取中…' : '一键提取'),
5248
+ h('button', { className: 'studio-btn', onClick: () => runExtract(false), disabled: extractBusy }, extractBusy ? h(Spinner) : h(Icon, { name: 'knowledge', size: 14 }), extractBusy ? '提取中…' : '手动提取一批(20 条)'),
3521
5249
  h('button', { className: 'studio-btn', onClick: () => runExtract(true), disabled: extractBusy }, '重新提取最近 20 条'),
3522
- h('button', { className: 'studio-btn', onClick: runSemanticIndex, disabled: semanticBusy || extractBusy }, semanticBusy ? h(Spinner) : h(Icon, { name: 'shield', size: 14 }), semanticBusy ? '索引中…' : '语义索引(5 条)')
5250
+ h('button', { className: 'studio-btn', onClick: runSemanticIndex, disabled: semanticBusy || extractBusy }, semanticBusy ? h(Spinner) : h(Icon, { name: 'shield', size: 14 }), semanticBusy ? '索引中…' : '手动索引一批(5 条)')
3523
5251
  ),
3524
5252
  extractError ? h('div', { className: 'studio-note tone-danger', style: { marginTop: 8 } }, extractError) : null,
3525
5253
  extractResult ? h('div', { className: 'studio-note', style: { marginTop: 8 } },
@@ -3527,8 +5255,8 @@ window.__ModuleLoader__.load({
3527
5255
  (extractResult.remaining !== undefined ? ',还有 ' + extractResult.remaining + ' 条未提取' : '')
3528
5256
  ) : null
3529
5257
  ),
3530
- extractionsLoading ? h('div', { className: 'studio-note' }, h(Spinner), ' 正在读取提取结果…') : null,
3531
- !extractionsLoading && !extractions.length ? h(Empty, { icon: 'knowledge', title: '还没有提取记录', desc: '点击「一键提取」,从现有知识和导入文档中整理分类要点。' }) : null,
5258
+ extractionsLoading ? h('div', { className: 'studio-loading' }, h(Spinner), '正在读取提取结果…') : null,
5259
+ !extractionsLoading && !extractions.length ? h(Empty, { icon: 'knowledge', title: '还没有提取记录', desc: '自动管线会持续提取;也可以手动补跑一批。' }) : null,
3532
5260
  h('div', { className: 'studio-list' },
3533
5261
  KNOWLEDGE_CATEGORY_TABS.filter((item) => item.id).map((item) => {
3534
5262
  const points = groupedExtractions.get(item.id) || [];
@@ -3553,7 +5281,7 @@ window.__ModuleLoader__.load({
3553
5281
  ? h('div', null,
3554
5282
  actionError ? h('div', { className: 'studio-note tone-danger', style: { marginBottom: 10 } }, actionError) : null,
3555
5283
  docsError ? h('div', { className: 'studio-note tone-danger', style: { marginBottom: 10 } }, '读取导入文档失败:' + docsError) : null,
3556
- docsLoading ? h('div', { className: 'studio-note' }, h(Spinner), ' 正在读取导入文档…') : null,
5284
+ docsLoading ? h('div', { className: 'studio-loading' }, h(Spinner), '正在读取导入文档…') : null,
3557
5285
  !docsLoading && !docsError && !documents.length
3558
5286
  ? h(Empty, { icon: 'file', title: '还没有导入文档', desc: '从上方「导入文件/文件夹」导入后,可以在这里查看、编辑和删除。' })
3559
5287
  : null,
@@ -3576,7 +5304,7 @@ window.__ModuleLoader__.load({
3576
5304
  )
3577
5305
  : h('div', null,
3578
5306
  listError ? h('div', { className: 'studio-note tone-danger', style: { marginBottom: 10 } }, '中心知识库读取失败:' + listError) : null,
3579
- loading ? h('div', { className: 'studio-note' }, h(Spinner), ' 正在读取中心知识库…') : null,
5307
+ loading ? h('div', { className: 'studio-loading' }, h(Spinner), '正在读取中心知识库…') : null,
3580
5308
  !loading && !listError && !items.length
3581
5309
  ? h(Empty, {
3582
5310
  icon: 'knowledge',
@@ -3722,19 +5450,19 @@ window.__ModuleLoader__.load({
3722
5450
  ) : h(Empty, { icon: 'file', title: '还没有业务规则', desc: '从文档导入或知识库合并后会出现。' });
3723
5451
  };
3724
5452
  return h('div', null,
3725
- h('div', { className: 'studio-page-head' },
3726
- h('div', null,
3727
- h('h1', { className: 'studio-page-title' }, '知识'),
3728
- h('p', { className: 'studio-page-desc' }, '中心知识库是主知识源;本地缓存只用于选择器与离线兜底。执行过程中看到的页面结构、动作与流程会先写入缓存,再增量同步到中心。')
3729
- ),
3730
- h('div', { className: 'studio-page-actions' },
3731
- h(Badge, { tone: central.ok ? 'success' : central.enabled ? 'danger' : 'warn' }, '中心 ' + centralStatusText(central)),
3732
- h('span', { className: 'studio-badge tone-business' }, summary.pages + ' 页面缓存'),
3733
- h('span', { className: 'studio-badge tone-link' }, summary.processes + ' 流程缓存'),
3734
- summary.corrections ? h('span', { className: 'studio-badge tone-success' }, summary.corrections + ' 条纠错经验') : null,
3735
- h('span', { className: 'studio-badge tone-muted' }, summary.learnings + ' 学习')
3736
- )
3737
- ),
5453
+ h(PageHeader, {
5454
+ kicker: '知识沉淀',
5455
+ icon: 'knowledge',
5456
+ title: '知识',
5457
+ desc: '中心知识库是主知识源;本地缓存只用于选择器与离线兜底。执行过程中看到的页面结构、动作与流程会先写入缓存,再增量同步到中心。',
5458
+ meta: [
5459
+ h(StatusBadge, { key: 'central', status: central.ok ? 'done' : central.enabled ? 'failed' : 'untested', label: '中心 ' + centralStatusText(central) }),
5460
+ h('span', { key: 'pages', className: 'studio-badge tone-muted' }, (summary.pages || 0) + ' 页面缓存'),
5461
+ h('span', { key: 'processes', className: 'studio-badge tone-muted' }, (summary.processes || 0) + ' 流程缓存'),
5462
+ summary.corrections ? h('span', { key: 'fixes', className: 'studio-badge tone-success' }, summary.corrections + ' 条纠错经验') : null,
5463
+ h('span', { key: 'learn', className: 'studio-badge tone-muted' }, (summary.learnings || 0) + ' 学习'),
5464
+ ],
5465
+ }),
3738
5466
  h(TabBar, {
3739
5467
  tabs: [
3740
5468
  { id: 'central', label: '中心知识库' },
@@ -4198,15 +5926,21 @@ window.__ModuleLoader__.load({
4198
5926
  const centralInfo = centralResult || snapshot.central || {};
4199
5927
  const centralNodeCount = asArray(centralInfo.nodes).reduce((sum, item) => sum + (Number(item.count) || 0), 0);
4200
5928
  return h('div', null,
4201
- h('div', { className: 'studio-page-head' },
4202
- h('div', null,
4203
- h('h1', { className: 'studio-page-title' }, '设置'),
4204
- h('p', { className: 'studio-page-desc' }, '连接被测环境、并发策略与回写方式。测试步骤会按角色从已导入账号中自动选择并切换账号;账号密码保存在本地测试工程。')
4205
- ),
4206
- h('div', { className: 'studio-page-actions' },
4207
- h('button', { className: 'studio-btn', onClick: runDoctor, disabled: doctorBusy }, doctorBusy ? h(Spinner) : h(Icon, { name: 'shield', size: 14 }), '环境自检')
4208
- )
4209
- ),
5929
+ h(PageHeader, {
5930
+ kicker: '运行配置',
5931
+ icon: 'settings',
5932
+ title: '设置',
5933
+ desc: '连接被测环境、并发策略与回写方式。测试步骤会按角色从已导入账号中自动选择并切换账号;账号密码保存在本地测试工程。',
5934
+ meta: [
5935
+ h('span', { key: 'url', className: 'studio-code', title: config.baseUrl || '' }, config.baseUrl || '未配置被测地址'),
5936
+ h('span', { key: 'conc', className: 'studio-badge tone-muted' }, '并发 ' + (config.concurrency || 0)),
5937
+ h('span', { key: 'wb', className: 'studio-badge tone-muted' }, config.writeBack === 'none' ? '不回写' : config.writeBack === 'batch' ? '批次文档' : '回写用例文档'),
5938
+ accounts.length ? h('span', { key: 'acc', className: 'studio-badge tone-muted' }, accounts.length + ' 个测试账号') : null,
5939
+ ],
5940
+ actions: [
5941
+ h('button', { key: 'doctor', className: 'studio-btn', onClick: runDoctor, disabled: doctorBusy }, doctorBusy ? h(Spinner) : h(Icon, { name: 'shield', size: 14 }), '环境自检'),
5942
+ ],
5943
+ }),
4210
5944
  h('div', { className: 'studio-grid-2' },
4211
5945
  h('div', { className: 'studio-card' },
4212
5946
  h('div', { className: 'studio-form' },
@@ -4338,9 +6072,10 @@ window.__ModuleLoader__.load({
4338
6072
  /* ------------------------------------------------------------------ */
4339
6073
 
4340
6074
  function ImportDialog(props) {
4341
- const [file, setFile] = useState('');
4342
- const [name, setName] = useState('');
4343
- const [mode, setMode] = useState('merge');
6075
+ const targetDoc = props.targetDoc || null;
6076
+ const [file, setFile] = useState(targetDoc?.sourcePath || '');
6077
+ const [name, setName] = useState(targetDoc?.name || '');
6078
+ const [mode, setMode] = useState(targetDoc?.mode === 'overwrite' ? 'overwrite' : 'merge');
4344
6079
  const [busy, setBusy] = useState(false);
4345
6080
  const [error, setError] = useState('');
4346
6081
  const [result, setResult] = useState(null);
@@ -4349,7 +6084,7 @@ window.__ModuleLoader__.load({
4349
6084
  const docs = asArray(props.snapshot?.docs);
4350
6085
  const identity = normalizeDocKey(name || baseName(file));
4351
6086
  const docKeyOf = (doc) => normalizeDocKey(doc?.docKey) || normalizeDocKey(doc?.name);
4352
- const matchedDoc = identity ? docs.find((doc) => normalizeDocKey(doc?.name) === identity || docKeyOf(doc) === identity) : null;
6087
+ const matchedDoc = targetDoc || (identity ? docs.find((doc) => normalizeDocKey(doc?.name) === identity || docKeyOf(doc) === identity) : null);
4353
6088
  const applyResult = (payload) => {
4354
6089
  const count = Math.max(
4355
6090
  Number(payload && payload.caseCount) || 0,
@@ -4371,7 +6106,12 @@ window.__ModuleLoader__.load({
4371
6106
  setResult(null);
4372
6107
  setStatus('正在从服务器路径导入…');
4373
6108
  try {
4374
- const payload = await props.onImport({ file: file.trim(), name: name.trim(), mode });
6109
+ const payload = await props.onImport({
6110
+ file: file.trim(),
6111
+ name: targetDoc ? '' : name.trim(),
6112
+ mode,
6113
+ ...(targetDoc ? { docId: targetDoc.id } : {}),
6114
+ });
4375
6115
  applyResult(payload);
4376
6116
  } catch (err) {
4377
6117
  setError(err.message);
@@ -4394,10 +6134,12 @@ window.__ModuleLoader__.load({
4394
6134
  const payload = await props.onUpload({
4395
6135
  name: input.name,
4396
6136
  dataBase64,
4397
- docName: name.trim() || input.name.replace(/\.[^.]+$/, ''),
4398
6137
  mode,
6138
+ ...(targetDoc
6139
+ ? { docId: targetDoc.id }
6140
+ : { docName: name.trim() || input.name.replace(/\.[^.]+$/, '') }),
4399
6141
  });
4400
- if (!name.trim()) setName(input.name.replace(/\.[^.]+$/, ''));
6142
+ if (!targetDoc && !name.trim()) setName(input.name.replace(/\.[^.]+$/, ''));
4401
6143
  setFile(payload.uploadedFile || input.name);
4402
6144
  applyResult(payload);
4403
6145
  } catch (err) {
@@ -4416,8 +6158,10 @@ window.__ModuleLoader__.load({
4416
6158
  : 0;
4417
6159
  const diff = result && result.diffSummary ? result.diffSummary : null;
4418
6160
  return h(Modal, {
4419
- title: '导入用例文档',
4420
- desc: '支持 .md / .markdown / .txt / .xlsx / .json。可以点击选择本地文件上传,也可以填写服务器上的文件或目录路径。',
6161
+ title: targetDoc ? '重新关联源文件' : '导入用例文档',
6162
+ desc: targetDoc
6163
+ ? '选择新的源文件并导入到该文档;文档 id、名称和用例归属保持不变。'
6164
+ : '支持 .md / .markdown / .txt / .xlsx / .csv / .json。可以点击选择本地文件上传,也可以填写服务器上的文件或目录路径。',
4421
6165
  onClose: props.onClose,
4422
6166
  footer: h(React.Fragment, null,
4423
6167
  h('button', { className: 'studio-btn', onClick: props.onClose }, result ? '完成' : '取消'),
@@ -4425,6 +6169,18 @@ window.__ModuleLoader__.load({
4425
6169
  ),
4426
6170
  },
4427
6171
  h('div', { className: 'studio-form' },
6172
+ targetDoc ? h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
6173
+ h('div', { className: 'studio-doc-meta' },
6174
+ h(Badge, { tone: docKindTone(targetDoc.kind) }, docKindLabel(targetDoc.kind)),
6175
+ h(Badge, { tone: 'link' }, '目标文档'),
6176
+ h('span', { className: 'studio-row-sub' },
6177
+ 'v' + (targetDoc.version || 1) + ' · ' + (Number(targetDoc.visibleCount) || 0) + ' 条用例'
6178
+ + (targetDoc.archived ? ' · 已归档' : '')
6179
+ )
6180
+ ),
6181
+ h('div', { className: 'studio-note studio-mono-break', style: { marginTop: 6 } },
6182
+ '当前源文件:' + (targetDoc.sourcePath || '—'))
6183
+ ) : null,
4428
6184
  h('div', { className: 'studio-card', style: { padding: '13px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
4429
6185
  h('div', { style: { display: 'flex', alignItems: 'center', gap: 10, flexWrap: 'wrap' } },
4430
6186
  h('label', {
@@ -4435,7 +6191,7 @@ window.__ModuleLoader__.load({
4435
6191
  '选择本地文件',
4436
6192
  h('input', {
4437
6193
  type: 'file',
4438
- accept: '.md,.markdown,.txt,.xlsx,.json',
6194
+ accept: '.md,.markdown,.txt,.xlsx,.csv,.json',
4439
6195
  style: { display: 'none' },
4440
6196
  disabled: !uploadSupported || busy,
4441
6197
  onChange: onLocalFile,
@@ -4445,44 +6201,59 @@ window.__ModuleLoader__.load({
4445
6201
  ),
4446
6202
  !uploadSupported ? h('div', { className: 'studio-note tone-warn', style: { marginTop: 8 } }, '当前 Host 没有加载上传接口。请重启 DSH 后再试;也可以先用下面的服务器路径导入。') : null
4447
6203
  ),
4448
- docs.length ? h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
4449
- h('div', { className: 'studio-nl-label' }, '已导入文档(点击可覆盖更新)'),
4450
- h('div', { className: 'studio-list' },
4451
- docs.slice(0, 8).map((doc) => h('div', {
4452
- key: doc.id || doc.docKey || doc.name,
4453
- className: 'studio-row',
4454
- role: 'button',
4455
- tabIndex: 0,
4456
- onClick: () => {
4457
- setName(doc.name || '');
4458
- if (doc.sourcePath) setFile(doc.sourcePath);
4459
- setMode('overwrite');
4460
- setResult(null);
4461
- setError('');
6204
+ !targetDoc && docs.length ? h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
6205
+ h('div', { className: 'studio-nl-label' }, '已导入文档(点击可带入路径和导入方式)'),
6206
+ h('div', { className: 'studio-list', style: { maxHeight: 232, overflowY: 'auto' } },
6207
+ docs.map((doc) => {
6208
+ const visible = Number(doc.visibleCount ?? doc.count) || 0;
6209
+ const owned = Number(doc.ownedCount) || 0;
6210
+ const missing = doc.sourceState === 'missing';
6211
+ const isMatched = matchedDoc && (doc.id === matchedDoc.id || doc.docKey === matchedDoc.docKey);
6212
+ return h('div', {
6213
+ key: doc.id || doc.docKey || doc.name,
6214
+ className: 'studio-row',
6215
+ role: 'button',
6216
+ tabIndex: 0,
6217
+ title: doc.sourcePath || '',
6218
+ onClick: () => {
6219
+ setName(doc.name || '');
6220
+ if (doc.sourcePath) setFile(doc.sourcePath);
6221
+ setMode(doc.mode === 'overwrite' ? 'overwrite' : 'merge');
6222
+ setResult(null);
6223
+ setError('');
6224
+ },
6225
+ onKeyDown: (event) => {
6226
+ if (event.key !== 'Enter' && event.key !== ' ') return;
6227
+ event.preventDefault();
6228
+ event.currentTarget.click();
6229
+ },
4462
6230
  },
4463
- },
4464
- h('div', { className: 'studio-row-main' },
4465
- h('div', { className: 'studio-row-title' }, doc.name || doc.docKey),
4466
- h('div', { className: 'studio-row-sub' }, [
4467
- doc.kind || '文档',
4468
- (doc.count || 0) + ' 条',
4469
- 'v' + (doc.version || 1),
4470
- doc.mode === 'overwrite' ? '上次覆盖导入' : '上次合并导入',
4471
- relativeTime(doc.updatedAt || doc.importedAt),
4472
- ].join(' · '))
4473
- ),
4474
- h(Badge, { tone: matchedDoc && (doc.id === matchedDoc.id || doc.docKey === matchedDoc.docKey) ? 'link' : 'muted' }, doc.docKey || doc.name)
4475
- ))
4476
- ),
4477
- docs.length > 8 ? h('div', { className: 'studio-note', style: { marginTop: 4 } }, '还有 ' + (docs.length - 8) + ' 个文档未展示') : null
6231
+ h('div', { className: 'studio-row-main' },
6232
+ h('div', { className: 'studio-row-title' }, doc.name || doc.docKey),
6233
+ h('div', { className: 'studio-row-sub' }, [
6234
+ docKindLabel(doc.kind),
6235
+ visible + ' 条' + (owned > visible ? ' / 账本 ' + owned : ''),
6236
+ 'v' + (doc.version || 1),
6237
+ '回写 ' + (doc.writeback?.at ? relativeTime(doc.writeback.at) : '未回写'),
6238
+ relativeTime(doc.updatedAt || doc.importedAt),
6239
+ ].join(' · ')),
6240
+ missing ? h('div', { className: 'studio-row-sub tone-danger' }, '源文件缺失:' + (doc.sourcePath || '—')) : null
6241
+ ),
6242
+ h('div', { className: 'studio-row-side' },
6243
+ missing ? h(Badge, { tone: 'danger' }, '源缺失') : h(Badge, { tone: 'success' }, '源就绪'),
6244
+ h(Badge, { tone: isMatched ? 'link' : 'muted' }, docKindLabel(doc.kind))
6245
+ )
6246
+ );
6247
+ })
6248
+ )
4478
6249
  ) : null,
4479
6250
  h('div', { className: 'studio-note', style: { textAlign: 'center', color: 'var(--dsw-alias-label-tertiary)' } }, '或使用服务器路径'),
4480
6251
  h(Field, { label: '服务器文件 / 目录路径', hint: '绝对路径,或相对测试工程的路径;目录会递归扫描 .md/.markdown/.txt' },
4481
6252
  h('input', { className: 'studio-input', placeholder: '例如 /home/ocean/Projects/oms-v2/test/cases/M006/M006履约管理模块-测试用例.xlsx', value: file, onChange: (e) => setFile(e.target.value) })
4482
6253
  ),
4483
- h(Field, { label: '文档名称(可选)', hint: '同名的重复导入会更新同一个文档对象;用于生成用例编号前缀和 cases/studio 文件名' },
6254
+ !targetDoc ? h(Field, { label: '文档名称(可选)', hint: '同名的重复导入会更新同一个文档对象;用于生成用例编号前缀和 cases/studio 文件名' },
4484
6255
  h('input', { className: 'studio-input', placeholder: '例如 M006 履约回归', value: name, onChange: (e) => setName(e.target.value) })
4485
- ),
6256
+ ) : null,
4486
6257
  h('div', { className: 'studio-card', style: { padding: '12px 14px', background: 'var(--dsw-alias-bg-layer-2)' } },
4487
6258
  h('div', { className: 'studio-nl-label' }, '导入方式'),
4488
6259
  h('label', { className: 'studio-check', style: { padding: '4px 0' } },
@@ -4492,13 +6263,12 @@ window.__ModuleLoader__.load({
4492
6263
  h('div', { className: 'studio-note', style: { marginLeft: 22 } }, '新增用例,并更新同编号用例;文档里已删除的旧用例保留。'),
4493
6264
  h('label', { className: 'studio-check', style: { padding: '4px 0', marginTop: 6 } },
4494
6265
  h('input', { type: 'radio', name: 'studio-import-mode', checked: mode === 'overwrite', onChange: () => setMode('overwrite') }),
4495
- '覆盖同名文档'
6266
+ targetDoc ? '覆盖该文档' : '覆盖同名文档'
4496
6267
  ),
4497
6268
  h('div', { className: 'studio-note', style: { marginLeft: 22 } }, '以当前文档为准:删除该文档上次导入、本次已不存在的用例;同编号用例以文档内容更新。'),
4498
6269
  matchedDoc
4499
- ? h('div', { className: 'studio-note tone-warn', style: { marginTop: 6 } }, '将更新已导入文档:' + matchedDoc.name + '(v' + (matchedDoc.version || 1) + ' · ' + (matchedDoc.count || 0) + ' 条)')
4500
- : h('div', { className: 'studio-note', style: { marginTop: 6 } }, '没有匹配到同名文档;本次会作为新文档导入。')
4501
- ),
6270
+ ? h('div', { className: 'studio-note tone-warn', style: { marginTop: 6 } }, '将更新已导入文档:' + matchedDoc.name + '(v' + (matchedDoc.version || 1) + ' · ' + (matchedDoc.visibleCount ?? matchedDoc.count ?? 0) + ' 条)')
6271
+ : h('div', { className: 'studio-note', style: { marginTop: 6 } }, '没有匹配到同名文档;本次会作为新文档导入。') ),
4502
6272
  status ? h('div', { className: 'studio-note' }, h(Spinner), ' ' + status) : null,
4503
6273
  error ? h('div', { className: 'studio-note tone-danger' }, error) : null,
4504
6274
  result ? h('div', { className: 'studio-nl' },
@@ -4530,7 +6300,7 @@ window.__ModuleLoader__.load({
4530
6300
  ) : null,
4531
6301
  h('div', { className: 'studio-note' }, '导入完成后可在「用例」中检查自然语言内容;如有偏差,直接编辑用例即可。')
4532
6302
  ) : h('div', { className: 'studio-note', style: { background: 'var(--dsw-alias-bg-layer-2)', padding: '10px 12px', borderRadius: 8 } },
4533
- '文档没有固定模板:带编号的用例标题、前置条件/操作步骤/预期结果字段表、或编号列表都能识别。xlsx 会解析所有包含表头的工作表。'
6303
+ '文档没有固定模板:带编号的用例标题、前置条件/操作步骤/预期结果字段表、或编号列表都能识别。xlsx 会解析所有包含表头的工作表;CSV 按同一套表头识别用例。'
4534
6304
  )
4535
6305
  )
4536
6306
  );
@@ -4584,7 +6354,45 @@ window.__ModuleLoader__.load({
4584
6354
  const [startBusy, setStartBusy] = useState(false);
4585
6355
  const [error, setError] = useState('');
4586
6356
  const cases = asArray(snapshot.cases);
4587
- const visible = cases.filter((item) => caseMatches(item, query, filter));
6357
+ const activeDocs = useMemo(() => asArray(snapshot.docs).filter((doc) => doc.archived !== true), [snapshot.docs]);
6358
+ const docById = useMemo(() => new Map(activeDocs.map((doc) => [doc.id, doc])), [activeDocs]);
6359
+ const archivedDocIds = useMemo(() => new Set(asArray(snapshot.docs).filter((doc) => doc.archived === true).map((doc) => doc.id)), [snapshot.docs]);
6360
+ const pickable = useMemo(() => cases.filter((item) => {
6361
+ const id = String(item.docId || item.source?.docId || '');
6362
+ return !id || !archivedDocIds.has(id);
6363
+ }), [cases, archivedDocIds]);
6364
+ const visible = pickable.filter((item) => caseMatches(item, query, filter));
6365
+ // 批次选择沿用用例库的两层结构:文档分组,用例缩进并带文档内序号。
6366
+ const groups = useMemo(() => {
6367
+ const byDoc = new Map();
6368
+ const unassigned = [];
6369
+ for (const item of visible) {
6370
+ const id = String(item.docId || item.source?.docId || '');
6371
+ if (id && docById.has(id)) {
6372
+ if (!byDoc.has(id)) byDoc.set(id, []);
6373
+ byDoc.get(id).push(item);
6374
+ } else {
6375
+ unassigned.push(item);
6376
+ }
6377
+ }
6378
+ const out = activeDocs
6379
+ .map((doc) => ({ doc, cases: byDoc.get(doc.id) || [] }))
6380
+ .filter((group) => group.cases.length > 0);
6381
+ if (unassigned.length) out.push({ doc: null, cases: unassigned });
6382
+ return out;
6383
+ }, [visible, activeDocs, docById]);
6384
+ // 序号按文档内稳定顺序计算,搜索或筛选后仍与用例库一致。
6385
+ const seqByCase = useMemo(() => {
6386
+ const groups = new Map();
6387
+ for (const item of pickable) {
6388
+ const key = String(item.docId || item.source?.docId || '__unassigned__');
6389
+ if (!groups.has(key)) groups.set(key, []);
6390
+ groups.get(key).push(item);
6391
+ }
6392
+ const map = new Map();
6393
+ for (const list of groups.values()) list.forEach((item, index) => map.set(item.tcId, index + 1));
6394
+ return map;
6395
+ }, [pickable]);
4588
6396
  const toggle = (id) => setSelected((current) => current.includes(id) ? current.filter((item) => item !== id) : [...current, id]);
4589
6397
  const selectAll = (ids) => setSelected((current) => Array.from(new Set([...current, ...ids])));
4590
6398
  const removeAll = (ids) => { const set = new Set(ids); setSelected((current) => current.filter((item) => !set.has(item))); };
@@ -4664,14 +6472,41 @@ window.__ModuleLoader__.load({
4664
6472
  h('button', { className: 'studio-btn studio-btn-sm', onClick: () => removeAll(visible.map((item) => item.tcId)) }, '取消当前结果')
4665
6473
  )
4666
6474
  ),
4667
- h('div', { className: 'studio-case-list', style: { maxHeight: 360, overflow: 'auto' } },
4668
- visible.slice(0, 400).map((item) => h('label', { key: item.tcId, className: cx('studio-case', selected.includes(item.tcId) ? 'is-active' : ''), style: { cursor: 'pointer' } },
4669
- h('span', { className: 'studio-case-check' }, h('input', { type: 'checkbox', checked: selected.includes(item.tcId), onChange: () => toggle(item.tcId) })),
4670
- h('span', { className: 'studio-case-main' },
4671
- h('span', { className: 'studio-case-top' }, h('span', { className: 'studio-case-title' }, item.title || item.tcId), h('span', { className: 'studio-case-id' }, item.tcId)),
4672
- h('span', { className: 'studio-case-meta' }, h(ModeBadge, { mode: item.mode }), h(StatusBadge, { status: item.status }), item.module ? h('span', null, item.module) : null)
4673
- )
4674
- ))
6475
+ h('div', { className: 'studio-case-list', style: { maxHeight: 420, overflow: 'auto' } },
6476
+ groups.map((group) => {
6477
+ const ids = group.cases.map((item) => item.tcId);
6478
+ const selectedCount = ids.filter((id) => selected.includes(id)).length;
6479
+ return h('div', { key: group.doc ? group.doc.id : '__unassigned__', className: 'studio-picker-group' },
6480
+ h('div', { className: 'studio-doc-row studio-picker-doc' },
6481
+ group.doc ? h(SelectCheckbox, {
6482
+ checked: ids.length > 0 && selectedCount === ids.length,
6483
+ mixed: selectedCount > 0 && selectedCount < ids.length,
6484
+ label: '选择该文档下的用例',
6485
+ onChange: (next) => next ? selectAll(ids) : removeAll(ids),
6486
+ }) : null,
6487
+ h(Icon, { name: 'folder', size: 14, className: 'studio-folder-icon' }),
6488
+ h('div', { className: 'studio-doc-main' },
6489
+ h('div', { className: 'studio-doc-top' },
6490
+ h('span', { className: 'studio-doc-name' }, group.doc?.name || '未归属文档'),
6491
+ group.doc ? h(Badge, { tone: docKindTone(group.doc.kind), className: 'studio-doc-kind' }, docKindLabel(group.doc.kind)) : h(Badge, { tone: 'warn' }, '未关联文档'),
6492
+ h('span', { className: 'studio-doc-count' }, group.cases.length + ' 条' + (selectedCount ? ' · 已选 ' + selectedCount : ''))
6493
+ ),
6494
+ h('div', { className: 'studio-doc-sub' },
6495
+ h('span', { className: 'studio-doc-hint' }, group.doc?.sourcePath || '这些用例没有关联到导入文档')
6496
+ )
6497
+ )
6498
+ ),
6499
+ group.cases.map((item) => h(CaseListItem, {
6500
+ key: item.tcId,
6501
+ item,
6502
+ selected: selected.includes(item.tcId),
6503
+ seq: seqByCase.get(item.tcId),
6504
+ indent: true,
6505
+ onSelect: () => toggle(item.tcId),
6506
+ onToggle: () => toggle(item.tcId),
6507
+ }))
6508
+ );
6509
+ })
4675
6510
  )
4676
6511
  ) : null,
4677
6512
  step === 2 ? h('div', { className: 'studio-form' },
@@ -4770,7 +6605,7 @@ window.__ModuleLoader__.load({
4770
6605
  const snapshot = props.snapshot;
4771
6606
  const error = snapshot?.projectError || {};
4772
6607
  const workspaces = asArray(snapshot?.workspaces);
4773
- return h('div', { className: 'studio-content' },
6608
+ return h('div', null,
4774
6609
  h('div', { className: 'studio-card' },
4775
6610
  h('div', { className: 'studio-empty-icon', style: { justifyContent: 'flex-start', color: 'var(--dsw-alias-state-error-primary)' } }, h(Icon, { name: 'alert', size: 28 })),
4776
6611
  h('div', { style: { fontSize: 16, fontWeight: 650, marginTop: 8 } }, '工作区没有加载成功'),
@@ -4801,6 +6636,7 @@ window.__ModuleLoader__.load({
4801
6636
  const [caseRunCaseId, setCaseRunCaseId] = useState('');
4802
6637
  const [selectedIds, setSelectedIds] = useState([]);
4803
6638
  const [importOpen, setImportOpen] = useState(false);
6639
+ const [importTargetDoc, setImportTargetDoc] = useState(null);
4804
6640
  const [batchOpen, setBatchOpen] = useState(false);
4805
6641
  const [batchInitial, setBatchInitial] = useState([]);
4806
6642
  const [editCase, setEditCase] = useState(null);
@@ -4900,6 +6736,14 @@ window.__ModuleLoader__.load({
4900
6736
  setBatchInitial(initial.length ? initial : selectedIds);
4901
6737
  setBatchOpen(true);
4902
6738
  };
6739
+ const openImport = (target) => {
6740
+ setImportTargetDoc(target || null);
6741
+ setImportOpen(true);
6742
+ };
6743
+ const closeImport = () => {
6744
+ setImportOpen(false);
6745
+ setImportTargetDoc(null);
6746
+ };
4903
6747
  const onCreated = (batch) => {
4904
6748
  setBatchOpen(false);
4905
6749
  setSelectedBatchId(batch.id);
@@ -4910,6 +6754,37 @@ window.__ModuleLoader__.load({
4910
6754
  const onImportDone = () => {
4911
6755
  studio.reload();
4912
6756
  };
6757
+ const onArchiveDocument = async (doc, archived) => {
6758
+ try {
6759
+ const owned = new Set(asArray(studio.snapshot.cases)
6760
+ .filter((item) => String(item.docId || item.source?.docId || '') === doc.id)
6761
+ .map((item) => item.tcId));
6762
+ const payload = await api('/docs/archive', { method: 'POST', project: studio.snapshot.project, body: { docId: doc.id, archived } });
6763
+ if (archived) {
6764
+ setSelectedIds((ids) => ids.filter((id) => !owned.has(id)));
6765
+ if (owned.has(selectedCaseId)) setSelectedCaseId('');
6766
+ }
6767
+ studio.reload();
6768
+ showToast({ kind: 'success', text: (archived ? '已归档文档:' : '已恢复文档:') + (doc.name || doc.id) });
6769
+ return payload;
6770
+ } catch (error) {
6771
+ showToast({ kind: 'error', text: error.message });
6772
+ return null;
6773
+ }
6774
+ };
6775
+ const onDeleteDocument = async (doc) => {
6776
+ const payload = await api('/docs/delete', { method: 'POST', project: studio.snapshot.project, body: { docId: doc.id } });
6777
+ studio.reload();
6778
+ setSelectedCaseId('');
6779
+ setSelectedIds([]);
6780
+ showToast({ kind: 'success', text: '已删除文档记录:' + (doc.name || doc.id) + ';用例保留为未归属' });
6781
+ return payload;
6782
+ };
6783
+ const onDocsWriteback = async (body) => {
6784
+ const payload = await api('/docs/writeback', { method: 'POST', project: studio.snapshot.project, body, timeoutMs: 120000 });
6785
+ if (body.dryRun !== true) studio.reload();
6786
+ return payload;
6787
+ };
4913
6788
  const onRunCase = async (item) => {
4914
6789
  const batchId = item.lastRun?.batchId || '';
4915
6790
  try {
@@ -4952,14 +6827,14 @@ window.__ModuleLoader__.load({
4952
6827
  showToast({ kind: 'error', text: error.message });
4953
6828
  }
4954
6829
  };
4955
- const onStopCase = async (batch, caseId) => {
6830
+ const onStopCase = async (batch, caseId, run, options = {}) => {
4956
6831
  try {
4957
6832
  const payload = await api('/batch/case/stop', { method: 'POST', project: studio.snapshot.project, body: { id: batch.id, caseId } });
4958
6833
  studio.reload();
4959
- showToast({ kind: 'success', text: '已请求停止该用例' });
6834
+ if (!options.silent) showToast({ kind: 'success', text: '已请求停止该用例' });
4960
6835
  return payload;
4961
6836
  } catch (error) {
4962
- showToast({ kind: 'error', text: error.message });
6837
+ if (!options.silent) showToast({ kind: 'error', text: error.message });
4963
6838
  return null;
4964
6839
  }
4965
6840
  };
@@ -4974,16 +6849,18 @@ window.__ModuleLoader__.load({
4974
6849
  return null;
4975
6850
  }
4976
6851
  };
4977
- const onRequeueCase = async (batch, caseId, run) => {
6852
+ const onRequeueCase = async (batch, caseId, run, options = {}) => {
4978
6853
  try {
4979
6854
  const forceAgent = ['manual', 'blocked'].includes(run?.mode) || run?.status === 'blocked';
4980
6855
  const payload = await api('/case/run', { method: 'POST', project: studio.snapshot.project, body: { id: caseId, batchId: batch.id, ...(forceAgent ? { forceAgent: true } : {}) } });
4981
6856
  studio.reload();
4982
- if (payload.alreadyActive) showToast({ kind: 'warn', text: '该用例已经在队列或执行中' });
4983
- else showToast({ kind: 'success', text: '已重新排队到原批次' });
6857
+ if (!options.silent) {
6858
+ if (payload.alreadyActive) showToast({ kind: 'warn', text: '该用例已经在队列或执行中' });
6859
+ else showToast({ kind: 'success', text: '已重新排队到原批次' });
6860
+ }
4984
6861
  return payload;
4985
6862
  } catch (error) {
4986
- showToast({ kind: 'error', text: error.message });
6863
+ if (!options.silent) showToast({ kind: 'error', text: error.message });
4987
6864
  return null;
4988
6865
  }
4989
6866
  };
@@ -5018,6 +6895,17 @@ window.__ModuleLoader__.load({
5018
6895
  showToast({ kind: 'error', text: error.message });
5019
6896
  }
5020
6897
  };
6898
+ const onResumeBatch = async (id) => {
6899
+ try {
6900
+ const payload = await api('/batch/resume', { method: 'POST', project: studio.snapshot.project, body: { id } });
6901
+ studio.reload();
6902
+ showToast({ kind: 'success', text: '已继续执行 ' + (payload?.resumed || 0) + ' 条未完成用例' });
6903
+ return payload;
6904
+ } catch (error) {
6905
+ showToast({ kind: 'error', text: error.message });
6906
+ return null;
6907
+ }
6908
+ };
5021
6909
  const onWritebackDone = () => {
5022
6910
  studio.reload();
5023
6911
  showToast({ kind: 'success', text: '用例文档已回写' });
@@ -5069,14 +6957,14 @@ window.__ModuleLoader__.load({
5069
6957
  const snapshot = studio.snapshot;
5070
6958
  const content = () => {
5071
6959
  if (!snapshot && studio.loading) {
5072
- return h('div', { className: 'studio-content' },
6960
+ return h('div', null,
5073
6961
  h('div', { className: 'studio-card', style: { display: 'flex', alignItems: 'center', gap: 10, justifyContent: 'center', minHeight: 160 } },
5074
6962
  h(Spinner), h('span', { className: 'studio-note' }, '正在加载测试工作室…')
5075
6963
  )
5076
6964
  );
5077
6965
  }
5078
6966
  if (!snapshot && studio.error) {
5079
- return h('div', { className: 'studio-content' },
6967
+ return h('div', null,
5080
6968
  h('div', { className: 'studio-card' },
5081
6969
  h('div', { className: 'studio-note tone-danger' }, studio.error.message),
5082
6970
  h('button', { className: 'studio-btn studio-btn-primary', onClick: studio.reload, style: { marginTop: 12 } }, '重试')
@@ -5105,7 +6993,16 @@ window.__ModuleLoader__.load({
5105
6993
  onDeleteFlow,
5106
6994
  onEditCase: setEditCase,
5107
6995
  onShot: setLightbox,
5108
- onImport: () => setImportOpen(true),
6996
+ onImport: () => openImport(),
6997
+ onReassociateDocument: openImport,
6998
+ onArchiveDocument,
6999
+ onDeleteDocument,
7000
+ onDocsWriteback,
7001
+ onReReadDocument: async (body) => {
7002
+ const payload = await api('/docs/re-read', { method: 'POST', project: studio.snapshot.project, body, timeoutMs: 120000 });
7003
+ studio.reload();
7004
+ return payload;
7005
+ },
5109
7006
  onDeleteCases,
5110
7007
  onOpenBatch: (id) => { setCaseRunBatchId(''); setCaseRunCaseId(''); setSelectedBatchId(id); setView('batches'); studio.reload(); },
5111
7008
  onCloseCaseRun: () => { setCaseRunBatchId(''); setCaseRunCaseId(''); studio.reload(); },
@@ -5120,6 +7017,7 @@ window.__ModuleLoader__.load({
5120
7017
  onSelectBatch: setSelectedBatchId,
5121
7018
  onNewBatch: openNewBatch,
5122
7019
  onStopBatch,
7020
+ onResumeBatch,
5123
7021
  onWritebackDone,
5124
7022
  onShot: setLightbox,
5125
7023
  onOpenBatch: (id) => { setSelectedBatchId(id); setView('batches'); studio.reload(); },
@@ -5145,7 +7043,7 @@ window.__ModuleLoader__.load({
5145
7043
  snapshot,
5146
7044
  onNavigate: navigate,
5147
7045
  onNewBatch: () => openNewBatch([]),
5148
- onImport: () => setImportOpen(true),
7046
+ onImport: () => openImport(),
5149
7047
  onOpenBatch: (id) => { setSelectedBatchId(id); setView('batches'); },
5150
7048
  });
5151
7049
  };
@@ -5156,18 +7054,20 @@ window.__ModuleLoader__.load({
5156
7054
  snapshot,
5157
7055
  refreshing: studio.refreshing,
5158
7056
  onProject: selectProject,
7057
+ onNavigate: navigate,
5159
7058
  onPickWorkspace: () => { setWorkspaceInitial(studio.snapshot?.project || ''); setWorkspaceInitialInfo(null); setWorkspaceOpen(true); },
5160
7059
  onRefresh: studio.reload,
5161
- onImport: () => setImportOpen(true),
7060
+ onImport: () => openImport(),
5162
7061
  onNewBatch: () => openNewBatch(selectedIds),
5163
7062
  }),
5164
7063
  h('div', { className: 'studio-body' },
5165
7064
  h(Rail, { snapshot, view, onNavigate: navigate }),
5166
- h('main', { className: 'studio-main' }, content())
7065
+ h('main', { className: 'studio-main' }, h('div', { className: 'studio-content' }, content()))
5167
7066
  ),
5168
7067
  importOpen ? h(ImportDialog, {
5169
7068
  snapshot: studio.snapshot,
5170
- onClose: () => setImportOpen(false),
7069
+ targetDoc: importTargetDoc,
7070
+ onClose: closeImport,
5171
7071
  onDone: onImportDone,
5172
7072
  onToast: showToast,
5173
7073
  onImport: (body) => api('/import', { method: 'POST', project: studio.snapshot.project, body, timeoutMs: 120000 }),