mirror of https://github.com/buster-so/buster.git
Merge pull request #495 from buster-so/dallin/bus-1328-ability-to-kill-a-chat-while-running-stop-button
Dallin/bus 1328 ability to kill a chat while running stop button
This commit is contained in:
commit
b7c40e2ea8
|
@ -1,23 +1,23 @@
|
|||
{
|
||||
"folders": [
|
||||
{ "path": "./apps/api" },
|
||||
{ "path": "./apps/electric-server" },
|
||||
{ "path": "./apps/server" },
|
||||
{ "path": "./apps/trigger" },
|
||||
{ "path": "./apps/web" },
|
||||
{ "path": "./packages/access-controls" },
|
||||
{ "path": "./packages/ai" },
|
||||
{ "path": "./packages/data-source" },
|
||||
{ "path": "./packages/database" },
|
||||
{ "path": "./packages/rerank" },
|
||||
{ "path": "./packages/server-shared" },
|
||||
{ "path": "./packages/slack" },
|
||||
{ "path": "./packages/stored-values" },
|
||||
{ "path": "./packages/supabase" },
|
||||
{ "path": "./packages/test-utils" },
|
||||
{ "path": "./packages/typescript-config" },
|
||||
{ "path": "./packages/vitest-config" },
|
||||
{ "path": "./packages/web-tools" }
|
||||
{ "path": "../apps/api" },
|
||||
{ "path": "../apps/electric-server" },
|
||||
{ "path": "../apps/server" },
|
||||
{ "path": "../apps/trigger" },
|
||||
{ "path": "../apps/web" },
|
||||
{ "path": "../packages/access-controls" },
|
||||
{ "path": "../packages/ai" },
|
||||
{ "path": "../packages/data-source" },
|
||||
{ "path": "../packages/database" },
|
||||
{ "path": "../packages/rerank" },
|
||||
{ "path": "../packages/server-shared" },
|
||||
{ "path": "../packages/slack" },
|
||||
{ "path": "../packages/stored-values" },
|
||||
{ "path": "../packages/supabase" },
|
||||
{ "path": "../packages/test-utils" },
|
||||
{ "path": "../packages/typescript-config" },
|
||||
{ "path": "../packages/vitest-config" },
|
||||
{ "path": "../packages/web-tools" }
|
||||
],
|
||||
"settings": {
|
||||
"editor.defaultFormatter": "biomejs.biome",
|
||||
|
|
|
@ -6,5 +6,5 @@ export const createNewChat = async (props: ChatCreateRequest) => {
|
|||
};
|
||||
|
||||
export const stopChat = async ({ chatId }: { chatId: string }) => {
|
||||
return mainApiV2.patch<unknown>(`/chats/${chatId}`, { stop: true }).then((res) => res.data);
|
||||
return mainApiV2.delete<unknown>(`/chats/${chatId}/cancel`).then((res) => res.data);
|
||||
};
|
||||
|
|
|
@ -108,12 +108,9 @@ const SubmitButton: React.FC<{
|
|||
onSubmitPreflight: () => void;
|
||||
onStop?: () => void;
|
||||
}> = React.memo(({ disabled, sendIcon, loading, loadingIcon, onSubmitPreflight, onStop }) => {
|
||||
const memoizedPrefix = useMemo(() => {
|
||||
return (
|
||||
const prefix = (
|
||||
<div
|
||||
className={cn(
|
||||
'relative h-4 w-4 transition-all duration-300 ease-out will-change-transform'
|
||||
)}>
|
||||
className={cn('relative h-4 w-4 transition-all duration-300 ease-out will-change-transform')}>
|
||||
<div
|
||||
className={`absolute inset-0 transition-all duration-300 ease-out ${loading ? 'scale-80 opacity-0' : 'scale-100 opacity-100'}`}>
|
||||
{sendIcon}
|
||||
|
@ -124,13 +121,12 @@ const SubmitButton: React.FC<{
|
|||
</div>
|
||||
</div>
|
||||
);
|
||||
}, [loading, sendIcon, loadingIcon]);
|
||||
|
||||
return (
|
||||
<Button
|
||||
rounding={'large'}
|
||||
variant="black"
|
||||
prefix={memoizedPrefix}
|
||||
prefix={prefix}
|
||||
onClick={loading && onStop ? onStop : onSubmitPreflight}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
|
|
|
@ -17,8 +17,8 @@ export const ChatInput: React.FC = React.memo(() => {
|
|||
const [inputValue, setInputValue] = useState('');
|
||||
|
||||
const disableSubmit = useMemo(() => {
|
||||
return !inputHasText(inputValue);
|
||||
}, [inputValue]);
|
||||
return !inputHasText(inputValue) && !isStreamingMessage;
|
||||
}, [inputValue, isStreamingMessage]);
|
||||
|
||||
const { onSubmitPreflight, onStopChat } = useChatInputFlow({
|
||||
disableSubmit,
|
||||
|
|
|
@ -135,8 +135,10 @@ export const useChatInputFlow = ({
|
|||
const onStopChat = useMemoizedFn(() => {
|
||||
if (!chatId) return;
|
||||
onStopChatContext({ chatId, messageId: currentMessageId });
|
||||
setTimeout(() => {
|
||||
textAreaRef.current?.focus();
|
||||
textAreaRef.current?.select();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
return useMemo(
|
||||
|
|
Loading…
Reference in New Issue