unbridled-41 opened a new pull request, #5425:
URL: https://github.com/apache/rocketmq-dashboard/pull/5425
## Problem / Evidence
While a run is stopping, pressing Enter in the AI composer silently discards
the typed prompt: the textarea empties, no request is made and no error appears.
- `web/src/pages/ai/components/Composer.tsx:250` derived the send enablement
from `generating = isStreaming && !stopRequested`, so during the stop
round-trip the send slot is the disabled `stopping` button
(`SendStopButton.tsx:60` — "`stopping` always disabled") while `canSend` is
still `true`.
- The keyboard path (`Composer.tsx:267-277`) calls `handleSend()` without
consulting the button state, and `handleSend` clears the draft first:
`onSend(text); onChange('');` (`:256-261`).
- The send itself is refused: `useAgentRun.ts:307` returns early while
`chatInFlightRef.current` is `true`, which lasts until the stream closes
(`:259`), i.e. the whole stopping window.
- For an existing conversation the page cannot even restore the draft:
`useAiSend.ts:109-111` returns the conversation id regardless of whether `send`
dispatched, so the `target === null` restore in `pages/ai/index.tsx:119-124`
never runs.
Reproduced by the new test: `fireEvent.keyDown(textarea, { key: 'Enter' })`
with `isStreaming: true, stopRequested: true` calls `onSend` once even though
the button beside it is disabled.
## Root cause / Fix
The composer treated "stopping" as idle for the keyboard while the run was
still in flight. Fix: derive `canSend` from `!isStreaming`, matching the
button's own disabled state. In the `send` state (`generating === isStreaming
=== false`) nothing changes; the only behavioural difference is Enter during
`stopping`, which now leaves the draft in the box.
## Priority & scoring
PRIORITY 62 = 影响 28 (silent loss of user input with no feedback, on the
page's primary input) + 波及 8 (AI composer) + 可复现 14 (deterministic inside the
stop window) + 维护价值 12 (keyboard now agrees with the visible control).
FIX_CONFIDENCE 80: one condition and the comment that documents it, pinned
by a focused regression test.
## Tests
```
cd web && npx vitest run src/pages/ai
```
- Red before the fix:
`keepsTheDraftWhenEnterArrivesWhileTheStopIsStillInFlightTest` fails —
`expected "onSend" to not be called, number of calls: 1`.
- Green after: `Test Files 17 passed (17) | Tests 195 passed (195)`.
- `npx tsc -b` and `npx eslint` on both touched files: clean.
## Risk
Low. The change is a strictly narrower send window for a state in which the
send was already being refused; no other state transition or handler is touched.
--
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]