mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:39:47 +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.
57 lines
2.2 KiB
TypeScript
57 lines
2.2 KiB
TypeScript
/** Product grouping only. Existing URLs and persisted records remain authoritative. */
|
|
import type { SessionSummary } from '@/lib/session-api'
|
|
import { sessionRoute } from '@/lib/mastery-session'
|
|
export type NavigationCategory = 'home' | 'learning' | 'resources' | 'partners' | 'personalization'
|
|
/** Account-level places: the same in every workspace. */
|
|
export const PERSONALIZATION_ROOTS = [
|
|
'/personalization',
|
|
'/agents',
|
|
'/space/personas',
|
|
'/space/skills',
|
|
'/space/mcp',
|
|
'/space/cli-apps',
|
|
'/memory',
|
|
] as const
|
|
const under = (pathname: string, root: string) => pathname === root || pathname.startsWith(`${root}/`)
|
|
export function categoryForPath(pathname: string): NavigationCategory {
|
|
if (under(pathname, '/partners')) return 'partners'
|
|
if (PERSONALIZATION_ROOTS.some(root => under(pathname, root))) return 'personalization'
|
|
if (
|
|
pathname === '/learning' ||
|
|
pathname.startsWith('/learning/')
|
|
)
|
|
return 'learning'
|
|
if (['/space', '/notebooks', '/knowledge-bases'].some(root => under(pathname, root)))
|
|
return 'resources'
|
|
return 'home'
|
|
}
|
|
export function isLearningSession(session: SessionSummary): boolean {
|
|
return categoryForPath(sessionRoute(session).split('?')[0]) === 'learning'
|
|
}
|
|
export function partnerSessionHref(session: {
|
|
kind: 'partner' | 'group'
|
|
owner_id: string
|
|
session_key: string
|
|
}): string {
|
|
const root = session.kind === 'group' ? '/partners/groups' : '/partners'
|
|
return `${root}/${encodeURIComponent(session.owner_id)}?${new URLSearchParams({ session: session.session_key })}`
|
|
}
|
|
|
|
/** Query identities matter: practice items share a page but not a record. */
|
|
export function isNavigationTargetActive(
|
|
href: string,
|
|
pathname: string,
|
|
search: URLSearchParams
|
|
): boolean {
|
|
const target = new URL(href, 'http://localhost')
|
|
const workspace = target.searchParams.get('dt_workspace') ?? target.searchParams.get('workspace')
|
|
const currentWorkspace = search.get('dt_workspace') ?? search.get('workspace') ?? ''
|
|
return (
|
|
(pathname === target.pathname || pathname.startsWith(`${target.pathname}/`)) &&
|
|
(workspace === null || workspace === currentWorkspace) &&
|
|
[...target.searchParams].every(
|
|
([key, value]) => key === 'dt_workspace' || key === 'workspace' || search.get(key) === value
|
|
)
|
|
)
|
|
}
|