From a089380dbe8212c99efa891075de70c21ac57475 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Thu, 13 Nov 2025 18:12:27 +0000 Subject: [PATCH 1/2] feat: migrate eigent_server changes --- ...5_11_13_1731-add_timestamp_to_chat_step.py | 28 +++++++++++++++++++ server/app/controller/chat/step_controller.py | 8 +++++- server/app/model/chat/chat_step.py | 2 ++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 server/alembic/versions/2025_11_13_1731-add_timestamp_to_chat_step.py diff --git a/server/alembic/versions/2025_11_13_1731-add_timestamp_to_chat_step.py b/server/alembic/versions/2025_11_13_1731-add_timestamp_to_chat_step.py new file mode 100644 index 000000000..9f9f7edc5 --- /dev/null +++ b/server/alembic/versions/2025_11_13_1731-add_timestamp_to_chat_step.py @@ -0,0 +1,28 @@ +"""add_timestamp_to_chat_step + +Revision ID: add_timestamp_to_chat_step +Revises: eec7242b3a9b +Create Date: 2025-11-13 17:31:51.692506 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = "add_timestamp_to_chat_step" +down_revision: Union[str, None] = "eec7242b3a9b" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + """Add timestamp column to chat_step table.""" + op.add_column("chat_step", sa.Column("timestamp", sa.Float(), nullable=True)) + + +def downgrade() -> None: + """Remove timestamp column from chat_step table.""" + op.drop_column("chat_step", "timestamp") diff --git a/server/app/controller/chat/step_controller.py b/server/app/controller/chat/step_controller.py index 21e7199a9..d16a7b7b9 100644 --- a/server/app/controller/chat/step_controller.py +++ b/server/app/controller/chat/step_controller.py @@ -4,6 +4,7 @@ from typing import List, Optional from fastapi import Depends, HTTPException, Query, Response, APIRouter from fastapi.responses import StreamingResponse from sqlmodel import Session, asc, select +from sqlalchemy.sql.expression import case from app.component.database import session from app.component.auth import Auth, auth_must from fastapi_babel import _ @@ -46,7 +47,11 @@ async def share_playback( async def event_generator(): try: - stmt = select(ChatStep).where(ChatStep.task_id == task_id).order_by(asc(ChatStep.id)) + stmt = select(ChatStep).where(ChatStep.task_id == task_id).order_by( + asc(case((ChatStep.timestamp.is_(None), 1), else_=0)), + asc(ChatStep.timestamp), + asc(ChatStep.id) + ) steps = session.exec(stmt).all() if not steps: @@ -101,6 +106,7 @@ async def create_chat_step(step: ChatStepIn, session: Session = Depends(session) task_id=step.task_id, step=step.step, data=step.data, + timestamp=step.timestamp ) session.add(chat_step) session.commit() diff --git a/server/app/model/chat/chat_step.py b/server/app/model/chat/chat_step.py index 7b567d924..a81e00eec 100644 --- a/server/app/model/chat/chat_step.py +++ b/server/app/model/chat/chat_step.py @@ -11,6 +11,7 @@ class ChatStep(AbstractModel, DefaultTimes, table=True): task_id: str = Field(index=True) step: str data: str = Field(sa_type=JSON) + timestamp: float | None = Field(default=None, nullable=True) @field_validator("data", mode="before") @classmethod @@ -34,6 +35,7 @@ class ChatStepIn(BaseModel): task_id: str step: str data: Any + timestamp: float | None = None class ChatStepOut(BaseModel): From f358b140db0f54edaec87b5d47fb74eb2b80b289 Mon Sep 17 00:00:00 2001 From: Wendong-Fan Date: Fri, 14 Nov 2025 14:47:33 +0800 Subject: [PATCH 2/2] add attribute to ChatStepOut --- server/app/model/chat/chat_step.py | 1 + 1 file changed, 1 insertion(+) diff --git a/server/app/model/chat/chat_step.py b/server/app/model/chat/chat_step.py index a81e00eec..4694ff64c 100644 --- a/server/app/model/chat/chat_step.py +++ b/server/app/model/chat/chat_step.py @@ -43,3 +43,4 @@ class ChatStepOut(BaseModel): task_id: str step: str data: Any + timestamp: float | None = None