Skip to content

Commit

Permalink
Don't block sending chat when clicking Ask button (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
humphd authored Nov 4, 2024
1 parent 05f1a3d commit e29d6d0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 22 deletions.
20 changes: 1 addition & 19 deletions src/Chat/ChatBase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ import { useUser } from "../hooks/use-user";
import { ChatCraftChat } from "../lib/ChatCraftChat";
import { ChatCraftCommand } from "../lib/ChatCraftCommand";
import { ChatCraftFunction } from "../lib/ChatCraftFunction";
import {
ChatCraftFunctionCallMessage,
ChatCraftFunctionResultMessage,
ChatCraftHumanMessage,
} from "../lib/ChatCraftMessage";
import { ChatCraftFunctionCallMessage, ChatCraftHumanMessage } from "../lib/ChatCraftMessage";
import { WebHandler } from "../lib/WebHandler";
import { ChatCraftCommandRegistry } from "../lib/commands";
import ChatHeader from "./ChatHeader";
Expand Down Expand Up @@ -285,20 +281,6 @@ function ChatBase({ chat }: ChatBaseProps) {
// Add only image to the chat
promptMessage = new ChatCraftHumanMessage({ text: "", imageUrls, user });
await chat.addMessage(promptMessage);
} else {
// If there isn't any prompt text, see if the final message in the chat was a human
// message or a function response. If it was either, we'll allow sending that through
// again (e.g., if you modified something and want to retry, or want to share the
// response from the function). Otherwise bail now.
const finalMessage = chat.messages({ includeAppMessages: false }).at(-1);
if (
!(
finalMessage instanceof ChatCraftHumanMessage ||
finalMessage instanceof ChatCraftFunctionResultMessage
)
) {
return;
}
}

// If there's any problem loading referenced functions, show an error
Expand Down
3 changes: 0 additions & 3 deletions src/components/PromptForm/DesktopPromptForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,6 @@ function DesktopPromptForm({
const handlePromptSubmit = (e: FormEvent) => {
e.preventDefault();
const textValue = inputPromptRef.current?.value.trim() || "";
if (!textValue) {
return;
}
if (inputPromptRef.current) {
inputPromptRef.current.value = "";
}
Expand Down

0 comments on commit e29d6d0

Please sign in to comment.