autokap 1.7.2 → 1.7.3

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.
Files changed (2) hide show
  1. package/dist/cli-runner.js +30 -0
  2. package/package.json +1 -1
@@ -223,6 +223,13 @@ export async function runCapture(options) {
223
223
  // AUT-149: collect structured logs + progress events for export on failure.
224
224
  const logCollector = new LogCollector();
225
225
  logCollector.start();
226
+ // Register this local run server-side so the dashboard shows an "En cours"
227
+ // badge on the preset while it captures. Best-effort + local-only: skip dry
228
+ // runs and cloud runs (AUTOKAP_RUN_ID is set on cloud runners, which own
229
+ // their own capture_runs row). A failure here must never block the capture.
230
+ if (!options.dryRun && !process.env.AUTOKAP_RUN_ID) {
231
+ await postRunStart(config, runId, program.presetId, program.variants.length, options.env);
232
+ }
226
233
  const runOptions = {
227
234
  recoveryChain,
228
235
  abortSignal: options.abortSignal,
@@ -664,6 +671,29 @@ function getProgramFetchRetryDelayMs(attempt) {
664
671
  function sleep(ms) {
665
672
  return new Promise((resolve) => setTimeout(resolve, ms));
666
673
  }
674
+ // Best-effort registration of a local run at its start, so the dashboard can
675
+ // surface an "En cours" badge on the preset while the capture is in flight.
676
+ // Never throws — a registration failure must not abort the capture.
677
+ async function postRunStart(config, runId, presetId, variantCount, env) {
678
+ try {
679
+ const response = await fetch(`${config.apiBaseUrl}/api/cli/runs`, {
680
+ method: 'POST',
681
+ headers: {
682
+ 'Authorization': `Bearer ${config.apiKey}`,
683
+ 'Content-Type': 'application/json',
684
+ },
685
+ body: JSON.stringify({ runId, presetId, variantCount, env }),
686
+ signal: AbortSignal.timeout(10_000),
687
+ });
688
+ if (!response.ok) {
689
+ logger.warn(`[capture] Run registration failed (HTTP ${response.status}); the dashboard "in progress" badge may not appear`);
690
+ }
691
+ }
692
+ catch (err) {
693
+ const message = err instanceof Error ? err.message : String(err);
694
+ logger.warn(`[capture] Run registration error: ${message}`);
695
+ }
696
+ }
667
697
  async function uploadResults(config, program, result, runId = randomUUID()) {
668
698
  const artifactJobs = result.variantResults.flatMap((variant) => {
669
699
  const variantSpec = program.variants.find((entry) => entry.id === variant.variantId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "autokap",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "AI-powered CLI tool for capturing clean screenshots of websites",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",