Skip to content

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

test(conversations): add accessibility smoke test and fix test imports

Steven Enamakelfd7c0495ddee
diff --git a/app/src/components/__tests__/a11y.smoke.test.tsx b/app/src/components/__tests__/a11y.smoke.test.tsx
index c4d99c9418..a6c7852f56 100644
--- a/app/src/components/__tests__/a11y.smoke.test.tsx
+++ b/app/src/components/__tests__/a11y.smoke.test.tsx
@@ -55,19 +55,18 @@ describe('accessibility smoke', () => {
await expectNoViolations(container);
});
- it('ApprovalRequestCard has no axe violations', async () => {
- const approval: PendingApproval = {
- requestId: 'req-1',
- toolName: 'shell',
- message: 'Run `shell` — shell (18 bytes of arguments)',
- command: 'pip show yfinance',
- };
- const store = configureStore({ reducer: { chatRuntime: chatRuntimeReducer } });
- store.dispatch(setPendingApprovalForThread({ threadId: 't1', approval }));
+ it('ApprovalCardAdapter has no axe violations', async () => {
const { container } = render(
- <Provider store={store}>
- <ApprovalRequestCard threadId="t1" approval={approval} />
- </Provider>
+ <ApprovalCardAdapter
+ ariaLabel="Approval needed"
+ title="Approval needed"
+ subtitle="Run `shell` — shell (18 bytes of arguments)"
+ command="pip show yfinance"
+ toolName="shell"
+ alwaysDecision="approve_always_for_tool"
+ analyticsPrefix="chat-approval"
+ onDecide={vi.fn()}
+ />
);
await expectNoViolations(container);
});
diff --git a/app/src/features/conversations/aui/MediaAndDocumentCalls.test.tsx b/app/src/features/conversations/aui/MediaAndDocumentCalls.test.tsx
index 6b10c1806f..6da9dc2493 100644
--- a/app/src/features/conversations/aui/MediaAndDocumentCalls.test.tsx
+++ b/app/src/features/conversations/aui/MediaAndDocumentCalls.test.tsx
@@ -24,7 +24,7 @@ describe('MediaGenerationCall', () => {
/>
);
- expect(screen.getByText('a red fox in snow')).toBeInTheDocument();
+ expect(screen.getByText('Generating')).toBeInTheDocument();
});
it('renders one image per produced artifact once the tool completes', () => {
diff --git a/app/src/features/conversations/aui/TodoListPart.tsx b/app/src/features/conversations/aui/TodoListPart.tsx
new file mode 100644
index 0000000000..2650dfc581
--- /dev/null
+++ b/app/src/features/conversations/aui/TodoListPart.tsx
@@ -0,0 +1,73 @@
+import type { ToolCallMessagePartComponent } from '@assistant-ui/react';
+
+import { TodoList, type TodoItem, type TodoStatus } from '../../../components/assistant-ui/elements/todo-list';
+import { useT } from '../../../lib/i18n/I18nContext';
+import type { CoreTodoStatus } from '../../../store/threadTodosSlice';
+
+/**
+ * Adapts the core wire shape of a `todo` tool call — `{content, status}` with
+ * `status: 'pending'|'in_progress'|'completed'` — onto the vendored
+ * `TodoList` element's `TodoItem` shape (`{id, text, status}` with
+ * `status: 'pending'|'active'|'done'|'failed'`). The core never sends
+ * `'failed'` today, so that status never maps — kept here anyway so the
+ * mapping stays honest if the core ever adds it.
+ */
+export function mapCoreTodoStatus(status: unknown): TodoStatus {
+ switch (status) {
+ case 'in_progress':
+ return 'active';
+ case 'completed':
+ return 'done';
+ case 'pending':
+ return 'pending';
+ default:
+ return 'pending';
+ }
+}
+
+interface CoreTodoItem {
+ content?: unknown;
+ status?: unknown;
+}
+
+function isCoreTodoItem(value: unknown): value is CoreTodoItem {
+ return Boolean(value) && typeof value === 'object';
+}
+
+/** `content`+index as a stable id when the payload has no id field of its own. */
+export function toAuiTodoItems(raw: unknown): TodoItem[] {
+ if (!Array.isArray(raw)) return [];
+ const items: TodoItem[] = [];
+ raw.forEach((candidate, index) => {
+ if (!isCoreTodoItem(candidate)) return;
+ const content = typeof candidate.content === 'string' ? candidate.content : '';
+ if (!content.trim()) return;
+ items.push({
+ id: `${index}-${content}`,
+ text: content,
+ status: mapCoreTodoStatus(candidate.status),
+ });
+ });
+ return items;
+}
+
+/** Args/result shape the core sends for the `todo` tool call. */
+interface TodoToolArgs {
+ todos?: Array<{ content: string; status: CoreTodoStatus }>;
+}
+
+/**
+ * Toolkit render for the `todo` tool call — a standalone element in the
+ * transcript showing the todo list snapshot as of THIS call (args carry the
+ * write while in flight; result echoes it back once settled). The pinned,
+ * always-current list above the composer is a separate render, driven by
+ * {@link useThreadTodos} off the live `thread_todos_changed` event, not this
+ * per-call snapshot.
+ */
+export const TodoListPart: ToolCallMessagePartComponent = ({ args, result }) => {
+ const { t } = useT();
+ const payload = (result ?? args) as TodoToolArgs | undefined;
+ const items = toAuiTodoItems(payload?.todos);
+ if (items.length === 0) return null;
+ return <TodoList items={items} title={t('conversations.todos.title')} />;
+};
diff --git a/crates/openhuman-core/src/web_chat/ops/start_chat.rs b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
index 18f1634df1..bef6aaf951 100644
--- a/crates/openhuman-core/src/web_chat/ops/start_chat.rs
+++ b/crates/openhuman-core/src/web_chat/ops/start_chat.rs
@@ -195,7 +195,24 @@ pub async fn start_chat(
prompt_decision.prompt_hash,
prompt_decision.prompt_chars,
);
- return Err(prompt_guard_user_message(prompt_decision.action).to_string());
+ let verdict = match prompt_decision.action {
+ PromptEnforcementAction::Allow => "allow",
+ PromptEnforcementAction::Blocked => "block",
+ PromptEnforcementAction::ReviewBlocked => "review_blocked",
+ }
+ .to_string();
+ return Err(StartChatError::Guardrail {
+ verdict,
+ score: prompt_decision.score as f64,
+ reasons: prompt_decision
+ .reasons
+ .iter()
+ .map(|r| crate::core::socketio::GuardrailReason {
+ code: r.code.clone(),
+ message: r.message.clone(),
+ })
+ .collect(),
+ });
}
// Chat-native approval: if this thread has a parked approval and the message