Skip to content

[fix] canvas: send the draft to the API in the shape it accepts - #395

Merged
FayeSpica merged 1 commit into
ThinkFlowLab:mainfrom
wtz2333:fix/draft-payload
Nov 18, 2026
Merged

FayeSpica merged 1 commit into
ThinkFlowLab:mainfrom
wtz2333:fix/draft-payload

Conversation

@wtz2333

@wtz2333 wtz2333 commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Autosaving the composer fails with 422 请求字段无效,请检查必填项及字段格式。 whenever the conversation the view holds was read while a reply was running.

GET /assistant adds activeTurnId while a chain is running. The view stores that object, and the draft autosave stripped only messages before PUT /assistant/draft. Because Draft is declared with extra='forbid', the extra member is rejected — and since send() flushes the draft before posting the turn, the failed save also blocks sending the next message: the request never leaves the browser.

The draft is now built from the fields the endpoint owns instead of forwarded wholesale, so members added to the read model later cannot break saving.

Refs #379.

Test plan

  • node --test tests/chatDrafts.test.ts — new case fails before the change (activeTurnId present in the body) and passes after
  • node --test tests/*.test.ts — 838 passed
  • tsc --noEmit clean
  • Browser journey — cannot run in this environment (no Playwright/Chromium), left to CI

Evidence

Reproduced against a project that had a running reply: PUT /assistant/draft with the read model minus messages → 422 {"detail": "请求字段无效,请检查必填项及字段格式。", "code": "invalid_input"}; the same body without activeTurnId → 200. Verified on a real instance: the toast 保存草稿失败,当前内容已保留:请求字段无效… appears on every keystroke and no POST /assistant/messages is ever sent.

Labels

type:bug, area:canvas, area:agent — I do not have permission to set labels on this repository.

Provider usage

No provider call is involved.

Bilingual check

No user-facing copy added or changed.

@github-actions github-actions Bot added area:agent Agent runtime, assistant chat and tools type:bug Something is broken labels Nov 18, 2026
@github-actions
github-actions Bot requested review from FayeSpica and wuzhf9 November 18, 2026 08:01

@FayeSpica FayeSpica left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

I manually reproduced the draft save failure on main and verified on 45f1070e that drafts save while the assistant is replying and the next message sends successfully.

LGTM.

@FayeSpica
FayeSpica merged commit d05a56d into ThinkFlowLab:main Nov 18, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:agent Agent runtime, assistant chat and tools type:bug Something is broken

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants