Skip to content

fix(chat): restore first draft after attachment rejection - #5881

Open
Winoren wants to merge 1 commit into
Tencent:mainfrom
Winoren:fix/restore-first-attachment-draft
Open

Winoren wants to merge 1 commit into
Tencent:mainfrom
Winoren:fix/restore-first-attachment-draft

Conversation

@Winoren

@Winoren Winoren commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

Description

The create-chat page consumes the first question before its local attachments can be uploaded to the newly created session. If that deferred upload is rejected, the send path returned after showing the error, leaving an empty session and no editable draft.

Restore the consumed draft in that failure branch. Cleaned-up temporary document IDs are removed, each rejected attachment is shown in the existing failed/removable state, and the question, images, and attachments are put back into the mounted composer. Existing-session upload behavior and successful first-message sends are unchanged.

Prepared and verified with Codex assistance.

Type of Change

  • 🐛 Bug fix
  • 🧪 Test

Related Issue

Fixes #5876

Testing

  • node --import tsx --test src/components/Input-field.prefill.test.ts src/views/chat/sessionLoad.test.ts src/views/chat/firstMessageDraft.test.ts — 28 tests passed.
  • node --max-old-space-size=4096 ./node_modules/vue-tsc/bin/vue-tsc.js --build — passed.
  • git diff --cached --check — passed.

The new regression verifies that a rejected deferred upload clears its rolled-back temporary document ID, becomes a visible failed attachment, and restores the question, image, and attachment to the composer. The full frontend test suite and production deployment were not run.

Checklist

  • git diff --check origin/main...HEAD passes
  • Changed source files are formatted
  • Targeted tests for the changed components pass
  • Diff-scoped lint passes where applicable (no frontend lint script is configured)
  • Full-repository checks were run (targeted frontend tests and full type-check are documented above)
  • Self-reviewed the complete patch with Codex
  • Added/updated tests covering the change
  • Updated related documentation (no public API or configuration change)
  • Breaking changes are clearly called out above (none)

Screenshots / Recordings

Not applicable; failure-state draft restoration.

@Winoren
Winoren force-pushed the fix/restore-first-attachment-draft branch from 8b1a0eb to 703ab7e Compare November 23, 2026 15:47

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: New chat loses the question when the first attachment upload is rejected (400)

1 participant