Skip to content

Support original source locations in deployed Preview environments through an opt-in build plugin #198

Description

@SweetRetry

Background

Agentation is useful in a designer–coding-agent workflow where each PR has a deployed Preview environment and reviewers annotate the rendered interface directly. The feedback needs to identify the original component so the coding agent can apply the next change.

Source attribution is currently reliable mainly in local development builds. In a production-optimized Preview build, an annotation may report a generated bundle location such as:

_next/static/chunks/<hash>.js:63:5578

instead of the original source location:

src/components/Banner.tsx:16:6

Root cause

In React production builds:

  • React Fiber normally no longer exposes _debugSource.
  • The Error.stack fallback points to bundled and minified chunks.
  • Browser source maps do not automatically remap the Error.stack value available to runtime JavaScript.

Enabling browser source maps alone therefore does not make original source locations available to Agentation at runtime.

Proposed approach

Provide an opt-in build-time integration that:

  1. adds a short data-agentation-id to JSX that renders to the DOM;
  2. generates a compact manifest mapping each ID to a repository-relative file:line:column location; and
  3. lets the Agentation runtime resolve the selected DOM element through that manifest before falling back to React internals.

The manifest should contain relative paths and position mappings only, never source content.

Initial scope

  • A separately installable first-party build plugin.
  • Production-only instrumentation by default, with explicit opt-in for development.
  • Next.js 16 with Turbopack.
  • Vite 7 with React.
  • Single-project repositories and monorepos.
  • Intrinsic JSX plus next/link and next/image.
  • Preserve existing Next.js and Turbopack configuration.
  • Do not inject unknown DOM attributes into arbitrary custom components.
  • Include tests and integration documentation.

Because the manifest exposes relative source paths to clients, applications should explicitly install the plugin and decide which Preview or staging deployments enable it.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions