diff --git a/src/components/insights/insight-detail.test.tsx b/src/components/insights/insight-detail.test.tsx
index 45cf8ae..bd093eb 100644
--- a/src/components/insights/insight-detail.test.tsx
+++ b/src/components/insights/insight-detail.test.tsx
@@ -218,6 +218,34 @@ const insight: StudentInsight = {
created_at: NOW,
expires_at: NOW + WEEK,
},
+ {
+ id: "card-2",
+ product: "O2",
+ rule_id: "O2.segment_cognitive_gap",
+ rule_version: 1,
+ scope: "bilissel_talep=var",
+ audience_role: "student",
+ course: null,
+ evidence: {
+ dimension: "dikkat_tuzagi",
+ label: "var",
+ fact: "Dikkat tuzağı sorularında doğruluk, öğrencinin genel düzeyinin altında.",
+ n_answers: 20,
+ n_correct: 9,
+ accuracy: 0.45,
+ overall_accuracy: 0.6,
+ overall_n_answers: 100,
+ contrast: -0.15,
+ reference_mean_contrast: -0.02,
+ reference_n_students: 180,
+ relative_contrast: -0.13,
+ gate_n_answers: 12,
+ rule: "relative_contrast <= -0.08 ve n_answers >= 12",
+ },
+ confidence: "exploratory",
+ created_at: NOW,
+ expires_at: NOW + WEEK,
+ },
],
segments: [
{
@@ -327,6 +355,44 @@ describe("InsightDetail", () => {
expect(disclosure.open).toBe(true);
});
+ it("claims school-wide only when the payload has no course at all", () => {
+ const base = insight.attention[0];
+ render(() => (
+
+
+
+ ));
+ const human = screen.getByTestId("insight-human").textContent ?? "";
+
+ expect(human).toContain("Okul geneli devamsızlık artışı.");
+ expect(human).toContain("Ders adı çözümlenemedi");
+ // Exactly one item may read as school-wide: a course id whose title did not
+ // resolve is not evidence of a school-wide fact.
+ expect((human.match(/Okul geneli/g) ?? []).length).toBe(1);
+ expect(human).not.toContain("01a0b1b0-9d58-77f7-966f-5bfa87cb7e11");
+ });
+
+ it("maps the segment vocabulary everywhere, never the machine name", () => {
+ renderDrawer();
+ const human = screen.getByTestId("insight-human").textContent ?? "";
+
+ // Segments section and the O2 card's evidence must agree on the label.
+ expect(human).toContain("Dikkat tuzağı");
+ expect(human).toContain("Bilişsel talep: var");
+ expect(human).not.toContain("dikkat_tuzagi");
+ expect(human).not.toContain("bilissel_talep");
+
+ expect(screen.getByTestId("insight-technical").textContent).toContain("dikkat_tuzagi");
+ });
+
it("keeps the cards-only mode free of the drawer's full-view sections", () => {
renderDrawer({ mode: "cards" });
const human = screen.getByTestId("insight-human").textContent ?? "";
diff --git a/src/components/insights/insight-detail.tsx b/src/components/insights/insight-detail.tsx
index ccc4891..4f32edc 100644
--- a/src/components/insights/insight-detail.tsx
+++ b/src/components/insights/insight-detail.tsx
@@ -8,7 +8,7 @@ import {
import { Badge } from "@/components/ui/badge";
import { EmptyInline } from "@/components/ui/empty-inline";
import { IconAlert, IconChart, IconSparkles } from "@/components/ui/icons";
-import { detailText, type InsightDetailKey } from "@/i18n/insights-detail";
+import { detailText, dimensionLabel, type InsightDetailKey } from "@/i18n/insights-detail";
import { cn } from "@/lib/cn";
import { formatDateTime } from "@/lib/format";
import { isRecord } from "@/lib/is-record";
@@ -30,11 +30,6 @@ const TRIGGER_KEYS: Record = {
homework: "trigger.homework",
mark_trend: "trigger.mark_trend",
};
-const DIMENSION_KEYS: Record = {
- bilissel_talep: "segments.dimension.bilissel_talep",
- dikkat_tuzagi: "segments.dimension.dikkat_tuzagi",
- okuma_yuku: "segments.dimension.okuma_yuku",
-};
const PRODUCT_KEYS: Record = {
O1: "product.O1",
O2: "product.O2",
@@ -66,10 +61,16 @@ export function InsightDetail(props: { insight: StudentInsight; mode?: "full" |
const title = isRecord(entry) ? entry.course_title : undefined;
return typeof title === "string" && title.length > 0 ? title : null;
};
- const courseLine = (id?: string | null) => courseTitle(id) ?? (id ? tx("insights.schoolWide") : null);
- const dimensionLabel = (dimension: string | null | undefined) => {
- const key = dimension ? DIMENSION_KEYS[dimension] : undefined;
- return key ? detailText(key) : null;
+ /**
+ * The attention list's own contract: a null `course` means the fact is
+ * school-wide, so that is the only case that may say so. A course id whose
+ * title never made it into the payload is NOT school-wide — saying it were
+ * invents a fact on a student's report, so it is labelled as unresolved
+ * (the id itself stays in the technical disclosure).
+ */
+ const courseLine = (id?: string | null) => {
+ if (!id) return tx("insights.schoolWide");
+ return courseTitle(id) ?? detailText("detail.unresolvedCourse");
};
/** A card scope is `=