Skip to content

Commit dee3771

Browse files
committed
Add Disable Modes to Agent Example
1 parent a69629c commit dee3771

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

typescript/agent/src/app/page.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,17 @@ export default function Home() {
5454
const handleSubmit = useCallback(
5555
(e: React.FormEvent) => {
5656
e.preventDefault();
57+
58+
if (status === "streaming" || status === "submitted") {
59+
return;
60+
}
61+
5762
if (input.trim()) {
5863
sendMessage({ text: input }, { body: { model: model } });
5964
setInput("");
6065
}
6166
},
62-
[input, model, sendMessage],
67+
[input, model, sendMessage, status],
6368
);
6469

6570
const handleSuggestionClick = useCallback(
@@ -215,7 +220,11 @@ export default function Home() {
215220
</PromptInputModelSelectContent>
216221
</PromptInputModelSelect>
217222
</PromptInputTools>
218-
<PromptInputSubmit disabled={!input} status={status} />
223+
224+
<PromptInputSubmit
225+
disabled={!input || status === "streaming" || status === "submitted"}
226+
status={status}
227+
/>
219228
</PromptInputToolbar>
220229
</PromptInput>
221230
</div>

0 commit comments

Comments
 (0)