@ihyeon/flow-qa 0.10.10 → 0.10.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/src/i18n.js CHANGED
@@ -50,6 +50,7 @@ const koreanMessages = {
50
50
  'Invalid source flow path.': '원본 플로우 경로가 올바르지 않습니다.',
51
51
  'Only JSON requests are supported.': 'JSON 요청만 사용할 수 있습니다.',
52
52
  'The request body is too large.': '요청 본문이 너무 큽니다.',
53
+ 'The saved case file is too large.': '저장할 케이스 파일이 너무 큽니다.',
53
54
  'Invalid workspace path.': '작업 공간 경로가 올바르지 않습니다.',
54
55
  'Could not read the Flow QA configuration.': 'Flow QA 설정을 읽을 수 없습니다.',
55
56
  'Invalid configuration file path.': '설정 파일 경로가 올바르지 않습니다.',
@@ -5,6 +5,9 @@
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
+ let refreshRequest = 0;
9
+ let appliedRefreshRequest = 0;
10
+ let pendingSettingsRefresh = 0;
8
11
  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: '', reportRequest: 0, reportLoading: false, 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
12
 
10
13
  function el(tag, className, value) {
@@ -627,15 +630,29 @@
627
630
  readiness();
628
631
  }
629
632
  async function refresh(full = false) {
630
- const previousActive = app.state?.active;
633
+ const request = ++refreshRequest;
634
+ if (full) pendingSettingsRefresh = request;
631
635
  let state;
632
- try { state = await api('/api/state'); } catch (error) { app.connected = false; renderActive(); throw error; }
636
+ try { state = await api('/api/state'); }
637
+ catch (error) {
638
+ if (request !== refreshRequest) return;
639
+ appliedRefreshRequest = request;
640
+ app.connected = false;
641
+ renderActive();
642
+ throw error;
643
+ }
644
+ if (request < appliedRefreshRequest) return;
645
+ appliedRefreshRequest = request;
646
+ const previousActive = app.state?.active;
633
647
  const initialize = !app.state;
634
648
  const libraryChanged = JSON.stringify(app.state?.suites) !== JSON.stringify(state.suites);
635
649
  const historyChanged = JSON.stringify(app.state?.runs) !== JSON.stringify(state.runs);
636
650
  app.state = state; app.connected = true;
637
651
  renderActive(); if (libraryChanged) renderLibrary(); if (historyChanged) { recentRunsChanged(); renderComparisonOptions(); }
638
- if (full || initialize) { targetOptions(); modelForms(); }
652
+ // A newer poll can satisfy the pending settings refresh.
653
+ const refreshSettings = pendingSettingsRefresh !== 0 && request >= pendingSettingsRefresh;
654
+ if (refreshSettings) pendingSettingsRefresh = 0;
655
+ if (refreshSettings || initialize) { targetOptions(); modelForms(); }
639
656
  if (previousActive?.kind === 'run' && !state.active) { if (state.lastError) notice(state.lastError, true); else noticeKey('app.runEnded'); }
640
657
  if (state.lastError && state.lastError !== app.lastError) { app.lastError = state.lastError; notice(state.lastError, true); }
641
658
  await validateComparisonSelection(state);
@@ -680,7 +697,7 @@
680
697
  const jsonFiles = files.filter((file) => file.name.toLowerCase().endsWith('.json'));
681
698
  const markdownFiles = files.filter((file) => file.name.toLowerCase().endsWith('.md'));
682
699
  if (files.length > 2 || jsonFiles.length !== 1 || markdownFiles.length > 1 || jsonFiles.length + markdownFiles.length !== files.length) throw localizedError('app.importSelection');
683
- if (jsonFiles[0].size > 256 * 1024 || (markdownFiles[0] && markdownFiles[0].size > 128 * 1024)) throw localizedError('app.importTooLarge');
700
+ if (jsonFiles[0].size > 1024 * 1024 || (markdownFiles[0] && markdownFiles[0].size > 128 * 1024)) throw localizedError('app.importTooLarge');
684
701
  let suite;
685
702
  try { suite = JSON.parse(await jsonFiles[0].text()); } catch { throw localizedError('app.invalidJson'); }
686
703
  const flow = markdownFiles[0] ? await markdownFiles[0].text() : undefined;
@@ -366,7 +366,7 @@
366
366
  'app.compileStale': ['Scenario changed. Generate cases again or reload them from the library.', '시나리오가 변경됐습니다. 다시 생성하거나 보관함의 케이스를 불러오세요.'],
367
367
  'app.invalidJson': ['Check the JSON syntax. Use double quotes around property names and strings, and check commas and brackets.', 'JSON 구문을 확인하세요. 속성 이름과 문자열은 큰따옴표로 감싸고 쉼표·괄호를 확인해 주세요.'],
368
368
  'app.importSelection': ['Select exactly one TC JSON and at most one source Markdown file.', 'TC JSON 파일 1개와 원본 Markdown 파일 최대 1개를 선택하세요.'],
369
- 'app.importTooLarge': ['The selected files are too large to import. JSON must be at most 256 KiB, Markdown at most 128 KiB, and the request at most 256 KiB.', '선택한 파일이 너무 큽니다. JSON은 최대 256 KiB, Markdown은 최대 128 KiB, 요청 전체는 최대 256 KiB여야 합니다.'],
369
+ 'app.importTooLarge': ['The selected files are too large to import. JSON files can be up to 1 MiB, Markdown files up to 128 KiB, and the combined request up to 256 KiB.', '선택한 파일이 너무 큽니다. JSON 파일은 최대 1 MiB, Markdown 파일은 최대 128 KiB, 요청 전체는 최대 256 KiB여야 합니다.'],
370
370
  'app.importComplete': ['Case copy imported. Review the cases and source, then save before running.', '케이스 복사본을 가져왔습니다. 케이스와 원본을 검토한 뒤 실행 전에 저장하세요.'],
371
371
  'app.compileComplete': ['JSON validated and script generated. The linked source scenario was kept.', 'JSON 검증과 스크립트 생성이 완료됐습니다. 연결된 원본 시나리오는 유지됩니다.'],
372
372
  'app.savedSuite': ['Cases saved to a separate file: {file}. Review them again before running.', '케이스를 별도 파일로 저장했습니다: {file}. 실행 전 내용을 다시 검토하세요.'],
@@ -28,7 +28,7 @@ import { CONFIG_FILE, sha256, withConfigLock } from "../workspace.js";
28
28
  const MAX_BODY = 256 * 1024;
29
29
  const MAX_FLOW = 128 * 1024;
30
30
  const MAX_CONFIG = 256 * 1024;
31
- const MAX_SUITE = 512 * 1024;
31
+ const MAX_SUITE = 1024 * 1024; // Includes indentation added when saving validated request data.
32
32
  const MAX_REPORT = MAX_SAVED_REPORT_BYTES;
33
33
  const MAX_STATIC = 4 * 1024 * 1024;
34
34
  const PLAN_TIMEOUT_MS = 65_000;
@@ -823,22 +823,26 @@ export async function startUIServer(options) {
823
823
  const { suite: inputSuite, flow } = parse(z.object({ suite: suiteSchema, flow: z.string().min(1).optional() }).strict(), body);
824
824
  if (flow !== undefined && Buffer.byteLength(flow) > MAX_FLOW)
825
825
  throw new HTTPError(413, 'The flow is too large.');
826
- if (flow === undefined)
826
+ const source = flow === undefined ? undefined : { file: `${inputSuite.id}-${randomUUID()}.md`, flow };
827
+ if (!source)
827
828
  await readSource(inputSuite, true);
829
+ const suite = source
830
+ ? suiteSchema.parse({ ...inputSuite, source: { file: `flows/${source.file}`, sha256: sha256(source.flow) } })
831
+ : inputSuite;
832
+ const content = `${JSON.stringify(suite, null, 2)}\n`;
833
+ if (Buffer.byteLength(content) > MAX_SUITE)
834
+ throw new HTTPError(413, 'The saved case file is too large.');
828
835
  const casesRoot = await directory(['cases'], true);
829
836
  if (!casesRoot)
830
837
  throw new HTTPError(500, 'Could not prepare the cases directory.');
831
- let suite = inputSuite;
832
- if (flow !== undefined) {
838
+ if (source) {
833
839
  const flowsRoot = await directory(['flows'], true);
834
840
  if (!flowsRoot)
835
841
  throw new HTTPError(500, 'Could not prepare the flows directory.');
836
- const flowFile = `${suite.id}-${randomUUID()}.md`;
837
- await writeNew(flowsRoot, flowFile, flow);
838
- suite = suiteSchema.parse({ ...suite, source: { file: `flows/${flowFile}`, sha256: sha256(flow) } });
842
+ await writeNew(flowsRoot, source.file, source.flow);
839
843
  }
840
844
  const file = `${suite.id}-${randomUUID()}.json`;
841
- await writeNew(casesRoot, file, `${JSON.stringify(suite, null, 2)}\n`);
845
+ await writeNew(casesRoot, file, content);
842
846
  return { file };
843
847
  });
844
848
  sendJSON(response, 200, result);
package/docs/ui.md CHANGED
@@ -130,7 +130,7 @@ Swap reverses the baseline and current selections. Changing either selection cle
130
130
 
131
131
  From version `0.2.1`, select a `flow-qa/suite-1` JSON file and, when it declares a source, its Markdown file in case review, then choose **Import case files**. The two file controls let you select files from different folders. For an error-to-test export, select `cases/error-to-test.json` and `flows/error-to-test.md`. A JSON file without a source can be imported alone or with a Markdown file.
132
132
 
133
- Import validates the suite and checks the selected Markdown against its declared SHA-256 before replacing the draft. Cancelling or selecting invalid files preserves the current draft. The Markdown text, including line endings and trailing whitespace, is retained for saving. Markdown is limited to 128 KiB; the combined JSON request is limited to 256 KiB.
133
+ Import validates the suite and checks the selected Markdown against its declared SHA-256 before replacing the draft. Cancelling or selecting invalid files preserves the current draft. The Markdown text, including line endings and trailing whitespace, is retained for saving. Case JSON files can be up to 1 MiB and Markdown files up to 128 KiB. The combined request after JSON parsing and serialization can be up to 256 KiB.
134
134
 
135
135
  This creates an unsaved review copy. Choose **Save cases separately**, review the cases, and confirm review before running. Unresolved questions remain blocked. Saving assigns a new workspace source path and hash; it does not overwrite the input files or import `provenance.json`. If you need error-to-test `verify` / `link-run` provenance, keep the original bundle and use its original suite instead of this saved copy.
136
136
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihyeon/flow-qa",
3
- "version": "0.10.10",
3
+ "version": "0.10.12",
4
4
  "license": "MIT",
5
5
  "author": "Hyeonse Im",
6
6
  "repository": {