123123213weqw opened a new pull request, #5753:
URL: https://github.com/apache/rocketmq-dashboard/pull/5753

   ## What\n\n`GET /api/ai/runs/{runId}/stream` (the reconnect path, 
`AiRunService.attach`) read the persisted rows, replayed them to the socket, 
and only then registered the session as an observer with 
`AgentRunRegistry`.\n\n## Why it is a bug\n\nA live frame the run published 
between the replay query and the registration reached nobody: the session was 
not yet an observer, and its persisted row was written after the query, so it 
was not in the replay window either. The reconnecting client's transcript 
silently lost exactly the blocks the run produced while it was catching up (a 
tool call, a text flush), and only another reload could fill the hole.\n\nThis 
contradicts the invariant `AgentStreamSession` already documents and 
implements: "The observer is registered *before* the replay is sent … Frames 
that arrive during the replay are buffered and drained afterwards, still 
deduplicated." The service simply wired it in the opposite order.\n\n## The 
fix\n\nRegister the observer **befo
 re** the replay query. Frames published during the replay are buffered by the 
session (it is in the REPLAYING state), and `finishReplay()` drains them after 
the replayed rows, dropping anything at or below the replay watermark — the 
mechanism that already existed for exactly this purpose.\n\n## 
Test\n\nRed-first: 
`AiRunServiceTest.attachShouldRegisterTheObserverBeforeTheReplayQueryTest` 
publishes a frame from inside the replay query stub (the exact window) and 
asserts the observer still receives it. Fails on the previous ordering, passes 
with the fix; the rest of the class (23 tests) stays green.


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