From fa42592b950c66ad83e162aea4c782dfa65de862 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Sun, 13 Jul 2025 08:10:15 -0600 Subject: [PATCH 01/13] Focus input after chat comes in --- .../ChatContainer/ChatContent/ChatInput/ChatInput.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/ChatInput.tsx b/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/ChatInput.tsx index c311a9317..ec212b441 100644 --- a/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/ChatInput.tsx +++ b/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/ChatInput.tsx @@ -1,4 +1,4 @@ -import React, { type ChangeEvent, useMemo, useRef, useState } from 'react'; +import React, { type ChangeEvent, useEffect, useMemo, useRef, useState } from 'react'; import { InputTextAreaButton } from '@/components/ui/inputs/InputTextAreaButton'; import { useMemoizedFn } from '@/hooks'; import { cn } from '@/lib/classMerge'; @@ -32,6 +32,14 @@ export const ChatInput: React.FC = React.memo(() => { setInputValue(e.target.value); }); + useEffect(() => { + if (hasChat) { + requestAnimationFrame(() => { + textAreaRef.current?.focus(); + }); + } + }, [hasChat, textAreaRef]); + return (
Date: Sun, 13 Jul 2025 08:17:16 -0600 Subject: [PATCH 02/13] optimistically grab new chats --- apps/web/src/api/buster-electric/messages/hooks.ts | 7 ++++++- apps/web/src/api/buster_rest/chats/queryRequests.ts | 2 +- apps/web/src/api/query_keys/chat.ts | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/web/src/api/buster-electric/messages/hooks.ts b/apps/web/src/api/buster-electric/messages/hooks.ts index aa8a731c6..08b6c8e10 100644 --- a/apps/web/src/api/buster-electric/messages/hooks.ts +++ b/apps/web/src/api/buster-electric/messages/hooks.ts @@ -4,7 +4,7 @@ import { useShape, useShapeStream } from '../instances'; import { useChatUpdate } from '@/context/Chats/useChatUpdate'; import { updateMessageShapeToIChatMessage } from './helpers'; import { useMemoizedFn } from '@/hooks'; -import { useGetChatMemoized } from '@/api/buster_rest/chats'; +import { prefetchGetListChats, useGetChatMemoized } from '@/api/buster_rest/chats'; import uniq from 'lodash/uniq'; export const useGetMessage = ({ chatId, messageId }: { chatId: string; messageId: string }) => { @@ -33,6 +33,7 @@ export const useTrackAndUpdateMessageChanges = ( ) => { const { onUpdateChatMessage, onUpdateChat } = useChatUpdate(); const getChatMemoized = useGetChatMemoized(); + const shape = useMemo( () => messageShape({ chatId: chatId || '', messageId }), [chatId, messageId] @@ -58,6 +59,10 @@ export const useTrackAndUpdateMessageChanges = ( message_ids: allMessageIds }); } + + if(iChatMessage.is_completed){ + prefetchGetListChats() + } } callback?.(iChatMessage); onUpdateChatMessage(iChatMessage); diff --git a/apps/web/src/api/buster_rest/chats/queryRequests.ts b/apps/web/src/api/buster_rest/chats/queryRequests.ts index 616d3d838..bd19988aa 100644 --- a/apps/web/src/api/buster_rest/chats/queryRequests.ts +++ b/apps/web/src/api/buster_rest/chats/queryRequests.ts @@ -38,7 +38,7 @@ export const useGetListChats = ( filters?: Omit[0], 'page_token' | 'page_size'> ) => { const filtersCompiled: Parameters[0] = useMemo( - () => ({ admin_view: false, page_token: 0, page_size: 3500, ...filters }), + () => ({ admin_view: false, page_token: 0, page_size: 5000, ...filters }), [filters] ); diff --git a/apps/web/src/api/query_keys/chat.ts b/apps/web/src/api/query_keys/chat.ts index 7c975394e..39c8ca982 100644 --- a/apps/web/src/api/query_keys/chat.ts +++ b/apps/web/src/api/query_keys/chat.ts @@ -29,7 +29,7 @@ const chatsGetList = ( filters?: Omit[0], 'page_token' | 'page_size'> ) => queryOptions({ - queryKey: ['chats', 'list', filters || { page_token: 0, page_size: 3500 }] as const, + queryKey: ['chats', 'list', filters || { page_token: 0, page_size: 5000, admin_view: false }] as const, staleTime: 60 * 1000, // 1 minute initialData: [], initialDataUpdatedAt: 0 From bc623cdd303b06ea2abc5cced040ef7592379654 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Sun, 13 Jul 2025 08:21:53 -0600 Subject: [PATCH 03/13] stop chat --- apps/web/src/api/buster_rest/chats/requestsV2.ts | 2 +- .../ChatContainer/ChatContent/ChatInput/useChatInputFlow.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/web/src/api/buster_rest/chats/requestsV2.ts b/apps/web/src/api/buster_rest/chats/requestsV2.ts index 33546f28d..acb8811ae 100644 --- a/apps/web/src/api/buster_rest/chats/requestsV2.ts +++ b/apps/web/src/api/buster_rest/chats/requestsV2.ts @@ -6,5 +6,5 @@ export const createNewChat = async (props: ChatCreateRequest) => { }; export const stopChat = async ({ chatId }: { chatId: string }) => { - return mainApiV2.patch(`/chats/${chatId}`, { stop: true }).then((res) => res.data); + return mainApiV2.delete(`/chats/${chatId}/cancel`).then((res) => res.data); }; diff --git a/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/useChatInputFlow.ts b/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/useChatInputFlow.ts index 3b702bf48..864855182 100644 --- a/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/useChatInputFlow.ts +++ b/apps/web/src/layouts/ChatLayout/ChatContainer/ChatContent/ChatInput/useChatInputFlow.ts @@ -135,8 +135,10 @@ export const useChatInputFlow = ({ const onStopChat = useMemoizedFn(() => { if (!chatId) return; onStopChatContext({ chatId, messageId: currentMessageId }); - textAreaRef.current?.focus(); - textAreaRef.current?.select(); + setTimeout(() => { + textAreaRef.current?.focus(); + textAreaRef.current?.select(); + }, 100); }); return useMemo( From 12acbc426445dc991d485aefdb65c8d35a4937a6 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Sun, 13 Jul 2025 08:25:21 -0600 Subject: [PATCH 04/13] Update buster.code-workspace --- .vscode/buster.code-workspace | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/.vscode/buster.code-workspace b/.vscode/buster.code-workspace index 162400a94..689cebe60 100644 --- a/.vscode/buster.code-workspace +++ b/.vscode/buster.code-workspace @@ -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", From f84bf8e3d1570a0a89e546f819dc84ca8b41b967 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Sun, 13 Jul 2025 08:28:11 -0600 Subject: [PATCH 05/13] disable check --- .../ui/inputs/InputTextAreaButton.tsx | 28 ++++++++----------- .../ChatContent/ChatInput/ChatInput.tsx | 4 +-- 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/apps/web/src/components/ui/inputs/InputTextAreaButton.tsx b/apps/web/src/components/ui/inputs/InputTextAreaButton.tsx index b293f417d..8fe8cb60c 100644 --- a/apps/web/src/components/ui/inputs/InputTextAreaButton.tsx +++ b/apps/web/src/components/ui/inputs/InputTextAreaButton.tsx @@ -108,29 +108,25 @@ const SubmitButton: React.FC<{ onSubmitPreflight: () => void; onStop?: () => void; }> = React.memo(({ disabled, sendIcon, loading, loadingIcon, onSubmitPreflight, onStop }) => { - const memoizedPrefix = useMemo(() => { - return ( + const prefix = ( +
-
- {sendIcon} -
-
- {loadingIcon} -
+ className={`absolute inset-0 transition-all duration-300 ease-out ${loading ? 'scale-80 opacity-0' : 'scale-100 opacity-100'}`}> + {sendIcon}
- ); - }, [loading, sendIcon, loadingIcon]); +
+ {loadingIcon} +
+
+ ); return (