Skip to content

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

fix(chat): hide regenerate actions on failed turns

Steven Enamakeld0e5d9e43b8e
diff --git a/app/src/components/assistant-ui/elements/error-state.tsx b/app/src/components/assistant-ui/elements/error-state.tsx
index 3a9883de88..1bcc9ce990 100644
--- a/app/src/components/assistant-ui/elements/error-state.tsx
+++ b/app/src/components/assistant-ui/elements/error-state.tsx
@@ -18,7 +18,7 @@ export interface ErrorStateProps extends Omit<ComponentProps<'div'>, 'children'
title: string;
detail: string;
retrying: boolean;
- onRetry: () => void;
+ onRetry?: () => void;
retryingLabel?: string;
retryLabel?: string;
}
@@ -69,13 +69,15 @@ export function ErrorState({
{detail}
</p>
</div>
- <button
- type="button"
- onClick={onRetry}
- className="ms-auto flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium text-red-600 transition-colors hover:bg-red-500/10 dark:text-red-400">
- <RefreshCwIcon className="size-3" />
- {retryLabel}
- </button>
+ {onRetry && (
+ <button
+ type="button"
+ onClick={onRetry}
+ className="ms-auto flex items-center gap-1.5 rounded-full px-3 py-1 text-xs font-medium text-red-600 transition-colors hover:bg-red-500/10 dark:text-red-400">
+ <RefreshCwIcon className="size-3" />
+ {retryLabel}
+ </button>
+ )}
</div>
);
}
diff --git a/app/src/components/assistant-ui/thread.reloadCapability.test.tsx b/app/src/components/assistant-ui/thread.reloadCapability.test.tsx
index 98e18e88ad..893ab87995 100644
--- a/app/src/components/assistant-ui/thread.reloadCapability.test.tsx
+++ b/app/src/components/assistant-ui/thread.reloadCapability.test.tsx
@@ -29,9 +29,39 @@ const messages: ThreadMessageLike[] = [
{ role: 'assistant', content: [{ type: 'text', text: 'a reply' }] },
];
-function Harness({ withReload }: { withReload: boolean }) {
+function Harness({
+ withReload,
+ failed = false,
+ guardrail = false,
+}: {
+ withReload: boolean;
+ failed?: boolean;
+ guardrail?: boolean;
+}) {
const runtime = useExternalStoreRuntime({
- messages,
+ messages: guardrail
+ ? [
+ messages[0],
+ {
+ role: 'assistant',
+ content: [],
+ metadata: { custom: { extraMetadata: { chatError: { errorType: 'guardrail' } } } },
+ } satisfies ThreadMessageLike,
+ ]
+ : failed
+ ? [
+ messages[0],
+ {
+ role: 'assistant',
+ content: [],
+ status: {
+ type: 'incomplete',
+ reason: 'error',
+ error: 'The turn failed before a reply was saved',
+ },
+ } satisfies ThreadMessageLike,
+ ]
+ : messages,
isRunning: false,
convertMessage: (m: ThreadMessageLike) => m,
onNew: async () => {},
@@ -55,4 +85,16 @@ describe('assistant action bar reload gate', () => {
render(<Harness withReload />);
expect(screen.getAllByRole('button', { name: 'Refresh' }).length).toBeGreaterThan(0);
});
+
+ it('shows a failed turn without retry or Refresh controls', () => {
+ render(<Harness withReload failed />);
+ expect(screen.getByText('The turn failed before a reply was saved')).toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Retry' })).not.toBeInTheDocument();
+ expect(screen.queryByRole('button', { name: 'Refresh' })).not.toBeInTheDocument();
+ });
+
+ it('hides Refresh on a guardrail failed turn', () => {
+ render(<Harness withReload guardrail />);
+ expect(screen.queryByRole('button', { name: 'Refresh' })).not.toBeInTheDocument();
+ });
});
diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsx
index 63dce0d85d..d84bcb3ce3 100644
--- a/app/src/components/assistant-ui/thread.tsx
+++ b/app/src/components/assistant-ui/thread.tsx
@@ -32,6 +32,7 @@ import {
} from '@/features/conversations/components/aui/auiThreadState';
import { useT } from '@/lib/i18n/I18nContext';
import { useAuiThreadId } from '@/providers/AssistantUiRuntimeProvider';
+import { CHAT_ERROR_METADATA_KEY } from '@/store/threadSlice';
import { useActionBarReload, useMessageError } from '@assistant-ui/core/react';
import {
ActionBarMorePrimitive,
@@ -1313,15 +1314,12 @@ const ComposerAction: FC<{
* projection marks persisted `chat_error` rows as incomplete/error, so they
* use this same card as errors raised directly by assistant-ui.
*
- * `useMessageError`/`useActionBarReload` come straight from
- * `@assistant-ui/core/react` rather than through a primitive: there is no
- * primitive that hands back the raw error VALUE (only
- * `ErrorPrimitive.Message`, which renders it directly), and Retry needs the
- * same reload callback `ActionBarPrimitive.Reload` uses internally.
+ * `useMessageError` gives us the raw error value for the card. Failed turns
+ * have no committed assistant reply id for `threads.regenerate`, so this card
+ * must not offer Reload even when the runtime supports it for settled replies.
*/
const MessageError: FC = () => {
const error = useMessageError();
- const { disabled: reloadDisabled, reload } = useActionBarReload();
if (error === undefined) return null;
const detail = typeof error === 'string' ? error : JSON.stringify(error);
return (
@@ -1331,9 +1329,6 @@ const MessageError: FC = () => {
title="Something went wrong"
detail={detail}
retrying={false}
- onRetry={() => {
- if (!reloadDisabled) reload();
- }}
/>
</MessagePrimitive.Error>
);
@@ -1567,13 +1562,21 @@ const AssistantActionBar: FC = () => {
// Hoisted to a `const` rather than written inline for the same coverage
// reason as `editAction` in `UserActionBar`.
const canReload = useAuiReloadCapability();
- const reloadAction = canReload ? (
- <ActionBarPrimitive.Reload asChild>
- <TooltipIconButton tooltip="Refresh">
- <RefreshCwIcon />
- </TooltipIconButton>
- </ActionBarPrimitive.Reload>
- ) : null;
+ const isFailedTurn = useAuiState(s => {
+ if (s.message.status?.type === 'incomplete' && s.message.status.reason === 'error') return true;
+ const custom = s.message.metadata?.custom as
+ | { extraMetadata?: Record<string, unknown> }
+ | undefined;
+ return custom?.extraMetadata?.[CHAT_ERROR_METADATA_KEY] !== undefined;
+ });
+ const reloadAction =
+ canReload && !isFailedTurn ? (
+ <ActionBarPrimitive.Reload asChild>
+ <TooltipIconButton tooltip="Refresh">
+ <RefreshCwIcon />
+ </TooltipIconButton>
+ </ActionBarPrimitive.Reload>
+ ) : null;
return (
<ActionBarPrimitive.Root
diff --git a/docs/RELEASE-MANUAL-SMOKE.md b/docs/RELEASE-MANUAL-SMOKE.md
index 7d4ae50135..1f0560e5aa 100644
--- a/docs/RELEASE-MANUAL-SMOKE.md
+++ b/docs/RELEASE-MANUAL-SMOKE.md
@@ -23,6 +23,7 @@ Applies to every release, all platforms.
### Conversation resume
- [ ] **An existing chat accepts another turn after restart** — Send a message and wait for its reply, fully quit OpenHuman, then reopen that conversation and send a second message. Expected: the second reply streams normally, retains the earlier context, and does not show a generic error. Repeat after the conversation has compacted if a long-running test profile is available (#6608).
+- [ ] **A failed chat turn does not offer an invalid regenerate action** — Trigger a provider failure in a test profile and inspect its error card. Expected: the diagnostic text remains visible, with no Retry or Refresh button on that failed message. A completed assistant reply still offers Refresh (#6613).
### Checkbox appearance
diff --git a/docs/TEST-COVERAGE-MATRIX.md b/docs/TEST-COVERAGE-MATRIX.md
index c3452c43be..40f002608b 100644
--- a/docs/TEST-COVERAGE-MATRIX.md
+++ b/docs/TEST-COVERAGE-MATRIX.md
@@ -229,7 +229,7 @@ End-to-end coverage of the agent harness via the web-chat RPC surface against an
| 4.4.14 | Session todo list (the `todo` tool) | RI+VU+WD | `tests/agent_harness_e2e.rs`, `crates/openhuman-core/src/agent/tools/todo_tests.rs`, `vendor/tinyagents/crates/tinyagents-graph/src/todos/test.rs`, `app/src/features/conversations/utils/harnessState.test.ts`, `app/src/features/conversations/components/TodoChecklist.test.tsx`, `app/src/features/conversations/hooks/useThreadHarnessState.test.ts`, `app/test/e2e/specs/chat-todos-goals.spec.ts` | ✅ | Whole-list write per call (Claude/Codex shape), single-`in_progress` invariant, per-session scoping; five items ticked off across turns, live on the socket, persisted in the turn state, and rendered as the chat pane's checklist |
| 4.4.15 | Thread goal (`goal_set` / `goal_get` / `goal_complete`) | RI+RU+VU+WD | `tests/agent_harness_e2e.rs`, `crates/openhuman-core/src/agent/goals/{tools_tests.rs,runtime_tests.rs,continuation_tests.rs}`, `vendor/tinyagents/crates/tinyagents-graph/src/goals/test.rs`, `app/src/features/conversations/utils/harnessState.test.ts`, `app/src/features/conversations/components/GoalBanner.test.tsx`, `app/src/features/conversations/hooks/useThreadHarnessState.test.ts`, `app/test/e2e/specs/chat-todos-goals.spec.ts` | ✅ | Objective + token budget set, read back across turns, and completed; structured `{goal, text}` payload drives the chat pane's goal banner. Budget accounting and the budget-limit stop hook are unit-covered (the scripted e2e upstream reports no usage) |
| 4.4.16 | Builder-supplied session definition (library host) | RU | `crates/openhuman-core/src/agent/session_host/builder/builder_tests_session_definition_tests.rs` | ✅ | `SessionHostBuilder::agent_definition` stamps a caller's own `AgentDefinition` on the session, so a hosted root invocation resolves an id the process registry never held; it outranks a registry entry sharing its id, it carries the turn's tool allow-list, the session is stamped with the definition's own id, a contradicting `agent_definition_name` fails the build, and without it the same id stays unknown |
-| 4.4.17 | Chat failure presentation | RU+VU | `crates/openhuman-core/src/web_chat/web_tests_rate_limit_classification_tests.rs`, `app/src/providers/__tests__/assistantUiMessages.test.ts`, `app/src/features/conversations/aui/ChatErrorNotice.test.tsx` | ✅ | Failed turns use assistant-ui's error card; old custom link markup is removed from saved errors (#6609) |
+| 4.4.17 | Chat failure presentation | RU+VU | `crates/openhuman-core/src/web_chat/web_tests_rate_limit_classification_tests.rs`, `app/src/providers/__tests__/assistantUiMessages.test.ts`, `app/src/features/conversations/aui/ChatErrorNotice.test.tsx`, `app/src/components/assistant-ui/thread.reloadCapability.test.tsx` | ✅ | Failed turns use assistant-ui's error card; old custom link markup is removed from saved errors (#6609); uncommitted failures and guardrail notices hide invalid regenerate controls while completed replies retain Refresh (#6613) |
---