← Back to Pull requests

fix: recover chat after rejected file uploads #419

Open
unknown opened this pull request with 217 lines diff across 2 files
View on GitHub
unknown unknown commented on Oct 03, 2026 05:28 UTC
Author

What changed

When an agent inference request failed, the client left optimistic user turns (including rejected base64 file payloads) in chat history. A later text-only request then resent the same invalid file and failed again. The client also retained the rejected attachment in its pending upload list.

This restores the conversation to its last accepted history on failed requests. For the server's Invalid file format response, it also clears pending image/document attachments and shows the specific server message; transient errors keep pending attachments available for retry. The user's text remains available. Adds dependency-free regression tests using Node's built-in test runner.

Closes #413.

Validation

  • pnpm test: 3 passed.

  • pnpm typecheck: passed.

  • pnpm lint: passed with 16 existing warnings.

  • pnpm build: blocked by four TypeScript errors in existing guardrails files (guardrails/index.tsx, PiiPreviewDialog.tsx, and PolicyTestPanel.tsx), outside this change.

  • Prettier check and git diff --check: passed.
  • The build failure remains visible and is not attributed to this patch.

    <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Bug Fixes
    Chat history is preserved when an inference request fails.
    The submitted prompt is restored, making it easier to retry after a failure.
    Uploaded files are cleared when the service rejects an invalid file format, while attachments remain available to retry after network errors.
    * Error notifications appear when a meaningful error message is available, helping explain why a request could not be completed.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 217 lines (+162 / -55) across 2 files Reviewer: rupayon123 Review duration: 22134m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.37 · 217 lines diff across 2 files
    0.37
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    42%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.322
    Real PR Conversation Timeline
    1 comments
    "Review active on #419"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 43.0% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 36.7% (MEDIUM) · Higher = larger blast radius
    36.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 43.0% · Lower = rushed or shallow review
    43.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.9% · Safe to merge
    20.9%