Skip to content

feat: Add utilities for custom views (bt custom-views push & bt custom-views preview) - #2191

Open
Luca Forstner (lforst) wants to merge 4 commits into
mainfrom
lforst/sdk-view-helpers
Open

feat: Add utilities for custom views (bt custom-views push & bt custom-views preview)#2191
Luca Forstner (lforst) wants to merge 4 commits into
mainfrom
lforst/sdk-view-helpers

Conversation

@lforst

@lforst Luca Forstner (lforst) commented Jul 2, 2026

Copy link
Copy Markdown
Member

Exposes a new API to be usable by bt for pushing and previewing custom-views.

The idea is that the user defines custom views in files:

// Trace View
import { customTraceView } from "braintrust/custom-views";

type Input = {
  question: string;
};

type Output = {
  answer: string;
};

type Expected = {
  answer: string;
};

type Metadata = {
  reviewed: boolean;
};

export default customTraceView<Input, Output, Expected, Metadata>(
  {
    name: "Trace summary",
    slug: "trace-summary",
    project: { name: "customer-support" },
  },
  ({ span, trace, selectSpan }) => (
    <main>
      <h1>{span.data.input?.question}</h1>
      <p>{span.data.output?.answer}</p>

      <button
        onClick={() =>
          void trace.update({
            target: "selected",
            metadata: { reviewed: true },
          })
        }
      >
        Mark reviewed
      </button>

      {trace.spanOrder.map((spanId) => (
        <button key={spanId} onClick={() => selectSpan?.(spanId)}>
          {spanId}
        </button>
      ))}
    </main>
  ),
);
// Dataset View
import { customDatasetView } from "braintrust/custom-views";

type Input = {
  question: string;
};

type Expected = {
  answer: string;
};

type Metadata = {
  reviewed: boolean;
};

export default customDatasetView<Input, Expected, Metadata>(
  {
    name: "Dataset review",
    slug: "dataset-review",
    dataset: { name: "support-questions" },
    project: { name: "customer-support" },
  },
  ({ input, expected, metadata, update }) => (
    <main>
      <h1>{input?.question}</h1>
      <p>{expected?.answer}</p>

      <button
        disabled={metadata?.reviewed}
        onClick={() =>
          void update({
            metadata: { reviewed: true },
          })
        }
      >
        Mark reviewed
      </button>
    </main>
  ),
);

Users can then work with the view through the CLI:

bt custom-views preview ./trace-view.tsx
bt custom-views push ./trace-view.tsx

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If this PR is still relevant, please leave a comment, push an update, or remove the stale label. Thank you for your contributions!

@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If this PR is still relevant, please leave a comment, push an update, or remove the stale label. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Aug 4, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This pull request was closed because it has been inactive for 21 days (14 days of inactivity before being marked stale, plus 7 additional days). If this PR is still relevant, please feel free to reopen it. Thank you!

@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If this PR is still relevant, please leave a comment, push an update, or remove the stale label. Thank you for your contributions!

@github-actions github-actions Bot added the stale label Aug 27, 2026
@lforst Luca Forstner (lforst) added never-stale Makes stalebot never close an issue and removed stale labels Aug 27, 2026
@lforst Luca Forstner (lforst) changed the title feat: Add utilities for custom views (push + preview) feat: Add utilities for custom views (bt custom-views push & bt custom-views preview) Sep 11, 2026
@lforst
Luca Forstner (lforst) marked this pull request as ready for review September 11, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

never-stale Makes stalebot never close an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants