Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions ui/desktop/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ export default function ChatView({
// isUserMessage also checks if the message is a toolConfirmationRequest
// check if the last message is a real user's message
if (lastMessage && isUserMessage(lastMessage) && !isToolResponse) {
// Get the text content from the last message before removing it
const textContent = lastMessage.content.find((c) => c.type === 'text')?.text || '';

// Set the text back to the input field
_setInput(textContent);

// Remove the last user message if it's the most recent one
if (messages.length > 1) {
setMessages(messages.slice(0, -1));
Expand Down Expand Up @@ -432,6 +438,8 @@ export default function ChatView({
isLoading={isLoading}
onStop={onStopGoose}
commandHistory={commandHistory}
value={_input}
onValueChange={_setInput}
/>
<BottomMenu hasMessages={hasMessages} setView={setView} />
</div>
Expand Down
15 changes: 14 additions & 1 deletion ui/desktop/src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@ interface InputProps {
isLoading?: boolean;
onStop?: () => void;
commandHistory?: string[];
value?: string;
onValueChange?: (value: string) => void;
}

export default function Input({
handleSubmit,
isLoading = false,
onStop,
commandHistory = [],
value: controlledValue,
onValueChange,
}: InputProps) {
const [value, setValue] = useState('');
const [internalValue, setInternalValue] = useState('');
// Use controlled value if provided, otherwise use internal state
const value = controlledValue !== undefined ? controlledValue : internalValue;
const setValue = (newValue: string) => {
if (controlledValue !== undefined && onValueChange) {
onValueChange(newValue);
} else {
setInternalValue(newValue);
}
};
// State to track if the IME is composing (i.e., in the middle of Japanese IME input)
const [isComposing, setIsComposing] = useState(false);
const [historyIndex, setHistoryIndex] = useState(-1);
Expand Down
Loading