fix(conversation): 离屏不丢回复、列表预热 WS 与非阻塞进入聊天
- 后端:文本/转写后 AI 生成改为独立任务,避免断连取消整轮;按需 TTS 等与 WS 改动 - 前端:RealtimeSession 重绑 UI 时恢复流式 buffer;列表 onPressIn/挂载预热、已有会话立即 push - 同步会话相关类型、i18n、测试与 env/资源等累计改动 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -9,9 +9,15 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.core.cos_url_keys import presign_tts_urls_for_playback
|
||||
from app.core.cos_url_keys import (
|
||||
TTS_PRESIGNED_EXPIRES_SEC,
|
||||
extract_cos_object_key_if_owned,
|
||||
)
|
||||
from app.core.logging import get_logger
|
||||
from app.ports.storage import ObjectStorage
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def apply_presigned_tts_urls_to_messages(
|
||||
messages: list[dict],
|
||||
@@ -24,5 +30,26 @@ def apply_presigned_tts_urls_to_messages(
|
||||
tts = m.get("ttsAudioUrls")
|
||||
if not isinstance(tts, list) or not tts:
|
||||
continue
|
||||
str_urls = [x for x in tts if isinstance(x, str)]
|
||||
m["ttsAudioUrls"] = presign_tts_urls_for_playback(str_urls, storage)
|
||||
out: list[str] = []
|
||||
for x in tts:
|
||||
if not isinstance(x, str):
|
||||
out.append("")
|
||||
continue
|
||||
s = x.strip()
|
||||
if not s:
|
||||
out.append("")
|
||||
continue
|
||||
key = extract_cos_object_key_if_owned(s)
|
||||
if key:
|
||||
try:
|
||||
out.append(storage.get_url(key, expires=TTS_PRESIGNED_EXPIRES_SEC))
|
||||
except Exception as exc:
|
||||
logger.warning(
|
||||
"presign tts url failed, keeping original url: key={} err={}",
|
||||
key,
|
||||
exc,
|
||||
)
|
||||
out.append(s)
|
||||
else:
|
||||
out.append(s)
|
||||
m["ttsAudioUrls"] = out
|
||||
|
||||
Reference in New Issue
Block a user