Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Pace first batched Assistant content

rcourtmanfcf91aed7621
diff --git a/frontend-modern/src/api/aiChatDevStreamFixture.ts b/frontend-modern/src/api/aiChatDevStreamFixture.ts
index b30f7a1161..18acebd4ec 100644
--- a/frontend-modern/src/api/aiChatDevStreamFixture.ts
+++ b/frontend-modern/src/api/aiChatDevStreamFixture.ts
@@ -1091,6 +1091,9 @@ const fixtureStepDelay = (
) {
return 2400;
}
+ if (normalizedPrompt === '/fixture long-output' && event.type === 'content') {
+ return 1800;
+ }
if (normalizedPrompt === '/fixture pending-tool') return defaultDelayMs;
if (normalizedPrompt !== '/fixture tool-burst') return defaultDelayMs;
if (event.type === 'tool_start') {
diff --git a/frontend-modern/src/components/AI/Chat/MessageItem.tsx b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
index 393bbcbc79..654f513853 100644
--- a/frontend-modern/src/components/AI/Chat/MessageItem.tsx
+++ b/frontend-modern/src/components/AI/Chat/MessageItem.tsx
@@ -137,13 +137,21 @@ const createPacedText = (getText: () => string, live: () => boolean, cacheKey: (
cancelPacedTextCleanup(initialKey);
}
const cachedText = initialKey ? pacedTextCache.get(initialKey) : undefined;
+ const initialLiveText = () => {
+ if (!initialText) return initialText;
+ if (initialText.length <= 48) return initialText;
+ const end = nextPacedTextIndex(initialText, 0);
+ return end < initialText.length ? initialText.slice(0, end) : initialText;
+ };
const initialValue =
live() &&
cachedText &&
initialText.startsWith(cachedText) &&
- cachedText.length < initialText.length
+ cachedText.length <= initialText.length
? cachedText
- : initialText;
+ : live()
+ ? initialLiveText()
+ : initialText;
const [value, setValue] = createSignal(initialValue);
let shown = initialValue;
let timeout: ReturnType<typeof setTimeout> | undefined;
diff --git a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
index 986130d29f..8d633ceb10 100644
--- a/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
+++ b/frontend-modern/src/components/AI/Chat/__tests__/MessageItem.test.tsx
@@ -1537,6 +1537,31 @@ describe('MessageItem', () => {
expect(prose().innerHTML).toContain('A readable streaming answer lands over a few frames.');
});
+ it('paces the first batched streaming content block instead of dumping it at once', async () => {
+ vi.useFakeTimers();
+ const content = 'A batched provider response should still reveal progressively.';
+
+ const { container } = render(() => (
+ <MessageItem
+ message={makeMessage({
+ role: 'assistant',
+ content,
+ isStreaming: true,
+ streamEvents: [{ type: 'content', content }],
+ })}
+ {...makeHandlers()}
+ />
+ ));
+ const prose = () => container.querySelector('.prose') as HTMLElement;
+
+ expect(prose().innerHTML).toContain('<p>A ');
+ expect(prose().innerHTML).not.toContain('provider response');
+
+ await vi.runAllTimersAsync();
+
+ expect(prose().innerHTML).toContain(content);
+ });
+
it('strips serialized tool-call text from content blocks', () => {
const events: StreamDisplayEvent[] = [
{