forge
Explore
Log in

Don't you dare go Hollow

🧠 keep insight table cells on one line and name roster failures

Browse files at this commit

881f809ecf9966f1704fd7a25beb45e7e531cfd6Burak BoduroğluParent: c748801
  • fix
    • 🧠 keep insight table cells on one line and name roster failures
Show full message
fix: 🧠 keep insight table cells on one line and name roster failures

- status cell shows a short "Analiz yok" pill, the full sentence moves to
  its tooltip; it used to wrap inside the 20px badge over nearby rows
- empty mark and attendance cells use the same "Veri yok" pill
- widen the status column so "Okunamadı" fits
- student analysis page no longer turns a failed roster read into
  "not in your list" with the raw account id as the heading; it shows the
  read error with a retry and a generic title until the name is known
src/components/insights/insight-students-table.tsxmodified+24 -8
@@ -54,8 +54,15 @@ export function InsightStudentsTable(props: {
54 const muted = "text-muted-foreground";54 const muted = "text-muted-foreground";
55 // The app-wide "18 Eyl 2026" date, not a numeric 18.09.2026.55 // The app-wide "18 Eyl 2026" date, not a numeric 18.09.2026.
56 const calculatedDate = (value: number | null | undefined) => formatDate(value, locale());56 const calculatedDate = (value: number | null | undefined) => formatDate(value, locale());
57+ // A cell with no value to show wears the same quiet pill as "Analiz yok",
58+ // so the empty states read as one kind of thing across the row.
59+ const emptyPill = (row: StudentSignal) => (
60+ <Badge variant="outline" class={cn("max-w-full rounded-full text-muted-foreground", row.state === "not_loaded" && "animate-pulse")}>
61+ <span class="truncate">{row.state === "not_loaded" ? rt("notLoaded") : t("insights.noData")}</span>
62+ </Badge>
63+ );
57 64
58- // Widths sum to ~1095px with the action column, so the grid fits a 1440px65+ // Widths sum to ~1105px with the action column, so the grid fits a 1440px
59 // screen beside the sidebar; at the 120px default every column got, the66 // screen beside the sidebar; at the 120px default every column got, the
60 // last one slid under the sticky actions and the table asked to scroll.67 // last one slid under the sticky actions and the table asked to scroll.
61 const columns = createMemo<ColumnDef<StudentSignal>[]>(() => [68 const columns = createMemo<ColumnDef<StudentSignal>[]>(() => [
@@ -73,24 +80,30 @@ export function InsightStudentsTable(props: {
73 },80 },
74 {81 {
75 id: "status",82 id: "status",
76- size: 108,83+ size: 118,
77 accessorFn: (row) => row.state,84 accessorFn: (row) => row.state,
78 header: rt("status" as never),85 header: rt("status" as never),
79 meta: { align: "center" },86 meta: { align: "center" },
80 cell: (cell) => {87 cell: (cell) => {
81 const row = cell.row.original;88 const row = cell.row.original;
89+ // The badge is one 20px line: the full "no analysis computed" sentence
90+ // wrapped inside it and spilled over the rows above and below, so the
91+ // cell shows a short label and the sentence rides in the tooltip.
92+ const label = row.state === "error"
93+ ? t("insights.readFailed")
94+ : row.state === "no_summary" ? t("insights.noAnalysis") : studentStatusText(locale(), row);
82 return (95 return (
83 <Badge96 <Badge
84 variant="outline"97 variant="outline"
85 class={cn(98 class={cn(
86- "rounded-full",99+ "max-w-full rounded-full",
87 row.state === "ok" && "border-success/30 bg-success/10 text-success-text",100 row.state === "ok" && "border-success/30 bg-success/10 text-success-text",
88 row.state === "error" && "border-destructive/30 bg-destructive/10 text-destructive-text",101 row.state === "error" && "border-destructive/30 bg-destructive/10 text-destructive-text",
89 row.state === "not_loaded" && "animate-pulse",102 row.state === "not_loaded" && "animate-pulse",
90 )}103 )}
91- title={row.error ?? undefined}104+ title={row.error ?? (row.state === "no_summary" ? studentStatusText(locale(), row) : undefined)}
92 >105 >
93- {row.state === "error" ? t("insights.readFailed") : studentStatusText(locale(), row)}106+ <span class="truncate">{label}</span>
94 </Badge>107 </Badge>
95 );108 );
96 },109 },
@@ -121,7 +134,9 @@ export function InsightStudentsTable(props: {
121 accessorFn: (row) => row.marks.average ?? -1,134 accessorFn: (row) => row.marks.average ?? -1,
122 header: rt("marksAverage"),135 header: rt("marksAverage"),
123 meta: { align: "center" },136 meta: { align: "center" },
124- cell: (cell) => <span class={cn("tabular-nums", !loaded(cell.row.original) && muted)}>{studentMarksText(locale(), cell.row.original)}</span>,137+ cell: (cell) => loaded(cell.row.original)
138+ ? <span class="tabular-nums">{studentMarksText(locale(), cell.row.original)}</span>
139+ : emptyPill(cell.row.original),
125 },140 },
126 {141 {
127 id: "attendance",142 id: "attendance",
@@ -131,8 +146,9 @@ export function InsightStudentsTable(props: {
131 meta: { align: "center" },146 meta: { align: "center" },
132 cell: (cell) => {147 cell: (cell) => {
133 const row = cell.row.original;148 const row = cell.row.original;
134- const low = loaded(row) && row.attendance.observed > 0 && (row.attendance.rate ?? 1) < 0.85;149+ if (!loaded(row) || row.attendance.observed === 0) return emptyPill(row);
135- return <span class={cn("tabular-nums", low && "font-semibold text-warning-text", !loaded(row) && muted)}>{studentAttendanceText(locale(), row)}</span>;150+ const low = (row.attendance.rate ?? 1) < 0.85;
151+ return <span class={cn("tabular-nums", low && "font-semibold text-warning-text")}>{studentAttendanceText(locale(), row)}</span>;
136 },152 },
137 },153 },
138 {154 {
src/i18n/locales/en.tsmodified+3 -0
@@ -680,6 +680,8 @@ export const en: Dict = {
680 "common.saved": "Saved successfully.",680 "common.saved": "Saved successfully.",
681 "common.loadAll": "Load all",681 "common.loadAll": "Load all",
682 "insights.readFailed": "Could not read",682 "insights.readFailed": "Could not read",
683+ "insights.noAnalysis": "No analysis",
684+ "insights.noData": "No data",
683 "insights.studyStints": "Focus",685 "insights.studyStints": "Focus",
684 "insights.filter.all": "All",686 "insights.filter.all": "All",
685 "insights.filter.attention": "Needs attention",687 "insights.filter.attention": "Needs attention",
@@ -1116,6 +1118,7 @@ export const en: Dict = {
1116 "insights.recompute": "Recompute",1118 "insights.recompute": "Recompute",
1117 "insights.recomputing": "Queuing…",1119 "insights.recomputing": "Queuing…",
1118 "insights.recomputeQueued": "Analysis for {student} was queued.",1120 "insights.recomputeQueued": "Analysis for {student} was queued.",
1121+ "insights.recomputeQueuedUnnamed": "The analysis was queued.",
1119 "insights.summary": "Summary",1122 "insights.summary": "Summary",
1120 "insights.noSummary": "No analysis yet",1123 "insights.noSummary": "No analysis yet",
1121 "insights.noSummaryHint": "Queue a computation to create the first analysis.",1124 "insights.noSummaryHint": "Queue a computation to create the first analysis.",
src/i18n/locales/tr.tsmodified+3 -0
@@ -676,6 +676,8 @@ export const tr: Dict = {
676 "common.saved": "Başarıyla kaydedildi.",676 "common.saved": "Başarıyla kaydedildi.",
677 "common.loadAll": "Tümünü yükle",677 "common.loadAll": "Tümünü yükle",
678 "insights.readFailed": "Okunamadı",678 "insights.readFailed": "Okunamadı",
679+ "insights.noAnalysis": "Analiz yok",
680+ "insights.noData": "Veri yok",
679 "insights.studyStints": "Odak",681 "insights.studyStints": "Odak",
680 "insights.filter.all": "Tümü",682 "insights.filter.all": "Tümü",
681 "insights.filter.attention": "Dikkat gerekenler",683 "insights.filter.attention": "Dikkat gerekenler",
@@ -1112,6 +1114,7 @@ export const tr: Dict = {
1112 "insights.recompute": "Yeniden hesapla",1114 "insights.recompute": "Yeniden hesapla",
1113 "insights.recomputing": "Sıraya alınıyor…",1115 "insights.recomputing": "Sıraya alınıyor…",
1114 "insights.recomputeQueued": "{student} için analiz sıraya alındı.",1116 "insights.recomputeQueued": "{student} için analiz sıraya alındı.",
1117+ "insights.recomputeQueuedUnnamed": "Analiz sıraya alındı.",
1115 "insights.summary": "Özet",1118 "insights.summary": "Özet",
1116 "insights.noSummary": "Henüz analiz yok",1119 "insights.noSummary": "Henüz analiz yok",
1117 "insights.noSummaryHint": "İlk analizi oluşturmak için hesaplamayı sıraya alın.",1120 "insights.noSummaryHint": "İlk analizi oluşturmak için hesaplamayı sıraya alın.",
src/i18n/messages.tsmodified+3 -0
@@ -664,6 +664,8 @@ export type MessageKey =
664 | "common.saved"664 | "common.saved"
665 | "common.loadAll"665 | "common.loadAll"
666 | "insights.readFailed"666 | "insights.readFailed"
667+ | "insights.noAnalysis"
668+ | "insights.noData"
667 | "insights.studyStints"669 | "insights.studyStints"
668 | "insights.filter.all"670 | "insights.filter.all"
669 | "insights.filter.attention"671 | "insights.filter.attention"
@@ -1103,6 +1105,7 @@ export type MessageKey =
1103 | "insights.recompute"1105 | "insights.recompute"
1104 | "insights.recomputing"1106 | "insights.recomputing"
1105 | "insights.recomputeQueued"1107 | "insights.recomputeQueued"
1108+ | "insights.recomputeQueuedUnnamed"
1106 | "insights.summary"1109 | "insights.summary"
1107 | "insights.noSummary"1110 | "insights.noSummary"
1108 | "insights.noSummaryHint"1111 | "insights.noSummaryHint"
src/pages/ai-insight-student-page.tsxmodified+34 -10
@@ -16,6 +16,7 @@ import { createFlash } from "@/lib/flash";
16 import { loadInsightStudents } from "@/lib/insight-students";16 import { loadInsightStudents } from "@/lib/insight-students";
17 import { personLabel } from "@/lib/person";17 import { personLabel } from "@/lib/person";
18 import { hasMinRole } from "@/lib/roles";18 import { hasMinRole } from "@/lib/roles";
19+import { runReportText } from "@/i18n/insights-run-report";
19 import { useAuth } from "@/stores/auth-context";20 import { useAuth } from "@/stores/auth-context";
20 import { formatDate } from "@/lib/format";21 import { formatDate } from "@/lib/format";
21 import { usePreferences } from "@/stores/preferences-context";22 import { usePreferences } from "@/stores/preferences-context";
@@ -53,11 +54,24 @@ function AiInsightStudentContent() {
53 const [actionError, setActionError] = createSignal("");54 const [actionError, setActionError] = createSignal("");
54 const [flash, setFlash] = createFlash();55 const [flash, setFlash] = createFlash();
55 56
56- const [students] = createResource(() => role() ?? null, (viewerRole) => loadInsightStudents(viewerRole).catch(() => []));57+ // A failed roster read is kept apart from an empty one: swallowing it into
57- const person = createMemo(() => (students() ?? []).find((student) => student.id === userId()) ?? null);58+ // `[]` told a rate-limited viewer the student was "not in your list" and
59+ // put the raw account id where the name goes.
60+ const [roster, { refetch: refetchRoster }] = createResource(
61+ () => role() ?? null,
62+ (viewerRole) => loadInsightStudents(viewerRole).then(
63+ (list) => ({ list, error: null as unknown }),
64+ (error: unknown) => ({ list: null, error }),
65+ ),
66+ );
67+ const person = createMemo(() => roster()?.list?.find((student) => student.id === userId()) ?? null);
68+ const notInList = () => roster()?.list != null && !person();
58 const [insight, { refetch }] = createResource(userId, (id) => getInsightByUserId(id));69 const [insight, { refetch }] = createResource(userId, (id) => getInsightByUserId(id));
59- const studentName = () => person() ? personLabel(person()!) : userId();70+ const studentName = () => {
60- const initials = () => studentName()71+ const current = person();
72+ return current ? personLabel(current) : null;
73+ };
74+ const initials = () => (studentName() ?? "")
61 .split(/\s+/)75 .split(/\s+/)
62 .filter(Boolean)76 .filter(Boolean)
63 .slice(0, 2)77 .slice(0, 2)
@@ -77,7 +91,7 @@ function AiInsightStudentContent() {
77 setActionError("");91 setActionError("");
78 try {92 try {
79 await postInsightComputeByUserId(userId());93 await postInsightComputeByUserId(userId());
80- setFlash(t("insights.recomputeQueued", { student: current ? personLabel(current) : userId() }));94+ setFlash(current ? t("insights.recomputeQueued", { student: personLabel(current) }) : t("insights.recomputeQueuedUnnamed"));
81 } catch (error) {95 } catch (error) {
82 setActionError(formatApiError(error));96 setActionError(formatApiError(error));
83 } finally {97 } finally {
@@ -86,9 +100,9 @@ function AiInsightStudentContent() {
86 };100 };
87 101
88 return (102 return (
89- <div class="mx-auto w-full max-w-[1240px] space-y-5">103+ <div class="w-full space-y-5">
90 <div class="space-y-2">104 <div class="space-y-2">
91- <Breadcrumbs items={[{ label: t("insights.title"), to: "/ai/insights" }, { label: studentName() }]} />105+ <Breadcrumbs items={[{ label: t("insights.title"), to: "/ai/insights" }, { label: studentName() ?? t("insights.studentAnalysis") }]} />
92 </div>106 </div>
93 <Show when={flash()}>107 <Show when={flash()}>
94 <Alert variant="success">{flash()}</Alert>108 <Alert variant="success">{flash()}</Alert>
@@ -96,7 +110,15 @@ function AiInsightStudentContent() {
96 <Show when={actionError()}>110 <Show when={actionError()}>
97 <Alert variant="destructive">{actionError()}</Alert>111 <Alert variant="destructive">{actionError()}</Alert>
98 </Show>112 </Show>
99- <Show when={students() && !person()}>113+ <Show when={roster()?.error}>
114+ {(error) => (
115+ <ErrorAlert
116+ message={runReportText(prefs.locale(), "rosterFailed", { message: formatApiError(error()) })}
117+ onRetry={() => void refetchRoster()}
118+ />
119+ )}
120+ </Show>
121+ <Show when={notInList()}>
100 <Alert variant="warning">{t("insights.notFound")}</Alert>122 <Alert variant="warning">{t("insights.notFound")}</Alert>
101 </Show>123 </Show>
102 <Show when={insight.error}>124 <Show when={insight.error}>
@@ -115,7 +137,7 @@ function AiInsightStudentContent() {
115 <div class="min-w-0">137 <div class="min-w-0">
116 <p class="text-xs font-semibold uppercase tracking-[0.14em] text-primary-text">{t("insights.title")}</p>138 <p class="text-xs font-semibold uppercase tracking-[0.14em] text-primary-text">{t("insights.title")}</p>
117 <div class="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1">139 <div class="mt-1 flex flex-wrap items-center gap-x-3 gap-y-1">
118- <h1 class="truncate text-2xl font-semibold tracking-tight text-text-strong">{studentName()}</h1>140+ <h1 class="truncate text-2xl font-semibold tracking-tight text-text-strong">{studentName() ?? t("insights.studentAnalysis")}</h1>
119 <Show141 <Show
120 when={value().summary}142 when={value().summary}
121 fallback={<span class="text-xs text-muted-foreground">{t("insights.noSummary")}</span>}143 fallback={<span class="text-xs text-muted-foreground">{t("insights.noSummary")}</span>}
@@ -131,7 +153,9 @@ function AiInsightStudentContent() {
131 )}153 )}
132 </Show>154 </Show>
133 </div>155 </div>
134- <p class="mt-0.5 text-sm text-muted-foreground">{t("insights.studentAnalysis")}</p>156+ <Show when={studentName()}>
157+ <p class="mt-0.5 text-sm text-muted-foreground">{t("insights.studentAnalysis")}</p>
158+ </Show>
135 </div>159 </div>
136 </div>160 </div>
137 <div class="flex flex-wrap items-center gap-2">161 <div class="flex flex-wrap items-center gap-2">