- record a trace for each scenario run and upload it as trace.zip - add PLAYWRIGHT_TRACE_MODE (on, retain-on-failure, off) as the default - add a trace mode option to the run modal, stored per run and reused by repeat run; expose the default via GET /scenarios/run-defaults - accept traceMode in POST /scenarios/:id/run and run_scenario MCP tool - share one run modal component between scenario list and detail pages - git-ignore server/data
27 lines
825 B
TypeScript
27 lines
825 B
TypeScript
import { useEffect, useState } from 'react';
|
|
import { scenarios } from '../api';
|
|
import type { RunDefaults } from '../api';
|
|
|
|
// Server run defaults don't change while the app is open; fetch them once
|
|
let cached: Promise<RunDefaults> | null = null;
|
|
|
|
/**
|
|
* Returns the server-configured defaults for new scenario runs, or null
|
|
* while they are loading (or if the request failed).
|
|
*/
|
|
export function useRunDefaults(): RunDefaults | null {
|
|
const [defaults, setDefaults] = useState<RunDefaults | null>(null);
|
|
useEffect(() => {
|
|
let cancelled = false;
|
|
cached ??= scenarios.runDefaults().catch((err: unknown) => {
|
|
cached = null;
|
|
throw err;
|
|
});
|
|
cached.then((d) => !cancelled && setDefaults(d)).catch(() => undefined);
|
|
return () => {
|
|
cancelled = true;
|
|
};
|
|
}, []);
|
|
return defaults;
|
|
}
|