Merge pull request #2528 from DongjaJ/feat/disable-chat-input

feat : disable the enter button of chat input while ai answers
This commit is contained in:
Nate Sesti 2024-10-16 11:17:27 -07:00 • committed by GitHub
commit 9dd5581ec4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 13 additions and 1 deletions

View file

@ -52,7 +52,8 @@ const HoverItem = styled.span<{ isActive?: boolean }>`
transition: color 200ms, background-color 200ms, box-shadow 200ms;
`;
const EnterButton = styled.div`
const EnterButton = styled.button`
all: unset;
padding: 2px 4px;
display: flex;
align-items: center;
@ -60,6 +61,9 @@ const EnterButton = styled.div`
border-radius: ${defaultBorderRadius};
color: ${vscForeground};
cursor: pointer;
:disabled {
cursor: wait;
}
`;
interface InputToolbarProps {
@ -70,6 +74,7 @@ interface InputToolbarProps {
onImageFileSelected?: (file: File) => void;
hidden?: boolean;
activeKey: string | null;
disabled?: boolean;
}
function InputToolbar(props: InputToolbarProps) {
@ -168,6 +173,7 @@ function InputToolbar(props: InputToolbarProps) {
noContext: useActiveFile ? e.altKey : !e.altKey,
});
}}
disabled={props.disabled}
>
<span className="hidden md:inline">⏎ Enter</span>
<span className="md:hidden">⏎</span>

View file

@ -502,6 +502,7 @@ function TipTapEditor(props: TipTapEditorProps) {
}
}
},
editable: !active,
});
const [shouldHideToolbar, setShouldHideToolbar] = useState(false);
@ -606,6 +607,10 @@ function TipTapEditor(props: TipTapEditorProps) {
const onEnterRef = useUpdatingRef(
(modifiers: InputModifiers) => {
if (active) {
return;
}
const json = editor.getJSON();
// Don't do anything if input box is empty
@ -915,6 +920,7 @@ function TipTapEditor(props: TipTapEditorProps) {
});
});
}}
disabled={active}
/>
{showDragOverMsg &&