mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 10:40:42 +08:00
Remove course pages, APIs and the course_study capability. Add anchored note threads and reviewed learning-block generation, queued and withdrawable chat messages, quote attachments, side chats, and the calendar/favorites/navigation updates. Keep preview's existing backend architecture. Wire the new features through its Python application and existing chat engine, retain legacy selected-text requests, persist mid-turn messages in replay, and restore note context when regenerating. Leave stored user data intact. Validate frontend contracts, dependency boundaries, types, 1290 node tests, 840 rendered tests, lint, localization and the production build. Exercise session/notes/API regressions, 53 chat-engine tests and 20 Python/native integration tests with isolated runtime data.
38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
"use client";
|
|
|
|
import { useCallback } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { useUiLayout } from "@/hooks/useUiLayout";
|
|
import type { UiLayout } from "@/lib/ui-layout";
|
|
import { classicTokens } from "./classic/tokens";
|
|
import { modernTokens } from "./modern/tokens";
|
|
import type { UiLayoutTokens } from "./types";
|
|
|
|
const UI_LAYOUT_TOKENS: Record<UiLayout, UiLayoutTokens> = {
|
|
classic: classicTokens,
|
|
modern: modernTokens,
|
|
};
|
|
|
|
/** Translated copy for a label the two UIs name differently. */
|
|
export function useUiLayoutLabel(key: keyof UiLayoutTokens["labels"]): string {
|
|
const { t } = useTranslation();
|
|
const label = UI_LAYOUT_TOKENS[useUiLayout()].labels[key];
|
|
// An empty token means "this layout shows nothing here".
|
|
return label ? t(label) : "";
|
|
}
|
|
|
|
/** The mode picker's name for a capability; the default one is layout copy. */
|
|
export function useCapabilityLabel(): (capability: { value: string; label: string }) => string {
|
|
const { t } = useTranslation();
|
|
const defaultLabel = useUiLayoutLabel("defaultCapability");
|
|
return useCallback(
|
|
// The layout names the default action; a surface that relabelled it
|
|
// (the note companion's "Write together") keeps its own name.
|
|
(capability) =>
|
|
capability.value === "" && capability.label === "Chat"
|
|
? defaultLabel
|
|
: t(capability.label),
|
|
[defaultLabel, t],
|
|
);
|
|
}
|