fix: stabilize thinking block animation and bg streaming
This commit is contained in:
parent
15e1f3c40f
commit
7639e0677b
@ -42,7 +42,8 @@
|
|||||||
:class="{
|
:class="{
|
||||||
'streaming-content': action.streaming,
|
'streaming-content': action.streaming,
|
||||||
'completed-tool': action.type === 'tool' && !action.streaming,
|
'completed-tool': action.type === 'tool' && !action.streaming,
|
||||||
'immediate-show': action.streaming || action.type === 'text'
|
'immediate-show': action.streaming || action.type === 'text' || action.type === 'thinking',
|
||||||
|
'thinking-finished': action.type === 'thinking' && !action.streaming
|
||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@ -388,7 +388,27 @@ export async function initializeLegacySocket(ctx: any) {
|
|||||||
return action;
|
return action;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const drainStreamingBufferImmediately = () => {
|
||||||
|
if (!streamingState.buffer.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const chunk = streamingState.buffer.join('');
|
||||||
|
streamingState.buffer.length = 0;
|
||||||
|
applyTextChunk(chunk);
|
||||||
|
};
|
||||||
|
|
||||||
const scheduleStreamingFlush = () => {
|
const scheduleStreamingFlush = () => {
|
||||||
|
const shouldFlushImmediately = typeof document !== 'undefined' && document.hidden === true;
|
||||||
|
if (shouldFlushImmediately) {
|
||||||
|
stopStreamingTimer();
|
||||||
|
drainStreamingBufferImmediately();
|
||||||
|
if (streamingState.apiCompleted) {
|
||||||
|
finalizeStreamingText({ force: true });
|
||||||
|
} else {
|
||||||
|
scheduleFinalizationAfterDrain();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (streamingState.timer !== null) {
|
if (streamingState.timer !== null) {
|
||||||
logStreamingDebug('scheduleStreamingFlush:timer-exists', snapshotStreamingState());
|
logStreamingDebug('scheduleStreamingFlush:timer-exists', snapshotStreamingState());
|
||||||
return;
|
return;
|
||||||
@ -814,7 +834,12 @@ export async function initializeLegacySocket(ctx: any) {
|
|||||||
});
|
});
|
||||||
streamingState.apiCompleted = true;
|
streamingState.apiCompleted = true;
|
||||||
streamingState.pendingCompleteContent = data?.full_content || '';
|
streamingState.pendingCompleteContent = data?.full_content || '';
|
||||||
if (!streamingState.buffer.length) {
|
const hidden = typeof document !== 'undefined' && document.hidden === true;
|
||||||
|
if (hidden) {
|
||||||
|
stopStreamingTimer();
|
||||||
|
drainStreamingBufferImmediately();
|
||||||
|
finalizeStreamingText({ force: true });
|
||||||
|
} else if (!streamingState.buffer.length) {
|
||||||
scheduleFinalizationAfterDrain();
|
scheduleFinalizationAfterDrain();
|
||||||
} else {
|
} else {
|
||||||
scheduleStreamingFlush();
|
scheduleStreamingFlush();
|
||||||
|
|||||||
@ -295,6 +295,10 @@
|
|||||||
animation-delay: 100ms;
|
animation-delay: 100ms;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.action-item.thinking-finished {
|
||||||
|
animation: none;
|
||||||
|
}
|
||||||
|
|
||||||
.progress-indicator {
|
.progress-indicator {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user