fix(conversation): 修复实时会话 TTS/回复被离屏 WS 抢占
- 列表预热仅预取消息缓存,避免后台 WebSocket 覆盖服务端连接 - RealtimeSession UI 回调按 owner 独占,防止 offscreen 覆盖聊天页 - 列表页聚焦时再 prewarm,会话页 TTS 入队优先 base64 - 管线下发 TTS 同时带 audio_base64 与 audio_url;协议说明同步 - 移除 TTS 排查用前后端调试日志,保留错误/告警 - 补充 WS / RealtimeSession / entry-warmup / 播放器相关单测 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -289,13 +289,6 @@ async def websocket_endpoint(
|
||||
data = message.get("data") or {}
|
||||
text_message = data.get("text", "")
|
||||
tts_this_turn = bool(data.get("tts_this_turn"))
|
||||
# 长期保留:TTS 决策入口可见性(INFO 级别即可定位 FE 是否带 tts_this_turn)
|
||||
logger.info(
|
||||
"ws.user_message tts_this_turn={} conversation_id={} text_len={}",
|
||||
tts_this_turn,
|
||||
conversation_id,
|
||||
len(text_message or ""),
|
||||
)
|
||||
|
||||
if text_message:
|
||||
can_send, quota_msg = await check_ws_quota(
|
||||
@@ -397,16 +390,6 @@ async def websocket_endpoint(
|
||||
is_last = bool(data.get("is_last", False))
|
||||
audio_duration = int(data.get("duration", 0) or 0)
|
||||
tts_this_turn_segment = bool(data.get("tts_this_turn"))
|
||||
# 长期保留:分段语音轮的 TTS 决策入口可见性
|
||||
logger.info(
|
||||
"ws.audio_segment tts_this_turn={} is_last={} "
|
||||
"conversation_id={} voice_session_id={} segment_index_raw={}",
|
||||
tts_this_turn_segment,
|
||||
is_last,
|
||||
conversation_id,
|
||||
voice_session_id,
|
||||
segment_index_raw,
|
||||
)
|
||||
|
||||
if not audio_base64:
|
||||
await manager.send_message(
|
||||
@@ -524,13 +507,6 @@ async def websocket_endpoint(
|
||||
audio_base64 = data.get("audio_base64", "")
|
||||
audio_duration = data.get("duration", 0)
|
||||
tts_this_turn = bool(data.get("tts_this_turn"))
|
||||
# 长期保留:单次整段音频路径的 TTS 决策入口可见性
|
||||
logger.info(
|
||||
"ws.audio_message tts_this_turn={} conversation_id={} duration_s={}",
|
||||
tts_this_turn,
|
||||
conversation_id,
|
||||
audio_duration,
|
||||
)
|
||||
|
||||
if audio_base64:
|
||||
can_send, quota_msg = await check_ws_quota(
|
||||
@@ -719,15 +695,6 @@ async def websocket_endpoint(
|
||||
st_val = None
|
||||
else:
|
||||
st_val = str(st).strip() or None
|
||||
logger.info(
|
||||
"ws.TTS_REQUEST received conversation_id={} user_id={} "
|
||||
"assistant_message_id={} segment_index={} segment_text_len={}",
|
||||
conversation_id,
|
||||
user_id,
|
||||
str(aid).strip(),
|
||||
seg_idx,
|
||||
len(st_val or ""),
|
||||
)
|
||||
ok, err_msg = await handle_tts_request_on_demand(
|
||||
conversation_id=conversation_id,
|
||||
user_id=user_id,
|
||||
@@ -736,15 +703,6 @@ async def websocket_endpoint(
|
||||
segment_text=st_val,
|
||||
db=db,
|
||||
)
|
||||
logger.info(
|
||||
"ws.TTS_REQUEST handled conversation_id={} assistant_message_id={} "
|
||||
"segment_index={} ok={} err_msg={}",
|
||||
conversation_id,
|
||||
str(aid).strip(),
|
||||
seg_idx,
|
||||
ok,
|
||||
err_msg,
|
||||
)
|
||||
if not ok:
|
||||
await manager.send_message(
|
||||
conversation_id,
|
||||
|
||||
Reference in New Issue
Block a user