Component & Source-Map Resolver ๐Ÿงฌ

A core challenge for AI coding agents during frontend debugging is bridging the gap between what the browser renders (e.g., <button class="sc-bdVaJa bDwzTH">) and the actual source code file in the repository (e.g., src/components/CheckoutButton.tsx:42).

BrowserTrack includes an automated Component & Source-Map Resolver that inspects internal framework virtual DOM instances in real time and attaches exact component and source locations to visual notes, user interaction breadcrumbs, and error incidents.


โšก Supported Frameworks #

FrameworkInspection TechniqueResolved Metadata
React (v16โ€“19)__reactFiber$, _debugSource, _debugOwnerComponent Name, Source File, Line, Column, Component Hierarchy, Props
Vue 3__vueParentComponent, __vnodeComponent Name (__name), SFC File (__file), Hierarchy, Props
Vue 2__vue__.$optionsComponent Tag, SFC File (__file)
Svelte__svelte_meta.locSvelte Component Name, File Path, Line, Column
Web ComponentsHyphenated custom element tagsCustom Element Tag Name
Generic / Vanilladata-component, data-source-file, data-source-lineExplicit Component & File Annotation

๐Ÿ” How It Works #

Mermaid Diagram
View diagram source
graph LR
    A[Target DOM Element] --> B[BrowserTrack Resolver]
    B -->|React Fiber| C[Extract _debugSource & _debugOwner]
    B -->|Vue VNode| D[Extract __file & type.__name]
    B -->|Svelte Meta| E[Extract loc.file & loc.line]
    C & D & E --> F[ComponentSourceInfo]
    F --> G[Visual Notes, Breadcrumbs & Incidents]
    G --> H[AI Agent opens exact file:line via MCP]

Development Mode Source Maps #

Modern bundlers (Vite, Next.js, Create React App, Nuxt, SvelteKit) automatically populate _debugSource and __file on virtual DOM nodes during local development. BrowserTrack reads this data directly without requiring additional build plugins.


๐Ÿ“ฆ Resolved Metadata Structure #

Whenever a visual note is taken, or when user interactions precede a crash:

TYPESCRIPT
export interface ComponentSourceInfo {
  framework?: 'react' | 'vue' | 'svelte' | 'web-component' | 'vanilla';
  componentName?: string;     // e.g. "CheckoutButton"
  sourceFile?: string;        // e.g. "src/components/CheckoutButton.tsx"
  sourceLine?: number;        // e.g. 42
  sourceColumn?: number;      // e.g. 8
  hierarchy?: string[];       // e.g. ["App", "ShopLayout", "CartDrawer", "CheckoutButton"]
  props?: Record<string, any>;// Sanitized component props
}

๐Ÿค– AI Agent MCP Usage #

When an agent retrieves an incident or visual note:

In get_incident: #

The lastInteractedElement provides direct source coordinates:

JSON
{
  "lastInteractedElement": {
    "selector": "button#checkout-btn",
    "tag": "button",
    "componentSource": {
      "framework": "react",
      "componentName": "CheckoutButton",
      "sourceFile": "src/components/CheckoutButton.tsx",
      "sourceLine": 42,
      "hierarchy": ["App", "ShopLayout", "CheckoutButton"]
    }
  }
}

In get_note: #

JSON
{
  "elementContext": {
    "selector": ".user-profile-card",
    "componentSource": {
      "framework": "vue",
      "componentName": "UserProfileCard",
      "sourceFile": "src/components/UserProfileCard.vue"
    }
  }
}

The AI agent can immediately edit the exact file and line without running codebase searches or guessing CSS selectors!


๐ŸŽจ Interactive Visual Badges in Browser #

When inspecting elements or viewing saved notes on screen:

  • The Note Editor modal displays a purple pill: ๐Ÿงฌ <CheckoutButton> (src/components/CheckoutButton.tsx:42).
  • The Note Details Card popover displays the component badge and framework tag (REACT, VUE, SVELTE).
2 min read ยท Updated