The run report speaks Turkish, not the service's enum
Browse files at this commit0550b106367d67e3ef28dbb3d16797c341ba2dfdParent: 9895664- fix
- the run report speaks Turkish, not the service's enum
4 changed files +99 -8
- src/components/insights/insight-run-report.test.tsx +41 -1
- src/components/insights/insight-run-report.tsx +12 -2
- src/components/insights/insight-runs-table.tsx +4 -1
- src/lib/insight-run-report.ts +42 -4
src/components/insights/insight-run-report.test.tsxmodified+41 -1
| @@ -53,7 +53,9 @@ const RUN_B: InsightRun = { | ||
| 53 | 53 | students_skipped: 6, |
| 54 | 54 | rows_written: 9, |
| 55 | 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 | 61 | const ROSTER: PersonRef[] = [ |
| @@ -272,6 +274,43 @@ describe("InsightRunReport", () => { | ||
| 272 | 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 | 314 | it("builds the same Markdown without a DOM", () => { |
| 276 | 315 | const model = buildRunReportModel({ |
| 277 | 316 | run: RUN_A, |
| @@ -290,6 +329,7 @@ describe("InsightRunReport", () => { | ||
| 290 | 329 | expect(markdown).toContain("71,0 (1/2)"); |
| 291 | 330 | expect(markdown).toContain("75%"); |
| 292 | 331 | expect(markdown).toContain("Çalışma: 0/3 öğrencide veri var → veri yok"); |
| 332 | + expect(markdown).toContain("Keşifsel"); | |
| 293 | 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 | 13 | import { |
| 14 | 14 | buildRunReportMarkdown, |
| 15 | 15 | buildRunReportModel, |
| 16 | + confidenceText, | |
| 17 | + failedStageText, | |
| 16 | 18 | formatRunDuration, |
| 17 | 19 | moduleLabel, |
| 18 | 20 | runReportFileName, |
| @@ -130,7 +132,13 @@ function ReportDocument(props: { | ||
| 130 | 132 | </li> |
| 131 | 133 | </Show> |
| 132 | 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 | 142 | </Show> |
| 135 | 143 | </ul> |
| 136 | 144 | </Show> |
| @@ -216,7 +224,9 @@ function ReportDocument(props: { | ||
| 216 | 224 | <tr class="border-t border-border-hairline"> |
| 217 | 225 | <td class="py-2 pr-3 font-medium text-text-strong">{student.name}</td> |
| 218 | 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 | 230 | <td class="mono py-2 pr-3 text-right tabular-nums">{student.attention}</td> |
| 221 | 231 | <td class="mono py-2 pr-3 text-right tabular-nums">{student.cards}</td> |
| 222 | 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 | 10 | import { runReportText, type RunReportKey } from "@/i18n/insights-run-report"; |
| 11 | 11 | import { cn } from "@/lib/cn"; |
| 12 | 12 | import { formatDateTime, formatDurationMinutes } from "@/lib/format"; |
| 13 | +import { failedStageText } from "@/lib/insight-run-report"; | |
| 13 | 14 | import { usePreferences } from "@/stores/preferences-context"; |
| 14 | 15 | |
| 15 | 16 | function statusVariant(status: string) { |
| @@ -96,7 +97,9 @@ export function InsightRunsTable(props: { runs: InsightRun[] }) { | ||
| 96 | 97 | )} |
| 97 | 98 | {run.failed_modules.length > 0 && ( |
| 98 | 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 | 103 | </p> |
| 101 | 104 | )} |
| 102 | 105 | </div> |
src/lib/insight-run-report.tsmodified+42 -4
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | import type { InsightRun, PersonRef, StudentInsight } from "@/api/client"; |
| 2 | 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 | 4 | import { formatDateTime } from "@/lib/format"; |
| 5 | 5 | |
| 6 | 6 | /** |
| @@ -281,6 +281,38 @@ export function runReportStatusLabel(locale: Locale, status: string): string { | ||
| 281 | 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 | 316 | export function runReportFileName(runDay: string): string { |
| 285 | 317 | return `okul-analiz-raporu-${runDay}.md`; |
| 286 | 318 | } |
| @@ -349,10 +381,16 @@ export function buildRunReportMarkdown(model: RunReportModel, locale: Locale): s | ||
| 349 | 381 | const issueCount = run.pending_students.length + run.failed_modules.length + (run.budget_exceeded ? 1 : 0); |
| 350 | 382 | lines.push(`- ${t("issues")}: ${issueCount === 0 ? t("noIssues") : String(issueCount)}`); |
| 351 | 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 | 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 | 395 | lines.push(""); |
| 358 | 396 | lines.push(`## ${t("schoolSection")}`); |
| @@ -390,7 +428,7 @@ export function buildRunReportMarkdown(model: RunReportModel, locale: Locale): s | ||
| 390 | 428 | const cells = [ |
| 391 | 429 | student.name, |
| 392 | 430 | studentStatusText(locale, student), |
| 393 | - student.confidence ?? t("noData"), | |
| 431 | + student.confidence == null ? t("noData") : confidenceText(locale, student.confidence), | |
| 394 | 432 | String(student.attention), |
| 395 | 433 | String(student.cards), |
| 396 | 434 | studentMarksText(locale, student), |