Fix session wait state refresh

This commit is contained in:
shiyue
2026-06-22 23:34:23 +08:00
parent 844281ab4c
commit 01c7fdd27a
2 changed files with 25 additions and 7 deletions

View File

@@ -2,7 +2,7 @@
(function () {
'use strict';
const ASSET_VERSION = '20260622-queued-send';
const ASSET_VERSION = '20260622-streaming-restore';
const WS_URL = `${location.protocol === 'https:' ? 'wss' : 'ws'}://${location.host}/ws`;
const RENDER_DEBOUNCE = 100;
const COMPOSER_SUGGESTION_DEBOUNCE = 120;
@@ -3196,10 +3196,11 @@
function currentSessionWaitState() {
const meta = currentSessionId ? getSessionMeta(currentSessionId) : null;
const cached = currentSessionId ? sessionCache.get(currentSessionId)?.snapshot : null;
const source = meta || cached || {};
return {
waitingOnChildren: !!(meta?.waitingOnChildren || cached?.waitingOnChildren),
pendingReplyCount: Number(meta?.pendingReplyCount ?? cached?.pendingReplyCount ?? 0),
readyReplyCount: Number(meta?.readyReplyCount ?? cached?.readyReplyCount ?? 0),
waitingOnChildren: !!source.waitingOnChildren,
pendingReplyCount: Number(source.pendingReplyCount || 0),
readyReplyCount: Number(source.readyReplyCount || 0),
};
}
@@ -3342,6 +3343,9 @@
currentModel = snapshot.model || '';
if (!preserveStreaming) {
renderMessages(snapshot.messages || [], { immediate: !!options.immediate });
if (snapshot.isRunning && snapshot.sessionId === currentSessionId) {
startGenerating(snapshot.sessionId);
}
} else {
generatingSessionId = snapshot.sessionId;
}
@@ -4122,16 +4126,30 @@
case 'session_message':
if (msg.sessionId && msg.message) {
const isCrossConversationReply = !!msg.message.crossConversation?.replyToRequestId;
updateCachedSession(msg.sessionId, (snapshot) => {
snapshot.messages = Array.isArray(snapshot.messages) ? snapshot.messages : [];
snapshot.messages.push(deepClone(msg.message));
snapshot.updated = msg.message.timestamp || new Date().toISOString();
if (msg.message.crossConversation?.replyToRequestId) {
if (isCrossConversationReply) {
snapshot.readyReplyCount = Math.max(0, Number(snapshot.readyReplyCount || 0) - 1);
snapshot.pendingReplyCount = Math.max(0, Number(snapshot.pendingReplyCount || 0) - 1);
snapshot.waitingOnChildren = Number(snapshot.pendingReplyCount || 0) > 0;
}
});
if (isCrossConversationReply) {
sessions = sessions.map((session) => {
if (session.id !== msg.sessionId) return session;
const pendingReplyCount = Math.max(0, Number(session.pendingReplyCount || 0) - 1);
const readyReplyCount = Math.max(0, Number(session.readyReplyCount || 0) - 1);
return {
...session,
readyReplyCount,
pendingReplyCount,
waitingOnChildren: pendingReplyCount > 0,
};
});
}
}
if (msg.sessionId === currentSessionId && msg.message) {
collectClosedCollabAgentIds([msg.message]).forEach((id) => closedCollabAgentIds.add(id));

View File

@@ -14,7 +14,7 @@
document.documentElement.dataset.dividerTime = dividerTime;
})();
</script>
<link rel="stylesheet" href="style.css?v=20260622-queued-send">
<link rel="stylesheet" href="style.css?v=20260622-streaming-restore">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/atom-one-dark.min.css">
</head>
<body>
@@ -163,6 +163,6 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/marked/12.0.1/marked.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/highlight.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/10.9.1/mermaid.min.js"></script>
<script src="app.js?v=20260622-queued-send"></script>
<script src="app.js?v=20260622-streaming-restore"></script>
</body>
</html>