-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: New way to stop the loading task (#631)
- Loading branch information
Showing
4 changed files
with
51 additions
and
47 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
frontend/src/components/organisms/chat/inputBox/SubmitButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import StopCircle from '@mui/icons-material/StopCircle'; | ||
import Telegram from '@mui/icons-material/Telegram'; | ||
import { Tooltip } from '@mui/material'; | ||
import Box from '@mui/material/Box'; | ||
import IconButton from '@mui/material/IconButton'; | ||
import InputAdornment from '@mui/material/InputAdornment'; | ||
|
||
import { useChatData, useChatInteract } from '@chainlit/react-client'; | ||
|
||
interface SubmitButtonProps { | ||
disabled?: boolean; | ||
onSubmit: () => void; | ||
} | ||
|
||
const SubmitButton = ({ disabled, onSubmit }: SubmitButtonProps) => { | ||
const { loading } = useChatData(); | ||
const { stopTask } = useChatInteract(); | ||
|
||
const handleClick = () => { | ||
stopTask(); | ||
}; | ||
|
||
return ( | ||
<Box | ||
sx={{ | ||
mr: 1, | ||
color: 'text.secondary' | ||
}} | ||
> | ||
{!loading ? ( | ||
<Tooltip title="Send message"> | ||
<InputAdornment position="end"> | ||
<IconButton disabled={disabled} color="inherit" onClick={onSubmit}> | ||
<Telegram /> | ||
</IconButton> | ||
</InputAdornment> | ||
</Tooltip> | ||
) : ( | ||
<Tooltip title="Stop task"> | ||
<IconButton id="stop-button" onClick={handleClick}> | ||
<StopCircle /> | ||
</IconButton> | ||
</Tooltip> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
export { SubmitButton }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.