feat: add branching columns to ai_sessions, ai_session_steps, file_uploads
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -20,6 +20,10 @@ if TYPE_CHECKING:
|
||||
from app.models.account import Account
|
||||
from app.models.tree import Tree
|
||||
from app.models.psa_connection import PsaConnection
|
||||
from app.models.session_branch import SessionBranch
|
||||
from app.models.fork_point import ForkPoint
|
||||
from app.models.session_handoff import SessionHandoff
|
||||
from app.models.session_resolution_output import SessionResolutionOutput
|
||||
|
||||
|
||||
class AISession(Base):
|
||||
@@ -206,6 +210,28 @@ class AISession(Base):
|
||||
comment="Full LLM message history for context continuity",
|
||||
)
|
||||
|
||||
# ── Branching ──
|
||||
is_branching: Mapped[bool] = mapped_column(
|
||||
default=False,
|
||||
comment="Whether conversational branching is active for this session",
|
||||
)
|
||||
active_branch_id: Mapped[Optional[uuid.UUID]] = mapped_column(
|
||||
UUID(as_uuid=True), nullable=True,
|
||||
comment="Currently viewed branch. No FK — soft pointer to avoid circular FK with session_branches",
|
||||
)
|
||||
handoff_count: Mapped[int] = mapped_column(
|
||||
Integer, nullable=False, default=0,
|
||||
comment="Number of times this session has been handed off",
|
||||
)
|
||||
total_active_seconds: Mapped[int] = mapped_column(
|
||||
Integer, nullable=False, default=0,
|
||||
comment="Cumulative active time in seconds",
|
||||
)
|
||||
total_parked_seconds: Mapped[int] = mapped_column(
|
||||
Integer, nullable=False, default=0,
|
||||
comment="Cumulative parked time in seconds",
|
||||
)
|
||||
|
||||
# ── Relationships ──
|
||||
user: Mapped["User"] = relationship("User", foreign_keys=[user_id])
|
||||
account: Mapped["Account"] = relationship("Account")
|
||||
@@ -218,3 +244,18 @@ class AISession(Base):
|
||||
cascade="all, delete-orphan",
|
||||
order_by="AISessionStep.step_order",
|
||||
)
|
||||
branches: Mapped[list["SessionBranch"]] = relationship(
|
||||
"SessionBranch",
|
||||
foreign_keys="SessionBranch.session_id",
|
||||
cascade="all, delete-orphan",
|
||||
order_by="SessionBranch.branch_order",
|
||||
)
|
||||
handoffs: Mapped[list["SessionHandoff"]] = relationship(
|
||||
"SessionHandoff",
|
||||
cascade="all, delete-orphan",
|
||||
order_by="SessionHandoff.created_at",
|
||||
)
|
||||
resolution_outputs: Mapped[list["SessionResolutionOutput"]] = relationship(
|
||||
"SessionResolutionOutput",
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user