修复版本1.0.7的若干问题 (#11)

* fix/ 0:00 audio ui

* fix/ persist memoir image state and collapse voice history

Keep generated chapter images from staying in processing after successful uploads, and restore segmented voice recordings as a single audio message when reopening conversations.

Made-with: Cursor

* fix/ persist local conversation state and stabilize voice UI

Keep CreateMemory conversations driven by Room so recent text and audio survive page exits, and prevent stale 0:00 voice bubbles while list ordering follows the latest local message time.

Made-with: Cursor

* fix/ server-side root cause for conversation list time and message timestamps

- Add Conversation.last_message_at column with migration and index
- Update last_message_at on text message, audio segment, and AI response
- Sort conversation list by COALESCE(last_message_at, started_at) DESC
- Return real per-message timestamps from Redis history instead of now()
- Pass user_message_timestamp through agent pipeline to avoid LLM delay skew
- Remove all debug logging from server, client, and CI workflow
- Restore import json in conversation_agent (was broken by debug removal)
- Client: remove DebugRuntimeLogger, stop sending transcript as text message

Made-with: Cursor

---------

Co-authored-by: Kevin <kevin@brighteng.org>
This commit is contained in:
Sully
2026-03-14 23:58:46 +08:00
committed by GitHub
parent 9636c059d0
commit c2ce4c61f1
29 changed files with 1041 additions and 216 deletions

View File

@@ -5,6 +5,7 @@
"""
import json
import logging
from datetime import datetime
from typing import List, Optional, Dict, Any
from langchain_core.messages import HumanMessage, AIMessage
@@ -50,10 +51,17 @@ class ConversationAgent:
role: str,
content: str,
message_type: str = "text",
voice_session_id: str | None = None,
timestamp: datetime | str | int | None = None,
):
"""保存消息到 Redis"""
await redis_service.add_message(
conversation_id, role, content, message_type=message_type
conversation_id,
role,
content,
message_type=message_type,
voice_session_id=voice_session_id,
timestamp=timestamp.isoformat() if isinstance(timestamp, datetime) else timestamp,
)
def _format_history_string(self, messages: List[Any]) -> str:
@@ -245,6 +253,8 @@ class ConversationAgent:
filled_fields: Dict[str, str],
nickname: str = "",
is_from_voice: bool = False,
voice_session_id: str | None = None,
user_message_timestamp: datetime | None = None,
) -> List[str]:
"""在资料收集过程中生成跟进回复"""
if not self.llm:
@@ -260,7 +270,14 @@ class ConversationAgent:
response_text = response.content if hasattr(response, 'content') else str(response)
human_msg_type = "audio" if is_from_voice else "text"
await self._save_message(conversation_id, "human", user_message, message_type=human_msg_type)
await self._save_message(
conversation_id,
"human",
user_message,
message_type=human_msg_type,
voice_session_id=voice_session_id,
timestamp=user_message_timestamp,
)
await self._save_message(conversation_id, "ai", response_text)
messages = [msg.strip() for msg in response_text.split("[SPLIT]") if msg.strip()]
@@ -296,6 +313,8 @@ class ConversationAgent:
memoir_state: MemoirStateSchema,
user_profile_context: str = "",
is_from_voice: bool = False,
voice_session_id: str | None = None,
user_message_timestamp: datetime | None = None,
) -> List[str]:
"""
基于共享状态异步生成引导式回复
@@ -347,7 +366,14 @@ class ConversationAgent:
response_text = response.content if hasattr(response, 'content') else str(response)
human_msg_type = "audio" if is_from_voice else "text"
await self._save_message(conversation_id, "human", user_message, message_type=human_msg_type)
await self._save_message(
conversation_id,
"human",
user_message,
message_type=human_msg_type,
voice_session_id=voice_session_id,
timestamp=user_message_timestamp,
)
await self._save_message(conversation_id, "ai", response_text)
messages = [msg.strip() for msg in response_text.split("[SPLIT]") if msg.strip()]