mirror of
https://github.com/pocketpaw/pocketpaw.git
synced 2026-05-19 08:26:34 +00:00
- Auto-fix 155 errors (import sorting, annotations, deprecated imports) - Format 87 files with ruff format for line length compliance - Fix 15 F401 unused imports (add __all__ for re-exports, remove truly unused) - Fix 7 F841 unused variables (prefix with _) - Fix 2 F821 undefined names (add missing imports) - Fix 3 E402 module-level imports not at top - Fix 2 UP042 str+Enum → StrEnum - Fix 1 E712 == False comparison - Fix remaining 51 E501 line-too-long in string literals and expressions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
"""Session document — pocket-scoped chat sessions."""
|
|
|
|
from __future__ import annotations
|
|
|
|
from datetime import UTC, datetime
|
|
|
|
from beanie import Indexed
|
|
from pydantic import Field
|
|
|
|
from ee.cloud.models.base import TimestampedDocument
|
|
|
|
|
|
class Session(TimestampedDocument):
|
|
"""Chat session tracked by cloud, messages stored in Python.
|
|
|
|
Field names use camelCase aliases to match the frontend contract.
|
|
"""
|
|
|
|
sessionId: Indexed(str, unique=True) = Field(alias="sessionId") # type: ignore[valid-type]
|
|
pocket: str | None = None
|
|
group: str | None = None
|
|
agent: str | None = None
|
|
workspace: Indexed(str) # type: ignore[valid-type]
|
|
owner: str
|
|
title: str = "New Chat"
|
|
lastActivity: datetime = Field(default_factory=lambda: datetime.now(UTC), alias="lastActivity")
|
|
messageCount: int = Field(default=0, alias="messageCount")
|
|
deleted_at: datetime | None = None
|
|
|
|
model_config = {"populate_by_name": True}
|
|
|
|
class Settings:
|
|
name = "sessions"
|
|
indexes = [
|
|
[("workspace", 1), ("pocket", 1), ("lastActivity", -1)],
|
|
[("workspace", 1), ("group", 1), ("agent", 1)],
|
|
]
|