Tidy the site's problem pages and typeset math in explanations
Test and publish the site / test (push) Successful in 1m10s
Test and publish the site / publish (push) Successful in 1m29s

The problem page's Explain and recording-review forms took most of the
first screen, above the solution. They now fold into the admin bar with
the editor, one open at a time; a running job is reported in the bar,
so a form can be closed while it works.

The problem list is grouped by month when sorted by recency, as one
card per month with divided rows, laid out on a fixed grid so rows
line up on a phone. Empty status tabs are hidden.

Rust solutions are now highlighted, the file picker is styled like the
other buttons, header links no longer break mid-word on a phone, and
keyboard focus is visible.

Markdown everywhere now goes through one renderer that typesets
$...$, $$...$$ and ```math with KaTeX. The explanation prompt asked for
$...$ only when the statement used it, so formulas came out as inline
code; it now asks for LaTeX for math and code spans for code, and the
review prompt does the same for complexities.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-10-20 02:19:24 +01:00
co-authored by Claude Opus 5.5
parent 63608f130c
commit 4dc8d1674c
11 changed files with 348 additions and 102 deletions
+153 -56
View File
@@ -10,10 +10,10 @@
*/
import { computed, onUnmounted, ref, watch } from "vue";
import { RouterLink } from "vue-router";
import MarkdownIt from "markdown-it";
import CodeBlock from "@/components/CodeBlock.vue";
import Explanation from "@/components/Explanation.vue";
import ReviewList from "@/components/ReviewList.vue";
import { markdown } from "@/markdown";
import {
explainStatus,
fetchStatement,
@@ -29,19 +29,24 @@ import { LANG_LABELS, STATUS_LABELS, formatDate, title } from "@/format";
const props = defineProps({ name: { type: String, required: true } });
// html: false — notes are rendered as markdown only, never as raw HTML.
const md = new MarkdownIt({ html: false, linkify: true });
const md = markdown();
const problem = ref(null);
const admin = ref(false);
const loading = ref(true);
const error = ref("");
const activeFile = ref(0);
// The editor, Explain and Review forms fold into the admin bar, one open at
// a time, so the solution is not pushed below the fold. A running job is
// reported in the bar, so a panel can be closed while it works. Declared
// here because load() closes it and runs as soon as the watch below is set.
const panel = ref("");
async function load() {
loading.value = true;
error.value = "";
activeFile.value = 0;
panel.value = "";
try {
const [p, me] = await Promise.all([getProblem(props.name), getMe().catch(() => ({ admin: false }))]);
problem.value = p;
@@ -63,10 +68,35 @@ const notesHtml = computed(() => (problem.value?.notes ? md.render(problem.value
const statementHtml = computed(() => (problem.value?.statement ? md.render(problem.value.statement) : ""));
const file = computed(() => problem.value?.files[activeFile.value]);
// ---- admin tools ----
const tools = [
{ id: "edit", label: "Edit details" },
{ id: "explain", label: "Explain" },
{ id: "review", label: "Review a recording" },
];
function toggle(id) {
// The file input goes with the panel, so the picked file must too.
if (panel.value === "review") recording.value = null;
if (panel.value === id) {
panel.value = "";
return;
}
if (id === "edit") startEdit();
panel.value = id;
}
const busy = computed(() => {
const out = [];
if (job.value.state === "running") out.push("Claude is writing an explanation…");
if (reviewJob.value.state === "uploading") out.push("Uploading the recording…");
if (reviewJob.value.state === "running") out.push("Transcribing and reviewing the recording… this takes a minute or two.");
return out;
});
// ---- admin edits ----
const saving = ref(false);
const editError = ref("");
const editing = ref(false);
const draftUrl = ref("");
const draftNotes = ref("");
const draftStatement = ref("");
@@ -77,7 +107,6 @@ function startEdit() {
draftNotes.value = problem.value.notes || "";
draftStatement.value = problem.value.statement || "";
editError.value = "";
editing.value = true;
}
async function run(action) {
@@ -97,7 +126,7 @@ async function run(action) {
async function saveMeta() {
const meta = { url: draftUrl.value, notes: draftNotes.value, statement: draftStatement.value };
if (await run(() => updateMeta(props.name, meta))) {
editing.value = false;
panel.value = "";
}
}
@@ -148,6 +177,7 @@ async function checkExplain() {
async function explain() {
try {
job.value = await startExplain(props.name, { note: stuckNote.value, includeCode: includeCode.value });
panel.value = "";
poll = setTimeout(checkExplain, 3000);
} catch (e) {
job.value = { state: "error", error: e.message };
@@ -160,7 +190,6 @@ const canExplain = computed(() => !!(problem.value?.statement || problem.value?.
// The same shape as explanations, with its own job and timer: both can run
// at once.
const recording = ref(null);
const recordingInput = ref(null);
const reviewNote = ref("");
const reviewCode = ref(true);
const reviewJob = ref({ state: "idle" });
@@ -212,7 +241,7 @@ async function submitReview() {
try {
reviewJob.value = await startReview(props.name, form);
recording.value = null;
if (recordingInput.value) recordingInput.value.value = "";
panel.value = "";
reviewPoll = setTimeout(checkReview, 3000);
} catch (e) {
reviewJob.value = { state: "error", error: e.message };
@@ -265,10 +294,25 @@ const moves = computed(() => {
<button v-for="m in moves" :key="m.to" class="btn" :disabled="saving" @click="run(() => setStatus(problem.name, m.to))">
{{ m.label }}
</button>
<button v-if="!editing" class="btn" :disabled="saving" @click="startEdit">Edit link, statement and notes</button>
<span v-if="saving" class="muted">Saving to git…</span>
<span class="sep" aria-hidden="true"></span>
<button
v-for="t in tools"
:key="t.id"
class="btn tool"
:class="{ on: panel === t.id }"
:aria-expanded="panel === t.id"
:disabled="t.id === 'edit' && saving"
@click="toggle(t.id)"
>
{{ t.label }}
</button>
</div>
<form v-if="editing" class="editor" @submit.prevent="saveMeta">
<div v-if="saving || busy.length" class="admin-row status" role="status">
<span v-if="saving" class="muted">Saving to git…</span>
<span v-for="b in busy" :key="b" class="working">{{ b }}</span>
</div>
<form v-if="panel === 'edit'" class="editor panel" @submit.prevent="saveMeta">
<label>
Problem link
<input v-model="draftUrl" type="url" placeholder="https://usaco.org/index.php?page=viewproblem2&cpid=…" />
@@ -288,47 +332,47 @@ const moves = computed(() => {
</label>
<div class="admin-row">
<button class="btn primary" type="submit" :disabled="saving">Save</button>
<button class="btn" type="button" :disabled="saving" @click="editing = false">Cancel</button>
<button class="btn" type="button" :disabled="saving" @click="panel = ''">Cancel</button>
</div>
</form>
<div v-if="panel === 'explain'" class="panel">
<h2>Stuck?</h2>
<p class="muted">
Claude writes an intuitive explanation with diagrams, laid out as hints you open one at a time. It takes a
minute or two and is committed as <code>explain.md</code>.
</p>
<textarea v-model="stuckNote" rows="3" placeholder="Optional: what you've tried and where you're stuck"></textarea>
<div class="admin-row">
<label class="check"><input v-model="includeCode" type="checkbox" /> Include my current code</label>
<button class="btn primary" :disabled="job.state === 'running' || !canExplain" @click="explain">
{{ problem.explanation ? "Explain again" : "Explain" }}
</button>
<span v-if="!canExplain" class="muted">Add a link or the statement first.</span>
</div>
</div>
<div v-if="panel === 'review'" class="panel">
<h2>Review my explanation</h2>
<p class="muted">
Record yourself explaining your solution as you would to an interviewer, then upload it (mp3, m4a, wav,
webm, ogg or flac, up to 25 MB). It is transcribed, and Claude gives feedback on the approach and on your
delivery. Each review is committed under <code>reviews/</code>.
</p>
<input type="file" accept="audio/*,.mp3,.m4a,.wav,.webm,.ogg,.flac" @change="pickRecording" />
<textarea v-model="reviewNote" rows="2" placeholder="Optional context: a mock interview, a time limit, what to focus on"></textarea>
<div class="admin-row">
<label class="check"><input v-model="reviewCode" type="checkbox" /> Include my code</label>
<button class="btn primary" :disabled="!canReview" @click="submitReview">Review</button>
<span v-if="!canExplain" class="muted">Add a link or the statement first.</span>
</div>
</div>
<!-- Outside the panels, so a job that fails after its panel was
closed still says so. -->
<p v-if="editError" class="error">{{ editError }}</p>
</section>
<section v-if="admin" class="stuck card">
<h2>Stuck?</h2>
<p class="muted">
Claude writes an intuitive explanation with diagrams, laid out as hints you open one at a time. It takes a
minute or two and is committed as <code>explain.md</code>.
</p>
<textarea v-model="stuckNote" rows="3" placeholder="Optional: what you've tried and where you're stuck"></textarea>
<div class="admin-row">
<label class="check"><input v-model="includeCode" type="checkbox" /> Include my current code</label>
<button class="btn primary" :disabled="job.state === 'running' || !canExplain" @click="explain">
{{ problem.explanation ? "Explain again" : "Explain" }}
</button>
<span v-if="job.state === 'running'" class="muted">Claude is writing it…</span>
<span v-else-if="!canExplain" class="muted">Add a link or the statement first.</span>
</div>
<p v-if="job.state === 'error'" class="error">{{ job.error }}</p>
</section>
<section v-if="admin" class="stuck card">
<h2>Review my explanation</h2>
<p class="muted">
Record yourself explaining your solution as you would to an interviewer, then upload it (mp3, m4a, wav,
webm, ogg or flac, up to 25 MB). It is transcribed, and Claude gives feedback on the approach and on your
delivery. Each review is committed under <code>reviews/</code>.
</p>
<input ref="recordingInput" type="file" accept="audio/*,.mp3,.m4a,.wav,.webm,.ogg,.flac" @change="pickRecording" />
<textarea v-model="reviewNote" rows="2" placeholder="Optional context: a mock interview, a time limit, what to focus on"></textarea>
<div class="admin-row">
<label class="check"><input v-model="reviewCode" type="checkbox" /> Include my code</label>
<button class="btn primary" :disabled="!canReview" @click="submitReview">Review</button>
<span v-if="reviewJob.state === 'uploading'" class="muted">Uploading…</span>
<span v-else-if="reviewJob.state === 'running'" class="muted">Transcribing and reviewing… this takes a minute or two.</span>
<span v-else-if="!canExplain" class="muted">Add a link or the statement first.</span>
</div>
<p v-if="reviewJob.state === 'error'" class="error">{{ reviewJob.error }}</p>
<p v-if="job.state === 'error'" class="error">Explain: {{ job.error }}</p>
<p v-if="reviewJob.state === 'error'" class="error">Review: {{ reviewJob.error }}</p>
</section>
<section v-if="notesHtml" class="notes card prose" v-html="notesHtml"></section>
@@ -489,23 +533,64 @@ h2 {
padding: 2px 10px;
font-size: 0.8rem;
}
.stuck {
padding: 12px 16px 16px;
.sep {
width: 1px;
align-self: stretch;
margin: 0 4px;
background: var(--color-line-soft);
}
/* On a phone the buttons wrap, and the divider would end a line. */
@media (max-width: 639px) {
.sep {
display: none;
}
}
.btn.tool.on {
border-color: var(--color-ink);
background: var(--color-paper-shade);
}
.status {
font-size: 0.9rem;
}
/* A pulsing dot: the job is still going, and the page is polling for it. */
.working::before {
content: "";
display: inline-block;
width: 8px;
height: 8px;
margin-right: 8px;
border-radius: 50%;
background: var(--color-solving);
animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
50% {
opacity: 0.25;
}
}
@media (prefers-reduced-motion: reduce) {
.working::before {
animation: none;
}
}
.panel {
display: grid;
gap: 10px;
padding-top: 12px;
border-top: 1px solid var(--color-line-soft);
}
.stuck h2 {
.panel h2 {
margin: 0;
}
.stuck p {
.panel p {
margin: 0;
font-size: 0.9rem;
}
.stuck code {
.panel code {
font-family: var(--font-mono);
font-size: 0.85em;
}
.stuck textarea {
.panel textarea {
padding: 8px 10px;
border: 1px solid var(--color-line);
border-radius: 4px;
@@ -513,10 +598,22 @@ h2 {
color: var(--color-ink);
background: var(--color-paper);
}
.stuck input[type="file"] {
.panel input[type="file"] {
font-size: 0.9rem;
max-width: 100%;
}
.panel input[type="file"]::file-selector-button {
margin-right: 10px;
padding: 6px 14px;
border: 1px solid var(--color-line);
border-radius: 4px;
background: var(--color-paper);
color: var(--color-ink);
cursor: pointer;
}
.panel input[type="file"]::file-selector-button:hover {
border-color: var(--color-ink-muted);
}
.check {
display: flex;
align-items: center;