Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat: Enable new prompt input while waiting for an answer (#6676)

Trang Le476fdd604037
diff --git a/web-app/src/containers/ChatInput.tsx b/web-app/src/containers/ChatInput.tsx
index 1cf20fdd2..2ba52c2e9 100644
--- a/web-app/src/containers/ChatInput.tsx
+++ b/web-app/src/containers/ChatInput.tsx
@@ -594,7 +594,6 @@ const ChatInput = ({
)}
<TextareaAutosize
ref={textareaRef}
- disabled={Boolean(streamingContent)}
minRows={2}
rows={1}
maxRows={10}
@@ -610,15 +609,15 @@ const ChatInput = ({
// e.keyCode 229 is for IME input with Safari
const isComposing =
e.nativeEvent.isComposing || e.keyCode === 229
- if (
- e.key === 'Enter' &&
- !e.shiftKey &&
- prompt.trim() &&
- !isComposing
- ) {
+ if (e.key === 'Enter' && !e.shiftKey && !isComposing) {
e.preventDefault()
- // Submit the message when Enter is pressed without Shift
- handleSendMessage(prompt)
+ // Submit prompt when the following conditions are met:
+ // - 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)
}
}}
diff --git a/web-app/src/containers/__tests__/ChatInput.test.tsx b/web-app/src/containers/__tests__/ChatInput.test.tsx
index 1d296e15d..acb1269e7 100644
--- a/web-app/src/containers/__tests__/ChatInput.test.tsx
+++ b/web-app/src/containers/__tests__/ChatInput.test.tsx
@@ -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 () => {
// Mock connected servers
mockGetConnectedServers.mockResolvedValue(['server1'])