mirror of
https://github.com/aljazceru/goose.git
synced 2026-02-09 08:34:22 +01:00
fix: disappearing user text when stopped (#1839)
This commit is contained in:
@@ -255,6 +255,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));
|
||||
@@ -433,6 +439,8 @@ export default function ChatView({
|
||||
isLoading={isLoading}
|
||||
onStop={onStopGoose}
|
||||
commandHistory={commandHistory}
|
||||
value={_input}
|
||||
onValueChange={_setInput}
|
||||
/>
|
||||
<BottomMenu hasMessages={hasMessages} setView={setView} />
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,8 @@ interface InputProps {
|
||||
isLoading?: boolean;
|
||||
onStop?: () => void;
|
||||
commandHistory?: string[];
|
||||
value?: string;
|
||||
onValueChange?: (value: string) => void;
|
||||
}
|
||||
|
||||
export default function Input({
|
||||
@@ -15,8 +17,19 @@ export default function Input({
|
||||
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);
|
||||
|
||||
Reference in New Issue
Block a user