Skip to content

Commit

Permalink
Merge pull request #21 from rjmacarthy/fix/disabled-generating
Browse files Browse the repository at this point in the history
Disable send/chat when generating
  • Loading branch information
rjmacarthy authored Jan 4, 2024
2 parents 8c6a7db + 3c02613 commit dd0317b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/webview/chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import styles from './index.module.css'
const global = globalThis as any
export const Chat = () => {
const [inputText, setInputText] = useState('')
const [isGenerating, setIsGenerating] = useState(false)
const [loading, setLoading] = useState(false)
const [messages, setMessages] = useState<Message[]>([])
const [completion, setCompletion] = useState<Message | null>()
Expand Down Expand Up @@ -70,6 +71,7 @@ export const Chat = () => {
const message: PostMessage = event.data
switch (message.type) {
case 'onCompletion': {
setIsGenerating(true)
setLoading(false)
setCompletion({
role: BOT_NAME,
Expand All @@ -95,6 +97,7 @@ export const Chat = () => {
]
})
setCompletion(null)
setIsGenerating(false)
}
}
})
Expand Down Expand Up @@ -130,7 +133,8 @@ export const Chat = () => {
<Selection onSelect={scrollBottom} />
<div className={styles.chatbox}>
<VSCodeTextArea
placeholder='Message twinny'
disabled={isGenerating}
placeholder="Message twinny"
rows={5}
value={inputText}
onChange={(e) => {
Expand All @@ -141,7 +145,11 @@ export const Chat = () => {
/>
</div>
<div className={styles.send}>
<VSCodeButton type="submit" appearance="primary">
<VSCodeButton
disabled={isGenerating}
type="submit"
appearance="primary"
>
Send message
</VSCodeButton>
</div>
Expand Down

0 comments on commit dd0317b

Please sign in to comment.