mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 06:19:43 +08:00
The Mastery Path sidebar, composer and progress ring, in four changes.
Study conversations are filed under their topic. They were already ordinary
chat sessions carrying `mastery_path_id`, so the sidebar had everything it
needed and used none of it: they sat loose among the recents, and a click
opened them on /home, which drops the outline, the waypoint header and the
tutor's own composer. `lib/mastery-session.ts` answers both questions in one
place, because a sidebar that files a conversation under a heading and then
navigates somewhere else is worse than one that does neither. Grouped
conversations are exempt from the eight-row cut on recents: a heading that
says "4" while listing two of them is worse than a slightly longer list.
The composer placeholder is written by the task model. "Ask your tutor about
X" was the third appearance of that waypoint on screen and proposed nothing,
and a learner who is stuck is stuck on what to ask. So it offers one question
the tutor's last message did not already answer, and Tab takes it. It is a
question and never an answer -- on a mastery path the learner produces the
understanding, so anything not ending in a question mark is dropped. Nothing
waits on the call: the static placeholder stands until a hint arrives, and a
failure just leaves it standing.
`/topics/index` exists because the sidebar refreshes on every stream end and
`/topics` answers with each path's whole knowledge map and source excerpts.
It is declared above `/topics/{path_id}`, which matches any single segment.
The connected-agent and persona chips reach every surface sharing the
composer. StandaloneComposer already filtered subagents out of the knowledge
picker, commented "they are their own composer control" -- and then never
mounted that control, so a connected agent was unreachable from Mastery Path,
Immersive Reading and quiz follow-ups alike. Owning the split once lifts all
three, and keeps them on the same composer the chat page renders.
The progress ring stops competing with the card it sits on. A bare "7" is an
id or a step number, not a measurement; `--primary` is what buttons and links
are, and the card is itself one; and a 2.5px round cap at low percentages
reads as a stuck spinner. Ink hairline, a real unit, and `--primary` kept for
the one moment it means something.
89 lines
3.1 KiB
TypeScript
89 lines
3.1 KiB
TypeScript
/**
|
|
* A topic's completion, drawn as a ring.
|
|
*
|
|
* This replaced a system emoji sitting in a bordered tile. The emoji was
|
|
* whatever the model happened to pick, rendered at whatever the OS font
|
|
* decided — it carried no information and read as clip art. The ring is the
|
|
* one number the card is actually about, and it inherits the theme.
|
|
*
|
|
* Three things it deliberately is not:
|
|
*
|
|
* A *bare integer* in a circle. "7" with no unit is an id, a step number, an
|
|
* avatar badge — anything but a measurement. The figure carries a small `%`
|
|
* so it reads as the quantity it is, and the two are set at different sizes
|
|
* so the number stays the thing you see.
|
|
*
|
|
* *Action-coloured*. `--primary` is what buttons and links are, and the card
|
|
* this sits on is itself one big link. An arc in that blue competes with the
|
|
* title for the eye and quietly suggests it can be clicked. So the arc is
|
|
* ink — the page's own foreground — and `--primary` is kept for the single
|
|
* moment it means something: the path is finished.
|
|
*
|
|
* *Heavy*. The stroke is a hairline, and the unfilled track is dimmer than
|
|
* the border it is drawn from. A ring is a footnote to the title next to it;
|
|
* at 2.5px it read as the loudest thing on the card, and at low percentages
|
|
* a thick round cap turns a real value into what looks like a stuck spinner.
|
|
*/
|
|
export function ProgressRing({
|
|
value,
|
|
size = 32,
|
|
stroke = 1.75,
|
|
showLabel = true,
|
|
}: {
|
|
/** Completion in 0..1. */
|
|
value: number;
|
|
size?: number;
|
|
stroke?: number;
|
|
showLabel?: boolean;
|
|
}) {
|
|
const safe = Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0));
|
|
const radius = (size - stroke) / 2;
|
|
const circumference = 2 * Math.PI * radius;
|
|
const percent = Math.round(safe * 100);
|
|
const complete = safe >= 1;
|
|
|
|
return (
|
|
<span
|
|
className="relative inline-flex shrink-0 items-center justify-center"
|
|
style={{ width: size, height: size }}
|
|
>
|
|
<svg width={size} height={size} aria-hidden="true" className="-rotate-90">
|
|
<circle
|
|
cx={size / 2}
|
|
cy={size / 2}
|
|
r={radius}
|
|
fill="none"
|
|
stroke="var(--border)"
|
|
strokeWidth={stroke}
|
|
opacity={0.45}
|
|
/>
|
|
{safe > 0 && (
|
|
<circle
|
|
cx={size / 2}
|
|
cy={size / 2}
|
|
r={radius}
|
|
fill="none"
|
|
stroke={complete ? "var(--primary)" : "var(--foreground)"}
|
|
strokeWidth={stroke}
|
|
strokeLinecap="round"
|
|
strokeDasharray={circumference}
|
|
strokeDashoffset={circumference * (1 - safe)}
|
|
opacity={complete ? 1 : 0.7}
|
|
className="transition-[stroke-dashoffset] duration-500"
|
|
/>
|
|
)}
|
|
</svg>
|
|
{showLabel && (
|
|
<span className="absolute flex items-baseline text-[var(--muted-foreground)]">
|
|
<span className="text-[11px] font-medium leading-none tabular-nums">
|
|
{percent}
|
|
</span>
|
|
<span className="text-[7px] font-medium leading-none opacity-70">
|
|
%
|
|
</span>
|
|
</span>
|
|
)}
|
|
</span>
|
|
);
|
|
}
|