Skip to content

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

refactor: reorganize imports and simplify formatting across multiple files

Steven Enamakel11a46fd3da70
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsx
index 15822d110e..e6c907475e 100644
--- a/app/src/features/conversations/Conversations.tsx
+++ b/app/src/features/conversations/Conversations.tsx
@@ -5,20 +5,14 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom';
import { type ChatSendError, chatSendError } from '../../chat/chatSendError';
import { checkPromptInjection, promptGuardMessage } from '../../chat/promptInjectionGuard';
import { trackAnalyticsEvent } from '../../components/analytics';
+import { AgentStatus } from '../../components/assistant-ui/elements/agent-status';
+import { TodoList } from '../../components/assistant-ui/elements/todo-list';
import ArtifactCard from '../../components/chat/ArtifactCard';
import ChatFilesChip from '../../components/chat/ChatFilesChip';
import ComposerTokenStats from '../../components/chat/ComposerTokenStats';
import WorkflowProposalCard from '../../components/chat/WorkflowProposalCard';
-import { decideApproval } from '../../services/api/approvalApi';
-import { ApprovalCardAdapter } from './aui/ApprovalCardAdapter';
-import { ComposerMessageQueue } from './aui/ComposerMessageQueue';
import { ConfirmationModal } from '../../components/intelligence/ConfirmationModal';
import { SidebarContent } from '../../components/layout/shell/SidebarSlot';
-import { AssistantUiChat } from '../../features/conversations/components/AssistantUiChat';
-import { TranscriptOverlays } from '../../features/conversations/components/aui/TranscriptOverlays';
-import { selectBackgroundProcesses } from '../../features/conversations/components/BackgroundProcessesPanel';
-import { AgentStatus } from '../../components/assistant-ui/elements/agent-status';
-import { TodoList } from '../../components/assistant-ui/elements/todo-list';
import { PlanReviewCardCore } from '../../features/conversations/aui/PlanReviewPart';
import { RunModeToggle } from '../../features/conversations/aui/RunModeToggle';
import { toAuiTodoItems } from '../../features/conversations/aui/TodoListPart';
@@ -27,7 +21,13 @@ import {
useLoadThreadGoal,
useThreadGoal,
} from '../../features/conversations/aui/useThreadGoal';
-import { useLoadThreadTodos, useThreadTodos } from '../../features/conversations/aui/useThreadTodos';
+import {
+ useLoadThreadTodos,
+ useThreadTodos,
+} from '../../features/conversations/aui/useThreadTodos';
+import { AssistantUiChat } from '../../features/conversations/components/AssistantUiChat';
+import { TranscriptOverlays } from '../../features/conversations/components/aui/TranscriptOverlays';
+import { selectBackgroundProcesses } from '../../features/conversations/components/BackgroundProcessesPanel';
import {
evaluateComposerSend,
getComposerBlockedSendFeedback,
@@ -58,13 +58,9 @@ import {
} from '../../lib/attachments';
import { useRegisterAction } from '../../lib/commands/useRegisterAction';
import { useT } from '../../lib/i18n/I18nContext';
+import { decideApproval } from '../../services/api/approvalApi';
import { fetchThreadTokenUsage } from '../../services/api/threadUsageApi';
-import {
- aiRegenerate,
- chatCancel,
- chatSend,
- useRustChat,
-} from '../../services/chatService';
+import { aiRegenerate, chatCancel, chatSend, useRustChat } from '../../services/chatService';
import { callCoreRpc } from '../../services/coreRpcClient';
import {
beginInferenceTurn,
@@ -98,6 +94,8 @@ import type { ConfirmationModal as ConfirmationModalType } from '../../types/int
import type { ThreadMessage } from '../../types/thread';
import { chatThreadPath } from '../../utils/chatRoutes';
import { CHAT_ATTACHMENTS_ENABLED } from '../../utils/config';
+import { ApprovalCardAdapter } from './aui/ApprovalCardAdapter';
+import { ComposerMessageQueue } from './aui/ComposerMessageQueue';
import { useChatSurfaceRegistration } from './hooks/useChatSurfaceRegistration';
import { ThreadList } from './threadList/ThreadList';
diff --git a/app/src/features/conversations/aui/queueAdapter.test.tsx b/app/src/features/conversations/aui/queueAdapter.test.tsx
index 855ba17a23..2955bc804d 100644
--- a/app/src/features/conversations/aui/queueAdapter.test.tsx
+++ b/app/src/features/conversations/aui/queueAdapter.test.tsx
@@ -30,11 +30,7 @@ describe('buildOpenHumanQueueAdapter', () => {
});
expect(adapter.items).toEqual([
- {
- id: 'q1',
- prompt: 'and the pricing?',
- parts: [{ type: 'text', text: 'and the pricing?' }],
- },
+ { id: 'q1', prompt: 'and the pricing?', parts: [{ type: 'text', text: 'and the pricing?' }] },
]);
expect(adapter.steerItems).toEqual([]);
});
@@ -130,7 +126,9 @@ describe('useOpenHumanQueueAdapter', () => {
},
})
);
- store.dispatch(queueItemQueued({ threadId: 't1', item: { id: 'q1', text_preview: 'drop me' } }));
+ store.dispatch(
+ queueItemQueued({ threadId: 't1', item: { id: 'q1', text_preview: 'drop me' } })
+ );
const { result } = renderHook(() => useOpenHumanQueueAdapter('t1', vi.fn()), {
wrapper: wrapperFor(store),
});
diff --git a/app/src/features/conversations/aui/queueAdapter.ts b/app/src/features/conversations/aui/queueAdapter.ts
index 293f301b0f..d9ec9a39b4 100644
--- a/app/src/features/conversations/aui/queueAdapter.ts
+++ b/app/src/features/conversations/aui/queueAdapter.ts
@@ -17,7 +17,11 @@
* failed removal leaves the item showing, because the core will still send it.
* - `move` and `edit` are no-ops: the core queue cannot reorder or rewrite.
*/
-import type { AppendMessage, ExternalThreadQueueAdapter, QueueItemState } from '@assistant-ui/react';
+import type {
+ AppendMessage,
+ ExternalThreadQueueAdapter,
+ QueueItemState,
+} from '@assistant-ui/react';
import debug from 'debug';
import { useCallback, useMemo } from 'react';
@@ -106,8 +110,5 @@ export function useOpenHumanQueueAdapter(
[dispatch, threadId]
);
- return useMemo(
- () => buildOpenHumanQueueAdapter({ items, send, remove }),
- [items, send, remove]
- );
+ return useMemo(() => buildOpenHumanQueueAdapter({ items, send, remove }), [items, send, remove]);
}
diff --git a/app/src/pages/__tests__/Conversations.render.test.tsx b/app/src/pages/__tests__/Conversations.render.test.tsx
index e61201d064..1d83f6d3da 100644
--- a/app/src/pages/__tests__/Conversations.render.test.tsx
+++ b/app/src/pages/__tests__/Conversations.render.test.tsx
@@ -33,8 +33,8 @@ import runModeReducer from '../../store/runModeSlice';
import socketReducer from '../../store/socketSlice';
import themeReducer from '../../store/themeSlice';
import threadGoalReducer from '../../store/threadGoalSlice';
-import threadTodosReducer from '../../store/threadTodosSlice';
import threadReducer from '../../store/threadSlice';
+import threadTodosReducer from '../../store/threadTodosSlice';
import type { Thread, ThreadMessage } from '../../types/thread';
// ── Hoisted mock state ─────────────────────────────────────────────────────
diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsx
index 2f3e043478..a070d5b89f 100644
--- a/app/src/providers/ChatRuntimeProvider.tsx
+++ b/app/src/providers/ChatRuntimeProvider.tsx
@@ -43,7 +43,6 @@ import {
clearInferenceStatusForThread,
clearPendingApprovalForThread,
clearPendingPlanReviewForThread,
- resolvePendingApprovalForThread,
clearProcessingForThread,
clearStreamingAssistantForThread,
endInferenceTurn,
@@ -53,6 +52,7 @@ import {
parseToolFailure,
recordChatTurnUsage,
recordSubagentTranscriptTool,
+ resolvePendingApprovalForThread,
resolveSubagentTranscriptTool,
setInferenceStatusForThread,
setPendingApprovalForThread,
@@ -78,7 +78,6 @@ import { useAppDispatch, useAppSelector } from '../store/hooks';
import { setRunMode } from '../store/runModeSlice';
import { selectSocketStatus } from '../store/socketSelectors';
import { clearThreadGoal, setThreadGoal } from '../store/threadGoalSlice';
-import { setThreadTodos } from '../store/threadTodosSlice';
import {
addInferenceResponse,
addMessageLocal,
@@ -91,6 +90,7 @@ import {
setSelectedThread,
TIMING_METADATA_KEY,
} from '../store/threadSlice';
+import { setThreadTodos } from '../store/threadTodosSlice';
import { reportUserError } from '../store/userErrorsSlice';
import { IS_PROD } from '../utils/config';
import { AssistantUiRuntimeProvider } from './AssistantUiRuntimeProvider';
@@ -263,9 +263,7 @@ function chatDoneExtraMetadata(event: ChatDoneEvent): Record<string, unknown> |
* card needs a `GuardrailPayload` no other `error_type` carries).
*/
function chatErrorExtraMetadata(event: ChatErrorEvent): Record<string, unknown> {
- return {
- [CHAT_ERROR_METADATA_KEY]: { errorType: event.error_type, guardrail: event.guardrail },
- };
+ return { [CHAT_ERROR_METADATA_KEY]: { errorType: event.error_type, guardrail: event.guardrail } };
}
/**
@@ -1365,7 +1363,10 @@ const ChatRuntimeProvider = ({ children }: { children: React.ReactNode }) => {
// would race the optimistic clear and, worse, drop a card whose
// decision the USER on this client is mid-click on when the event
// for a DIFFERENT thread's request arrives.
- if (!event.thread_id || (event.resolution !== 'expired' && event.resolution !== 'cancelled')) {
+ if (
+ !event.thread_id ||
+ (event.resolution !== 'expired' && event.resolution !== 'cancelled')
+ ) {
return;
}
dispatch(
diff --git a/app/src/providers/__tests__/useOpenHumanExternalStore.queue.test.tsx b/app/src/providers/__tests__/useOpenHumanExternalStore.queue.test.tsx
index 2906e6542f..696a394454 100644
--- a/app/src/providers/__tests__/useOpenHumanExternalStore.queue.test.tsx
+++ b/app/src/providers/__tests__/useOpenHumanExternalStore.queue.test.tsx
@@ -19,13 +19,15 @@ import { useOpenHumanExternalStore } from '../useOpenHumanExternalStore';
vi.mock('../../services/api/threadApi', () => ({
threadApi: {
- getDerivedTranscript: vi.fn().mockResolvedValue({
- threadId: 't-queue',
- items: [],
- total: 0,
- hasMore: false,
- hasTranscript: false,
- }),
+ getDerivedTranscript: vi
+ .fn()
+ .mockResolvedValue({
+ threadId: 't-queue',
+ items: [],
+ total: 0,
+ hasMore: false,
+ hasTranscript: false,
+ }),
},
}));
diff --git a/app/src/services/chatService.ts b/app/src/services/chatService.ts
index 5d89f7be96..331882705b 100644
--- a/app/src/services/chatService.ts
+++ b/app/src/services/chatService.ts
@@ -1273,7 +1273,12 @@ export function subscribeChatEvents(listeners: ChatEventListeners): () => void {
if (listeners.onThreadTodosChanged) {
const cb = (payload: unknown) => {
const e = payload as ChatThreadTodosChangedEvent;
- chatLog('%s thread_id=%s count=%d', EVENTS.threadTodosChanged, e.thread_id, e.todos?.length ?? 0);
+ chatLog(
+ '%s thread_id=%s count=%d',
+ EVENTS.threadTodosChanged,
+ e.thread_id,
+ e.todos?.length ?? 0
+ );
listeners.onThreadTodosChanged?.(e);
};
socket.on(EVENTS.threadTodosChanged, cb);
@@ -1650,10 +1655,7 @@ export interface ChatCancelOutcome {
* turn on the thread. Optional and omittable for the existing single-turn
* callers.
*/
-export async function chatCancel(
- threadId: string,
- requestId?: string
-): Promise<ChatCancelOutcome> {
+export async function chatCancel(threadId: string, requestId?: string): Promise<ChatCancelOutcome> {
const socket = socketService.getSocket();
const clientId = socket?.id;
if (!clientId) {
@@ -1664,11 +1666,7 @@ export async function chatCancel(
try {
const result = await callCoreRpc<{ result?: { request_id?: unknown } }>({
method: 'openhuman.channel_web_cancel',
- params: {
- client_id: clientId,
- thread_id: threadId,
- request_id: requestId ?? undefined,
- },
+ params: { client_id: clientId, thread_id: threadId, request_id: requestId ?? undefined },
});
const turnCancelled = typeof result?.result?.request_id === 'string';
chatLog('chat_cancel: thread=%s turnCancelled=%s', threadId, turnCancelled);
diff --git a/app/src/store/queueSlice.test.ts b/app/src/store/queueSlice.test.ts
index dc783b2e2c..bc57f310de 100644
--- a/app/src/store/queueSlice.test.ts
+++ b/app/src/store/queueSlice.test.ts
@@ -68,7 +68,10 @@ describe('queueSlice — core run-queue items', () => {
});
it('keeps pending follow-ups when an item is delivered (they persist on turn end)', () => {
- let state = reducer(undefined, pendingFollowupAdded({ threadId: 't1', message: message('m1', 'hi'), text: 'hi' }));
+ let state = reducer(
+ undefined,
+ pendingFollowupAdded({ threadId: 't1', message: message('m1', 'hi'), text: 'hi' })
+ );
state = reducer(state, queued('t1', 'q1', 'hi'));
state = reducer(state, queueItemDelivered({ threadId: 't1', itemId: 'q1' }));
diff --git a/app/src/store/queueSlice.ts b/app/src/store/queueSlice.ts
index 53f1f4ead3..2a9a64b956 100644
--- a/app/src/store/queueSlice.ts
+++ b/app/src/store/queueSlice.ts
@@ -77,7 +77,10 @@ const queueSlice = createSlice({
name: 'queue',
initialState,
reducers: {
- queueItemQueued: (state, action: PayloadAction<{ threadId: string; item: QueueItemPayload }>) => {
+ queueItemQueued: (
+ state,
+ action: PayloadAction<{ threadId: string; item: QueueItemPayload }>
+ ) => {
const { threadId, item } = action.payload;
const bucket = state.itemsByThread[threadId] ?? [];
if (bucket.some(existing => existing.id === item.id)) return;
@@ -113,7 +116,9 @@ const queueSlice = createSlice({
extraReducers: builder => {
// The turn ended, so the core is dispatching whatever it still queued, and
// `ChatRuntimeProvider` has already persisted the pending follow-ups.
- builder.addCase(endInferenceTurn, (state, action) => clearThread(state, action.payload.threadId));
+ builder.addCase(endInferenceTurn, (state, action) =>
+ clearThread(state, action.payload.threadId)
+ );
builder.addCase(clearRuntimeForThread, (state, action) =>
clearThread(state, action.payload.threadId)
);