{"record":{"id":"7ce1d2de6ceede5b","repo":"jackwener/OpenCLI","slug":"no-account-button-detected-pass-username-name","errorCode":null,"errorMessage":"No account button detected. Pass --username <name> explicitly.","messagePattern":"No account button detected\\. Pass --username <name> explicitly\\.","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qoder/ui.js","lineNumber":274,"sourceCode":"        // for any short button text that doesn't match other known controls.\n        let label = String(kwargs?.username || '').trim();\n        if (!label) {\n            // Heuristic discovery.\n            label = await evaluateQoder(page, `(() => {\n        ${IS_VISIBLE_JS}\n        const btns = Array.from(document.querySelectorAll('button')).filter(isVisible);\n        const known = new Set(['Pin', 'Copy', 'New Quest', 'Search', 'Settings', 'View all', 'Knowledge', 'Marketplace', 'Credits Usage', 'Open Editor', 'Add Workspace', 'More Actions', 'Send message', 'Prompt Enhance', 'Voice input', 'button']);\n        const candidate = btns.find((b) => {\n          const tx = (b.innerText || '').trim();\n          if (!tx || tx.length > 30 || tx.includes('⌘') || known.has(tx)) return false;\n          if (/^(New|Open|Add|Save|Edit|Cancel|OK|Close)/.test(tx)) return false;\n          return true;\n        });\n        return candidate ? (candidate.innerText || '').trim() : '';\n      })()`);\n        }\n        if (!label) {\n            throw new CommandExecutionError('No account button detected. Pass --username <name> explicitly.', '');\n        }\n        // Click the username button\n        const clickRes = await evaluateQoder(page, clickByTextScript([label], { exact: true, maxLen: 60 }));\n        if (!clickRes?.ok) throw new CommandExecutionError(`Click on account button \"${label}\" failed`, '');\n        await page.wait(0.5);\n        const items = requireArrayResult(await evaluateQoder(page, `(() => {\n      ${IS_VISIBLE_JS}\n      const popovers = Array.from(document.querySelectorAll('[role=\"menu\"], [role=\"dialog\"], [class*=\"popover\"i], [class*=\"dropdown\"i]')).filter(isVisible)\n        .filter((el) => { const r = el.getBoundingClientRect(); return r.width < 500 && r.height < 600; });\n      if (!popovers.length) return [];\n      const pop = popovers[popovers.length - 1];\n      return Array.from(pop.querySelectorAll('button, [role=\"menuitem\"], a'))\n        .filter(isVisible)\n        .map((b) => (b.innerText || b.textContent || '').trim().replace(/\\\\s+/g, ' '))\n        .filter(Boolean);\n    })()`), 'qoder account');\n        try { await page.evaluate(`document.body.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));`); } catch {}\n        const rows = [{ Field: 'Username', Value: label }];","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qoder/ui.js#L256-L292","documentation":"In the Qoder 'account' flow, the adapter tries to auto-detect the logged-in username by scraping visible candidate buttons; if no candidate label is found (label is empty), it throws CommandExecutionError('No account button detected. Pass --username <name> explicitly.'). The library throws this because it cannot safely guess which button is the account menu.","triggerScenarios":"Running the account command without --username when: the user is not signed in to Qoder, the account widget shows only an avatar icon with no text, the account popover is behind a modal, or the heuristic that extracts candidate.innerText returns an empty string.","commonSituations":"Fresh Qoder install / logged-out state; account button rendered as an icon-only avatar (no innerText); UI not yet rendered when the probe runs; Qoder update moved the account control out of the scanned container.","solutions":["Pass the username explicitly: run the command with --username <name> as the error instructs.","Sign in to Qoder first, then retry without the flag.","Wait for the UI to fully render before running the account command.","If the button is icon-only, the auto-detection cannot work — always use --username in that setup.","Update the detection script in clis/qoder/ui.js if Qoder moved the account control."],"exampleFix":"// before\nopencli qoder account\n// after (explicit username)\nopencli qoder account --username alice","handlingStrategy":"validation","validationCode":"// Validate inputs before invoking the account command\nfunction assertAccountArgs(args) {\n  if (!args.username) {\n    throw new Error('Auto-detection may fail (icon-only avatar / logged out). Pass --username explicitly.');\n  }\n  if (typeof args.username !== 'string' || !args.username.trim()) {\n    throw new Error('--username must be a non-empty string matching the UI display name.');\n  }\n}","typeGuard":"function hasUsernameArg(args) {\n  return typeof args === 'object' && args !== null &&\n    typeof args.username === 'string' && args.username.trim().length > 0;\n}","tryCatchPattern":"try {\n  await cli.run(['qoder', 'account']);\n} catch (e) {\n  if (String(e.message).includes('No account button detected')) {\n    await cli.run(['qoder', 'account', '--username', process.env.QODER_USER]);\n  } else throw e;\n}","preventionTips":["Always pass --username in scripts/CI instead of relying on auto-detection","Sign in to Qoder before running account commands","Set an env var (e.g. QODER_USER) so the fallback username is always available","Remember icon-only avatar buttons cannot be auto-detected by text"],"tags":["ui-automation","electron","auto-detection","missing-argument"],"backgroundTag":"ui-element-not-found","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}