feat: tasks

This commit is contained in:
Timothy Jaeryang Baek
2026-03-29 18:01:04 -05:00
parent 66c9bf57da
commit bcb71bb520
12 changed files with 382 additions and 13 deletions
+31
View File
@@ -54,6 +54,9 @@ class Chat(Base):
meta = Column(JSON, server_default='{}')
folder_id = Column(Text, nullable=True)
tasks = Column(JSON, nullable=True)
summary = Column(Text, nullable=True)
__table_args__ = (
# Performance indexes for common queries
# WHERE folder_id = ...
@@ -87,6 +90,9 @@ class ChatModel(BaseModel):
meta: dict = {}
folder_id: Optional[str] = None
tasks: Optional[list] = None
summary: Optional[str] = None
class ChatFile(Base):
__tablename__ = 'chat_file'
@@ -161,6 +167,9 @@ class ChatResponse(BaseModel):
meta: dict = {}
folder_id: Optional[str] = None
tasks: Optional[list] = None
summary: Optional[str] = None
class ChatTitleIdResponse(BaseModel):
id: str
@@ -1552,5 +1561,27 @@ class ChatTable:
return [ChatModel.model_validate(chat) for chat in all_chats]
def update_chat_tasks_by_id(self, id: str, tasks: list[dict]) -> Optional[ChatModel]:
"""Update the tasks list on a chat."""
try:
with get_db_context() as db:
chat = db.get(Chat, id)
if chat is None:
return None
chat.tasks = tasks
db.commit()
db.refresh(chat)
return ChatModel.model_validate(chat)
except Exception:
return None
def get_chat_tasks_by_id(self, id: str) -> list[dict]:
"""Read the tasks list from a chat (lightweight column query)."""
with get_db_context() as db:
result = db.query(Chat.tasks).filter_by(id=id).first()
if result is None or result[0] is None:
return []
return result[0]
Chats = ChatTable()