forge
Explore
Log in

Don't you dare go Hollow

The run report speaks Turkish, not the service's enum

Browse files at this commit

0550b106367d67e3ef28dbb3d16797c341ba2dfdAhmet Kaan GümüşParent: 9895664
  • fix
    • the run report speaks Turkish, not the service's enum
Show full message
🐛 fix(insights): the run report speaks Turkish, not the service's enum

Three flags from the batch verification, one commit:

- The Güven column printed the raw confidence tier (exploratory / stable /
  none). It now reads the app's own dictionary (insights.confidence.*), the
  same labels the student drawer shows, in both the view and the Markdown; an
  unknown tier stays raw rather than being guessed at.
- failed_modules are zeka pipeline stage names (discover_students / fetch /
  compute / store). They get labels with an honest fallback for a stage this
  build does not know, the same sweep applied to the runs table's own issue
  line, and the raw stage list stays in the technical disclosure.
- The export counted the pending students while the panel named them. The
  export now carries the same list in the same order (`—` for a student the
  roster could not resolve), so the .md, the clipboard and the print sheet say
  what the screen says.

Tests pin each: the panel and the export show Keşifsel/Kararlı and never the
raw enum; a known stage reads Veri toplama while an unknown one keeps its
technical name and the raw list survives in the JSON disclosure; the pending
line names Ayça Şahin.
src/components/insights/insight-run-report.test.tsxmodified+41 -1
@@ -53,7 +53,9 @@ const RUN_B: InsightRun = {
5353 students_skipped: 6,
5454 rows_written: 9,
5555 pending_students: ["s2"],
56- failed_modules: ["attendance"],
56+ // Real stage vocabulary (discover_students / fetch / compute / store), plus one
57+ // unknown stage so the fallback is pinned too.
58+ failed_modules: ["fetch", "mystery_stage"],
5759 };
5860
5961 const ROSTER: PersonRef[] = [
@@ -272,6 +274,43 @@ describe("InsightRunReport", () => {
272274 expect(print).toHaveBeenCalledTimes(1);
273275 });
274276
277+ it("labels the confidence tier and the failed stage instead of printing the raw vocabulary", async () => {
278+ await openReport(DAY_B);
279+ await waitFor(() => expect(panel().getByText("Keşifsel")).toBeTruthy());
280+
281+ // The tier comes from the app's own dictionary (insights.confidence.*).
282+ expect(panel().queryByText("exploratory")).toBeNull();
283+ // The failed stage is a zeka pipeline stage name, labelled; the unknown one
284+ // keeps its technical name rather than getting a guessed label.
285+ const issues = panel().getByText(/Veri üretmeyen modüller:/).textContent ?? "";
286+ expect(issues).toContain("Veri toplama");
287+ expect(issues).toContain("mystery_stage");
288+ expect(issues).not.toContain("fetch");
289+ // The raw stage list survives in the technical disclosure.
290+ expect(panel().getByText(/"failed_modules"/)).toBeTruthy();
291+ });
292+
293+ it("names the pending students in the export exactly as the panel does", async () => {
294+ await openReport(DAY_B);
295+ await waitFor(() => expect(panel().getByText(/1 öğrenci sıradaki çalıştırmaya kaldı/)).toBeTruthy());
296+
297+ const markdown = buildRunReportMarkdown(
298+ buildRunReportModel({
299+ run: RUN_B,
300+ roster: ROSTER,
301+ insights: { s1: INSIGHT_S1, s2: INSIGHT_S2, s3: INSIGHT_S3 },
302+ errors: {},
303+ coverageTotal: ROSTER.length,
304+ rosterError: null,
305+ }),
306+ "tr",
307+ );
308+ expect(markdown).toContain("1 öğrenci sıradaki çalıştırmaya kaldı: Ayça Şahin");
309+ expect(markdown).toContain("Veri üretmeyen modüller: Veri toplama, mystery_stage");
310+ expect(markdown).toContain("Keşifsel");
311+ expect(markdown).not.toContain("exploratory");
312+ });
313+
275314 it("builds the same Markdown without a DOM", () => {
276315 const model = buildRunReportModel({
277316 run: RUN_A,
@@ -290,6 +329,7 @@ describe("InsightRunReport", () => {
290329 expect(markdown).toContain("71,0 (1/2)");
291330 expect(markdown).toContain("75%");
292331 expect(markdown).toContain("Çalışma: 0/3 öğrencide veri var → veri yok");
332+ expect(markdown).toContain("Keşifsel");
293333 expect(markdown).toContain("```json");
294334 });
295335 });
src/components/insights/insight-run-report.tsxmodified+12 -2
@@ -13,6 +13,8 @@ import { formatDateTime } from "@/lib/format";
1313 import {
1414 buildRunReportMarkdown,
1515 buildRunReportModel,
16+ confidenceText,
17+ failedStageText,
1618 formatRunDuration,
1719 moduleLabel,
1820 runReportFileName,
@@ -130,7 +132,13 @@ function ReportDocument(props: {
130132 </li>
131133 </Show>
132134 <Show when={props.model.run.failed_modules.length > 0}>
133- <li>{tx("failedModules", { modules: props.model.run.failed_modules.join(", ") })}</li>
135+ <li>
136+ {tx("failedModules", {
137+ modules: props.model.run.failed_modules
138+ .map((stage) => failedStageText(prefs.locale(), stage))
139+ .join(", "),
140+ })}
141+ </li>
134142 </Show>
135143 </ul>
136144 </Show>
@@ -216,7 +224,9 @@ function ReportDocument(props: {
216224 <tr class="border-t border-border-hairline">
217225 <td class="py-2 pr-3 font-medium text-text-strong">{student.name}</td>
218226 <td class="py-2 pr-3 text-muted-foreground">{studentStatusText(prefs.locale(), student)}</td>
219- <td class="py-2 pr-3 text-muted-foreground">{student.confidence ?? tx("noData")}</td>
227+ <td class="py-2 pr-3 text-muted-foreground">
228+ {student.confidence == null ? tx("noData") : confidenceText(prefs.locale(), student.confidence)}
229+ </td>
220230 <td class="mono py-2 pr-3 text-right tabular-nums">{student.attention}</td>
221231 <td class="mono py-2 pr-3 text-right tabular-nums">{student.cards}</td>
222232 <td class="mono py-2 pr-3 tabular-nums">{studentMarksText(prefs.locale(), student)}</td>
src/components/insights/insight-runs-table.tsxmodified+4 -1
@@ -10,6 +10,7 @@ import { TableRowActions } from "@/components/ui/table-row-actions";
1010 import { runReportText, type RunReportKey } from "@/i18n/insights-run-report";
1111 import { cn } from "@/lib/cn";
1212 import { formatDateTime, formatDurationMinutes } from "@/lib/format";
13+import { failedStageText } from "@/lib/insight-run-report";
1314 import { usePreferences } from "@/stores/preferences-context";
1415
1516 function statusVariant(status: string) {
@@ -96,7 +97,9 @@ export function InsightRunsTable(props: { runs: InsightRun[] }) {
9697 )}
9798 {run.failed_modules.length > 0 && (
9899 <p class="max-w-56 truncate text-[11px] text-muted-foreground" title={run.failed_modules.join(", ")}>
99- {tx("insights.failedModules", { modules: run.failed_modules.join(", ") })}
100+ {tx("insights.failedModules", {
101+ modules: run.failed_modules.map((stage) => failedStageText(prefs.locale(), stage)).join(", "),
102+ })}
100103 </p>
101104 )}
102105 </div>
src/lib/insight-run-report.tsmodified+42 -4
@@ -1,6 +1,6 @@
11 import type { InsightRun, PersonRef, StudentInsight } from "@/api/client";
22 import { runReportText } from "@/i18n/insights-run-report";
3-import type { Locale } from "@/i18n/messages";
3+import { messages, type Locale, type MessageKey } from "@/i18n/messages";
44 import { formatDateTime } from "@/lib/format";
55
66 /**
@@ -281,6 +281,38 @@ export function runReportStatusLabel(locale: Locale, status: string): string {
281281 return STATUS_LABELS[locale][status] ?? status;
282282 }
283283
284+const CONFIDENCE_KEYS: Record<string, MessageKey> = {
285+ none: "insights.confidence.none",
286+ exploratory: "insights.confidence.exploratory",
287+ stable: "insights.confidence.stable",
288+};
289+
290+/**
291+ * ZEKA's confidence tiers, in the reader's language. They come from the app's
292+ * own dictionary so the drawer and the report cannot disagree; a tier the
293+ * dictionary does not know stays raw rather than being guessed at.
294+ */
295+export function confidenceText(locale: Locale, confidence: string): string {
296+ const key = CONFIDENCE_KEYS[confidence];
297+ if (!key) return confidence;
298+ return messages[locale][key] ?? messages.en[key] ?? confidence;
299+}
300+
301+/**
302+ * A failed pipeline stage. The values are zeka's own stage names
303+ * (`discover_students` / `fetch` / `compute` / `store`); an unrecognised one is
304+ * shown as the technical stage it is, and the raw list stays in the report's
305+ * technical disclosure.
306+ */
307+const FAILED_STAGE_LABELS: Record<string, Record<string, string>> = {
308+ tr: { discover_students: "Öğrenci listesi", fetch: "Veri toplama", compute: "Hesaplama", store: "Kayıt" },
309+ en: { discover_students: "Student list", fetch: "Data fetch", compute: "Computation", store: "Storage" },
310+};
311+
312+export function failedStageText(locale: Locale, stage: string): string {
313+ return FAILED_STAGE_LABELS[locale][stage] ?? stage;
314+}
315+
284316 export function runReportFileName(runDay: string): string {
285317 return `okul-analiz-raporu-${runDay}.md`;
286318 }
@@ -349,10 +381,16 @@ export function buildRunReportMarkdown(model: RunReportModel, locale: Locale): s
349381 const issueCount = run.pending_students.length + run.failed_modules.length + (run.budget_exceeded ? 1 : 0);
350382 lines.push(`- ${t("issues")}: ${issueCount === 0 ? t("noIssues") : String(issueCount)}`);
351383 if (run.pending_students.length > 0) {
352- lines.push(`- ${t("pendingStudents", { count: run.pending_students.length })}`);
384+ // Same list, same order as the panel: the export names them, not just counts them.
385+ const named = model.pending.length > 0
386+ ? `: ${model.pending.map((row) => row.name ?? "—").join(", ")}`
387+ : "";
388+ lines.push(`- ${t("pendingStudents", { count: run.pending_students.length })}${named}`);
353389 }
354390 if (run.failed_modules.length > 0) {
355- lines.push(`- ${t("failedModules", { modules: run.failed_modules.join(", ") })}`);
391+ lines.push(
392+ `- ${t("failedModules", { modules: run.failed_modules.map((stage) => failedStageText(locale, stage)).join(", ") })}`,
393+ );
356394 }
357395 lines.push("");
358396 lines.push(`## ${t("schoolSection")}`);
@@ -390,7 +428,7 @@ export function buildRunReportMarkdown(model: RunReportModel, locale: Locale): s
390428 const cells = [
391429 student.name,
392430 studentStatusText(locale, student),
393- student.confidence ?? t("noData"),
431+ student.confidence == null ? t("noData") : confidenceText(locale, student.confidence),
394432 String(student.attention),
395433 String(student.cards),
396434 studentMarksText(locale, student),