From cdf1551e9d488ffa4614378d3cca2872a0093452 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Thu, 27 Mar 2025 21:07:23 -0600 Subject: [PATCH] adjust query provider menu --- web/src/api/query_keys/chat.ts | 2 +- web/src/api/query_keys/collection.ts | 2 +- web/src/api/query_keys/dashboard.ts | 2 +- web/src/api/query_keys/metric.ts | 2 +- .../components/ui/scroll-area/ScrollArea.tsx | 4 ++-- .../BusterReactQueryAndApi.tsx | 22 ++++++++++++++++--- .../ChatHeaderOptions/ChatHeaderDropdown.tsx | 6 ++++- 7 files changed, 30 insertions(+), 10 deletions(-) diff --git a/web/src/api/query_keys/chat.ts b/web/src/api/query_keys/chat.ts index 8f480e820..5b011f199 100644 --- a/web/src/api/query_keys/chat.ts +++ b/web/src/api/query_keys/chat.ts @@ -34,7 +34,7 @@ const chatsGetList = (filters?: Parameters[0]) => const chatsBlackBoxMessages = (messageId: string) => queryOptions({ - queryKey: ['chats', 'messages', messageId, 'black-box'] as const, + queryKey: ['chats', 'messages', messageId, 'local-only-black-box'] as const, staleTime: Infinity, enabled: false, //this is local queryFn: () => Promise.resolve(null) diff --git a/web/src/api/query_keys/collection.ts b/web/src/api/query_keys/collection.ts index 01d9da899..71b28aba4 100644 --- a/web/src/api/query_keys/collection.ts +++ b/web/src/api/query_keys/collection.ts @@ -7,7 +7,7 @@ const collectionsGetList = ( ) => queryOptions({ queryKey: ['collections', 'list', filters] as const, - staleTime: 4 * 1000, + staleTime: 60 * 1000, initialData: [], initialDataUpdatedAt: 0 }); diff --git a/web/src/api/query_keys/dashboard.ts b/web/src/api/query_keys/dashboard.ts index 8cafbbb32..fad3fb342 100644 --- a/web/src/api/query_keys/dashboard.ts +++ b/web/src/api/query_keys/dashboard.ts @@ -10,8 +10,8 @@ const dashboardGetList = ( ) => queryOptions({ queryKey: ['dashboard', 'list', filters] as const, - staleTime: 10 * 1000, initialData: [], + staleTime: 60 * 1000, initialDataUpdatedAt: 0 }); diff --git a/web/src/api/query_keys/metric.ts b/web/src/api/query_keys/metric.ts index 124edfb2f..7f829aace 100644 --- a/web/src/api/query_keys/metric.ts +++ b/web/src/api/query_keys/metric.ts @@ -16,7 +16,7 @@ export const metricsGetMetric = (metricId: string, version_number?: number) => { export const metricsGetList = (filters?: Parameters[0]) => queryOptions({ queryKey: ['metrics', 'list', filters] as const, - staleTime: 10 * 1000 + staleTime: 60 * 1000 }); export const metricsGetData = (id: string, version_number?: number) => diff --git a/web/src/components/ui/scroll-area/ScrollArea.tsx b/web/src/components/ui/scroll-area/ScrollArea.tsx index b453574a6..cbdc7c285 100644 --- a/web/src/components/ui/scroll-area/ScrollArea.tsx +++ b/web/src/components/ui/scroll-area/ScrollArea.tsx @@ -33,8 +33,8 @@ const ScrollBar = React.forwardRef< orientation={orientation} className={cn( 'flex touch-none transition-colors select-none', - orientation === 'vertical' && 'h-full w-2.5 border-l border-l-transparent p-[1px]', - orientation === 'horizontal' && 'h-2.5 flex-col border-t border-t-transparent p-[1px]', + orientation === 'vertical' && 'h-full w-2 border-l border-l-transparent p-[1px]', + orientation === 'horizontal' && 'h-2 flex-col border-t border-t-transparent p-[1px]', className )} {...props}> diff --git a/web/src/context/BusterReactQuery/BusterReactQueryAndApi.tsx b/web/src/context/BusterReactQuery/BusterReactQueryAndApi.tsx index f10463f93..dbe383e1d 100644 --- a/web/src/context/BusterReactQuery/BusterReactQueryAndApi.tsx +++ b/web/src/context/BusterReactQuery/BusterReactQueryAndApi.tsx @@ -1,18 +1,29 @@ 'use client'; import { QueryClientProvider } from '@tanstack/react-query'; -import React, { useLayoutEffect } from 'react'; +import React, { useLayoutEffect, useState } from 'react'; import mainApi from '@/api/buster_rest/instances'; import { defaultRequestHandler } from '@/api/createInstance'; import nextApi from '@/api/next/instances'; import { useSupabaseContext } from '../Supabase/SupabaseContextProvider'; import { getQueryClient } from './getQueryClient'; -import { ReactQueryDevtoolsPanel } from '@tanstack/react-query-devtools'; +import {} from '@tanstack/react-query-devtools'; +import dynamic from 'next/dynamic'; +import { useHotkeys } from 'react-hotkeys-hook'; + +const ReactQueryDevtoolsPanel = dynamic( + () => import('@tanstack/react-query-devtools').then((mod) => mod.ReactQueryDevtoolsPanel), + { + loading: () =>
Loading dev tools...
, + ssr: false + } +); export const BusterReactQueryProvider = ({ children }: { children: React.ReactElement }) => { const accessToken = useSupabaseContext((state) => state.accessToken); const checkTokenValidity = useSupabaseContext((state) => state.checkTokenValidity); const queryClient = getQueryClient(accessToken); + const [isDevToolsOpen, setIsDevToolsOpen] = useState(false); useLayoutEffect(() => { //reset all request interceptors @@ -22,10 +33,15 @@ export const BusterReactQueryProvider = ({ children }: { children: React.ReactEl nextApi.interceptors.request.use((v) => defaultRequestHandler(v, { checkTokenValidity })); }, []); + useHotkeys('meta+shift+i', () => { + console.log('meta+shift+i'); + setIsDevToolsOpen((prev) => !prev); + }); + return ( {children} - + {isDevToolsOpen && } ); }; diff --git a/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderOptions/ChatHeaderDropdown.tsx b/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderOptions/ChatHeaderDropdown.tsx index a8adf25d0..2dea9ad0b 100644 --- a/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderOptions/ChatHeaderDropdown.tsx +++ b/web/src/layouts/ChatLayout/ChatContainer/ChatHeader/ChatHeaderOptions/ChatHeaderDropdown.tsx @@ -46,7 +46,11 @@ export const ChatContainerHeaderDropdown: React.FC<{ ]; }, [chatId, currentMessageId, deleteChat, duplicateChat]); - return {chatId ? children : null}; + return ( + + {chatId ? children : null} + + ); }); ChatContainerHeaderDropdown.displayName = 'ChatContainerHeaderDropdown';