Skip to content

[Bug]: Provider finish_reason network_error hides revert button #7982

Description

@ImBIOS

Description

When the provider finishes with finish_reason: network_error the last user message row shows only the copy button — the revert/undo affordance is missing. Users expect to be able to revert the failed turn (to retry or remove it), especially after transient network failures.

Screenshot/behavior: input I last gave shows only copy, no revert arrow.

Root cause

  • Failed turns still create a checkpoint (CheckpointReactor.ts:355 status: error, thread.turn.diff.complete), but they often have no assistant_message or a synthetic assistant:${turnId} id that never appears in timelineEntries.
  • ChatView.tsx:2620 derives revertTurnCountByUserMessageId only by scanning forward to the next assistant message and looking up turnDiffSummaryByAssistantMessageId. When the assistant message is missing/synthetic the lookup misses -> canRevertAgentWork false -> MessagesTimeline.tsx:995 hides the revert button.

Evidence:

  • apps/server/src/orchestration/Layers/CheckpointReactor.ts:355,65 creates error checkpoint.
  • apps/web/src/components/ChatView.tsx:2620-2651 direct scan misses.
  • apps/web/src/components/chat/MessagesTimeline.tsx:995,1068 only renders copy.

Expected

After any terminal turn, including network_error/status:error/missing, the preceding user message must expose the revert button (disabled only when isRevertingCheckpoint or isWorking).

Patch

Managed via fh as fix-chat-show-revert-after-network-error-vq3yckjy:

  • Keep existing assistant-message scan, add fallback: map nth user message to nth checkpoint sorted by completedAt (1:1 user->turn) when direct scan finds nothing. Covers synthetic ids and zero-message failed turns.
  • Change: apps/web/src/components/ChatView.tsx:2620 + fallback block.

Verify:

pnpm exec vp test run apps/web/src/components/ChatView.logic.test.ts
pnpm exec vp test run apps/web/src/components/chat/MessagesTimeline.logic.test.ts

Manual: trigger Provider finish_reason: network_error (e.g. kill network mid-turn), observe last user bubble now shows undo icon next to copy.

Tracking

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions