Skip to content

fix(details): share one message handler across both details-panel entry points - #300

Open
X-Guardian wants to merge 1 commit into
eFAILution:betafrom
X-Guardian:fix/details-panel-shared-message-handler
Open

X-Guardian wants to merge 1 commit into
eFAILution:betafrom
X-Guardian:fix/details-panel-shared-message-handler

Conversation

@X-Guardian

Copy link
Copy Markdown
Contributor

Summary

  • The component-details webview is opened two ways — the Component Browser's Details button and a hover's View Full Component Details — and each path carried its own full copy of the panel's message handler. Same three inbound commands, same four outbound, same HTML, but the copies had drifted and each was missing a field the other sent.
  • Consolidates both into one registerDetailsPanelMessageHandler on ComponentBrowserProvider. Net −97 lines.
  • Fixes the Template File link disappearing after a version switch in the detached panel, and closes a latent bug — a stale currentVersion reported after a version switch.
  • Link related issue(s): bug: details panel: Template File link disappears after changing version in the detached view #299

Change Type

  • feat
  • fix
  • refactor
  • docs
  • test
  • chore

Context

User-facing impact

  • The Template File link no longer disappears. In the detached (hover) panel, switching version dropped the link, because only the browser path attached templateFileUrl to componentDetailsUpdated. The webview hides the element when the field is absent, so the link vanished until the panel was reopened.
  • Refresh Versions after a version switch now reports the version on screen. The browser path never replaced its component after versionChanged, so a later fetchVersions sent the originally-opened currentVersion.

GitLab scope

  • gitlab.com
  • self-managed GitLab
  • both (no change to GitLab interaction; message routing and payload shaping only)

Affected areas

  • Component Browser (details panel, both entry points)
  • Hover provider (the detached "View Full Component Details" panel)
  • Completion provider
  • Validation provider
  • Cache and refresh behavior
  • GitLab API calls/auth/token storage
  • Docs only

What changed by bucket

Bucket Files Approach
Shared handler src/providers/componentBrowserProvider.ts New registerDetailsPanelMessageHandler(panel, component, options) holding the merged behaviour of both copies, plus a DetailsPanelOptions interface. The component is held in a mutable local so a versionChanged round trip replaces it — the detached path's behaviour, now applied to both. _hoverContext is carried across that reassignment so an edit-in-place after a version switch still edits rather than inserting anew.
Browser call site src/providers/componentBrowserProvider.ts showComponentDetails's inline if/else-if chain (~105 lines) collapses to one call.
Detached call site src/extension.ts The switch (~137 lines) collapses to one call passing { detachedFrom: originalEditor }, dropping the imports it no longer needs.
Editor adoption src/providers/componentBrowserProvider.ts The detached path builds its own ComponentBrowserProvider and never calls show(), so originalEditor is unset and insertComponent would refuse to insert. The handler adopts the editor passed via detachedFrom at registration, so insertComponent behaves identically on both paths.
Dead code src/providers/componentBrowserProvider.ts insertComponentFromDetached, a one-line pass-through to insertComponent, has no callers left and is removed.

Validation

Local checks

  • npm run compile
  • npm test — 411 passing; npm run lint clean
  • Extension-host suite — 25 passing
  • Manual verification in VS Code Extension Host

Manual test notes

  • Confirmed both ways. Hover a component: include → View Full Component Details → switch version: the Template File link disappears on beta and is retained here. Needs a component with a cached templatePath, or the link is absent on initial render too.
  • Insert on both paths, with and without inputs, checking what lands in the .gitlab-ci.yml: the browser path adds an include at the cursor, the detached path edits the existing one in place. Both now run the same handler, and nothing automated covers either write.

Breaking Changes

  • No breaking changes
  • Breaking changes (describe below)

Risk and Rollback

  • Main risks: medium. One handler now picks between editing an include in place and adding a new one, keyed on _hoverContext. The wrong branch duplicates an include or overwrites the wrong lines, which only the insert checks above would catch.
  • Rollback strategy: revert the commit.

Release Notes Draft

  • Fix: the Template File link no longer disappears after switching version in the detached component details view.

Checklist

  • Branch is up to date with target branch
  • Commit messages follow conventional commits
  • Added/updated docs for behavior or settings changes (this PR description)
  • Added/updated tests for new behavior (the handler imports vscode and is not reachable from the unit suite; the label logic it calls is covered by the existing tagScoping tests)
  • No secrets or tokens in code, logs, screenshots, or test fixtures

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant