mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-06-02 00:57:41 +08:00
feat: support install browser in chat
This commit is contained in:
@@ -891,6 +891,15 @@ function startSSE(requestId, loadingEl, timestamp) {
|
||||
mediaEl.appendChild(fileEl);
|
||||
scrollChatToBottom();
|
||||
|
||||
} else if (item.type === 'phase') {
|
||||
// Coarse progress (e.g. cow install-browser); must not close SSE (unlike "done")
|
||||
ensureBotEl();
|
||||
const wrap = document.createElement('div');
|
||||
wrap.className = 'text-xs sm:text-sm text-slate-600 dark:text-slate-400 border-l-2 border-primary-400 pl-2 py-1 my-0.5';
|
||||
wrap.textContent = String(item.content || '');
|
||||
stepsEl.appendChild(wrap);
|
||||
scrollChatToBottom();
|
||||
|
||||
} else if (item.type === 'done') {
|
||||
es.close();
|
||||
delete activeStreams[requestId];
|
||||
|
||||
@@ -96,10 +96,22 @@ class WebChannel(ChatChannel):
|
||||
logger.error(f"No session_id found for request {request_id}")
|
||||
return
|
||||
|
||||
# SSE mode: push done event to SSE queue
|
||||
# SSE mode: push events to SSE queue
|
||||
if request_id in self.sse_queues:
|
||||
content = reply.content if reply.content is not None else ""
|
||||
|
||||
# Intermediate status lines (e.g. /install-browser phases) must NOT use "done",
|
||||
# or the frontend closes EventSource and drops subsequent events.
|
||||
if getattr(reply, "sse_phase", False):
|
||||
self.sse_queues[request_id].put({
|
||||
"type": "phase",
|
||||
"content": content,
|
||||
"request_id": request_id,
|
||||
"timestamp": time.time(),
|
||||
})
|
||||
logger.debug(f"SSE phase for request {request_id}")
|
||||
return
|
||||
|
||||
# Files are already pushed via on_event (file_to_send) during agent execution.
|
||||
# Skip duplicate file pushes here; just let the done event through.
|
||||
if reply.type in (ReplyType.IMAGE_URL, ReplyType.FILE) and content.startswith("file://"):
|
||||
|
||||
Reference in New Issue
Block a user