Skip to content

Commit 0e1b610

Browse files
tahierhussainclaude
andcommitted
fix: hide Stop button once response streaming begins
When a prompt is running, the Stop button was shown throughout the entire process (thought chain + response streaming). Now the Stop button is only shown during the thought chain phase. Once the response starts streaming, the Send button is displayed instead. Changes: - Add isResponseStreaming computed state in ExistingChat.jsx - Thread isResponseStreaming prop through InputPrompt, PromptInput - Update button condition in MonacoPromptInput and DefaultPromptInput 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b3e752c commit 0e1b610

5 files changed

Lines changed: 21 additions & 3 deletions

File tree

frontend/src/ide/chat-ai/DefaultPromptInput.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Sender } from "@ant-design/x";
66
function DefaultPromptInput({
77
value,
88
isPromptRunning,
9+
isResponseStreaming,
910
onSenderChange,
1011
onSubmit,
1112
onCancel,
@@ -25,7 +26,7 @@ function DefaultPromptInput({
2526
actions={(_, info) => {
2627
const { SendButton, LoadingButton } = info.components;
2728

28-
if (isPromptRunning) {
29+
if (isPromptRunning && !isResponseStreaming) {
2930
return (
3031
<Tooltip title="Stop">
3132
<LoadingButton variant="text" color="secondary" shape="default" />
@@ -64,6 +65,7 @@ function DefaultPromptInput({
6465
DefaultPromptInput.propTypes = {
6566
value: PropTypes.string.isRequired,
6667
isPromptRunning: PropTypes.bool.isRequired,
68+
isResponseStreaming: PropTypes.bool,
6769
onSenderChange: PropTypes.func.isRequired,
6870
onSubmit: PropTypes.func.isRequired,
6971
onCancel: PropTypes.func.isRequired,

frontend/src/ide/chat-ai/ExistingChat.jsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,13 @@ const ExistingChat = memo(function ExistingChat({
246246
return -1;
247247
}, [chatMessages, chatIntents]);
248248

249+
// Check if response is actively streaming (thought chain done, response started)
250+
const isResponseStreaming = useMemo(() => {
251+
if (!chatMessages?.length) return false;
252+
const lastMessage = chatMessages?.[chatMessages.length - 1];
253+
return isPromptRunning && lastMessage?.response?.length > 0;
254+
}, [chatMessages, isPromptRunning]);
255+
249256
useEffect(() => {
250257
if (chatMessages.length) {
251258
setLastChatMessageId(
@@ -454,6 +461,7 @@ const ExistingChat = memo(function ExistingChat({
454461
<InputPrompt
455462
savePrompt={handleSavePrompt}
456463
isPromptRunning={isPromptRunning}
464+
isResponseStreaming={isResponseStreaming}
457465
chatIntents={chatIntents}
458466
selectedChatIntent={selectedChatIntent}
459467
setSelectedChatIntent={setSelectedChatIntent}

frontend/src/ide/chat-ai/InputPrompt.jsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const InputPrompt = memo(function InputPrompt({
1010
savePrompt,
1111
isNewChat = false,
1212
isPromptRunning,
13+
isResponseStreaming = false,
1314
chatIntents,
1415
selectedChatIntent,
1516
setSelectedChatIntent,
@@ -209,6 +210,7 @@ const InputPrompt = memo(function InputPrompt({
209210
value={value}
210211
editorHeight={editorHeight}
211212
isPromptRunning={isPromptRunning}
213+
isResponseStreaming={isResponseStreaming}
212214
onSenderChange={handleSenderChange}
213215
onSubmit={handleSubmit}
214216
onEditorMount={handleEditorMount}
@@ -252,6 +254,7 @@ InputPrompt.propTypes = {
252254
savePrompt: PropTypes.func.isRequired,
253255
isNewChat: PropTypes.bool,
254256
isPromptRunning: PropTypes.bool.isRequired,
257+
isResponseStreaming: PropTypes.bool,
255258
chatIntents: PropTypes.array.isRequired,
256259
selectedChatIntent: PropTypes.string,
257260
setSelectedChatIntent: PropTypes.func.isRequired,

frontend/src/ide/chat-ai/MonacoPromptInput.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const MonacoPromptInput = memo(function MonacoPromptInput({
1212
value,
1313
editorHeight,
1414
isPromptRunning,
15+
isResponseStreaming,
1516
onEditorMount,
1617
onMonacoChange,
1718
onSubmit,
@@ -159,9 +160,8 @@ const MonacoPromptInput = memo(function MonacoPromptInput({
159160
return (
160161
<div className="monaco-editor-wrapper">
161162
{editorContent}
162-
163163
<div className="monaco-editor-send">
164-
{isPromptRunning ? (
164+
{isPromptRunning && !isResponseStreaming ? (
165165
<Tooltip title="Stop">
166166
<Button type="text" icon={<CloseOutlined />} onClick={onCancel} />
167167
</Tooltip>
@@ -204,6 +204,7 @@ MonacoPromptInput.propTypes = {
204204
value: PropTypes.string.isRequired,
205205
editorHeight: PropTypes.number.isRequired,
206206
isPromptRunning: PropTypes.bool.isRequired,
207+
isResponseStreaming: PropTypes.bool,
207208
onEditorMount: PropTypes.func,
208209
onMonacoChange: PropTypes.func.isRequired,
209210
onSubmit: PropTypes.func.isRequired,

frontend/src/ide/chat-ai/PromptInput.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const PromptInput = memo(function PromptInput({
1010
value,
1111
editorHeight,
1212
isPromptRunning,
13+
isResponseStreaming,
1314
onSenderChange,
1415
onSubmit,
1516
onEditorMount,
@@ -34,6 +35,7 @@ const PromptInput = memo(function PromptInput({
3435
<DefaultPromptInput
3536
value={value}
3637
isPromptRunning={isPromptRunning}
38+
isResponseStreaming={isResponseStreaming}
3739
onSenderChange={onSenderChange}
3840
onSubmit={onSubmit}
3941
onCancel={onCancel}
@@ -49,6 +51,7 @@ const PromptInput = memo(function PromptInput({
4951
value={value}
5052
editorHeight={editorHeight}
5153
isPromptRunning={isPromptRunning}
54+
isResponseStreaming={isResponseStreaming}
5255
onEditorMount={onEditorMount}
5356
onMonacoChange={onMonacoChange}
5457
onSubmit={onSubmit}
@@ -70,6 +73,7 @@ PromptInput.propTypes = {
7073
value: PropTypes.string.isRequired,
7174
editorHeight: PropTypes.number.isRequired,
7275
isPromptRunning: PropTypes.bool.isRequired,
76+
isResponseStreaming: PropTypes.bool,
7377
onSenderChange: PropTypes.func.isRequired,
7478
onSubmit: PropTypes.func.isRequired,
7579
onEditorMount: PropTypes.func.isRequired,

0 commit comments

Comments
 (0)