Skip to content

The platform for continuously improving AI agents.

1.8 KB
Raw Blame
import { useId } from "react";

import { Checkbox } from "@/components/ui/checkbox";
import { cn } from "@/lib/utils";

export const AGENT_FEEDBACK_DOCS = "https://docs.overmindlab.ai/reference/agent-feedback";

/**
 * What Connect saves: the choice the person made on the screen, or the ticked default when the
 * account's current value is still unset. An untouched box never overwrites a stored choice.
 */
export function choiceToRecord(touched: boolean | null, current: boolean | null | undefined) {
  if (touched !== null) return touched;
  return current === null ? true : null;
}

function DocsLink({ className }: { className?: string }) {
  return (
    <a
      className={cn("underline underline-offset-4 hover:text-foreground", className)}
      href={AGENT_FEEDBACK_DOCS}
      rel="noreferrer"
      target="_blank"
    >
      What is sent
    </a>
  );
}

/** The sign-up and connect screens: a choice the person sees before any agent reports. */
export function AgentFeedbackCheckbox({
  checked,
  onCheckedChange,
  tone = "console",
}: {
  checked: boolean;
  onCheckedChange: (checked: boolean) => void;
  tone?: "auth" | "console";
}) {
  const id = useId();
  const muted = tone === "auth" ? "text-auth-text/70" : "text-muted-foreground";
  return (
    <div className="flex items-start gap-3 text-sm">
      <Checkbox
        checked={checked}
        className="mt-0.5"
        id={id}
        onCheckedChange={(value) => onCheckedChange(value === true)}
      />
      <div className="space-y-1">
        <label className={tone === "auth" ? "text-auth-text" : undefined} htmlFor={id}>
          Let my coding agents send feedback to Overmind
        </label>
        <p className={cn("text-xs leading-relaxed", muted)}>
          Feedback is about Overmind itself, never your code, prompts or data. <DocsLink />
        </p>
      </div>
    </div>
  );
}