DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(chat): label sent-message KB references with catalog names
XZH8079dd8def71
diff --git a/web/components/space/learning/MasteryStudy.tsx b/web/components/space/learning/MasteryStudy.tsxindex dbb035339..555f13395 100644--- a/web/components/space/learning/MasteryStudy.tsx+++ b/web/components/space/learning/MasteryStudy.tsx@@ -242,6 +242,21 @@ export function MasteryStudy({() => buildChatOutline(state.messages, state.selectedBranches),[state.messages, state.selectedBranches],);+ // The study composer lists KB sources by label, but the stored request+ // snapshot keeps the qualified ref — resolve it so sent-message reference+ // chips read the same way.+ const kbDisplayNames = useMemo(+ () =>+ Object.fromEntries(+ (topic?.sources ?? [])+ .filter(+ (source) =>+ source.kind === "knowledge_base" && source.source_id && source.label,+ )+ .map((source) => [source.source_id as string, source.label]),+ ),+ [topic],+ );const jumpToTurn = useCallback((key: string) => {if (@@ -807,6 +822,7 @@ export function MasteryStudy({}}}availableKbNames={new Set(knowledgeBases)}+ kbDisplayNames={kbDisplayNames}showModeBadge={false}/></div>diff --git a/web/features/chat/components/ChatWorkspace.tsx b/web/features/chat/components/ChatWorkspace.tsxindex ff98cce8c..f82ee3efb 100644--- a/web/features/chat/components/ChatWorkspace.tsx+++ b/web/features/chat/components/ChatWorkspace.tsx@@ -328,6 +328,12 @@ export default function ChatWorkspace({() => new Set(knowledgeBases.map(knowledgeBaseRef)),[knowledgeBases],);+ // Sent-message reference chips show the readable KB name; the snapshot+ // stores the qualified ref, so the label is resolved through this map.+ const kbDisplayNames = useMemo(+ () => Object.fromEntries(knowledgeBases.map((kb) => [knowledgeBaseRef(kb), kb.name])),+ [knowledgeBases],+ );// A connected agent to preselect once it loads, from `?agent=<name>` on the// URL (the partner list page links here to drop straight into a chat with a// partner). Captured once at first client render — the URL is rewritten to@@ -2652,6 +2658,9 @@ export default function ChatWorkspace({availableKbNames={knowledgeBasesLoaded ? availableKbNames : undefined}+ kbDisplayNames={+ knowledgeBasesLoaded ? kbDisplayNames : undefined+ }/><divref={messagesEndRef}diff --git a/web/features/chat/messages/ChatMessageList.tsx b/web/features/chat/messages/ChatMessageList.tsxindex 5647949c3..beb83e5a5 100644--- a/web/features/chat/messages/ChatMessageList.tsx+++ b/web/features/chat/messages/ChatMessageList.tsx@@ -1533,6 +1533,7 @@ export const UserMessage = memo(function UserMessage({siblingInfo,onSwitchBranch,availableKbNames,+ kbDisplayNames,showModeBadge,onOpenConsultation,}: {@@ -1546,6 +1547,9 @@ export const UserMessage = memo(function UserMessage({onSwitchBranch?: (parentMessageId: number | null, childId: number) => void;/** Names of KBs confirmed to exist. Omitted when the KB list is unavailable. */availableKbNames?: Set<string>;+ /** Qualified KB ref -> display name from the selection catalog; the chip+ * label falls back to the raw ref when no entry matches. */+ kbDisplayNames?: Record<string, string>;/** Label the bubble with its capability. A single-capability surface* already names the mode in its own chrome. */showModeBadge?: boolean;@@ -1636,7 +1640,7 @@ export const UserMessage = memo(function UserMessage({key: `kb-${name}`,icon: Database,kind: t("Knowledge"),- label: name,+ label: kbDisplayNames?.[name] ?? name,};}),...(snap?.bookReferences ?? []).map((ref): ContextTreeItem => ({@@ -1881,6 +1885,7 @@ export const ChatMessageList = memo(function ChatMessageList({onEditMessage,onSwitchBranch,availableKbNames,+ kbDisplayNames,onSubmitUserReply,onAnswerMasteryQuestion,onSkipMasteryQuestion,@@ -1942,8 +1947,12 @@ export const ChatMessageList = memo(function ChatMessageList({) => void | boolean | Promise<void | boolean>;/** Names of KBs confirmed to exist. Omitted when the KB list is unavailable. */availableKbNames?: Set<string>;+ /** Qualified KB ref -> display name, from the same catalog the composer+ * resolves against. Snapshots store the ref; only the chip label should+ * show the human-readable name (falls back to the ref when unmapped). */+ kbDisplayNames?: Record<string, string>;/** Label each user bubble with its capability. Off on surfaces that run a- * single capability and already name it in their own chrome. */+ * single capability and already name it in its own chrome. */showModeBadge?: boolean;onLoadMessageTrace?: (messageId: number) => Promise<void>;onReleaseMessageTrace?: (messageId: number) => void;@@ -2176,6 +2185,7 @@ export const ChatMessageList = memo(function ChatMessageList({siblingInfo={sib}onSwitchBranch={onSwitchBranch}availableKbNames={availableKbNames}+ kbDisplayNames={kbDisplayNames}showModeBadge={showModeBadge}onOpenConsultation={consultationEvents.length && onOpenConsultation? () => onOpenConsultation(consultationEvents)diff --git a/web/tests/integration/chat-messages.spec.tsx b/web/tests/integration/chat-messages.spec.tsxindex 3f6b90466..a05aee91e 100644--- a/web/tests/integration/chat-messages.spec.tsx+++ b/web/tests/integration/chat-messages.spec.tsx@@ -38,6 +38,45 @@ describe('chat message feature', () => {expect(retry).toHaveBeenCalledOnce()})+ // The snapshot stores the qualified KB ref, but the reference chip under a+ // sent message used to print that ref verbatim — while the composer chip+ // for the same resource showed its readable name. The label now resolves+ // through the selection catalog, falling back to the ref when unmapped.+ it('labels sent-message KB references with the catalog name, not the raw ref', () => {+ const renderWithKb = (kb: string[], kbDisplayNames?: Record<string, string>) =>+ render(+ <ChatMessageList+ messages={[{+ id: 7,+ role: 'user',+ content: 'Summarize the papers',+ parentMessageId: null,+ requestSnapshot: {+ content: 'Summarize the papers',+ enabledTools: [],+ knowledgeBases: kb,+ language: 'en',+ },+ }]}+ isStreaming={false}+ onCopyAssistantMessage={vi.fn(async () => undefined)}+ onRegenerateMessage={() => undefined}+ kbDisplayNames={kbDisplayNames}+ />,+ )+ // Identity is preserved: an unmapped ref still renders, as itself.+ renderWithKb(['account:kb:legacy_kb'])+ expect(screen.getByText('account:kb:legacy_kb')).toBeVisible()++ const { unmount } = renderWithKb(+ ['workspace:ws-1:kb:example_kb'],+ { 'workspace:ws-1:kb:example_kb': 'example_kb' },+ )+ expect(screen.getByText('example_kb')).toBeVisible()+ expect(screen.queryByText('workspace:ws-1:kb:example_kb')).toBeNull()+ unmount()+ })+it('renders a user row with keyboard-accessible message actions', async () => {const copy = vi.fn(async () => undefined)const user = userEvent.setup()