Skip to content

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

test(conversations): add coverage for agent status and stall warning

Steven Enamakelf2f5fb25608b
diff --git a/app/src/features/conversations/aui/AgentRunningStatus.test.tsx b/app/src/features/conversations/aui/AgentRunningStatus.test.tsx
index ee2309e51e..547d1fcc81 100644
--- a/app/src/features/conversations/aui/AgentRunningStatus.test.tsx
+++ b/app/src/features/conversations/aui/AgentRunningStatus.test.tsx
@@ -6,7 +6,7 @@ import { describe, expect, it, vi } from 'vitest';
import { AssistantUiRuntimeProvider } from '../../../providers/AssistantUiRuntimeProvider';
import chatRuntimeReducer from '../../../store/chatRuntimeSlice';
import threadReducer from '../../../store/threadSlice';
-import { AgentRunningStatus } from './AgentRunningStatus';
+import { AgentRunningStatus, hasPendingClarification, waitingOnUser } from './AgentRunningStatus';
vi.mock('../../../services/api/threadApi', () => ({
threadApi: {
@@ -24,10 +24,15 @@ vi.mock('../../../services/api/threadApi', () => ({
const THREAD_ID = 't-status';
-function buildStore() {
+function buildStore(chatRuntime?: Record<string, unknown>) {
+ const reducer = combineReducers({ thread: threadReducer, chatRuntime: chatRuntimeReducer });
+ const runtime = chatRuntime
+ ? { ...(reducer(undefined, { type: '@@init' }).chatRuntime as object), ...chatRuntime }
+ : undefined;
return configureStore({
- reducer: combineReducers({ thread: threadReducer, chatRuntime: chatRuntimeReducer }),
+ reducer,
preloadedState: {
+ ...(runtime ? { chatRuntime: runtime } : {}),
thread: {
threads: [],
selectedThreadId: THREAD_ID,
@@ -62,3 +67,70 @@ describe('AgentRunningStatus', () => {
expect(screen.queryByTestId('agent-running-status-tasks')).not.toBeInTheDocument();
});
});
+
+function renderStatus(chatRuntime?: Record<string, unknown>) {
+ return render(
+ <Provider store={buildStore(chatRuntime)}>
+ <AssistantUiRuntimeProvider>
+ <AgentRunningStatus />
+ </AssistantUiRuntimeProvider>
+ </Provider>
+ );
+}
+
+describe('AgentRunningStatus waiting states', () => {
+ it('says it is waiting for approval instead of thinking', () => {
+ renderStatus({
+ pendingApprovalByThread: {
+ [THREAD_ID]: { requestId: 'r1', toolName: 'shell', message: 'run', expiresAt: null },
+ },
+ });
+ const line = screen.getByTestId('agent-running-status-waiting');
+ expect(line).toHaveAttribute('data-waiting', 'approval');
+ expect(line).toHaveTextContent('Waiting for your approval');
+ expect(screen.queryByTestId('agent-running-status-thinking')).not.toBeInTheDocument();
+ });
+
+ it('says it is waiting for a plan review', () => {
+ renderStatus({ pendingPlanReviewByThread: { [THREAD_ID]: { requestId: 'p1' } } });
+ expect(screen.getByTestId('agent-running-status-waiting')).toHaveAttribute(
+ 'data-waiting',
+ 'review'
+ );
+ });
+});
+
+describe('waitingOnUser', () => {
+ it('ranks approval over review over answer', () => {
+ expect(waitingOnUser({ approval: true, review: true, answer: true })).toBe('approval');
+ expect(waitingOnUser({ approval: false, review: true, answer: true })).toBe('review');
+ expect(waitingOnUser({ approval: false, review: false, answer: true })).toBe('answer');
+ expect(waitingOnUser({ approval: false, review: false, answer: false })).toBeNull();
+ });
+});
+
+describe('hasPendingClarification', () => {
+ const ask = (result?: unknown) => ({
+ type: 'tool-call',
+ toolName: 'ask_user_clarification',
+ result,
+ });
+
+ it('is true only for an unanswered question on the newest assistant message', () => {
+ expect(hasPendingClarification([{ role: 'assistant', content: [ask()] }])).toBe(true);
+ expect(hasPendingClarification([{ role: 'assistant', content: [ask('ok')] }])).toBe(false);
+ expect(
+ hasPendingClarification([
+ { role: 'assistant', content: [ask()] },
+ { role: 'assistant', content: [{ type: 'text' }] },
+ ])
+ ).toBe(false);
+ expect(
+ hasPendingClarification([
+ { role: 'assistant', content: [ask()] },
+ { role: 'user', content: [{ type: 'text' }] },
+ ])
+ ).toBe(true);
+ expect(hasPendingClarification([])).toBe(false);
+ });
+});
diff --git a/app/src/features/conversations/aui/StallWarning.test.tsx b/app/src/features/conversations/aui/StallWarning.test.tsx
new file mode 100644
index 0000000000..74cb7cc8db
--- /dev/null
+++ b/app/src/features/conversations/aui/StallWarning.test.tsx
@@ -0,0 +1,43 @@
+import { act, fireEvent, render, screen } from '@testing-library/react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { StallWarning } from './StallWarning';
+
+vi.mock('../../../lib/i18n/I18nContext', () => ({
+ useT: () => ({
+ t: (key: string) => (key === 'chat.status.quietFor' ? 'Quiet for {duration}.' : key),
+ }),
+}));
+
+describe('StallWarning', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date(2026, 9, 7, 12, 0, 0));
+ });
+ afterEach(() => vi.useRealTimers());
+
+ it('shows the phase copy, a ticking quiet duration and a Stop action', () => {
+ const onStop = vi.fn();
+ render(<StallWarning phase="thinking" quietSince={Date.now() - 120_000} onStop={onStop} />);
+
+ const warning = screen.getByTestId('chat-stall-warning');
+ expect(warning).toHaveAttribute('data-chat-stall-phase', 'thinking');
+ expect(warning).toHaveTextContent('chat.stallWarning.thinking');
+ expect(screen.getByTestId('chat-stall-quiet')).toHaveTextContent('Quiet for 2m 0s.');
+
+ act(() => {
+ vi.advanceTimersByTime(5_000);
+ });
+ expect(screen.getByTestId('chat-stall-quiet')).toHaveTextContent('Quiet for 2m 5s.');
+
+ fireEvent.click(screen.getByTestId('chat-stall-stop'));
+ expect(onStop).toHaveBeenCalledTimes(1);
+ });
+
+ it('uses the working copy for a tool phase', () => {
+ render(<StallWarning phase="tool_use" quietSince={Date.now()} onStop={vi.fn()} />);
+ expect(screen.getByTestId('chat-stall-warning')).toHaveTextContent(
+ 'chat.stallWarning.working'
+ );
+ });
+});
diff --git a/app/src/features/conversations/aui/useLiveElapsed.test.ts b/app/src/features/conversations/aui/useLiveElapsed.test.ts
new file mode 100644
index 0000000000..6f5f4bb3ba
--- /dev/null
+++ b/app/src/features/conversations/aui/useLiveElapsed.test.ts
@@ -0,0 +1,31 @@
+import { act, renderHook } from '@testing-library/react';
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
+
+import { useLiveElapsed, useRunningSince } from './useLiveElapsed';
+
+describe('useLiveElapsed / useRunningSince', () => {
+ beforeEach(() => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date(2026, 9, 7, 12, 0, 0));
+ });
+ afterEach(() => vi.useRealTimers());
+
+ it('ticks while running and stops when it settles', () => {
+ const { result, rerender } = renderHook(
+ ({ running }) => useLiveElapsed(useRunningSince(running), running),
+ { initialProps: { running: true } }
+ );
+ expect(result.current).toBe(0);
+ act(() => {
+ vi.advanceTimersByTime(3_000);
+ });
+ expect(result.current).toBe(3_000);
+ rerender({ running: false });
+ expect(result.current).toBeUndefined();
+ });
+
+ it('is undefined without a start time', () => {
+ const { result } = renderHook(() => useLiveElapsed(undefined, true));
+ expect(result.current).toBeUndefined();
+ });
+});
diff --git a/app/src/lib/i18n/bn.ts b/app/src/lib/i18n/bn.ts
index db6dc4a006..42af60137f 100644
--- a/app/src/lib/i18n/bn.ts
+++ b/app/src/lib/i18n/bn.ts
@@ -4364,6 +4364,25 @@ const messages: TranslationMap = {
'composer.workspace.choose': 'ফোল্ডার বেছে নিন…',
'composer.workspace.hint': 'এই কথোপকথন কোথায় কাজ করবে তা বেছে নিন',
'composer.workspace.error': 'ওই ফোল্ডারটি ব্যবহার করা যায়নি',
+ 'composer.placeholder.running': 'একটি ফলো-আপ সারিতে রাখুন…',
+ 'composer.placeholder.waiting': 'উপরে উত্তর দিন, অথবা সারিতে রাখতে লিখুন…',
+ 'composer.queueSend': 'সারি · এটি শেষ হলে পাঠানো হবে',
+ 'composer.stopEsc': 'থামান (Esc)',
+ 'chat.message.copy': 'কপি',
+ 'chat.message.copyMessage': 'বার্তা কপি করুন',
+ 'chat.message.refresh': 'রিফ্রেশ',
+ 'chat.message.goodResponse': 'ভালো উত্তর',
+ 'chat.message.badResponse': 'খারাপ উত্তর',
+ 'chat.message.more': 'আরও',
+ 'chat.message.readAloud': 'জোরে পড়ুন',
+ 'chat.message.stopReading': 'পড়া থামান',
+ 'chat.message.edit': 'সম্পাদনা',
+ 'chat.message.scrollToBottom': 'নিচে স্ক্রল করুন',
+ 'chat.message.justNow': 'এইমাত্র',
+ 'chat.message.minutesAgo': '{count} মিনিট আগে',
+ 'chat.message.hoursAgo': '{count} ঘণ্টা আগে',
+ 'chat.message.interrupted': 'বাধাপ্রাপ্ত',
+ 'chat.message.interruptedDetail': 'এই উত্তরটি শেষ হওয়ার আগেই কেটে গেছে।',
'composer.settings.model': 'মডেল',
'composer.settings.temperature': 'টেম্পারেচার',
'composer.settings.chooseModel': 'অন্য মডেল বেছে নিন…',