Files
DeepTutor/web/components/whisper/WhisperMessageList.tsx
Bingxi Zhao (Frank) 31bf66b5e1 release: v1.5.15
Self-hostable PageIndex, a fileable question bank, and third-party plugins.

- PageIndex: adds PageIndex OSS as its own knowledge-base type, bound to
  the base's local library and driven by the configured LLM rather than a
  PageIndex API key. Retrieval moves off the built-in MCP server (removed)
  onto a workflow-owned reading loop that walks the document tree.
- Question bank: addEntryToCategory shipped in v1.3.6 and was never called
  from the frontend, so categories could be created but never filled. The
  quiz card now uses the shared CategoryMenu, the page is rebuilt around
  search / batch selection / an unfiled inbox, and a new question_bank tool
  lets the tutor file questions instead of misrouting them to write_note.
- Plugins: deeptutor.plugins was imported behind a try/except but the
  module never existed — implemented, plus a deeptutor.loop_capabilities
  group so third-party packages can register chat-loop capabilities.
  Builtins win on name collisions; broken entry points are skipped.
- Parsing: remote Apache Tika engine (TIKA_SERVER_URL), with no local
  package and no model download.
- LightRAG: the three indexing knobs from #877 get inputs under their own
  Indexing divider; unsupported keywords are dropped with a warning.
- Knowledge bases: uploads take a destination folder, same-named documents
  from different subtrees stop dropping one another, and linked folders
  keep their source-relative structure — closing #866.
- Book: a learning-capture inbox with an explicit status lifecycle, and
  drift warnings scoped to the KB documents that actually changed.
- Whisper: /whisper moves out of the primary nav into Learning Space →
  More Projects, credited to its contributor; the room needs its own
  capability package. The reusable half is CAPABILITY_COMPLETE forwarding
  of a capability-declared body and its declared extras.
- README: a Collaborate badge beside the Docs badge, in all twelve
  languages.
- Lint: nosec B608 on four false-positive question-bank queries (literal
  fragments only, every value bound), and three mypy fixes.

Release notes: assets/releases/ver1-5-15.md
2026-08-20 14:15:53 +08:00

138 lines
4.7 KiB
TypeScript

"use client";
import { Lock } from "lucide-react";
import { useTranslation } from "react-i18next";
import MarkdownRenderer from "@/components/common/MarkdownRenderer";
import type { WhisperMessage, WhisperSeat } from "@/lib/whisper-transcript";
type WhisperMessageListProps = {
messages: WhisperMessage[];
seat: WhisperSeat;
};
function bubbleClass(msg: WhisperMessage): string {
if (msg.role === "user") {
return "ml-auto bg-[var(--primary)] text-[var(--primary-foreground)]";
}
if (msg.stage === "whisper") {
return "mr-auto border border-amber-500/40 bg-amber-500/10 text-[var(--foreground)]";
}
if (msg.stage === "debrief") {
return "mr-auto border border-violet-500/40 bg-violet-500/10 text-[var(--foreground)]";
}
if (msg.role === "system") {
return "mx-auto border border-dashed border-[var(--border)] bg-[var(--background)]/60 text-[var(--muted-foreground)]";
}
return "mr-auto border border-[var(--border)] bg-[var(--card)] text-[var(--foreground)]";
}
function showSource(source?: string): boolean {
if (!source) return false;
return source !== "whisper_visitor" && source !== "whisper_trainee";
}
// A plain predicate, not a React hook. Under a `use` prefix it read as one, and
// calling it inside the map below tripped react-hooks/rules-of-hooks.
function rendersMarkdown(msg: WhisperMessage): boolean {
return msg.role !== "user" && msg.role !== "system";
}
export default function WhisperMessageList({
messages,
seat,
}: WhisperMessageListProps) {
const { t } = useTranslation();
if (messages.length === 0) {
return (
<div className="rounded-2xl border border-dashed border-[var(--border)] bg-[var(--background)]/50 p-4 text-xs leading-6 text-[var(--muted-foreground)]">
<p className="mb-2 font-medium text-[var(--foreground)]">
{t("Dual-seat whisper — 3 steps")}
</p>
<ol className="list-decimal space-y-1.5 pl-4">
<li>
<span className="font-medium text-[var(--foreground)]">
{t("Visitor")}:
</span>{" "}
{t("send the first message to get a room id.")}
</li>
<li>
<span className="font-medium text-[var(--foreground)]">
{t("Trainee")}:
</span>{" "}
{t(
"switch seats and send counselor lines. Private notes show with a lock.",
)}
</li>
<li>
<span className="font-medium text-[var(--foreground)]">
{t("End session")}:
</span>{" "}
{t("on Trainee, end the room for a debrief.")}
</li>
</ol>
<p className="mt-3 opacity-80">
{seat === "visitor"
? t("You are on Visitor — start with step 1.")
: t(
"You are on Trainee — complete step 1 as Visitor first if there is no room yet.",
)}
</p>
</div>
);
}
return (
<div className="space-y-3">
{messages.map((msg) => {
const isWhisper = msg.stage === "whisper";
const metaStage =
msg.stage && msg.stage !== "whisper" ? msg.stage : null;
const metaSource = showSource(msg.source) ? msg.source : null;
const showMeta =
isWhisper || metaStage || metaSource || Boolean(msg.localSeat);
return (
<div
key={msg.id}
className={`flex ${msg.role === "user" ? "justify-end" : "justify-start"}`}
>
<div
className={`max-w-[85%] rounded-2xl px-3.5 py-2.5 text-sm leading-6 ${bubbleClass(msg)} ${
rendersMarkdown(msg) ? "" : "whitespace-pre-wrap"
}`}
>
{showMeta && (
<div className="mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] uppercase tracking-wide opacity-70">
{isWhisper && (
<span className="inline-flex items-center gap-1 font-semibold text-amber-600 dark:text-amber-400">
<Lock className="h-3 w-3" aria-hidden />
{t("whisper")}
</span>
)}
{metaStage && <span>{metaStage}</span>}
{metaSource && <span>· {metaSource}</span>}
{msg.localSeat && (
<span>
· {t("you")} ({msg.localSeat})
</span>
)}
</div>
)}
{rendersMarkdown(msg) ? (
<MarkdownRenderer
content={msg.text}
variant="compact"
className="text-sm leading-6"
/>
) : (
msg.text
)}
</div>
</div>
);
})}
</div>
);
}