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 = {
53 students_skipped: 6,53 students_skipped: 6,
54 rows_written: 9,54 rows_written: 9,
55 pending_students: ["s2"],55 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"],
57 };59 };
58 60
59 const ROSTER: PersonRef[] = [61 const ROSTER: PersonRef[] = [
@@ -272,6 +274,43 @@ describe("InsightRunReport", () => {
272 expect(print).toHaveBeenCalledTimes(1);274 expect(print).toHaveBeenCalledTimes(1);
273 });275 });
274 276
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+
275 it("builds the same Markdown without a DOM", () => {314 it("builds the same Markdown without a DOM", () => {
276 const model = buildRunReportModel({315 const model = buildRunReportModel({
277 run: RUN_A,316 run: RUN_A,
@@ -290,6 +329,7 @@ describe("InsightRunReport", () => {
290 expect(markdown).toContain("71,0 (1/2)");329 expect(markdown).toContain("71,0 (1/2)");
291 expect(markdown).toContain("75%");330 expect(markdown).toContain("75%");
292 expect(markdown).toContain("Çalışma: 0/3 öğrencide veri var → veri yok");331 expect(markdown).toContain("Çalışma: 0/3 öğrencide veri var → veri yok");
332+ expect(markdown).toContain("Keşifsel");
293 expect(markdown).toContain("```json");333 expect(markdown).toContain("```json");
294 });334 });
295 });335 });
src/components/insights/insight-run-report.tsxmodified+12 -2
@@ -13,6 +13,8 @@ import { formatDateTime } from "@/lib/format";
13 import {13 import {
14 buildRunReportMarkdown,14 buildRunReportMarkdown,
15 buildRunReportModel,15 buildRunReportModel,
16+ confidenceText,
17+ failedStageText,
16 formatRunDuration,18 formatRunDuration,
17 moduleLabel,19 moduleLabel,
18 runReportFileName,20 runReportFileName,
@@ -130,7 +132,13 @@ function ReportDocument(props: {
130 </li>132 </li>
131 </Show>133 </Show>
132 <Show when={props.model.run.failed_modules.length > 0}>134 <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>
134 </Show>142 </Show>
135 </ul>143 </ul>
136 </Show>144 </Show>
@@ -216,7 +224,9 @@ function ReportDocument(props: {
216 <tr class="border-t border-border-hairline">224 <tr class="border-t border-border-hairline">
217 <td class="py-2 pr-3 font-medium text-text-strong">{student.name}</td>225 <td class="py-2 pr-3 font-medium text-text-strong">{student.name}</td>
218 <td class="py-2 pr-3 text-muted-foreground">{studentStatusText(prefs.locale(), student)}</td>226 <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>
220 <td class="mono py-2 pr-3 text-right tabular-nums">{student.attention}</td>230 <td class="mono py-2 pr-3 text-right tabular-nums">{student.attention}</td>
221 <td class="mono py-2 pr-3 text-right tabular-nums">{student.cards}</td>231 <td class="mono py-2 pr-3 text-right tabular-nums">{student.cards}</td>
222 <td class="mono py-2 pr-3 tabular-nums">{studentMarksText(prefs.locale(), student)}</td>232 <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";
10 import { runReportText, type RunReportKey } from "@/i18n/insights-run-report";10 import { runReportText, type RunReportKey } from "@/i18n/insights-run-report";
11 import { cn } from "@/lib/cn";11 import { cn } from "@/lib/cn";
12 import { formatDateTime, formatDurationMinutes } from "@/lib/format";12 import { formatDateTime, formatDurationMinutes } from "@/lib/format";
13+import { failedStageText } from "@/lib/insight-run-report";
13 import { usePreferences } from "@/stores/preferences-context";14 import { usePreferences } from "@/stores/preferences-context";
14 15
15 function statusVariant(status: string) {16 function statusVariant(status: string) {
@@ -96,7 +97,9 @@ export function InsightRunsTable(props: { runs: InsightRun[] }) {
96 )}97 )}
97 {run.failed_modules.length > 0 && (98 {run.failed_modules.length > 0 && (
98 <p class="max-w-56 truncate text-[11px] text-muted-foreground" title={run.failed_modules.join(", ")}>99 <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+ })}
100 </p>103 </p>
101 )}104 )}
102 </div>105 </div>
src/lib/insight-run-report.tsmodified+42 -4
@@ -1,6 +1,6 @@
1 import type { InsightRun, PersonRef, StudentInsight } from "@/api/client";1 import type { InsightRun, PersonRef, StudentInsight } from "@/api/client";
2 import { runReportText } from "@/i18n/insights-run-report";2 import { runReportText } from "@/i18n/insights-run-report";
3-import type { Locale } from "@/i18n/messages";3+import { messages, type Locale, type MessageKey } from "@/i18n/messages";
4 import { formatDateTime } from "@/lib/format";4 import { formatDateTime } from "@/lib/format";
5 5
6 /**6 /**
@@ -281,6 +281,38 @@ export function runReportStatusLabel(locale: Locale, status: string): string {
281 return STATUS_LABELS[locale][status] ?? status;281 return STATUS_LABELS[locale][status] ?? status;
282 }282 }
283 283
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+
284 export function runReportFileName(runDay: string): string {316 export function runReportFileName(runDay: string): string {
285 return `okul-analiz-raporu-${runDay}.md`;317 return `okul-analiz-raporu-${runDay}.md`;
286 }318 }
@@ -349,10 +381,16 @@ export function buildRunReportMarkdown(model: RunReportModel, locale: Locale): s
349 const issueCount = run.pending_students.length + run.failed_modules.length + (run.budget_exceeded ? 1 : 0);381 const issueCount = run.pending_students.length + run.failed_modules.length + (run.budget_exceeded ? 1 : 0);
350 lines.push(`- ${t("issues")}: ${issueCount === 0 ? t("noIssues") : String(issueCount)}`);382 lines.push(`- ${t("issues")}: ${issueCount === 0 ? t("noIssues") : String(issueCount)}`);
351 if (run.pending_students.length > 0) {383 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}`);
353 }389 }
354 if (run.failed_modules.length > 0) {390 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+ );
356 }394 }
357 lines.push("");395 lines.push("");
358 lines.push(`## ${t("schoolSection")}`);396 lines.push(`## ${t("schoolSection")}`);
@@ -390,7 +428,7 @@ export function buildRunReportMarkdown(model: RunReportModel, locale: Locale): s
390 const cells = [428 const cells = [
391 student.name,429 student.name,
392 studentStatusText(locale, student),430 studentStatusText(locale, student),
393- student.confidence ?? t("noData"),431+ student.confidence == null ? t("noData") : confidenceText(locale, student.confidence),
394 String(student.attention),432 String(student.attention),
395 String(student.cards),433 String(student.cards),
396 studentMarksText(locale, student),434 studentMarksText(locale, student),