reload after failed task
This commit is contained in:
@@ -31,20 +31,20 @@ function ToolCallView({
|
||||
const [displayError, setDisplayError] = useState<string | null>(
|
||||
toolCall.error ?? null,
|
||||
);
|
||||
const completionNotifiedRef = useRef(false);
|
||||
const terminalNotifiedRef = useRef(false);
|
||||
const onJobCompletedRef = useRef(onJobCompleted);
|
||||
useEffect(() => {
|
||||
onJobCompletedRef.current = onJobCompleted;
|
||||
}, [onJobCompleted]);
|
||||
useEffect(() => {
|
||||
if (toolCall.status !== 'not_completed' || !jobId) {
|
||||
completionNotifiedRef.current = false;
|
||||
terminalNotifiedRef.current = false;
|
||||
return;
|
||||
}
|
||||
// Only a different job may reinitialize the local display state.
|
||||
setDisplayStatus(initialDisplayStatus);
|
||||
setDisplayError(toolCall.error ?? null);
|
||||
completionNotifiedRef.current = false;
|
||||
terminalNotifiedRef.current = false;
|
||||
let disposed = false;
|
||||
let timeoutId: ReturnType<typeof setTimeout> | undefined;
|
||||
const poll = async () => {
|
||||
@@ -57,11 +57,8 @@ function ToolCallView({
|
||||
) {
|
||||
setDisplayStatus(response.job.status);
|
||||
setDisplayError(response.job.error ?? null);
|
||||
if (
|
||||
response.job.status === 'completed' &&
|
||||
!completionNotifiedRef.current
|
||||
) {
|
||||
completionNotifiedRef.current = true;
|
||||
if (!terminalNotifiedRef.current) {
|
||||
terminalNotifiedRef.current = true;
|
||||
onJobCompletedRef.current?.();
|
||||
}
|
||||
return;
|
||||
|
||||
+1
-1
@@ -492,7 +492,7 @@ describe('useEditorAgentConversation', () => {
|
||||
const getConversationCallsBeforeConfirm = vi.mocked(client.getConversation)
|
||||
.mock.calls.length;
|
||||
|
||||
let confirmationPromise: Promise<null> | undefined;
|
||||
let confirmationPromise: Promise<void> | undefined;
|
||||
act(() => {
|
||||
confirmationPromise = result.current.confirmToolCall(7);
|
||||
});
|
||||
|
||||
@@ -426,7 +426,7 @@ export function useEditorAgentConversation({
|
||||
async (messageId: number, action: EditorAgentToolCallAction) => {
|
||||
const conversationId = activeConversationIdRef.current;
|
||||
if (!conversationId || activeToolCallActionRef.current) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
const nextAction = { messageId, action } as const;
|
||||
@@ -440,7 +440,7 @@ export function useEditorAgentConversation({
|
||||
: client.cancelToolCall(conversationId, messageId));
|
||||
|
||||
if (activeConversationIdRef.current !== conversationId) {
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
const detail = await loadConversation(conversationId);
|
||||
@@ -450,7 +450,6 @@ export function useEditorAgentConversation({
|
||||
if (action === 'confirm' && updatedMessage?.toolCall?.externalJobId) {
|
||||
onConfirmSent?.();
|
||||
}
|
||||
return null;
|
||||
} catch (error) {
|
||||
if (activeConversationIdRef.current === conversationId) {
|
||||
setErrorMessage(
|
||||
|
||||
Reference in New Issue
Block a user