Skip to content

Commit b8d956a

Browse files
authored
Update SubmissionStatusChip for hacked kernels (#227)
* Update SubmissionStatusChip for hacked kernels * fix submission status ui --------- Co-authored-by: Sinatras <SinatrasC@users.noreply.github.com>
1 parent f97b054 commit b8d956a

5 files changed

Lines changed: 106 additions & 12 deletions

File tree

frontend/src/pages/leaderboard/LeaderboardEditor.tsx

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ import {
4444

4545
const DEFAULT_CODE = `# Write your code here`;
4646

47+
function isTerminalErrorStatus(status?: string | null) {
48+
const v = typeof status === "string" ? status.toLowerCase() : "";
49+
return (
50+
v.includes("fail") ||
51+
v.includes("err") ||
52+
v.includes("hack") ||
53+
v.includes("timed") ||
54+
v.includes("timeout")
55+
);
56+
}
57+
4758
export default function LeaderboardEditor() {
4859
const { id } = useParams<{ id: string }>();
4960
const navigate = useNavigate();
@@ -428,8 +439,17 @@ export default function LeaderboardEditor() {
428439
</Alert>
429440
)}
430441
{editorStatus.kind === "done" && (
431-
<Alert severity="success" sx={{ mt: 1 }}>
432-
Submission completed!
442+
<Alert
443+
severity={
444+
isTerminalErrorStatus(editorStatus.result.status)
445+
? "error"
446+
: "success"
447+
}
448+
sx={{ mt: 1 }}
449+
>
450+
{isTerminalErrorStatus(editorStatus.result.status)
451+
? `Submission completed with status: ${editorStatus.result.status}`
452+
: "Submission completed!"}
433453
</Alert>
434454
)}
435455
</>

frontend/src/pages/leaderboard/components/editor/JobOutputPanel.tsx

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,30 @@ interface JobOutputPanelProps {
88
uploadStatus: SubmitStatus;
99
}
1010

11+
function isTerminalErrorStatus(status?: string | null) {
12+
const v = typeof status === "string" ? status.toLowerCase() : "";
13+
return (
14+
v.includes("fail") ||
15+
v.includes("err") ||
16+
v.includes("hack") ||
17+
v.includes("timed") ||
18+
v.includes("timeout")
19+
);
20+
}
21+
1122
export function JobOutputPanel({ editorStatus, uploadStatus }: JobOutputPanelProps) {
23+
const completedResult =
24+
editorStatus.kind === "done"
25+
? editorStatus.result
26+
: uploadStatus.kind === "done"
27+
? uploadStatus.result
28+
: undefined;
29+
const completedWithError = isTerminalErrorStatus(completedResult?.status);
30+
const doneLabel = completedWithError
31+
? (completedResult?.status ?? "failed")
32+
: "Done";
33+
const doneColor = completedWithError ? "error" : "success";
34+
1235
return (
1336
<Box sx={{ flex: 1, minHeight: 80, display: "flex", flexDirection: "column" }}>
1437
<Stack direction="row" alignItems="center" spacing={1} sx={{ mb: 1, flexShrink: 0 }}>
@@ -28,8 +51,8 @@ export function JobOutputPanel({ editorStatus, uploadStatus }: JobOutputPanelPro
2851
{(editorStatus.kind === "done" || uploadStatus.kind === "done") && (
2952
<Chip
3053
icon={<CheckCircleIcon />}
31-
label="Done"
32-
color="success"
54+
label={doneLabel}
55+
color={doneColor}
3356
size="small"
3457
sx={{ height: 20, fontSize: "0.7rem" }}
3558
/>
@@ -109,7 +132,7 @@ export function JobOutputPanel({ editorStatus, uploadStatus }: JobOutputPanelPro
109132

110133
{editorStatus.kind === "done" && editorStatus.result && (
111134
<Box>
112-
<div style={{ color: "#569cd6" }}>
135+
<div style={{ color: completedWithError ? "#f14c4c" : "#569cd6" }}>
113136
Submission #{editorStatus.submissionId} completed
114137
</div>
115138
{editorStatus.result.error && (
@@ -154,7 +177,16 @@ export function JobOutputPanel({ editorStatus, uploadStatus }: JobOutputPanelPro
154177
)}
155178
</Box>
156179
))}
157-
<div style={{ color: "#4ec9b0", marginTop: 8 }}>$ Done</div>
180+
<div
181+
style={{
182+
color: completedWithError ? "#f14c4c" : "#4ec9b0",
183+
marginTop: 8,
184+
}}
185+
>
186+
{completedWithError
187+
? `$ ${editorStatus.result.status ?? "failed"}`
188+
: "$ Done"}
189+
</div>
158190
</Box>
159191
)}
160192

frontend/src/pages/leaderboard/components/submission-history/SubmissionDoneCell.tsx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,39 @@
11
import { Tooltip } from "@mui/material";
22
import CheckCircleOutlineIcon from "@mui/icons-material/CheckCircleOutline";
3+
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
34
import HourglassEmptyIcon from "@mui/icons-material/HourglassEmpty";
45

5-
function SubmissionDoneCell({ done }: { done: boolean }) {
6+
function SubmissionDoneCell({
7+
done,
8+
status,
9+
}: {
10+
done: boolean;
11+
status?: string | null;
12+
}) {
13+
const v = typeof status === "string" ? status.toLowerCase() : "";
14+
const hasErrorStatus =
15+
v.includes("fail") ||
16+
v.includes("err") ||
17+
v.includes("hack") ||
18+
v.includes("timed") ||
19+
v.includes("timeout");
20+
21+
if (!done) {
22+
return (
23+
<Tooltip title="In progress">
24+
<HourglassEmptyIcon fontSize="small" />
25+
</Tooltip>
26+
);
27+
}
28+
29+
if (hasErrorStatus) {
30+
return (
31+
<Tooltip title={`Completed with status: ${v}`}>
32+
<ErrorOutlineIcon color="error" fontSize="small" />
33+
</Tooltip>
34+
);
35+
}
36+
637
return done ? (
738
<Tooltip title="Completed">
839
<CheckCircleOutlineIcon fontSize="small" />

frontend/src/pages/leaderboard/components/submission-history/SubmissionHistorySection.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,10 @@ export default function SubmissionHistorySection({
293293
<SubmissionStatusChip status={s.status} />
294294
</TableCell>
295295
<TableCell align="center">
296-
<SubmissionDoneCell done={s.submission_done} />
296+
<SubmissionDoneCell
297+
done={s.submission_done}
298+
status={s.status}
299+
/>
297300
</TableCell>
298301
<TableCell>
299302
{hasRuns ? (

frontend/src/pages/leaderboard/components/submission-history/SubmissionStatusChip.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,27 @@ import { Chip, Tooltip } from "@mui/material";
33
function SubmissionStatusChip({ status }: { status?: string | null }) {
44
const str = typeof status === "string" ? status : ""; // normalize
55
const v = str.toLowerCase();
6+
const isSuccess = v.includes("ok") || v.includes("succ");
7+
const isRunning = v.includes("run");
8+
const isError =
9+
v.includes("fail") ||
10+
v.includes("err") ||
11+
v.includes("hack") ||
12+
v.includes("timed") ||
13+
v.includes("timeout");
614

7-
const color: "default" | "success" | "warning" | "error" = v.includes("run")
15+
const color: "default" | "success" | "warning" | "error" = isRunning
816
? "warning"
9-
: v.includes("ok") || v.includes("succ")
17+
: isSuccess
1018
? "success"
11-
: v.includes("fail") || v.includes("err")
19+
: isError
1220
? "error"
1321
: "default";
1422

1523
const showFallback = !str;
1624
const label = showFallback
1725
? "via CLI/Discord bot"
18-
: v.includes("ok") || v.includes("succ")
26+
: isSuccess
1927
? "finished"
2028
: v;
2129

0 commit comments

Comments
 (0)