{"record":{"id":"6fa52fe6eacbad6c","repo":"jackwener/OpenCLI","slug":"browser-bridge-native-click-support-is-required","errorCode":null,"errorMessage":"Browser Bridge native click support is required","messagePattern":"Browser Bridge native click support is required","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/midjourney/utils.js","lineNumber":1241,"sourceCode":"}\n\nexport async function clickVisibleControl(page, label) {\n  const target = unwrapEvaluateResult(await page.evaluate((wanted) => {\n    const visible = (element) => {\n      const rect = element.getBoundingClientRect();\n      return rect.width > 0 && rect.height > 0 && getComputedStyle(element).display !== 'none';\n    };\n    const button = [...document.querySelectorAll('button')].find((node) => visible(node) && (\n      node.textContent?.trim().replace(/\\s+/g, ' ') === wanted\n      || node.title === wanted\n      || node.getAttribute('aria-label') === wanted\n    ));\n    if (!button || button.disabled) return null;\n    const rect = button.getBoundingClientRect();\n    return { x: rect.left + rect.width / 2, y: rect.top + rect.height / 2 };\n  }, label));\n  if (!target) throw new CommandExecutionError(`Visible Midjourney control \"${label}\" was not found`);\n  if (typeof page.nativeClick !== 'function') throw new CommandExecutionError('Browser Bridge native click support is required');\n  await page.nativeClick(target.x, target.y);\n}\n\nexport async function clickComposerSubmit(page) {\n  const marked = unwrapEvaluateResult(await page.evaluate(() => {\n    document.querySelectorAll('[data-opencli-composer-submit]').forEach((node) => {\n      node.removeAttribute('data-opencli-composer-submit');\n    });\n    const visible = (element) => {\n      const rect = element.getBoundingClientRect();\n      return rect.width > 0 && rect.height > 0 && getComputedStyle(element).display !== 'none';\n    };\n    const input = document.querySelector('#desktop_input_bar');\n    const row = input?.parentElement;\n    if (!input || !row) return false;\n    const textSubmit = [...row.querySelectorAll('button')]\n      .find((button) => visible(button) && button.textContent?.trim() === 'Submit');\n    const following = [...row.querySelectorAll('button')].filter((button) => (","sourceCodeStart":1223,"sourceCodeEnd":1259,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/midjourney/utils.js#L1223-L1259","documentation":"CommandExecutionError thrown by the Midjourney CLI automation helpers when a browser automation page object does not implement nativeClick. The helper found a visible Midjourney control and computed its screen coordinates, but clicking it requires the Browser Bridge's OS-level (native) click API rather than synthetic DOM events, because some Midjourney UI controls ignore synthetic clicks. The library throws defensively instead of silently failing the interaction.","triggerScenarios":"Calling clickVisibleControl (e.g. clickComposerSubmit flows or 'Switch to Image') against a page object lacking a nativeClick function — typically when the page is driven by a plain automation client instead of the Browser Bridge-enabled bridge page.","commonSituations":"Using an older browser-bridge client version that predates nativeClick; constructing a fake/mock page in tests without nativeClick; pointing the CLI at a page wrapper from a different automation backend.","solutions":["Upgrade/enable the Browser Bridge so the page object exposes nativeClick(x, y)","Check feature support before calling: typeof page.nativeClick === 'function' and fall back to page.click on a marked selector otherwise","Update the opencli client package to match the CLI's expected bridge API","Fix test mocks/stubs to include a nativeClick no-op"],"exampleFix":"// before\nawait clickVisibleControl(page, 'Switch to Image');\n// after\nif (typeof page.nativeClick !== 'function') {\n  throw new Error('This command requires Browser Bridge native click support; update your bridge client');\n}\nawait clickVisibleControl(page, 'Switch to Image');","handlingStrategy":"type-guard","validationCode":"if (typeof page.nativeClick !== 'function') {\n  throw new Error('Browser Bridge nativeClick required; update your bridge client');\n}","typeGuard":"const supportsNativeClick = (page) => typeof page?.nativeClick === 'function';","tryCatchPattern":"try {\n  await clickVisibleControl(page, label);\n} catch (e) {\n  if (String(e.message).includes('native click support')) {\n    throw new Error('Upgrade/enable Browser Bridge to use this command');\n  }\n  throw e;\n}","preventionTips":["Pin the browser-bridge client version the CLI was built against","Feature-check nativeClick before any clickVisibleControl/toggleSettingsPanel call","Keep mocks in tests updated with nativeClick no-ops"],"tags":["browser-automation","api-compat","midjourney"],"backgroundTag":"missing-native-click-support","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}