Explain bugs with app state

Attach React Native store, navigation, and diagnostic snapshots to a session so you can compare internal state with visible app behavior.

An unexpected screen can originate in a store, a cached response, or navigation state. Artifacts preserve app-owned snapshots so people and agents can compare that internal context with the screenshots, logs, and gestures in a session.

Register artifact providers from JavaScript to expose named files, JSON snapshots, ZIPs, or binary/text payloads through artifacts.query and artifacts.request.

Good artifact candidates include:

ArtifactUseful contentsWhy use an artifact
network-request.jsonfetch, Axios, Apollo, Relay, or React Query operation name, route, sanitized URL, status, timing, retry count, cache hit, request/response snippets, correlation ids, redacted headers.Connects a failed screen or toast to the exact request or GraphQL operation that caused it.
map-state.jsonreact-native-maps or Mapbox camera, visible region, zoom/bearing/pitch, loaded sources/layers, selected markers/features, cluster state, last map error.Lets an agent compare the map’s internal state with screenshots and gestures.
store-state.jsonRedux, Zustand, Jotai, MobX, Apollo cache, React Query cache, selected ids, loading/error flags, dirty fields.Captures state that is too nested for logs and too broad for a one-line tool result.
navigation-state.jsonReact Navigation route tree, params, selected tab, modal stack, pending deep link, last failed navigation.Makes a replayable checkpoint for UI-flow bugs.
support-bundle.zipRecent JS/native logs, sanitized config, AsyncStorage or SQLite summaries, cache summaries, domain snapshots.Keeps related evidence together as one downloadable session artifact.

Use a custom tool instead when the host needs a small JSON answer or a narrow action. Use an artifact when the evidence should be durable, downloadable, and correlated with screenshots, logs, telemetry, visual trees, touches, and annotations.

Project runtime objects into safe plain objects, redact tokens and secrets, trim large bodies, and register providers only for approved local development or QA workflows.

Register A Provider

const registration = Ansight.registerArtifactProvider({
  descriptor: {
    id: "app.reports",
    name: "Reports",
    description: "Exports app report artifacts.",
    category: "reports",
    tags: ["reports", "support"],
  },

  async query() {
    return [
      {
        id: "current-report",
        name: "Current Report",
        description: "Exports the current report as CSV.",
        kind: "report",
        category: "reports",
        content: {
          supportedMimeTypes: ["text/csv"],
          defaultMimeType: "text/csv",
          suggestedFileName: "current-report.csv",
          supportsText: true,
        },
        tags: ["csv", "current"],
      },
    ];
  },

  async create(request) {
    if (request.artifactId !== "current-report") {
      throw new Error("Unknown artifact.");
    }

    const text = "id,total\n1,42\n";
    return {
      metadata: {
        artifactId: request.artifactId,
        providerId: request.providerId,
        name: "Current Report",
        kind: "report",
        mimeType: "text/csv",
        fileName: "current-report.csv",
        sizeBytes: text.length,
        tags: ["csv", "current"],
      },
      payload: { text },
    };
  },
});

await registration.ready;

Payloads can be text, base64, byte arrays, ArrayBuffer, or Uint8Array.

Artifact payloads can contain sensitive app data even though the request tools use the read policy. Treat every provider as an explicit export surface with stable ids, clear descriptions, and narrowly shaped payloads.

Management

const providers = Ansight.listRegisteredArtifactProviders();

await Ansight.unregisterArtifactProvider("app.reports");
await Ansight.clearArtifactProviders();

Choosing Artifacts

Choose artifacts for outputs that should leave the app as files or durable session evidence:

  • attach a sanitized network request/response or GraphQL operation bundle to a failed checkout, login, sync, or search flow
  • export a map-state snapshot when a map is blank, centered incorrectly, or missing expected markers
  • export Redux, Zustand, Apollo, React Query, navigation, or native-module state that is too nested for a short tool result
  • package a support bundle that should stay attached to the captured session

Use Custom Tools for small reads or controlled actions that do not need file materialization.