Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

1.9 KB
Raw Blame
import { Check, Copy } from "../icons";
import type { JSX } from "react";
import { useTranslation } from "react-i18next";
import { useCopyFeedback } from "../../hooks/useCopyFeedback";
import { formatProviderErrorDetails } from "../../utils/describeProviderError";
import { cn } from "../lib/utils";
import type { TechnicalErrorDetailsData } from "./useToast";

export function TechnicalErrorDetails({
  details,
  onDark = false,
}: {
  details?: TechnicalErrorDetailsData;
  onDark?: boolean;
}): JSX.Element | null {
  const { t } = useTranslation();
  const text = details ? formatProviderErrorDetails(details, t) : "";
  const { copied, copy } = useCopyFeedback(text, { resetMs: 2000 });
  if (!text) return null;

  return (
    <details
      className={cn(
        "group/details mt-1.5 rounded-[3px] border px-1.5 py-1 text-xs",
        onDark ? "border-white/6 bg-white/4 text-white/45" : "border-border bg-muted/50"
      )}
    >
      <summary className="cursor-pointer select-none text-xs text-muted-foreground">
        {t("reasoning.enterprise.technicalDetails.title")}
      </summary>
      <div className="mt-1.5 flex items-start justify-between gap-2">
        <pre
          dir="ltr"
          className="min-w-0 flex-1 whitespace-pre-wrap wrap-break-word font-mono text-[11px] leading-snug select-all"
        >
          {text}
        </pre>
        <button
          type="button"
          onClick={() => void copy()}
          className={cn(
            "shrink-0 rounded-xs p-1 transition-colors",
            onDark
              ? "text-white/30 hover:bg-white/6 hover:text-white/70"
              : "text-muted-foreground hover:bg-muted hover:text-foreground"
          )}
          aria-label={t("reasoning.enterprise.technicalDetails.copy")}
        >
          {copied ? <Check className="size-3" /> : <Copy className="size-3" />}
        </button>
      </div>
    </details>
  );
}