zjncs opened a new pull request, #5612:
URL: https://github.com/apache/rocketmq-dashboard/pull/5612

   Closes #5611
   
   ## Problem
   
   `AiMessageDTO.message` carries `@NotBlank @Size(max = 8192)` ("the same 
budget AiRunService enforces server-side"), and the controller converts a 
violation into an in-stream refusal frame the run never starts from. But 
nothing client-side knew about the budget: the composer textarea had no 
`maxLength`, and `buildMessageRequest` (plus `draftToMessageRequest` through 
it) forwarded any length — so pasting a long stack trace or log always failed 
with an unhelpful refusal and no prevention.
   
   ## Fix
   
   - `chatDraft.ts`: export `AI_MESSAGE_MAX_LENGTH = 8192` (mirroring the DTO) 
and refuse to build an over-budget request — one guard covers both the composer 
send and the home-page draft auto-send
   - `Composer.tsx`: `maxLength={AI_MESSAGE_MAX_LENGTH}` on the textarea, so 
the refusal path becomes a safety net rather than the user experience
   
   ## Verification
   
   - New contract test `chatDraftMessageLimitContract.test.ts`: a message at 
exactly 8192 builds; 8193 **throws** — the second case **FAILS on master** 
(`expected [Function] to throw an error`), **PASSES with this change**
   - Backend budget pinned by `AiMessageDtoSizeContractTest` (8193 → violation, 
8192 → clean)
   - Regression: the full `src/pages/ai` suite **193/193**; `tsc --noEmit` clean
   - Mutation check: reverting the guard makes the contract test fail again; 
restoring it passes
   
   ## Collision note
   
   `chatDraft.ts` has **no** open-PR occupants. `Composer.tsx` is touched by 5 
PRs (hunks at 59-71, 247, 443-462, 549) — this change adds one import line and 
one `maxLength` prop on the textarea at ~472-482, between the 462 and 549 hunks 
with clearance on both sides.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to