src/devtools/tabs/actions-tab.tsx

Total Symbols
2
Lines of Code
55
Avg Complexity
2.0
Symbol Types
1

File Relationships

graph LR toggleWatch["toggleWatch"] renderActionsTab["renderActionsTab"] toggleWatch -->|calls| renderActionsTab toggleWatch -->|calls| toggleWatch click toggleWatch "../symbols/5b1d47a07d7aa0c9.html" click renderActionsTab "../symbols/40e45c39675a3592.html"

Symbols by Kind

function 2

All Symbols

Name Kind Visibility Status Lines Signature
toggleWatch function exported- 24-35 toggleWatch(): : Promise<void>
renderActionsTab function exported- 39-46 renderActionsTab(): : void

Full Source

/**
 * Actions Tab — Main action cards for the DevTools panel.
 *
 * Responsibilities:
 * - Render the actions grid (fill, watch, save, detect)
 * - Toggle DOM watcher state
 */

import { t } from "@/lib/i18n";
import { panelState } from "../panel-state";
import { sendToPage } from "../panel-messaging";
import { addLog } from "../panel-utils";
import { renderTo, ActionsTabView } from "@/lib/ui/components";
import {
  detectFields,
  fillAll,
  fillOnlyEmpty,
  fillContextualAI,
} from "./fields-tab";
import { saveCurrentForm } from "./forms-tab";

// ── Watcher ───────────────────────────────────────────────────────────────────

export async function toggleWatch(): Promise<void> {
  if (panelState.watcherActive) {
    await sendToPage({ type: "STOP_WATCHING" });
    panelState.watcherActive = false;
    addLog(t("logWatchDeactivated"), "info");
  } else {
    await sendToPage({ type: "START_WATCHING", payload: { autoRefill: true } });
    panelState.watcherActive = true;
    addLog(t("logWatchActivated"), "success");
  }
  renderActionsTab();
}

// ── Render ────────────────────────────────────────────────────────────────────

export function renderActionsTab(): void {
  const content = document.getElementById("content");
  renderTo(
    content,
    <ActionsTabView
      watcherActive={panelState.watcherActive}
      detectedCount={panelState.detectedFields.length}
      onFillAll={() => void fillAll()}
      onFillEmpty={() => void fillOnlyEmpty()}
      onFillContextualAI={() => void fillContextualAI()}
      onSave={() => void saveCurrentForm()}
      onToggleWatch={() => void toggleWatch()}
      onDetect={() => void detectFields()}
    />,
  );
}