@ihyeon/flow-qa 0.10.2 → 0.10.6

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/README.ko.md CHANGED
@@ -74,6 +74,10 @@ CLI에서는 `flow-qa run cases/task-flow.json --target demo --case TC-001 --cas
74
74
 
75
75
  `0.5.0`부터 상세 보고서에서 **실패·오류 케이스 준비**를 누르면 실행 당시와 같은 저장된 케이스를 불러와 `실패`와 `실행 오류`만 선택합니다. 준비 후 케이스와 대상을 다시 검토하고 직접 실행하세요. 케이스·원본 파일이 없거나 바뀌었으면 준비를 중단하며, 실행 대상이 없거나 바뀌었으면 다시 선택해야 합니다. 자세한 동작은 [실패 케이스 준비](docs/ui.md#prepare-failed-cases)를 참고하세요.
76
76
 
77
+ 준비한 케이스 정의·대상·선택 케이스 그대로 실행하면 새 보고서에 원본 실행 ID가 남습니다. 상세 보고서에서 원본을 열거나 두 결과를 바로 비교할 수 있습니다. 이 조건을 변경해 실행하면 독립 실행으로 저장합니다. 원본 보고서가 삭제돼도 새 보고서는 읽을 수 있으며 원본이 없다는 상태를 표시합니다.
78
+
79
+ 원본 보고서의 **이 실행의 재실행 찾기**를 누르면 저장된 전체 기록에서 직접 연결된 재실행을 찾습니다. 오래된 결과는 **더 불러오기**로 열고, **전체 실행 보기**로 연결 조건을 해제할 수 있습니다.
80
+
77
81
  `0.8.0`부터 **상세 보고서**에서 케이스·오류 내용을 검색하고 상태별로 좁히거나 **실패·오류만** 볼 수 있습니다. **시도 2회 이상만 보기**(0.8.7)를 켜면 여러 번 시도한 케이스만 표시합니다. 표시 건수와 보고서 전체 케이스 수를 구분하며, Markdown·JSON 다운로드와 실패·오류 재실행 준비는 보고서 전체 범위를 유지합니다. 필터에 맞는 ID만 화면 순서대로 저장하려면 **표시된 케이스 ID 다운로드**(0.8.6)를 선택하세요. 자세한 동작은 [보고서 케이스 탐색](docs/ui.md#explore-cases-in-a-report)을 참고하세요.
78
82
 
79
83
  ## 실행 결과 비교
package/README.md CHANGED
@@ -74,6 +74,10 @@ The CLI supports repeated IDs: `flow-qa run cases/task-flow.json --target demo -
74
74
 
75
75
  From `0.5.0`, open a detailed report and choose **Prepare failed/error cases** to load its unchanged saved suite with only `failed` and `error` cases selected. Preparation never starts a run: review the cases and target, then run explicitly. Changed or missing case/source files block preparation; a changed or missing target must be selected again. See [preparing failed cases](docs/ui.md#prepare-failed-cases).
76
76
 
77
+ When the saved suite, target, and selected cases still match that preparation, the new report records the original run ID. Open or compare the original from the detailed report. If you change those inputs, the new result is saved as an independent run. An unavailable original is identified without hiding the new report.
78
+
79
+ From an original report, **Find reruns of this run** shows directly linked runs across the full saved history. Use **Load more** for older matches or **Show all runs** to clear the relation.
80
+
77
81
  From `0.8.0`, **Detailed report** supports case/error-text search, status filters, and **Failed/error only**. Use **At least 2 attempts** (0.8.7) to see only cases with multiple recorded attempts. Counts distinguish displayed matches from all recorded cases. Markdown/JSON downloads and failed/error preparation retain the full report scope. To save just the filtered IDs in the displayed order, choose **Download visible case IDs** (0.8.6). See [report case exploration](docs/ui.md#explore-cases-in-a-report).
78
82
 
79
83
  ## Compare recorded runs
@@ -161,6 +161,9 @@ function runnableSuite(suite, blocked) {
161
161
  export async function runSuite(options) {
162
162
  // A malformed selection must not leave a run directory behind.
163
163
  const selected = selectCases(options.suite, options.caseIds);
164
+ if (options.parentRunId && !/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(options.parentRunId)) {
165
+ throw new Error('Invalid parent run ID.');
166
+ }
164
167
  let executionSuite = selected.suite;
165
168
  let selection = selected.selection;
166
169
  const workspace = await realpath(options.workspace);
@@ -189,7 +192,7 @@ export async function runSuite(options) {
189
192
  let target = { name: options.targetName, url: '' };
190
193
  let releaseMobileDevice;
191
194
  let stepMap;
192
- const context = () => ({ suite: executionSuite, selection, runId, suiteHash, target, startedAt, finishedAt: new Date().toISOString(), blockedReasons: blocked });
195
+ const context = () => ({ suite: executionSuite, selection, runId, parentRunId: options.parentRunId, suiteHash, target, startedAt, finishedAt: new Date().toISOString(), blockedReasons: blocked });
193
196
  const blockAll = (suite, reason) => {
194
197
  for (const testCase of suite.cases)
195
198
  if (!blocked.has(testCase.id))
@@ -9,6 +9,7 @@ import { targetLabel } from "./targets.js";
9
9
  const RUN_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
10
10
  const archiveEnvelopeSchema = z.object({
11
11
  schemaVersion: z.literal('flow-qa/report-1'), runId: z.string().regex(RUN_ID), suiteId: idSchema,
12
+ parentRunId: z.string().regex(RUN_ID).optional(),
12
13
  suiteHash: z.string(), target: z.union([
13
14
  z.object({ name: z.string(), url: z.string() }),
14
15
  z.object({ name: z.string(), kind: z.literal('mobile'), platform: z.enum(['ios', 'android']), bundleId: z.string(), device: z.string() }),
@@ -23,7 +24,7 @@ const archiveEnvelopeSchema = z.object({
23
24
  /** The original UI metadata contract accepts older reports with incomplete attempt details. */
24
25
  export function parseArchivedReportEnvelope(raw) {
25
26
  const parsed = archiveEnvelopeSchema.safeParse(raw);
26
- return parsed.success && isReportSelectionValid(parsed.data.cases, parsed.data.selection) ? parsed.data : undefined;
27
+ return parsed.success && parsed.data.parentRunId !== parsed.data.runId && isReportSelectionValid(parsed.data.cases, parsed.data.selection) ? parsed.data : undefined;
27
28
  }
28
29
  const savedErrorSchema = z.object({ code: z.string(), message: z.string(), category: z.enum(['test', 'configuration', 'infrastructure', 'internal', 'interrupted']).optional() });
29
30
  const savedAttemptSchema = z.object({
@@ -49,6 +50,8 @@ export function isSavedReport(raw) {
49
50
  if (!savedReportSchema.safeParse(raw).success)
50
51
  return false;
51
52
  const report = raw;
53
+ if (report.parentRunId === report.runId)
54
+ return false;
52
55
  if (!isReportSelectionValid(report.cases, report.selection))
53
56
  return false;
54
57
  for (const item of report.cases) {
@@ -332,7 +335,7 @@ export function normalizeReport1(raw, context) {
332
335
  : rawStatus === 'failed' ? 'failed'
333
336
  : 'passed';
334
337
  return {
335
- schemaVersion: 'flow-qa/report-1', runId: context.runId, suiteId: context.suite.id,
338
+ schemaVersion: 'flow-qa/report-1', runId: context.runId, ...(context.parentRunId ? { parentRunId: context.parentRunId } : {}), suiteId: context.suite.id,
336
339
  suiteHash: context.suiteHash, target: context.target, startedAt: context.startedAt,
337
340
  finishedAt: context.finishedAt, status, cases, errors, usage: reportUsage, ...reportSelection(context),
338
341
  };
@@ -347,7 +350,7 @@ export function stoppedReport(raw, context, status, reason) {
347
350
  /** An explicit failure report still enumerates every expected case. */
348
351
  export function failureReport(context, status, error) {
349
352
  return {
350
- schemaVersion: 'flow-qa/report-1', runId: context.runId, suiteId: context.suite.id,
353
+ schemaVersion: 'flow-qa/report-1', runId: context.runId, ...(context.parentRunId ? { parentRunId: context.parentRunId } : {}), suiteId: context.suite.id,
351
354
  suiteHash: context.suiteHash, target: context.target, startedAt: context.startedAt,
352
355
  finishedAt: context.finishedAt, status,
353
356
  cases: scopedCases(context).map((testCase) => ({
@@ -387,6 +390,7 @@ export function renderMarkdown(report, locale = 'en') {
387
390
  `# ${label('QA results', 'QA 결과')}: ${safe(report.suiteId)}`,
388
391
  '',
389
392
  `- ${label('Run ID', '실행 ID')}: ${safe(report.runId)}`,
393
+ ...(report.parentRunId ? [`- ${label('Prepared from run', '재실행 원본')}: ${safe(report.parentRunId)}`] : []),
390
394
  `- ${label('Target', '대상')}: ${safe(report.target.name)} ${report.target.kind === 'mobile'
391
395
  ? safe(targetLabel(report.target))
392
396
  : label('(URL available in the local JSON report)', '(주소는 로컬 JSON 보고서에서 확인)')}`,
@@ -5,7 +5,7 @@
5
5
  const t = i18n.t;
6
6
  const names = { scenario: 'nav.scenario', library: 'nav.library', history: 'nav.history', settings: 'nav.settings' };
7
7
  const defaultReportFilter = () => ({ search: '', status: 'all', sort: 'recorded', repeatedOnly: false });
8
- const app = { state: null, connected: false, displayTargets: [], draft: null, selectedCaseIds: new Set(), script: '', neutralScript: '', scriptRevision: 0, savedFile: '', savedHash: '', origin: 'none', sourceFlow: '', boundSource: null, stale: false, dirty: false, busy: false, planning: false, planRequest: 0, stopping: false, report: null, reportMarkdown: '', selectedRun: '', reportFilter: defaultReportFilter(), rerunOrigin: null, rerunTargetMismatch: false, navigationVersion: 0, comparison: null, comparisonRequest: 0, comparisonBusy: false, comparisonStatus: 'comparison.selectBoth', comparisonPins: { baseline: null, current: null }, comparisonSelectionGeneration: 0, comparisonValidation: null, history: { runs: [], nextCursor: null, pagesLoaded: 0, loaded: false, loading: false, request: 0, debounce: null, kind: null, error: null, updatesAvailable: false, pendingRecentUpdate: false }, view: 'scenario' };
8
+ const app = { state: null, connected: false, displayTargets: [], draft: null, selectedCaseIds: new Set(), script: '', neutralScript: '', scriptRevision: 0, savedFile: '', savedHash: '', origin: 'none', sourceFlow: '', boundSource: null, stale: false, dirty: false, busy: false, planning: false, planRequest: 0, stopping: false, report: null, reportParent: null, reportMarkdown: '', selectedRun: '', reportFilter: defaultReportFilter(), rerunOrigin: null, rerunTargetMismatch: false, navigationVersion: 0, comparison: null, comparisonRequest: 0, comparisonBusy: false, comparisonStatus: 'comparison.selectBoth', comparisonPins: { baseline: null, current: null }, comparisonSelectionGeneration: 0, comparisonValidation: null, history: { runs: [], nextCursor: null, pagesLoaded: 0, loaded: false, loading: false, request: 0, debounce: null, kind: null, error: null, updatesAvailable: false, pendingRecentUpdate: false, parentRunId: '' }, view: 'scenario' };
9
9
 
10
10
  function el(tag, className, value) {
11
11
  const node = document.createElement(tag);
@@ -109,6 +109,7 @@
109
109
  const ready = !!app.draft && !!app.script && !app.stale && !app.dirty;
110
110
  $('run-btn').disabled = !app.connected || !ready || !app.savedFile || !app.savedHash || !selectedCases().length || !$('review-checkbox').checked || !compatibleTarget() || !!active || app.busy;
111
111
  updateCaseSelection();
112
+ renderRerunHints();
112
113
  $('save-btn').disabled = !ready || app.busy;
113
114
  $('suite-download').disabled = !canDownloadSavedCases();
114
115
  $('flow-download').disabled = !canDownloadSourceMarkdown();
@@ -253,10 +254,19 @@
253
254
  }
254
255
  function renderRerunHints() {
255
256
  $('rerun-origin-hint').hidden = !app.rerunOrigin;
256
- if (app.rerunOrigin) $('rerun-origin-hint').textContent = t('app.rerunPrepared', app.rerunOrigin);
257
+ if (app.rerunOrigin) $('rerun-origin-hint').textContent = t(canLinkRerun() ? 'app.rerunPrepared' : 'app.rerunChanged', app.rerunOrigin);
257
258
  $('rerun-target-hint').hidden = !app.rerunTargetMismatch;
258
259
  if (app.rerunTargetMismatch) $('rerun-target-hint').textContent = t('app.rerunTargetMismatch');
259
260
  }
261
+ function canLinkRerun() {
262
+ const origin = app.rerunOrigin;
263
+ const target = selectedTarget();
264
+ const caseIds = selectedCases().map((item) => item.id);
265
+ return !!origin && !app.dirty && !app.stale && app.savedFile === origin.file &&
266
+ app.savedHash === origin.suiteHash && target?.name === origin.targetName &&
267
+ target.targetFingerprint === origin.targetFingerprint &&
268
+ caseIds.length === origin.caseIds.length && caseIds.every((id, index) => id === origin.caseIds[index]);
269
+ }
260
270
  function modelDescription(role) {
261
271
  const model = app.state?.models?.[role] || {};
262
272
  const explanation = t(role === 'planner' ? 'app.modelPlannerHelp' : 'app.modelAgentHelp');
@@ -293,23 +303,33 @@
293
303
  const button = el('button', 'button', t('app.load')); button.type = 'button'; button.addEventListener('click', () => loadSuite(suite.file)); row.append(copy, button); host.append(row);
294
304
  }
295
305
  }
296
- function historyFilters() { return { query: $('history-search').value.trim(), status: $('history-status-filter').value }; }
306
+ function historyFilters() { return { query: $('history-search').value.trim(), status: $('history-status-filter').value, parentRunId: app.history.parentRunId }; }
297
307
  function renderHistory() {
298
308
  const history = app.history;
299
309
  const host = $('history-list'); replace(host);
300
310
  host.setAttribute('aria-busy', String(history.loading));
301
311
  if (!history.runs.length) {
302
- const { query, status } = historyFilters();
312
+ const { query, status, parentRunId } = historyFilters();
303
313
  const key = history.loading ? 'history.loading' : history.error && !history.loaded ? 'history.loadError'
304
- : query ? 'app.historyNoSearchMatches' : status ? 'app.historyNoStatusMatches'
314
+ : parentRunId && status ? 'history.noRerunsWithStatus'
315
+ : parentRunId ? 'history.noReruns' : query ? 'app.historyNoSearchMatches' : status ? 'app.historyNoStatusMatches'
305
316
  : app.state?.active ? 'app.historyActiveEmpty' : 'app.historyEmpty';
306
317
  host.append(el('p', 'empty', t(key)));
307
318
  }
319
+ if (history.parentRunId) {
320
+ const relation = el('div', 'actions');
321
+ relation.append(el('p', 'hint', t('history.relatedTo', { runId: history.parentRunId })));
322
+ const clear = el('button', 'button quiet', t('history.showAllRuns'));
323
+ clear.type = 'button'; clear.dataset.action = 'clear-related-runs';
324
+ clear.addEventListener('click', () => { history.parentRunId = ''; refreshHistory(); });
325
+ relation.append(clear); host.prepend(relation);
326
+ }
308
327
  const pair = comparisonPair();
309
328
  for (const run of history.runs) {
310
329
  const row = el('div', 'list-row history-run-row'); row.dataset.runId = run.runId;
311
330
  const copy = el('div'); copy.append(el('strong', '', `${run.suiteId} · ${i18n.status(run.status)}`), el('small', '', t('app.runMeta', { date: formatDate(run.startedAt), target: targetDisplay(run.target), passed: run.passedCount ?? 0, total: run.caseCount ?? 0, id: run.runId })));
312
331
  const scope = selectionScope(run.selection); if (scope) copy.append(el('small', 'selection-scope', scope));
332
+ if (run.parentRunId) copy.append(el('small', 'hint', t('history.parentRun', { runId: run.parentRunId })));
313
333
  const actions = el('div', 'run-row-actions');
314
334
  const button = el('button', 'button', t('app.viewReport')); button.type = 'button'; button.dataset.action = 'view-report'; button.disabled = run.status === 'running' || run.status === 'stopping'; button.addEventListener('click', () => loadReport(run.runId)); actions.append(button);
315
335
  for (const [role, label] of [['baseline', 'comparison.useBaseline'], ['current', 'comparison.useCurrent']]) {
@@ -337,6 +357,7 @@
337
357
  const history = app.history;
338
358
  const append = cursor !== null;
339
359
  const params = new URLSearchParams({ query: filters.query, status: filters.status, limit: '50' });
360
+ if (filters.parentRunId) params.set('parentRunId', filters.parentRunId);
340
361
  if (append) params.set('cursor', cursor);
341
362
  try {
342
363
  const result = await api(`/api/runs?${params}`);
@@ -388,6 +409,14 @@
388
409
  renderHistory();
389
410
  void fetchHistoryPage(request, historyFilters(), history.nextCursor);
390
411
  }
412
+ function showRelatedRuns(runId) {
413
+ app.history.parentRunId = runId;
414
+ $('history-search').value = '';
415
+ $('history-status-filter').value = '';
416
+ view('history');
417
+ refreshHistory();
418
+ $('history-list').scrollIntoView({ behavior: 'smooth', block: 'start' });
419
+ }
391
420
  function recentRunsChanged() {
392
421
  const history = app.history;
393
422
  if (history.loading) { history.pendingRecentUpdate = true; return; }
@@ -679,7 +708,22 @@
679
708
  noticeKey('app.compileComplete');
680
709
  }); }
681
710
  async function save() { await work(async () => { if (!app.draft || app.dirty || app.stale) throw localizedError('app.needValidated'); const body = { suite: app.draft }; if (!app.boundSource && app.sourceFlow && (app.origin === 'imported' ? editableFlow(app.sourceFlow) === $('flow-input').value : app.sourceFlow === $('flow-input').value.trim())) body.flow = app.sourceFlow; const result = await api('/api/save', body); const saved = await api(`/api/suite?file=${encodeURIComponent(result.file)}`); $('flow-input').value = saved.flow || ''; setDraft(saved.suite, saved.script, 'library', saved.flow || '', result.file, saved.suiteHash || ''); noticeKey('app.savedSuite', { file: result.file }); await refresh(false); }); }
682
- async function run() { await work(async () => { if (!app.draft || !app.script || !app.savedFile || !app.savedHash || app.dirty || app.stale || !selectedCases().length || !$('review-checkbox').checked || !compatibleTarget()) throw localizedError('app.runNotReady'); const target = selectedTarget(); const body = { suite: app.savedFile, suiteHash: app.savedHash, targetName: target.name, targetFingerprint: target.targetFingerprint }; if (selectedCases().length < app.draft.cases.length) body.caseIds = selectedCases().map((item) => item.id); const result = await api('/api/run', body); noticeKey('app.runStarted', { id: result.operationId }); await refresh(false); }); }
711
+ async function run() {
712
+ await work(async () => {
713
+ if (!app.draft || !app.script || !app.savedFile || !app.savedHash || app.dirty || app.stale ||
714
+ !selectedCases().length || !$('review-checkbox').checked || !compatibleTarget()) {
715
+ throw localizedError('app.runNotReady');
716
+ }
717
+ const target = selectedTarget();
718
+ const body = { suite: app.savedFile, suiteHash: app.savedHash,
719
+ targetName: target.name, targetFingerprint: target.targetFingerprint };
720
+ if (selectedCases().length < app.draft.cases.length) body.caseIds = selectedCases().map((item) => item.id);
721
+ if (canLinkRerun()) body.parentRunId = app.rerunOrigin.runId;
722
+ const result = await api('/api/run', body);
723
+ noticeKey('app.runStarted', { id: result.operationId });
724
+ await refresh(false);
725
+ });
726
+ }
683
727
  async function stop() {
684
728
  if (app.stopping || !app.state?.active) return;
685
729
  if (app.state.active.kind === 'plan' && app.planning) app.planRequest += 1;
@@ -688,7 +732,7 @@
688
732
  catch (error) { showError(error); }
689
733
  finally { app.stopping = false; readiness(); }
690
734
  }
691
- async function loadReport(runId) { await work(async () => { const result = await api(`/api/report?runId=${encodeURIComponent(runId)}`); if (app.selectedRun !== runId) app.reportFilter = defaultReportFilter(); app.report = result.report; app.reportMarkdown = result.markdown; app.selectedRun = runId; renderReport(); readiness(); $('report-panel').hidden = false; $('report-panel').scrollIntoView({ behavior: 'smooth', block: 'start' }); }); }
735
+ async function loadReport(runId) { await work(async () => { const result = await api(`/api/report?runId=${encodeURIComponent(runId)}`); if (app.selectedRun !== runId) app.reportFilter = defaultReportFilter(); app.report = result.report; app.reportParent = result.parentRun || null; app.reportMarkdown = result.markdown; app.selectedRun = runId; renderReport(); readiness(); $('report-panel').hidden = false; $('report-panel').scrollIntoView({ behavior: 'smooth', block: 'start' }); }); }
692
736
  async function prepareFailedCases() { await work(async () => {
693
737
  const runId = app.selectedRun;
694
738
  const report = app.report;
@@ -709,7 +753,8 @@
709
753
  $('target-select').value = sameTarget ? target.name : '';
710
754
  await syncScriptForTarget();
711
755
  app.rerunTargetMismatch = !sameTarget;
712
- app.rerunOrigin = { runId: result.originRunId, count: result.caseIds.length };
756
+ app.rerunOrigin = { runId: result.originRunId, count: result.caseIds.length, caseIds: result.caseIds,
757
+ file: result.file, suiteHash: result.suiteHash, targetName: result.targetName, targetFingerprint: result.targetFingerprint };
713
758
  renderRerunHints(); targetDescription();
714
759
  noticeKey(sameTarget ? 'app.rerunPrepared' : 'app.rerunPreparedTarget', app.rerunOrigin);
715
760
  view('scenario');
@@ -875,6 +920,24 @@
875
920
  $('report-heading').textContent = `${report.runId} · ${i18n.status(report.status)} · ${targetDisplay(report.target)}`;
876
921
  const host = $('report-content'); replace(host);
877
922
  const meta = el('div', 'report-meta'); for (const value of [t('app.reportStatus', { status: i18n.status(report.status) }), t('app.reportTarget', { target: targetDisplay(report.target) }), t('app.reportStarted', { date: formatDate(report.startedAt) }), t('app.reportFinished', { date: formatDate(report.finishedAt) })]) meta.append(el('span', '', value)); const scope = selectionScope(report.selection); if (scope) meta.append(el('span', 'selection-scope', scope)); host.append(meta);
923
+ if (report.parentRunId) {
924
+ const parent = el('section', 'report-parent'); parent.append(el('p', 'hint', t(app.reportParent ? 'history.parentRun' : 'history.parentMissing', { runId: report.parentRunId })));
925
+ if (app.reportParent) {
926
+ const actions = el('div', 'actions');
927
+ const open = el('button', 'button quiet', t('history.openParent')); open.type = 'button'; open.dataset.action = 'open-parent'; open.addEventListener('click', () => loadReport(report.parentRunId));
928
+ const compare = el('button', 'button quiet', t('history.compareParent')); compare.type = 'button'; compare.dataset.action = 'compare-parent'; compare.addEventListener('click', () => {
929
+ selectComparisonRun('baseline', app.reportParent);
930
+ selectComparisonRun('current', { runId: report.runId, suiteId: report.suiteId, status: report.status, startedAt: report.startedAt, target: report.target, selection: report.selection });
931
+ void compareRuns();
932
+ });
933
+ actions.append(open, compare); parent.append(actions);
934
+ }
935
+ host.append(parent);
936
+ }
937
+ const related = el('button', 'button quiet', t('history.findReruns'));
938
+ related.type = 'button'; related.dataset.action = 'find-reruns';
939
+ related.addEventListener('click', () => showRelatedRuns(report.runId));
940
+ host.append(related);
878
941
  if (report.usage) host.append(el('p', 'hint', t('app.usage', { tokens: report.usage.modelTokens ?? t('app.unavailable'), cost: typeof report.usage.estimatedCostUsd === 'number' ? `$${report.usage.estimatedCostUsd.toFixed(4)}` : t('app.unavailable') })));
879
942
  if (report.errors?.length) host.append(el('p', 'report-errors', report.errors.join('\n')));
880
943
  const caseList = el('div'); caseList.id = 'report-case-list'; host.append(caseList);
@@ -914,7 +977,7 @@
914
977
  window.addEventListener('beforeunload', warnBeforeUnload);
915
978
  document.querySelectorAll('[data-view]').forEach((button) => button.addEventListener('click', () => view(button.dataset.view)));
916
979
  $('library-search').addEventListener('input', renderLibrary);
917
- $('history-search').addEventListener('input', () => refreshHistory(150));
980
+ $('history-search').addEventListener('input', () => { app.history.parentRunId = ''; refreshHistory(150); });
918
981
  $('history-status-filter').addEventListener('change', () => refreshHistory());
919
982
  $('history-refresh').addEventListener('click', () => refreshHistory());
920
983
  $('history-load-more').addEventListener('click', loadMoreHistory);
@@ -99,6 +99,11 @@
99
99
  'history.loadError': ['Could not load run history. Try Refresh history.', '실행 기록을 불러오지 못했습니다. 실행 기록 새로고침을 눌러 다시 시도하세요.'],
100
100
  'history.loadMoreError': ['Could not load more runs. Retry loading more.', '실행 기록을 더 불러오지 못했습니다. 다시 시도하세요.'],
101
101
  'history.updatesAvailable': ['Recent runs changed. Refresh history to update this list.', '최근 실행 기록이 변경됐습니다. 실행 기록을 새로고침해 목록을 갱신하세요.'],
102
+ 'history.findReruns': ['Find reruns of this run', '이 실행의 재실행 찾기'],
103
+ 'history.relatedTo': ['Reruns of {runId}', '실행 {runId}의 재실행'],
104
+ 'history.noReruns': ['No linked reruns match these filters.', '조건에 맞는 연결된 재실행이 없습니다.'],
105
+ 'history.noRerunsWithStatus': ['No linked reruns have this status. Choose another status or All statuses.', '이 상태에 해당하는 연결된 재실행이 없습니다. 다른 상태나 전체 상태를 선택하세요.'],
106
+ 'history.showAllRuns': ['Show all runs', '전체 실행 보기'],
102
107
  'comparison.title': ['Compare two runs', '실행 2건 비교'],
103
108
  'comparison.help': ['Select a baseline and current run from history or the lists below. Inspect detailed reports for evidence.', '실행 기록이나 아래 목록에서 기준 실행과 현재 실행을 선택하세요. 증거는 상세 보고서에서 확인하세요.'],
104
109
  'comparison.baseline': ['Baseline run', '기준 실행'],
@@ -161,6 +166,10 @@
161
166
  'comparison.error': ['Comparison failed: {message}', '비교 실패: {message}'],
162
167
  'comparison.runLabel': ['{date} · {suite} · {shortId} · {target} · {status} · {id}', '{date} · {suite} · {shortId} · {target} · {status} · {id}'],
163
168
  'history.report': ['Detailed report', '상세 보고서'],
169
+ 'history.parentRun': ['Prepared from run {runId}', '실행 {runId}에서 재실행 준비'],
170
+ 'history.parentMissing': ['Original run {runId} is unavailable. This report is still readable.', '원본 실행 {runId}을(를) 찾을 수 없습니다. 현재 보고서는 계속 볼 수 있습니다.'],
171
+ 'history.openParent': ['View original report', '원본 보고서 보기'],
172
+ 'history.compareParent': ['Compare with original', '원본과 비교'],
164
173
  'report.searchLabel': ['Search cases', '케이스 검색'],
165
174
  'report.searchPlaceholder': ['Search ID, title, expected result, or errors', 'ID, 제목, 기대 결과 또는 오류 검색'],
166
175
  'report.statusLabel': ['Case status', '케이스 상태'],
@@ -365,6 +374,7 @@
365
374
  'app.runStarted': ['Run started. Task ID: {id}', '실행을 시작했습니다. 작업 ID: {id}'],
366
375
  'app.rerunPrepared': ['Prepared {count} failed/error cases from run {runId}. Review the cases and target before starting a new run.', '실행 {runId}의 실패·오류 케이스 {count}개를 준비했습니다. 새 실행 전 케이스와 대상을 검토하세요.'],
367
376
  'app.rerunPreparedTarget': ['Prepared {count} failed/error cases from run {runId}. The target changed or is unavailable. Select and review a target before starting a new run.', '실행 {runId}의 실패·오류 케이스 {count}개를 준비했습니다. 대상이 변경되었거나 없습니다. 새 실행 전 대상을 선택하고 검토하세요.'],
377
+ 'app.rerunChanged': ['Run {runId} prepared {count} cases. The definition, target, or case selection changed, so the next result will be independent.', '실행 {runId}에서 케이스 {count}개를 준비했습니다. 정의·대상·선택 케이스가 달라져 다음 결과는 독립 실행으로 저장됩니다.'],
368
378
  'app.rerunTargetMismatch': ['The report target changed or is unavailable. Select a current target and review it before running.', '보고서의 대상이 변경되었거나 없습니다. 현재 대상을 선택하고 검토한 뒤 실행하세요.'],
369
379
  'app.stopRequested': ['Stop request sent. Checking the final state.', '중지 요청을 보냈습니다. 실제 종료 상태를 확인 중입니다.'],
370
380
  'app.reportStatus': ['Status {status}', '상태 {status}'],
@@ -79,8 +79,8 @@ class HTTPError extends Error {
79
79
  }
80
80
  function invalid(message = 'Invalid input.') { throw new HTTPError(400, message); }
81
81
  function notFound() { throw new HTTPError(404, 'The requested item was not found.'); }
82
- function runFilterHash(query, status) {
83
- return sha256(JSON.stringify([query, status]));
82
+ function runFilterHash(query, status, parentRunId) {
83
+ return sha256(JSON.stringify(parentRunId ? [query, status, parentRunId] : [query, status]));
84
84
  }
85
85
  // The cursor is independent of page size, so clients may change limit between pages.
86
86
  function encodeRunCursor(candidate, filterHash) {
@@ -419,6 +419,55 @@ export async function startUIServer(options) {
419
419
  markdown = renderSavedMarkdown(raw, markdown, locale);
420
420
  return { report: raw, ...(markdown === undefined ? {} : { markdown }) };
421
421
  }
422
+ async function preparedRerun(runId) {
423
+ const { report: previous } = await report(runId, false);
424
+ const matches = (await suites()).filter((item) => item.id === previous.suiteId);
425
+ if (matches.length === 0)
426
+ throw new HTTPError(409, 'No saved case file matches this report.');
427
+ if (matches.length > 1)
428
+ throw new HTTPError(409, 'Multiple saved case files match this report.');
429
+ const file = matches[0].file;
430
+ let selected;
431
+ try {
432
+ selected = await getSuite(file, true);
433
+ }
434
+ catch (error) {
435
+ if (error instanceof HTTPError && error.status === 404) {
436
+ throw new HTTPError(409, 'The saved case file or source flow was not found.');
437
+ }
438
+ if (error instanceof HTTPError && error.status === 400) {
439
+ throw new HTTPError(409, 'The saved case file or source flow is invalid.');
440
+ }
441
+ throw error;
442
+ }
443
+ const { suite } = selected;
444
+ if (sha256(`${JSON.stringify(suite, null, 2)}\n`) !== previous.suiteHash) {
445
+ throw new HTTPError(409, 'The saved case file changed since this run. Review it before rerunning.');
446
+ }
447
+ const available = new Set(suite.cases.map((item) => item.id));
448
+ if (previous.cases.some((item) => !item.id.trim() || !available.has(item.id)) ||
449
+ new Set(previous.cases.map((item) => item.id)).size !== previous.cases.length ||
450
+ (!previous.selection && previous.cases.length !== suite.cases.length)) {
451
+ throw new HTTPError(409, 'The report cases do not match the saved case file.');
452
+ }
453
+ if (previous.selection && (previous.selection.totalCases !== suite.cases.length ||
454
+ !isReportSelectionValid(previous.cases, previous.selection))) {
455
+ throw new HTTPError(409, 'The report selection does not match the saved case file.');
456
+ }
457
+ const failing = new Set(previous.cases.filter((item) => item.status === 'failed' || item.status === 'error').map((item) => item.id));
458
+ const caseIds = suite.cases.filter((item) => failing.has(item.id)).map((item) => item.id);
459
+ if (caseIds.length === 0)
460
+ throw new HTTPError(409, 'No failed or errored cases are available to rerun.');
461
+ const settings = await config();
462
+ const targetName = previous.target.name;
463
+ const expectedFingerprint = targetFingerprint(previous.target);
464
+ const currentTarget = Object.hasOwn(settings.targets, targetName) ? settings.targets[targetName] : undefined;
465
+ return { originRunId: runId, file, ...selected, caseIds, targetName,
466
+ targetFingerprint: expectedFingerprint,
467
+ targetMatches: Boolean(currentTarget &&
468
+ (suite.platform ?? 'web') === (currentTarget.kind === 'mobile' ? 'mobile' : 'web') &&
469
+ targetFingerprint(currentTarget) === expectedFingerprint) };
470
+ }
422
471
  async function runCandidates() {
423
472
  const root = await directory(['.flowqa', 'runs']);
424
473
  if (!root)
@@ -440,15 +489,18 @@ export async function startUIServer(options) {
440
489
  return { runId: item.runId, suiteId: item.suiteId, status: item.status, startedAt: item.startedAt,
441
490
  finishedAt: item.finishedAt, caseCount: item.cases.length,
442
491
  passedCount: item.cases.filter((entry) => entry.status === 'passed' || entry.status === 'flaky').length,
443
- target: item.target, ...(item.selection ? { selection: item.selection } : {}) };
492
+ target: item.target, ...(item.selection ? { selection: item.selection } : {}),
493
+ ...(item.parentRunId ? { parentRunId: item.parentRunId } : {}) };
444
494
  }
445
- async function runSummaries(limit, query = '', status = '', after) {
495
+ async function runSummaries(limit, query = '', status = '', after, parentRunId = '') {
446
496
  const history = [];
447
497
  for (const candidate of await runCandidates()) {
448
498
  if (after && (candidate.mtime > after.mtime || (candidate.mtime === after.mtime && candidate.id <= after.id)))
449
499
  continue;
450
500
  try {
451
501
  const { report: item } = await report(candidate.id, false);
502
+ if (parentRunId && item.parentRunId !== parentRunId)
503
+ continue;
452
504
  if (status && item.status !== status)
453
505
  continue;
454
506
  if (query && ![item.suiteId, item.runId, item.target.name].some((field) => field.toLowerCase().includes(query)))
@@ -496,20 +548,22 @@ export async function startUIServer(options) {
496
548
  throw new HTTPError(403, 'Invalid request origin.');
497
549
  if (request.method === 'GET') {
498
550
  if (url.pathname === '/api/state') {
551
+ const observedActive = active;
499
552
  const settings = await config();
500
553
  const history = (await runSummaries(RUN_HISTORY_LIMIT)).map(({ summary }) => summary);
554
+ const stateActive = observedActive ?? active;
501
555
  sendJSON(response, 200, { csrfToken: token,
502
556
  targets: Object.entries(settings.targets).map(([name, target]) => ({ name, ...target, targetFingerprint: targetFingerprint(target) })),
503
557
  models: { planner: modelState(settings.planner), agent: modelState(settings.agent) },
504
558
  runtime: { browserInstalled: await browserInstalled(), browserInstallCommand: BROWSER_INSTALL_COMMAND },
505
559
  suites: await suites(), runs: history,
506
- active: active?.kind === 'plan' ? { ...active, title: localizeProductMessage(active.title, locale) } : active,
560
+ active: stateActive?.kind === 'plan' ? { ...stateActive, title: localizeProductMessage(stateActive.title, locale) } : stateActive,
507
561
  ...(history[0] ? { lastRunId: history[0].runId } : {}),
508
562
  ...(lastError ? { lastError: localizeProductMessage(lastError, locale) } : {}) });
509
563
  return;
510
564
  }
511
565
  if (url.pathname === '/api/runs') {
512
- for (const key of ['query', 'status', 'limit', 'cursor']) {
566
+ for (const key of ['query', 'status', 'limit', 'cursor', 'parentRunId']) {
513
567
  if (url.searchParams.getAll(key).length > 1)
514
568
  invalid();
515
569
  }
@@ -520,14 +574,17 @@ export async function startUIServer(options) {
520
574
  const status = url.searchParams.get('status') ?? '';
521
575
  if (status && !RUN_STATUSES.has(status))
522
576
  invalid('Invalid run status.');
577
+ const parentRunId = url.searchParams.get('parentRunId') ?? '';
578
+ if (parentRunId && !RUN_ID.test(parentRunId))
579
+ invalid('Invalid parent run ID.');
523
580
  const rawLimit = url.searchParams.get('limit');
524
581
  if (rawLimit !== null && !/^(?:[1-9]|[1-4][0-9]|50)$/.test(rawLimit))
525
582
  invalid('Invalid run limit.');
526
583
  const limit = rawLimit === null ? RUN_HISTORY_LIMIT : Number(rawLimit);
527
- const filterHash = runFilterHash(normalizedQuery, status);
584
+ const filterHash = runFilterHash(normalizedQuery, status, parentRunId);
528
585
  const rawCursor = url.searchParams.get('cursor');
529
586
  const after = rawCursor === null ? undefined : decodeRunCursor(rawCursor, filterHash);
530
- const rows = await runSummaries(limit + 1, normalizedQuery, status, after);
587
+ const rows = await runSummaries(limit + 1, normalizedQuery, status, after, parentRunId);
531
588
  const runs = rows.slice(0, limit);
532
589
  sendJSON(response, 200, { runs: runs.map(({ summary }) => summary),
533
590
  nextCursor: rows.length > limit ? encodeRunCursor(runs.at(-1).candidate, filterHash) : null });
@@ -562,60 +619,25 @@ export async function startUIServer(options) {
562
619
  const runId = url.searchParams.get('runId');
563
620
  if (!runId)
564
621
  invalid('A run ID is required.');
565
- sendJSON(response, 200, await report(runId, true, locale));
622
+ const saved = await report(runId, true, locale);
623
+ let parentRun = null;
624
+ if (saved.report.parentRunId) {
625
+ try {
626
+ parentRun = runSummary((await report(saved.report.parentRunId, false)).report);
627
+ }
628
+ catch (error) {
629
+ if (!(error instanceof HTTPError && (error.status === 404 || error.status === 400)))
630
+ throw error;
631
+ }
632
+ }
633
+ sendJSON(response, 200, { ...saved, ...(saved.report.parentRunId ? { parentRun } : {}) });
566
634
  return;
567
635
  }
568
636
  if (url.pathname === '/api/rerun') {
569
637
  const runId = url.searchParams.get('runId');
570
638
  if (!runId)
571
639
  invalid('A run ID is required.');
572
- const { report: previous } = await report(runId, false);
573
- const matches = (await suites()).filter((item) => item.id === previous.suiteId);
574
- if (matches.length === 0)
575
- throw new HTTPError(409, 'No saved case file matches this report.');
576
- if (matches.length > 1)
577
- throw new HTTPError(409, 'Multiple saved case files match this report.');
578
- const file = matches[0].file;
579
- let selected;
580
- try {
581
- selected = await getSuite(file, true);
582
- }
583
- catch (error) {
584
- if (error instanceof HTTPError && error.status === 404) {
585
- throw new HTTPError(409, 'The saved case file or source flow was not found.');
586
- }
587
- if (error instanceof HTTPError && error.status === 400) {
588
- throw new HTTPError(409, 'The saved case file or source flow is invalid.');
589
- }
590
- throw error;
591
- }
592
- const { suite } = selected;
593
- if (sha256(`${JSON.stringify(suite, null, 2)}\n`) !== previous.suiteHash) {
594
- throw new HTTPError(409, 'The saved case file changed since this run. Review it before rerunning.');
595
- }
596
- const available = new Set(suite.cases.map((item) => item.id));
597
- if (previous.cases.some((item) => !item.id.trim() || !available.has(item.id)) ||
598
- new Set(previous.cases.map((item) => item.id)).size !== previous.cases.length ||
599
- (!previous.selection && previous.cases.length !== suite.cases.length)) {
600
- throw new HTTPError(409, 'The report cases do not match the saved case file.');
601
- }
602
- if (previous.selection && (previous.selection.totalCases !== suite.cases.length ||
603
- !isReportSelectionValid(previous.cases, previous.selection))) {
604
- throw new HTTPError(409, 'The report selection does not match the saved case file.');
605
- }
606
- const failing = new Set(previous.cases.filter((item) => item.status === 'failed' || item.status === 'error').map((item) => item.id));
607
- const caseIds = suite.cases.filter((item) => failing.has(item.id)).map((item) => item.id);
608
- if (caseIds.length === 0)
609
- throw new HTTPError(409, 'No failed or errored cases are available to rerun.');
610
- const settings = await config();
611
- const targetName = previous.target.name;
612
- const expectedFingerprint = targetFingerprint(previous.target);
613
- const currentTarget = Object.hasOwn(settings.targets, targetName) ? settings.targets[targetName] : undefined;
614
- sendJSON(response, 200, { originRunId: runId, file, ...selected, caseIds, targetName,
615
- targetFingerprint: expectedFingerprint,
616
- targetMatches: Boolean(currentTarget &&
617
- (suite.platform ?? 'web') === (currentTarget.kind === 'mobile' ? 'mobile' : 'web') &&
618
- targetFingerprint(currentTarget) === expectedFingerprint) });
640
+ sendJSON(response, 200, await preparedRerun(runId));
619
641
  return;
620
642
  }
621
643
  if (url.pathname === '/api/comparison') {
@@ -857,10 +879,11 @@ export async function startUIServer(options) {
857
879
  if (url.pathname === '/api/run') {
858
880
  enterMutation();
859
881
  try {
860
- const { suite: file, suiteHash, targetName, targetURL, targetFingerprint: reviewedFingerprint, caseIds } = parse(z.object({
882
+ const { suite: file, suiteHash, targetName, targetURL, targetFingerprint: reviewedFingerprint, caseIds, parentRunId } = parse(z.object({
861
883
  suite: z.string(), suiteHash: z.string().regex(/^[a-f0-9]{64}$/), targetName: idSchema,
862
884
  targetURL: z.string().optional(), targetFingerprint: z.string().regex(/^[a-f0-9]{64}$/).optional(),
863
885
  caseIds: z.array(idSchema).min(1).max(100).optional(),
886
+ parentRunId: z.string().regex(RUN_ID).optional(),
864
887
  }).strict(), body);
865
888
  const selected = await getSuite(file, true);
866
889
  if (selected.suiteHash !== suiteHash)
@@ -889,6 +912,17 @@ export async function startUIServer(options) {
889
912
  else if (target.kind === 'mobile' || !targetURL || target.url !== targetURL) {
890
913
  throw new HTTPError(409, 'The selected target changed. Review it again.');
891
914
  }
915
+ if (parentRunId) {
916
+ const prepared = await preparedRerun(parentRunId);
917
+ const actualIds = selectedIds ?? suite.cases.map((item) => item.id);
918
+ if (prepared.file !== file || prepared.suiteHash !== suiteHash ||
919
+ prepared.targetName !== targetName || !prepared.targetMatches ||
920
+ prepared.targetFingerprint !== targetFingerprint(target) ||
921
+ actualIds.length !== prepared.caseIds.length ||
922
+ actualIds.some((id, index) => id !== prepared.caseIds[index])) {
923
+ throw new HTTPError(409, 'The prepared rerun changed. Review it again or start an independent run.');
924
+ }
925
+ }
892
926
  const operationId = randomUUID();
893
927
  const abort = new AbortController();
894
928
  controller = abort;
@@ -899,7 +933,7 @@ export async function startUIServer(options) {
899
933
  const suiteSnapshot = structuredClone(suite);
900
934
  const configSnapshot = structuredClone(settings);
901
935
  runTask = Promise.resolve().then(() => run({ workspace, suite: suiteSnapshot, config: configSnapshot, targetName, signal: abort.signal,
902
- ...(selectedIds ? { caseIds: [...selectedIds] } : {}) }))
936
+ ...(selectedIds ? { caseIds: [...selectedIds] } : {}), ...(parentRunId ? { parentRunId } : {}) }))
903
937
  .then(() => undefined)
904
938
  .catch(() => { lastError = 'Could not complete the run. Check the local records.'; })
905
939
  .finally(() => { active = null; controller = undefined; busy = false; runTask = undefined; });
package/docs/ui.md CHANGED
@@ -72,6 +72,8 @@ From version `0.2.6`, **Case library** filters saved suites as you type in **Sea
72
72
 
73
73
  **Run history → Search runs** matches part of a suite ID, run ID, or target name. Matching ignores letter case and surrounding whitespace, and supports Korean target names. Search combines with **Run status**; clear the search to return to the selected status. From `0.6.0`, search covers all valid saved reports, including older records. Target URLs and individual case content are not searched. Queries are limited to 200 characters.
74
74
 
75
+ **Find reruns of this run** in a detailed report opens Run history filtered by the exact original run ID recorded in each child. The list can be paginated and narrowed by status. **Show all runs** clears the relation, and typing in Search runs switches back to the ordinary text search.
76
+
75
77
  Results load 50 at a time, newest first by run-directory modification time, with run ID as a stable tie-breaker. **Load more** appends older matches. The displayed count describes loaded matches, not a global total. End-of-results, loading, and retry guidance distinguish an empty result from an unavailable request. A failed page request preserves loaded rows so you can retry.
76
78
 
77
79
  Changing search or status restarts at the first page. The query, status, and loaded pages stay through navigation and language changes, and reset on page reload. The open report, its downloads, and scenario draft stay intact. A delayed response from an older query cannot replace newer results. Older reports support the same report downloads and failed/error-case preparation.
@@ -108,7 +110,9 @@ The UI finds exactly one saved case file with the report's suite ID, verifies it
108
110
 
109
111
  Successful preparation opens Scenario with the original source and failed/error selection. The prior target is selected only when its current name and settings still match the recorded target. Otherwise the target is cleared for explicit selection. Review confirmation is always cleared; inspect the selected cases and target before pressing **Run QA**. The normal execution-time file, source, and target checks still apply. Each selected case must establish its own starting state. Mobile target matching compares configured selectors, not physical device identity.
110
112
 
111
- The preparation notice identifies the original run. The next execution creates a separate ordinary report with its selected scope; it does not overwrite the original report or store a persistent parent-run link. Selection stays through navigation, language changes, and polling, but resets on page reload.
113
+ The preparation notice identifies the original run. If the saved suite, target settings, and selected case IDs still match that preparation when you press **Run QA**, the new report records the original run ID. Its detailed report can open the original or compare the two runs directly. The comparison marks cases excluded from the rerun as missing from the current report; it does not count them as passes. A failed, blocked, or interrupted rerun keeps the same original run ID. If the original report is deleted later, the new report remains readable and shows that the original is unavailable.
114
+
115
+ Changing the suite, target, or case selection starts an independent run without the original link. The UI explains this before execution. The server rechecks the saved inputs and original run at submission time. Selection stays through navigation, language changes, and polling, but resets on page reload. Reports saved by older versions remain readable without an original run ID.
112
116
 
113
117
  ### Compare two runs
114
118
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihyeon/flow-qa",
3
- "version": "0.10.2",
3
+ "version": "0.10.6",
4
4
  "license": "MIT",
5
5
  "author": "Hyeonse Im",
6
6
  "repository": {