Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(chat): show the thinking state while a retried Vibey failure runs (#2865)

Call Whitebd15b992cff2
diff --git a/ui/src/components/workbench/ChatPage.hydration.test.tsx b/ui/src/components/workbench/ChatPage.hydration.test.tsx
index e45369870..c23b3e55f 100644
--- a/ui/src/components/workbench/ChatPage.hydration.test.tsx
+++ b/ui/src/components/workbench/ChatPage.hydration.test.tsx
@@ -1032,6 +1032,42 @@ describe('ChatPage transcript hydration', () => {
});
});
+ describe.each([false, true])('retried failure with Activity enabled=%s', (activityEnabled) => {
+ it.each(['live', 'bootstrap'])('keeps the retried work thinking after a %s retry admission', async (delivery) => {
+ // Vibey's retry resumes the transcript and adds no row after the notice, so the
+ // notice stays the last row while the retried work runs.
+ const failure = {
+ ...projectedMessage('failure-notice', 'Vibey 因内部错误而停止'),
+ author: 'agent', source: 'agent', type: 'notify',
+ metadata: { event: 'backend_failure', turn_id: 'failed-turn', failure_id: 'failed-turn' },
+ };
+ const retried = { ...failure, content: { failure_retry: { delivery_id: 'retry', state: 'accepted' } } };
+ mocks.api.getSession.mockResolvedValue({ id: 'session-new' });
+ mocks.api.getSessionBootstrap.mockResolvedValue({
+ ...bootstrapPayload('session-new'),
+ config: { ui: { show_agent_activity: activityEnabled } },
+ turn_state: { ...idleTurnState, foreground: 'running', in_flight: true },
+ messages: [delivery === 'bootstrap' ? retried : failure],
+ });
+ render(
+ <MemoryRouter initialEntries={['/chat/session-new']}>
+ <Routes>
+ <Route path="/chat/:sessionId" element={<ChatPage />} />
+ </Routes>
+ </MemoryRouter>,
+ );
+ await screen.findByText(failure.text, { exact: false });
+ if (delivery === 'live') {
+ // Before its Retry is admitted the failure still ends the visible response.
+ expect(screen.queryByText('chat.thinking')).toBeNull();
+ act(() => mocks.events?.onMessageUpdated(retried));
+ act(() => mocks.events?.onTurnStart({ session_id: 'session-new' }));
+ }
+ expect(await screen.findByText('chat.thinking')).toBeTruthy();
+ expect(mocks.composer?.busy).toBe(true);
+ });
+ });
+
describe.each([false, true])('Computer Use script prompt with Activity enabled=%s', (activityEnabled) => {
it('MESSAGE-DELIVERY-035 draws the confirm prompt as a visible Agent message while the Turn runs', async () => {
// The prompt lands mid-Turn over message.new; the owner must notice it and
diff --git a/ui/src/components/workbench/ChatPage.tsx b/ui/src/components/workbench/ChatPage.tsx
index 5eebb4e31..a0fbb3a1a 100644
--- a/ui/src/components/workbench/ChatPage.tsx
+++ b/ui/src/components/workbench/ChatPage.tsx
@@ -21,7 +21,7 @@ import { readChatViewMode, writeChatViewMode } from '../../lib/chatViewMemory';
import { normalizeChatMessageFontSize } from '../../lib/chatDisplay';
import { setConfigField } from '../../lib/configMutations';
import { annotationStandIn, annotationTitleKey, readAnnotationView } from '../../lib/annotationView';
-import { isAgentActivityBoundaryMessage, isRetryableFailureNotice, isTerminalAgentMessage, isTranscriptMessage, shouldRefreshAgentActivityForMessage } from '../../lib/chatMessageTypes';
+import { isAgentActivityBoundaryMessage, isRetriedFailureNotice, isRetryableFailureNotice, isTerminalAgentMessage, isTranscriptMessage, shouldRefreshAgentActivityForMessage } from '../../lib/chatMessageTypes';
import { chatRowKind, drawsEmptyBodyPlaceholder, isAgentAuthored } from '../../lib/chatRowKind';
import { useIosKeyboardInset } from '../../lib/useIosKeyboardInset';
import { isProxyMediaUrl } from '../../lib/mediaProxy';
@@ -4170,9 +4170,12 @@ export const Transcript: React.FC<TranscriptProps> = ({
// successful ``result``, a legacy ``error``, or a structured backend-failure
// ``notify`` all end the visible response. ``working`` itself still settles
// only from turn.end or the authoritative turn-state poll, so a late row from
- // an older Turn cannot clear Stop for a newer one.
+ // an older Turn cannot clear Stop for a newer one. A failure notice whose Retry
+ // was admitted no longer ends it: the retried work is the response now, and
+ // Vibey's in-place retry adds no row after the notice.
+ const lastMessage = messages.length > 0 ? messages[messages.length - 1] : null;
const lastIsAgentTerminal =
- messages.length > 0 && isTerminalAgentMessage(messages[messages.length - 1]);
+ !!lastMessage && isTerminalAgentMessage(lastMessage) && !isRetriedFailureNotice(lastMessage);
// The running Activity card replaces the ThinkingBubble. It renders only while a
// turn is in flight (``working``) AND the live buffer is non-empty and current-gen
// (round-4 clause). Gating on ``working`` makes a stale buffer — e.g. one left by
diff --git a/ui/src/components/workbench/FailureRetry.tsx b/ui/src/components/workbench/FailureRetry.tsx
index 6051dafdc..64dcd2b7c 100644
--- a/ui/src/components/workbench/FailureRetry.tsx
+++ b/ui/src/components/workbench/FailureRetry.tsx
@@ -3,7 +3,7 @@ import { Check, RotateCcw } from 'lucide-react';
import { useTranslation } from 'react-i18next';
import type { WorkbenchMessage } from '../../context/ApiContext';
-import { isRetryableFailureNotice } from '../../lib/chatMessageTypes';
+import { ADMITTED_RETRY_STATES, isRetryableFailureNotice } from '../../lib/chatMessageTypes';
import { Button } from '../ui/button';
export function FailureRetry({
@@ -25,7 +25,7 @@ export function FailureRetry({
// Local success bridges the response only until a durable state is present.
// In particular, a later retirement must unlock this same mounted row.
const admitted = action?.state
- ? ['queued', 'claimed', 'accepted'].includes(action.state)
+ ? ADMITTED_RETRY_STATES.includes(action.state)
: requested;
if (readOnly || !isRetryableFailureNotice(message)) return null;
return (
diff --git a/ui/src/lib/chatMessageTypes.ts b/ui/src/lib/chatMessageTypes.ts
index e534a9e9e..d4eb467d1 100644
--- a/ui/src/lib/chatMessageTypes.ts
+++ b/ui/src/lib/chatMessageTypes.ts
@@ -101,6 +101,26 @@ export function isRetryableFailureNotice(
&& !(Array.isArray(metadata.watch_ids) && metadata.watch_ids.length > 0);
}
+// The Retry states in which the notice's continuation is admitted: it was queued,
+// claimed, or accepted into a Turn. ``reserved`` and ``retired`` are not.
+export const ADMITTED_RETRY_STATES: readonly string[] = ['queued', 'claimed', 'accepted'];
+
+// A failure notice whose Retry was admitted. The failure no longer ends the visible
+// response: a retry continues it, and Vibey's retry writes no input row after the
+// notice (it resumes the transcript), so the notice can stay the last row while the
+// retried work runs. ``failure_retry.state`` is derived on the server from the
+// retry's Delivery, so it holds on reload as well as live.
+export function isRetriedFailureNotice(
+ message: TerminalAgentMessageCandidate & { source?: string | null; content?: unknown },
+): boolean {
+ if (!isBackendFailureNotice(message)) return false;
+ const content = message.content;
+ const action = content && typeof content === 'object'
+ ? (content as { failure_retry?: { state?: unknown } }).failure_retry
+ : undefined;
+ return typeof action?.state === 'string' && ADMITTED_RETRY_STATES.includes(action.state);
+}
+
// A terminal reply the TRANSCRIPT shows: the catalog's terminal activity role
// intersected with transcript visibility (``silent`` is terminal for activity
// bookkeeping but never rendered), plus the conditional terminals that only settle