Fix AiGenie throwing when container element is absent

What does this MR do and why?

The AiGenie component listens to the global selectionchange event and calls document.querySelector(containerSelector) on every selection change. When the result is null — which happens when the blob content hasn't finished rendering yet (async load) or when the component is being torn down during navigation — the handler threw a hard Error, producing a Sentry event for every affected user.

This MR replaces the throw with a silent bail-out: hide the button and return early. The next selectionchange event will re-check once the DOM is ready, so no functionality is lost.

Also removes the now-unused GENIE_NO_CONTAINER_ERROR i18n constant.

References

Screenshots or screen recordings

No visible UI change — the fix prevents an error from being thrown; the button simply stays hidden until the container is available.

How to set up and validate locally

  1. Open any blob viewer page (e.g. http://localhost:3000/gitlab-org/gitlab/-/blob/master/README.md).
  2. Select some text — the "Explain code" button should appear as before.
  3. Confirm no errors appear in the browser console when the page first loads (before the blob content renders).

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports

Loading
Loading