Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion ui/desktop/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import {
ToolCall,
ToolCallResult,
ToolRequestMessageContent,
ToolResponse,
ToolResponseMessageContent,
ToolConfirmationRequestMessageContent,
getTextContent,
createAssistantMessage,
} from '../types/message';

export interface ChatType {
Expand Down Expand Up @@ -132,15 +134,25 @@ export default function ChatView({
// Handle stopping the message stream
const lastMessage = messages[messages.length - 1];

// check if the last user message has any tool response(s)
const isToolResponse = lastMessage.content.some(
(content): content is ToolResponseMessageContent => content.type == 'toolResponse'
);

// isUserMessage also checks if the message is a toolConfirmationRequest
if (lastMessage && isUserMessage(lastMessage)) {
// check if the last message is a real user's message
if (lastMessage && isUserMessage(lastMessage) && !isToolResponse) {
// Remove the last user message if it's the most recent one
if (messages.length > 1) {
setMessages(messages.slice(0, -1));
} else {
setMessages([]);
}
// Interruption occured after a tool has completed, but no assistant reply
// handle his if we want to popup a message too the user
// } else if (lastMessage && isUserMessage(lastMessage) && isToolResponse) {
} else if (!isUserMessage(lastMessage)) {
// the last message was an assistant message
// check if we have any tool requests or tool confirmation requests
const toolRequests: [string, ToolCallResult<ToolCall>][] = lastMessage.content
.filter(
Expand Down