Skip to content

armgit / clipy

Public Imported from GitHub
0

The AI-native screen recorder. Record your screen and talk; the people you share it with and your AI agents both get it.

1.9 KB
Raw Blame
import { useCallback, useEffect, useState } from "react";
import { useTranslations } from "use-intl";
import { getTranscriptCleanup, setTranscriptCleanup, type TranscriptCleanupDto } from "../../lib/bridge";
import { SettingRow, Switch } from "./ui";

/**
 * Settings → Transcription → Remove filler words. Off by
 * default, since it changes what someone said. Applies to English local
 * transcripts and to what Talk to your agent pastes. Rendered where the
 * Transcription section is (macOS).
 */
export function TranscriptCleanup() {
  const t = useTranslations("desktop.settings.transcription.fillers");
  const [settings, setSettings] = useState<TranscriptCleanupDto | null>(null);
  const [saving, setSaving] = useState(false);
  const [error, setError] = useState<string | null>(null);

  useEffect(() => {
    const refresh = () => {
      getTranscriptCleanup()
        .then(setSettings)
        .catch((err) => setError(String(err)));
    };
    refresh();
    // Also shown in the Settings window: read again on focus.
    window.addEventListener("focus", refresh);
    return () => window.removeEventListener("focus", refresh);
  }, []);

  const toggle = useCallback(async (removeFillers: boolean) => {
    setSaving(true);
    setError(null);
    try {
      setSettings(await setTranscriptCleanup(removeFillers));
    } catch (err) {
      setError(String(err));
    } finally {
      setSaving(false);
    }
  }, []);

  if (!settings?.supported) return null;

  return (
    <>
      <SettingRow
        title={t("title")}
        subtitle={t("subtitle")}
        trailing={
          <Switch
            checked={settings.removeFillers}
            disabled={saving}
            onChange={(on) => void toggle(on)}
            label={t("title")}
          />
        }
      />
      {error && <p className="px-5 pt-2 text-[12px] text-flash-600">{error}</p>}
    </>
  );
}