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

   ## Summary
   - Add a `newMessageId()` helper (exported for testing) that builds message 
ids from a `crypto.randomUUID()`-based unique suffix, refactored out of the 
existing `newConversationId()` pattern
   - Use it for chat user/AI message ids instead of `user-${Date.now()}` / 
`ai-${Date.now()}`
   - Add a regression test: stop a first response, immediately send a second 
one with the clock frozen on the same millisecond, and verify the second 
stream's chunks do not leak into the stopped first response
   
   ## Why
   Chat message ids were derived from `Date.now()`, so two sends landing in the 
same millisecond produced identical `ai-…` response ids. The stream chunk 
handler and the `finally`-block `pending` update both locate messages by that 
id with `prev.map(...)`, so an in-flight second response appended its chunks to 
the first (already stopped) response as well — the stopped message visibly grew 
with the new answer's text, and the early `pending: false` write from the first 
request's `finally` could also clear the second response's "thinking" spinner 
prematurely.
   
   ## Testing
   - `./node_modules/.bin/vitest run src/pages/ai/__tests__/` → 15 passed (1 
new; verified the new test fails with the pre-fix `Date.now()`-based ids)
   - `./node_modules/.bin/tsc --noEmit` → clean
   - `./node_modules/.bin/eslint src/pages/ai/index.tsx 
src/pages/ai/__tests__/AiPage.test.tsx` → 0 errors
   


-- 
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