{"record":{"id":"9b4a369e984b1c6d","repo":"pbakaus/impeccable","slug":"impeccable-refusing-to-render-empty-variant-cycl","errorCode":null,"errorMessage":"[impeccable] Refusing to render empty variant cycling state:","messagePattern":"\\[impeccable\\] Refusing to render empty variant cycling state:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"skill/scripts/live-browser.js","lineNumber":3044,"sourceCode":"    pickerEl.style.opacity = '0';\n    pickerEl.style.transform = 'scale(0.96) translateY(4px)';\n    setTimeout(() => { if (pickerEl) pickerEl.style.display = 'none'; }, 180);\n  }\n\n  function ensureCyclingRenderable(reason) {\n    if (arrivedVariants > 0) {\n      if (visibleVariant < 1 || visibleVariant > arrivedVariants) visibleVariant = 1;\n      return true;\n    }\n    recoverEmptyCycling(reason);\n    return false;\n  }\n\n  function recoverEmptyCycling(reason) {\n    if (recoveringEmptyCycling) return;\n    recoveringEmptyCycling = true;\n    try {\n      console.warn('[impeccable] Refusing to render empty variant cycling state:', reason);\n      const message = 'No variants were mounted. Please try again.';\n      if (svelteComponentSession?.sessionId === currentSessionId) {\n        resetSvelteComponentSession(currentSessionId, message);\n        return;\n      }\n      cleanup();\n      showToast(message, 5000);\n    } finally {\n      recoveringEmptyCycling = false;\n    }\n  }\n\n  //\n  // Params panel (per-variant coarse controls)\n  //\n  // Variants may declare a parameter manifest via a JSON attribute on the\n  // variant wrapper:\n  //","sourceCodeStart":3026,"sourceCodeEnd":3062,"githubUrl":"https://github.com/pbakaus/impeccable/blob/2bc2879276c1f321a53c4ca99d3371e411329b52/skill/scripts/live-browser.js#L3026-L3062","documentation":"Guard against mounting a variant cycler with zero variants. recoverEmptyCycling logs the reason and recovers: if the Svelte session matches, it resets it with a 'No variants were mounted' message; otherwise it runs full cleanup. Rendering would otherwise produce a stuck/empty UI.","triggerScenarios":"Variant cycling state is about to render with an empty variant list (e.g. all candidate variants failed to mount, params parsed to [], or anchors missing); recoverEmptyCycling at skill/scripts/live-browser.js:3044 intercepts and warns.","commonSituations":"data-impeccable-params was invalid JSON so no variants were derived; every generated variant failed to inject into the page; a framework re-render wiped the mounted variants before cycling started.","solutions":["Fix the invalid/empty data-impeccable-params attribute so variants exist (see related JSON warning).","Retry the generate action; transient mounting races recover on the next attempt.","Reload the page if a framework re-render keeps wiping mounted variants.","Check the logged `reason` argument — it names which empty condition triggered."],"exampleFix":"// before: params attr missing/invalid => empty variants\n<div data-impeccable-params=\"not json\">\n// after\n<div data-impeccable-params=\"[{\\\"label\\\":\\\"A\\\"},{\\\"label\\\":\\\"B\\\"}]\">","handlingStrategy":"validation","validationCode":"function hasVariantsToCycle(state) {\n  return Array.isArray(state?.variants) && state.variants.length > 0;\n}\nif (!hasVariantsToCycle(cyclingState)) recoverEmptyCycling('variants array empty');","typeGuard":"function isNonEmptyVariantList(v) {\n  return Array.isArray(v) && v.length > 0 && v.every(x => x != null);\n}","tryCatchPattern":"try {\n  renderCyclingState(state);\n} catch (err) {\n  recoverEmptyCycling(err);\n}","preventionTips":["Validate data-impeccable-params parses to a non-empty array before generating","Abort generation early when zero variants mounted instead of entering cycling","Re-check mounted variants after framework re-renders before cycling"],"tags":["variants","empty-state","browser","recovery"],"backgroundTag":"empty-required-field","analyzedSha":"2bc2879276c1f321a53c4ca99d3371e411329b52","analyzedAt":"2026-09-08T04:51:14.109Z","contentChangedAt":"2026-09-08T04:51:14.109Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}