Fix missing code navigation for blame on legacy files

What does this MR do and why?

legacyViewerLoaded did not account for BLAME_VIEWER, even though loadLegacyViewer already assigns blame HTML to legacySimpleViewer. This left the computed property false while blame was active, which defeated the early-return guard in loadLegacyViewer and prevented CodeIntelligence from rendering for blame on legacy files.

The problem is pre-existing, but became observable after inline blame was fixed for legacy files.

References :

  • Closes #605636
  • Related: !244836 (merged) added the BLAME_VIEWER branch in loadLegacyViewer that routes blame HTML into legacySimpleViewer. That routing is in master, and it's what makes this gap observable.
  • Related: #605627 (closed), the inline blame bug that MR fixed.

Differences and Changes :

Before :

  1. Blame HTML was fetched and stored in legacySimpleViewer.
  2. legacyViewerLoaded never checked BLAME_VIEWER, so it stayed false.
  3. The duplicate-fetch guard stopped blocking once loading finished, allowing re-fetches.
  4. <code-intelligence> and the code-navigation button never rendered in blame view.

After :

  1. Blame HTML is fetched and stored in legacySimpleViewer.
  2. legacyViewerLoaded now checks BLAME_VIEWER, so it becomes true once loaded.
  3. The duplicate-fetch guard blocks repeat requests as intended.
  4. <code-intelligence> and the code-navigation button render in blame view.

How to set up and validate locally :

Automated (no GDK required):

  1. yarn install --frozen-lockfile
  2. yarn jest spec/frontend/repository/components/blob_content_viewer_spec.js

The added test is renders CodeIntelligence when blame is active on load for a legacy file. I confirmed it catches the bug by reverting the source change and running it alone:

● Blob content viewer component › simple viewer › legacy viewers ›
  renders CodeIntelligence when blame is active on load for a legacy file

  Expected: true
  Received: false

Tests: 1 failed, 90 skipped, 91 total

With the fix in place, both the CE and EE suites pass:

PASS ee/spec/frontend/repository/components/blob_content_viewer_spec.js
PASS spec/frontend/repository/components/blob_content_viewer_spec.js

Tests: 91 passed, 91 total

Manual (optional, requires GDK):

  1. Open a legacy-type file with blame active, for example /<group>/<project>/-/blob/<ref>/go.mod?blame=1
  2. In Vue DevTools, select BlobContentViewer and inspect the computed property legacyViewerLoaded.
    • Before: false, even though the blame content has rendered
    • After: true
  3. Confirm <code-intelligence> is present in the DOM after the change and absent before.

MR acceptance checklist :

I went through the acceptance checklist. It's a small frontend change, so here's what's relevant:

  • Added a test, and confirmed it fails without the fix.
  • Follows the Vue style guide.
  • Changelog: fixed trailer is on the commit.
  • No user-facing strings, so nothing to translate.
  • CE-only change, so no EE: true trailer.
  • No performance, security, or database impact, only one extra boolean check in an existing computed property.

Let me know if you'd like anything expanded.

Merge request reports

Loading
Loading