feat: Enable new prompt input while waiting for an answer (#6676)
* enable new prompt input while waiting for an answer * correct spelling of handleSendMessage function * remove test for disabling input while streaming content
This commit is contained in:
parent
8b687619b2
commit
476fdd6040
@ -594,7 +594,6 @@ const ChatInput = ({
|
|||||||
)}
|
)}
|
||||||
<TextareaAutosize
|
<TextareaAutosize
|
||||||
ref={textareaRef}
|
ref={textareaRef}
|
||||||
disabled={Boolean(streamingContent)}
|
|
||||||
minRows={2}
|
minRows={2}
|
||||||
rows={1}
|
rows={1}
|
||||||
maxRows={10}
|
maxRows={10}
|
||||||
@ -610,15 +609,15 @@ const ChatInput = ({
|
|||||||
// e.keyCode 229 is for IME input with Safari
|
// e.keyCode 229 is for IME input with Safari
|
||||||
const isComposing =
|
const isComposing =
|
||||||
e.nativeEvent.isComposing || e.keyCode === 229
|
e.nativeEvent.isComposing || e.keyCode === 229
|
||||||
if (
|
if (e.key === 'Enter' && !e.shiftKey && !isComposing) {
|
||||||
e.key === 'Enter' &&
|
|
||||||
!e.shiftKey &&
|
|
||||||
prompt.trim() &&
|
|
||||||
!isComposing
|
|
||||||
) {
|
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
// Submit the message when Enter is pressed without Shift
|
// Submit prompt when the following conditions are met:
|
||||||
handleSendMessage(prompt)
|
// - Enter is pressed without Shift
|
||||||
|
// - The streaming content has finished
|
||||||
|
// - Prompt is not empty
|
||||||
|
if (!streamingContent && prompt.trim()) {
|
||||||
|
handleSendMessage(prompt)
|
||||||
|
}
|
||||||
// When Shift+Enter is pressed, a new line is added (default behavior)
|
// When Shift+Enter is pressed, a new line is added (default behavior)
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
|||||||
@ -413,18 +413,6 @@ describe('ChatInput', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('disables input when streaming', async () => {
|
|
||||||
// Mock streaming state
|
|
||||||
mockAppState.streamingContent = { thread_id: 'test-thread' }
|
|
||||||
|
|
||||||
await act(async () => {
|
|
||||||
renderWithRouter()
|
|
||||||
})
|
|
||||||
|
|
||||||
const textarea = screen.getByTestId('chat-input')
|
|
||||||
expect(textarea).toBeDisabled()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('shows tools dropdown when model supports tools and MCP servers are connected', async () => {
|
it('shows tools dropdown when model supports tools and MCP servers are connected', async () => {
|
||||||
// Mock connected servers
|
// Mock connected servers
|
||||||
mockGetConnectedServers.mockResolvedValue(['server1'])
|
mockGetConnectedServers.mockResolvedValue(['server1'])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user