Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(conversations): add live thinking tests for ProcessingTranscriptView

Steven Enamakel44dec305aac6
diff --git a/app/src/features/conversations/components/ProcessingTranscriptView.test.tsx b/app/src/features/conversations/components/ProcessingTranscriptView.test.tsx
index 7ff9283815..9f9183252b 100644
--- a/app/src/features/conversations/components/ProcessingTranscriptView.test.tsx
+++ b/app/src/features/conversations/components/ProcessingTranscriptView.test.tsx
@@ -73,3 +73,60 @@ describe('ProcessingTranscriptView tool failure explanation', () => {
expect(screen.queryByTestId('processing-tool-failure')).toBeNull();
});
});
+
+describe('ProcessingTranscriptView live thinking', () => {
+ const thought = (seq: number, text: string) =>
+ ({ kind: 'thinking', round: 1, seq, text }) as const;
+
+ it('renders the trailing thought expanded while the turn is live', () => {
+ render(
+ <ProcessingTranscriptView
+ transcript={[thought(0, 'The user wants a week in Kashmir in October.')]}
+ entries={[]}
+ live
+ />
+ );
+ const live = screen.getByTestId('processing-thinking-live');
+ expect(live.textContent).toContain('The user wants a week in Kashmir in October.');
+ // No collapsed <details> row for the same thought.
+ expect(screen.queryByTestId('processing-thinking')).toBeNull();
+ });
+
+ it('keeps every thought collapsed once the turn has settled', () => {
+ render(
+ <ProcessingTranscriptView
+ transcript={[thought(0, 'Settled reasoning that should stay quiet.')]}
+ entries={[]}
+ />
+ );
+ expect(screen.queryByTestId('processing-thinking-live')).toBeNull();
+ const collapsed = screen.getByTestId('processing-thinking') as HTMLDetailsElement;
+ expect(collapsed.open).toBe(false);
+ });
+
+ it('only expands the LAST thought while live; earlier ones stay collapsed', () => {
+ render(
+ <ProcessingTranscriptView
+ transcript={[
+ thought(0, 'First pass of reasoning.'),
+ { kind: 'narration', round: 1, seq: 1, text: 'Let me look that up.' },
+ thought(2, 'Second pass of reasoning.'),
+ ]}
+ entries={[]}
+ live
+ />
+ );
+ expect(screen.getAllByTestId('processing-thinking')).toHaveLength(1);
+ expect(screen.getByTestId('processing-thinking').textContent).toContain('First pass');
+ expect(screen.getByTestId('processing-thinking-live').textContent).toContain('Second pass');
+ });
+
+ it('shows only the tail of a long live thought with a leading ellipsis', () => {
+ const long = 'x'.repeat(2000) + 'TAIL';
+ render(<ProcessingTranscriptView transcript={[thought(0, long)]} entries={[]} live />);
+ const live = screen.getByTestId('processing-thinking-live');
+ expect(live.textContent).toContain('…');
+ expect(live.textContent).toContain('TAIL');
+ expect(live.textContent!.length).toBeLessThan(long.length);
+ });
+});
diff --git a/app/src/features/conversations/components/aui/AgentInsightsSlot.test.tsx b/app/src/features/conversations/components/aui/AgentInsightsSlot.test.tsx
new file mode 100644
index 0000000000..8a765ad4f6
--- /dev/null
+++ b/app/src/features/conversations/components/aui/AgentInsightsSlot.test.tsx
@@ -0,0 +1,58 @@
+import { render, screen } from '@testing-library/react';
+import { describe, expect, it, vi } from 'vitest';
+
+import type { ProcessingTranscriptItem } from '../../../../store/chatRuntimeSlice';
+import { AgentInsightsSlot } from './AgentInsightsSlot';
+
+vi.mock('../../../../lib/i18n/I18nContext', () => ({
+ useT: () => ({ t: (key: string, fallback?: string) => fallback ?? key, locale: 'en' }),
+}));
+
+const thinking: ProcessingTranscriptItem[] = [
+ { kind: 'thinking', round: 1, seq: 0, text: 'Planning a Kashmir itinerary.' },
+];
+
+function renderSlot(props: Partial<Parameters<typeof AgentInsightsSlot>[0]> = {}) {
+ return render(
+ <AgentInsightsSlot
+ entries={[]}
+ transcript={thinking}
+ turnActive={false}
+ timelineBeforeLatestAnswer={false}
+ hideAgentInsights={false}
+ onViewDetails={() => {}}
+ onViewWholeRun={() => {}}
+ {...props}
+ />
+ );
+}
+
+describe('AgentInsightsSlot before the first tool call', () => {
+ it('streams the live thought inline while the turn is in flight', () => {
+ renderSlot({ turnActive: true });
+ expect(screen.getByTestId('agent-insights-live')).toBeTruthy();
+ expect(screen.getByTestId('processing-thinking-live').textContent).toContain(
+ 'Planning a Kashmir itinerary.'
+ );
+ // The whole-run opener stays reachable.
+ expect(screen.getByTestId('view-process-source')).toBeTruthy();
+ });
+
+ it('falls back to the static opener once the turn has settled', () => {
+ renderSlot({ turnActive: false });
+ expect(screen.queryByTestId('agent-insights-live')).toBeNull();
+ expect(screen.queryByTestId('processing-thinking-live')).toBeNull();
+ expect(screen.getByTestId('view-process-source')).toBeTruthy();
+ });
+
+ it('respects "hide agent insights" and shows only the processing link', () => {
+ renderSlot({ turnActive: true, hideAgentInsights: true });
+ expect(screen.queryByTestId('agent-insights-live')).toBeNull();
+ expect(screen.getByTestId('agent-processing-link')).toBeTruthy();
+ });
+
+ it('renders nothing with neither steps nor transcript', () => {
+ const { container } = renderSlot({ turnActive: true, transcript: [] });
+ expect(container.innerHTML).toBe('');
+ });
+});