{"record":{"id":"dc211f750d34ff39","repo":"jackwener/OpenCLI","slug":"credits-usage-not-visible","errorCode":null,"errorMessage":"Credits Usage not visible","messagePattern":"Credits Usage not visible","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qoder/ui.js","lineNumber":185,"sourceCode":"        if (!res?.ok) throw new CommandExecutionError(res?.reason || 'Marketplace button not found', '');\n        return [{ Status: 'clicked' }];\n    },\n});\n\n// -------- credits --------\ncli({\n    site: 'qoder',\n    name: 'credits',\n    access: 'read',\n    description: 'Click \"Credits Usage\" and return the credits-usage display text.',\n    domain: 'localhost',\n    strategy: Strategy.UI,\n    browser: true,\n    args: [],\n    columns: ['Field', 'Value'],\n    func: async (page) => {\n        const res = await evaluateQoder(page, clickByTextScript(['Credits Usage']));\n        if (!res?.ok) throw new CommandExecutionError(res?.reason || 'Credits Usage not visible', '');\n        await page.wait(0.5);\n        // Try to read whatever appears.\n        const info = await evaluateQoder(page, `(() => {\n      ${IS_VISIBLE_JS}\n      // Find any dialog/popover that appeared.\n      const popovers = Array.from(document.querySelectorAll('[role=\"dialog\"], [class*=\"popover\"i], [class*=\"popup\"i]')).filter(isVisible);\n      if (!popovers.length) return null;\n      const pop = popovers[popovers.length - 1];\n      return (pop.innerText || pop.textContent || '').trim().replace(/\\\\s+/g, ' ').slice(0, 600);\n    })()`);\n        try { await page.evaluate(`document.body.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));`); } catch {}\n        return [\n            { Field: 'Status', Value: 'clicked' },\n            { Field: 'Info', Value: info || '(no popover detected after click)' },\n        ];\n    },\n});\n","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qoder/ui.js#L167-L203","documentation":"The Qoder 'credits' UI command clicks a visible 'Credits Usage' element to open the credits popover, then scrapes whatever dialog/popover appears. If the click script reports no matching visible element ({ok:false}), it throws CommandExecutionError('Credits Usage not visible'). The message means the credits entry point was not found/clickable in the Qoder UI.","triggerScenarios":"Running 'credits' when the status-bar 'Credits Usage' item is not rendered (UI still loading), hidden behind a modal, its label changed, or the text lives in a non-clickable element that clickByTextScript does not scan.","commonSituations":"Account not signed in so the credits widget is absent; Qoder version change moved the label (e.g. 'Usage' vs 'Credits Usage'); window minimized so rects are zero-size and isVisible fails; slow startup — command issued before the status bar mounted.","solutions":["Make sure you are signed into Qoder and the window is visible, then retry the credits command.","Increase the pre-click wait so the status bar finishes rendering.","Dismiss any open dialogs covering the status bar.","Check the live label via CDP DevTools and update the 'Credits Usage' pattern in clis/qoder/ui.js if it changed.","Retry once after a short delay — transitive render timing is a common cause."],"exampleFix":"// before\nconst res = await evaluateQoder(page, clickByTextScript(['Credits Usage']));\n// after: retry with wait before failing\nlet res = await evaluateQoder(page, clickByTextScript(['Credits Usage', 'Credits', 'Usage']));\nif (!res?.ok) { await page.wait(2); res = await evaluateQoder(page, clickByTextScript(['Credits Usage', 'Credits', 'Usage'])); }","handlingStrategy":"validation","validationCode":"async function creditsWidgetPresent(page) {\n  const probe = await page.evaluate(`(() => {\n    const el = Array.from(document.querySelectorAll('button, [role=\"button\"], a, span, div'))\n      .find(e => (e.innerText||'').toLowerCase().includes('credits'));\n    return !!el && el.getBoundingClientRect().width > 0;\n  })()`);\n  if (probe !== true) throw new Error('Credits widget not rendered — sign in / wait for UI');\n}","typeGuard":"function isClickResult(res) {\n  return res !== null && typeof res === 'object' && typeof res.ok === 'boolean';\n}","tryCatchPattern":"try {\n  await cli.run(['qoder', 'credits']);\n} catch (e) {\n  if (String(e.message).includes('Credits Usage not visible')) {\n    console.error('Credits widget unavailable: check Qoder sign-in state and UI load.');\n  } else throw e;\n}","preventionTips":["Confirm you are signed in to Qoder before querying credits","Increase the pre-click wait on slow machines","Verify the exact rendered label after Qoder updates","Run commands against a visible (non-minimized) window"],"tags":["ui-automation","electron","cdp","selector-not-found"],"backgroundTag":"ui-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}