ebc79b34f9
- Migration 0030: add conversations.rag_project_id (NULL=orphan-only, -1=all notes, positive=project), projects.auto_summary and projects.summary_updated_at - Three-value scope semantics thread from build_context() → semantic search and keyword fallback via orphan_only + effective_project_id - Project summarization background job (generate_project_summary, backfill_project_summaries) called via Ollama; triggered on project update and note saves (debounced 1h); runs at startup - New LLM tools: search_projects (SequenceMatcher scoring on title+description+auto_summary) and set_rag_scope (persists to DB, workspace-guarded, emits new_rag_scope in SSE done event) - execute_tool() accepts conv_id + workspace_project_id; generation_task passes both and captures scope changes for SSE done enrichment - Frontend: Conversation type gets rag_project_id; chat store adds ragProjectId computed + updateRagScope(); SSE done handler syncs scope - ChatView: replace sidebar ProjectSelector with a scope chip pill above the input bar, animated dropdown, pulse on model-driven scope change Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
40 lines
1.5 KiB
Python
40 lines
1.5 KiB
Python
import enum
|
|
from datetime import datetime
|
|
from sqlalchemy import DateTime, ForeignKey, Integer, Text
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from fabledassistant.models import Base
|
|
from fabledassistant.models.base import TimestampMixin
|
|
|
|
|
|
class ProjectStatus(str, enum.Enum):
|
|
active = "active"
|
|
completed = "completed"
|
|
archived = "archived"
|
|
|
|
|
|
class Project(Base, TimestampMixin):
|
|
__tablename__ = "projects"
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
user_id: Mapped[int | None] = mapped_column(Integer, ForeignKey("users.id", ondelete="CASCADE"), nullable=True)
|
|
title: Mapped[str] = mapped_column(Text, default="")
|
|
description: Mapped[str] = mapped_column(Text, default="")
|
|
goal: Mapped[str] = mapped_column(Text, default="")
|
|
status: Mapped[str] = mapped_column(Text, default="active")
|
|
color: Mapped[str | None] = mapped_column(Text, nullable=True) # hex color
|
|
auto_summary: Mapped[str | None] = mapped_column(Text, nullable=True, default=None)
|
|
summary_updated_at: Mapped[datetime | None] = mapped_column(
|
|
DateTime(timezone=True), nullable=True, default=None
|
|
)
|
|
|
|
def to_dict(self) -> dict:
|
|
return {
|
|
"id": self.id,
|
|
"title": self.title,
|
|
"description": self.description,
|
|
"goal": self.goal,
|
|
"status": self.status,
|
|
"color": self.color,
|
|
"created_at": self.created_at.isoformat(),
|
|
"updated_at": self.updated_at.isoformat(),
|
|
}
|