mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-02 00:29:37 +08:00
Collections vs workspaces: a workspace holds many collections, and a collection's files and reading conversations live in the workspace it was created in. The library now shows collections as folders grouped under their workspace, and creating one asks which workspace it goes into. - Folder page at /learning/reading/folders/[folderId]: breadcrumb, files, the collection's conversations, and "Start reading" that opens the whole folder in the reader. The reader's back link returns to it. - Collections carry a user-picked color (new `color` column, migrated); tones are --folder-* tokens with dark variants. - One shared "New collection" / "Edit collection" dialog with consistent type sizes. - Selection popover gains AI actions; results land as cards at the foot of the companion. Read-aloud is a single header toggle. - The three ⋯ menus (collection, document, conversation) merge into one. - Outline toggle moves to the left and starts closed; navigator has Outline / Annotations tabs. - Reading conversations live in the main sidebar (with a page-shaped idle mark) instead of a history dropdown in the companion. - Fix sidebar rows never showing a selected state (bg-[var(--background)]/60 compiled to nothing). - Composer floats over the conversation (no divider, bottom fade); the toolbar wraps by content instead of splitting under 420px.
144 lines
3.9 KiB
Python
144 lines
3.9 KiB
Python
"""Typed records for the private Immersive Reading library.
|
|
|
|
The extracted source remains in :mod:`deeptutor.reading.store`. These records
|
|
describe how reusable sources are organised into reading workspaces, tabs, and
|
|
conversations. Keeping that distinction explicit prevents workspace UI state
|
|
from leaking into the content-addressed material store.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from enum import Enum
|
|
from typing import Any
|
|
|
|
|
|
class SourceKind(str, Enum):
|
|
FILE = "file"
|
|
WEB = "web"
|
|
VIDEO = "video"
|
|
YOUTUBE = "youtube"
|
|
BILIBILI = "bilibili"
|
|
AUDIO = "audio"
|
|
|
|
|
|
class IngestionStatus(str, Enum):
|
|
QUEUED = "queued"
|
|
PROCESSING = "processing"
|
|
READY = "ready"
|
|
FAILED = "failed"
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class MaterialRecord:
|
|
material_id: str
|
|
content_id: str
|
|
filename: str
|
|
title: str
|
|
source_kind: SourceKind
|
|
source_url: str = ""
|
|
mime: str = ""
|
|
render_mode: str = "text"
|
|
cover_url: str = ""
|
|
duration_seconds: float = 0.0
|
|
status: IngestionStatus = IngestionStatus.QUEUED
|
|
progress: int = 0
|
|
error_code: str = ""
|
|
error_detail: str = ""
|
|
created_at: float = 0.0
|
|
updated_at: float = 0.0
|
|
last_opened_at: float = 0.0
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
return {
|
|
"material_id": self.material_id,
|
|
"content_id": self.content_id,
|
|
"filename": self.filename,
|
|
"title": self.title,
|
|
"source_kind": self.source_kind.value,
|
|
"source_url": self.source_url,
|
|
"mime": self.mime,
|
|
"render_mode": self.render_mode,
|
|
"cover_url": self.cover_url,
|
|
"duration_seconds": self.duration_seconds,
|
|
"status": self.status.value,
|
|
"progress": self.progress,
|
|
"error_code": self.error_code,
|
|
"error_detail": self.error_detail,
|
|
"created_at": self.created_at,
|
|
"updated_at": self.updated_at,
|
|
"last_opened_at": self.last_opened_at,
|
|
}
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class WorkspaceTab:
|
|
material: MaterialRecord
|
|
tab_order: int
|
|
pinned: bool = False
|
|
opened: bool = True
|
|
added_at: float = 0.0
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
return {
|
|
"material": self.material.to_dict(),
|
|
"tab_order": self.tab_order,
|
|
"pinned": self.pinned,
|
|
"opened": self.opened,
|
|
"added_at": self.added_at,
|
|
}
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class WorkspaceRecord:
|
|
workspace_id: str
|
|
title: str
|
|
description: str = ""
|
|
color: str = ""
|
|
active_material_id: str | None = None
|
|
created_at: float = 0.0
|
|
updated_at: float = 0.0
|
|
tabs: tuple[WorkspaceTab, ...] = field(default_factory=tuple)
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
return {
|
|
"workspace_id": self.workspace_id,
|
|
"title": self.title,
|
|
"description": self.description,
|
|
"color": self.color,
|
|
"active_material_id": self.active_material_id,
|
|
"created_at": self.created_at,
|
|
"updated_at": self.updated_at,
|
|
"tabs": [row.to_dict() for row in self.tabs],
|
|
}
|
|
|
|
|
|
@dataclass(frozen=True, slots=True)
|
|
class ReadingSessionRecord:
|
|
workspace_id: str
|
|
session_id: str
|
|
title: str
|
|
active_material_id: str | None = None
|
|
created_at: float = 0.0
|
|
updated_at: float = 0.0
|
|
|
|
def to_dict(self) -> dict[str, Any]:
|
|
return {
|
|
"workspace_id": self.workspace_id,
|
|
"session_id": self.session_id,
|
|
"title": self.title,
|
|
"active_material_id": self.active_material_id,
|
|
"created_at": self.created_at,
|
|
"updated_at": self.updated_at,
|
|
}
|
|
|
|
|
|
__all__ = [
|
|
"IngestionStatus",
|
|
"MaterialRecord",
|
|
"ReadingSessionRecord",
|
|
"SourceKind",
|
|
"WorkspaceRecord",
|
|
"WorkspaceTab",
|
|
]
|