The admin can upload a recording of themselves explaining a problem's solution out loud (mp3, m4a, wav, webm, ogg or flac, up to 25 MB) and get interview-style feedback, committed as reviews/<id>.md so every attempt is kept. Claude can't take audio, so the recording is transcribed first by an OpenAI-compatible endpoint (whisper-1 by default; TRANSCRIBE_API_KEY, with TRANSCRIBE_URL for a self-hosted server). Pace, pauses, filler words and when complexity first comes up are measured from the word timestamps and given to Claude with the timestamped transcript, the statement and optionally the code. The reply covers the verdict, scores in five areas, the approach and its complexity, missed edge cases, delivery and what to work on. Recordings are kept for playback in an S3 bucket (Garage) when the S3_* settings are given, and are thrown away otherwise. Reviews are admin-only. The job runs in the background like Explain, and the statement fetch and save-error handling are now shared between the two. Co-Authored-By: Claude Opus 5.5 <[email protected]>
101 lines
3.0 KiB
Vue
101 lines
3.0 KiB
Vue
<script setup>
|
|
/**
|
|
* explain.md, laid out as the ladder it was written to be: every "## "
|
|
* section folded away so the reader opens only as much as they need (the
|
|
* observation, then one hint at a time, ...). The line above the first
|
|
* section (who wrote it, when) stays visible. Reviews use it too, with the
|
|
* sections worth reading at once named in open.
|
|
*
|
|
* Markdown is rendered with html: false like the notes. The one exception
|
|
* is ```svg fences, the walkthrough's diagrams: they are inserted as SVG
|
|
* after DOMPurify's SVG profile has stripped scripts, event handlers and
|
|
* anything else that is not drawing. Claude wrote them, the admin can edit
|
|
* them, and the public sees them once the problem is solved.
|
|
*/
|
|
import { computed } from "vue";
|
|
import MarkdownIt from "markdown-it";
|
|
import DOMPurify from "dompurify";
|
|
|
|
const props = defineProps({
|
|
source: { type: String, required: true },
|
|
open: { type: Array, default: () => [] },
|
|
});
|
|
|
|
const md = new MarkdownIt({ html: false, linkify: true });
|
|
const fence = md.renderer.rules.fence;
|
|
md.renderer.rules.fence = (tokens, idx, options, env, self) => {
|
|
const t = tokens[idx];
|
|
if (t.info.trim() !== "svg") return fence(tokens, idx, options, env, self);
|
|
const clean = DOMPurify.sanitize(t.content, { USE_PROFILES: { svg: true, svgFilters: true } });
|
|
return `<figure class="diagram">${clean}</figure>`;
|
|
};
|
|
|
|
// Split on "## " headings outside code fences.
|
|
const parts = computed(() => {
|
|
const intro = [];
|
|
const sections = [];
|
|
let inFence = false;
|
|
for (const line of props.source.split("\n")) {
|
|
if (line.startsWith("```")) inFence = !inFence;
|
|
if (!inFence && line.startsWith("## ")) {
|
|
sections.push({ title: line.slice(3).trim(), lines: [] });
|
|
} else {
|
|
(sections.length ? sections[sections.length - 1].lines : intro).push(line);
|
|
}
|
|
}
|
|
return {
|
|
intro: md.render(intro.join("\n")),
|
|
sections: sections.map((s) => ({ title: s.title, html: md.render(s.lines.join("\n")) })),
|
|
};
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<div class="explanation">
|
|
<div v-if="parts.intro.trim()" class="intro muted prose" v-html="parts.intro"></div>
|
|
<details v-for="(s, i) in parts.sections" :key="i + s.title" class="step card" :open="open.includes(s.title)">
|
|
<summary>{{ s.title }}</summary>
|
|
<div class="body prose" v-html="s.html"></div>
|
|
</details>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
.explanation {
|
|
display: grid;
|
|
gap: 8px;
|
|
min-width: 0;
|
|
}
|
|
.intro {
|
|
font-size: 0.85rem;
|
|
}
|
|
.step summary {
|
|
padding: 8px 14px;
|
|
cursor: pointer;
|
|
font-weight: bold;
|
|
}
|
|
.step[open] summary {
|
|
border-bottom: 1px solid var(--color-line-soft);
|
|
}
|
|
.body {
|
|
padding: 12px 16px 16px;
|
|
min-width: 0;
|
|
overflow-wrap: anywhere;
|
|
}
|
|
.body :deep(.diagram) {
|
|
margin: 12px 0;
|
|
padding: 12px;
|
|
border: 1px solid var(--color-line-soft);
|
|
border-radius: 4px;
|
|
background: var(--color-paper);
|
|
color: var(--color-ink);
|
|
}
|
|
.body :deep(.diagram svg) {
|
|
display: block;
|
|
width: 100%;
|
|
max-width: 640px;
|
|
height: auto;
|
|
margin: 0 auto;
|
|
}
|
|
</style>
|