From e28b679ddf2725ee10f51252810be88c351db966 Mon Sep 17 00:00:00 2001 From: yannickmonney <102406702+yannickmonney@users.noreply.github.com> Date: Sun, 4 Oct 2026 12:49:27 +0000 Subject: [PATCH 1/2] fix(platform): preserve agent transcript read failures --- .../components/agent-execution-log.test.tsx | 28 +++++++++++++++++-- .../components/agent-execution-log.tsx | 27 ++++++++++++++++++ services/platform/messages/de.yml | 3 ++ services/platform/messages/en.yml | 3 ++ services/platform/messages/fr.yml | 3 ++ 5 files changed, 62 insertions(+), 2 deletions(-) diff --git a/services/platform/app/features/automations/components/agent-execution-log.test.tsx b/services/platform/app/features/automations/components/agent-execution-log.test.tsx index 3072228093..902d12c89f 100644 --- a/services/platform/app/features/automations/components/agent-execution-log.test.tsx +++ b/services/platform/app/features/automations/components/agent-execution-log.test.tsx @@ -7,11 +7,19 @@ import { AgentActivityLine, AgentExecutionLog } from './agent-execution-log'; // Drives the mocked `useBackendQuery` return: the run's sandbox op, or `null` // for a run that never ran an agent node. const { state } = vi.hoisted(() => ({ - state: { data: undefined as unknown }, + state: { + data: undefined as unknown, + isError: false, + refetch: vi.fn(), + }, })); vi.mock('@/app/hooks/use-backend-query', () => ({ - useBackendQuery: () => ({ data: state.data }), + useBackendQuery: () => ({ + data: state.data, + isError: state.isError, + refetch: state.refetch, + }), })); const runId = 'run-1' as string; @@ -158,4 +166,20 @@ describe('AgentExecutionLog', () => { ); expect(container).toBeEmptyDOMElement(); }); + + it('keeps the transcript section visible and retries when the op read fails', async () => { + state.data = undefined; + state.isError = true; + const { user } = render( + , + ); + + expect(screen.getByRole('alert')).toHaveTextContent( + 'Could not load the agent log.', + ); + const retry = screen.getByRole('button', { name: 'Try again' }); + await user.click(retry); + expect(state.refetch).toHaveBeenCalledOnce(); + expect(retry).toHaveFocus(); + }); }); diff --git a/services/platform/app/features/automations/components/agent-execution-log.tsx b/services/platform/app/features/automations/components/agent-execution-log.tsx index a5408a543c..f8624a51c1 100644 --- a/services/platform/app/features/automations/components/agent-execution-log.tsx +++ b/services/platform/app/features/automations/components/agent-execution-log.tsx @@ -1,5 +1,6 @@ 'use client'; +import { Alert } from '@tale/ui/alert'; import { Button } from '@tale/ui/button'; import { cn } from '@tale/ui/cn'; import { CollapsibleDetails } from '@tale/ui/collapsible-details'; @@ -11,6 +12,7 @@ import { CheckCircle2, Loader2, MessageSquare, + RotateCcw, Wrench, } from 'lucide-react'; import { useEffect, useRef, useState } from 'react'; @@ -416,10 +418,35 @@ export function AgentExecutionLog({ waitingForRoom?: boolean; className?: string; }) { + const { t } = useT('automations'); const opQuery = useBackendQuery( 'sandbox/session_queries_public:getAgentNodeSandboxOp', { organizationId, runId }, ); + if (opQuery.isError) { + return ( + + + {t('runs.agentLog.title')} + + + + + + ); + } return ( Date: Mon, 5 Oct 2026 01:20:58 +0000 Subject: [PATCH 2/2] fix(platform): keep agent log mounted during retry --- .../components/agent-execution-log.test.tsx | 45 +++++++++++++ .../components/agent-execution-log.tsx | 64 ++++++++++++------- 2 files changed, 87 insertions(+), 22 deletions(-) diff --git a/services/platform/app/features/automations/components/agent-execution-log.test.tsx b/services/platform/app/features/automations/components/agent-execution-log.test.tsx index 902d12c89f..495ca72d54 100644 --- a/services/platform/app/features/automations/components/agent-execution-log.test.tsx +++ b/services/platform/app/features/automations/components/agent-execution-log.test.tsx @@ -10,6 +10,8 @@ const { state } = vi.hoisted(() => ({ state: { data: undefined as unknown, isError: false, + isFetching: false, + errorUpdateCount: 0, refetch: vi.fn(), }, })); @@ -18,6 +20,8 @@ vi.mock('@/app/hooks/use-backend-query', () => ({ useBackendQuery: () => ({ data: state.data, isError: state.isError, + isFetching: state.isFetching, + errorUpdateCount: state.errorUpdateCount, refetch: state.refetch, }), })); @@ -170,6 +174,7 @@ describe('AgentExecutionLog', () => { it('keeps the transcript section visible and retries when the op read fails', async () => { state.data = undefined; state.isError = true; + state.errorUpdateCount = 1; const { user } = render( , ); @@ -182,4 +187,44 @@ describe('AgentExecutionLog', () => { expect(state.refetch).toHaveBeenCalledOnce(); expect(retry).toHaveFocus(); }); + + it('keeps the section and focused retry mounted while a retry resets the query', async () => { + state.data = undefined; + state.isError = true; + state.errorUpdateCount = 1; + state.refetch.mockImplementation(() => { + state.isError = false; + state.isFetching = true; + }); + const { user, rerender } = render( + , + ); + + const retry = screen.getByRole('button', { name: 'Try again' }); + await user.click(retry); + rerender(); + + expect( + screen.getByRole('heading', { name: 'Agent log' }), + ).toBeInTheDocument(); + expect(screen.getByRole('alert')).toBeInTheDocument(); + expect(screen.getByRole('button', { name: 'Try again' })).toHaveFocus(); + expect(retry).toHaveAttribute('aria-disabled', 'true'); + expect(retry).toHaveAttribute('aria-busy', 'true'); + expect(retry).not.toBeDisabled(); + }); + + it('keeps cached transcript content visible when a refresh fails', () => { + state.data = op([{ type: 'text', text: 'cached thought' }]); + state.isError = true; + state.errorUpdateCount = 1; + const { container } = render( + , + ); + + expect(container).toHaveTextContent('cached thought'); + expect(screen.getByRole('alert')).toHaveTextContent( + 'Could not load the agent log.', + ); + }); }); diff --git a/services/platform/app/features/automations/components/agent-execution-log.tsx b/services/platform/app/features/automations/components/agent-execution-log.tsx index f8624a51c1..44d3bcea6e 100644 --- a/services/platform/app/features/automations/components/agent-execution-log.tsx +++ b/services/platform/app/features/automations/components/agent-execution-log.tsx @@ -19,6 +19,7 @@ import { useEffect, useRef, useState } from 'react'; import { useAutoScroll } from '@/app/hooks/use-auto-scroll'; import { useBackendQuery } from '@/app/hooks/use-backend-query'; +import { readStateOf } from '@/app/lib/backend/read-state'; import { mergeTimelineEntries, strippedText, @@ -409,11 +410,13 @@ export function ExecutionLogView({ export function AgentExecutionLog({ organizationId, runId, + nodeId, waitingForRoom = false, className, }: { organizationId: string; runId: string; + nodeId?: string; /** The run is parked on the turn's start, waiting for sandbox room. */ waitingForRoom?: boolean; className?: string; @@ -421,37 +424,54 @@ export function AgentExecutionLog({ const { t } = useT('automations'); const opQuery = useBackendQuery( 'sandbox/session_queries_public:getAgentNodeSandboxOp', - { organizationId, runId }, + { organizationId, runId, ...(nodeId !== undefined ? { nodeId } : {}) }, + ); + const read = readStateOf(opQuery); + const failure = (read.unavailable || read.stale) && ( + + + ); - if (opQuery.isError) { + if (read.unavailable) { return ( {t('runs.agentLog.title')} - - - + {failure} ); } + if (!read.stale) { + return ( + + ); + } return ( - + + + {failure} + ); }