Skip to content

The platform for continuously improving AI agents.

839 B
Raw Blame
import { launchRecordedTab } from "@/lib/launched-tabs";
import type { WorkshopMessage } from "@/openapi";

export function openDatasetActivityTabs(
  messages: WorkshopMessage[],
  projectId: string,
  userId: string | undefined
) {
  let opened: ReturnType<typeof launchRecordedTab>;
  for (const message of messages) {
    const activity = message.datasetActivity;
    if (
      message.role !== "activity" ||
      !activity ||
      !["queued", "running", "preparing"].includes(activity.state)
    )
      continue;
    const tab = launchRecordedTab({
      id: `/datasets:${activity.dataset}`,
      jobKey: `workshop:${activity.task}`,
      path: `/datasets/${activity.dataset}`,
      search: { projectId },
      section: "/datasets",
      title: activity.name,
      userId,
    });
    opened ??= tab;
  }
  return opened;
}