loadModelStatus function domain

Last updated: 2026-03-04T23:21:38.430Z

Metrics

LOC: 35 Complexity: 6 Params: 0

Signature

loadModelStatus(): : Promise<void>

Source Code

async function loadModelStatus(): Promise<void> {
  const statusText = document.getElementById("model-status-text");
  const deleteBtn = document.getElementById(
    "btn-delete-model",
  ) as HTMLButtonElement | null;
  if (!statusText) return;

  const result = (await chrome.runtime.sendMessage({
    type: "GET_RUNTIME_MODEL_META",
  })) as { exists: boolean; meta: TrainingMeta | null } | null;

  if (!result?.exists || !result.meta) {
    statusText.innerHTML = `
      <strong style="color: var(--text-muted)">${t("noRuntimeModel")}</strong><br>
      ${t("noRuntimeModelDesc")}
    `;
    if (deleteBtn) deleteBtn.style.display = "none";
    return;
  }

  const m = result.meta;
  const dateStr = new Date(m.trainedAt).toLocaleString();
  const acc = (m.finalAccuracy * 100).toFixed(1);
  statusText.innerHTML = `
    <span style="color:#4ade80; font-weight:600;">✅ ${t("runtimeModelActiveTitle")}</span><br>
    ${t("trainedOnLabel")}: <strong>${dateStr}</strong> &nbsp;|&nbsp;
    ${t("accuracyLabel")}: <strong>${acc}%</strong> &nbsp;|&nbsp;
    ${t("epochsLabel")}: <strong>${m.epochs}</strong><br>
    ${t("samplesUsedLabel")}: <strong>${m.entriesUsed}</strong> &nbsp;|&nbsp;
    ${t("vocabLabel")}: <strong>${m.vocabSize}</strong> ${t("ngramsLabel")} &nbsp;|&nbsp;
    ${t("classesLabel")}: <strong>${m.numClasses}</strong> &nbsp;|&nbsp;
    ${t("durationLabel")}: <strong>${m.durationMs}ms</strong>
  `;
  if (deleteBtn) deleteBtn.style.display = "";
}

Dependencies (Outgoing)

graph LR loadModelStatus["loadModelStatus"] FieldType["FieldType"] DatasetEntry["DatasetEntry"] TrainingProgress["TrainingProgress"] TrainingResult["TrainingResult"] TrainingMeta["TrainingMeta"] trainModelFromDataset["trainModelFromDataset"] t["t"] escapeHtml["escapeHtml"] showToast["showToast"] loadModelStatus -->|uses| FieldType loadModelStatus -->|uses| DatasetEntry loadModelStatus -->|uses| TrainingProgress loadModelStatus -->|uses| TrainingResult loadModelStatus -->|uses| TrainingMeta loadModelStatus -->|uses| trainModelFromDataset loadModelStatus -->|uses| t loadModelStatus -->|uses| escapeHtml loadModelStatus -->|uses| showToast style loadModelStatus fill:#dbeafe,stroke:#2563eb,stroke-width:2px click loadModelStatus "2c3f5e65d67a73f9.html" click FieldType "e49ed8a601306673.html" click DatasetEntry "bf963c6e1dcb39e9.html" click TrainingProgress "d4b62d289bd259d5.html" click TrainingResult "6fcd9383dcceb102.html" click TrainingMeta "9113dee04374643d.html" click trainModelFromDataset "116a4fd1e25c7132.html" click t "8e8864a3c5cfd1e1.html" click escapeHtml "67836c1424e9ebff.html" click showToast "087fe5d2f8cca7e9.html"

Impact (Incoming)

graph LR loadModelStatus["loadModelStatus"] loadDatasetTab["loadDatasetTab"] bindDatasetEvents["bindDatasetEvents"] loadDatasetTab -->|calls| loadModelStatus bindDatasetEvents -->|calls| loadModelStatus style loadModelStatus fill:#dbeafe,stroke:#2563eb,stroke-width:2px click loadModelStatus "2c3f5e65d67a73f9.html" click loadDatasetTab "b3fe54aefc5df3fa.html" click bindDatasetEvents "f0efa64bdb9c9631.html"
SourceType
loadDatasetTab calls
bindDatasetEvents calls