From 05194b004cb4f1a7d45c8cb6e84271f92d6105b6 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 19 Mar 2025 22:59:14 -0600 Subject: [PATCH] Add TODO --- web/.cursor/rules/api_buster_query_keys.mdc | 4 +++- web/src/api/buster_rest/chats/requests.ts | 12 ++++++++---- web/src/api/buster_rest/dashboards/queryRequests.ts | 4 ++-- web/src/api/buster_socket/chats/chatRequests.ts | 5 ----- web/src/api/query_keys/chat.ts | 6 +++--- web/src/api/request_interfaces/chats/interfaces.ts | 7 ------- web/src/components/features/modal/AddTypeModal.tsx | 5 +++-- .../ChatsListController/ChatListController.tsx | 12 ++++++++---- 8 files changed, 27 insertions(+), 28 deletions(-) diff --git a/web/.cursor/rules/api_buster_query_keys.mdc b/web/.cursor/rules/api_buster_query_keys.mdc index a8d443051..d7cb9041c 100644 --- a/web/.cursor/rules/api_buster_query_keys.mdc +++ b/web/.cursor/rules/api_buster_query_keys.mdc @@ -1,6 +1,7 @@ --- description: Creating tan stack query options to be consuming in providers and api calls globs: src/api/query_keys/**/* +alwaysApply: false --- # Query Keys Folder Rules @@ -17,6 +18,7 @@ Below is an example of how query options should be structured within a file: import { queryOptions } from '@tanstack/react-query'; import type { BusterChat, BusterChatListItem } from '@/api/asset_interfaces'; import type { GetChatListParams } from '@/api/request_interfaces/chats'; +import { type getListLogs } from '@/api/buster_rest/chats'; const chatsGetChat = (chatId: string) => queryOptions({ @@ -24,7 +26,7 @@ const chatsGetChat = (chatId: string) => staleTime: 10 * 1000 }); -const chatsGetList = (filters?: GetChatListParams) => +const chatsGetList = (filters?: Parameters[0]>) => queryOptions({ queryKey: ['chats', 'list', filters] as const, staleTime: 10 * 1000 diff --git a/web/src/api/buster_rest/chats/requests.ts b/web/src/api/buster_rest/chats/requests.ts index f52971894..ba774c502 100644 --- a/web/src/api/buster_rest/chats/requests.ts +++ b/web/src/api/buster_rest/chats/requests.ts @@ -3,7 +3,6 @@ import { serverFetch } from '../../createServerInstance'; import type { BusterChatListItem, BusterChat } from '@/api/asset_interfaces/chat'; import type { DuplicateChatParams, - GetChatListParams, GetChatParams, UpdateChatParams } from '../../request_interfaces/chats'; @@ -11,7 +10,10 @@ import type { const CHATS_BASE = '/chats'; // Client-side fetch version -export const getListChats = async (params?: GetChatListParams): Promise => { +export const getListChats = async (params?: { + page_token: number; + page_size: number; +}): Promise => { const { page_token = 0, page_size = 3000 } = params || {}; return mainApi .get(`${CHATS_BASE}`, { @@ -20,7 +22,9 @@ export const getListChats = async (params?: GetChatListParams): Promise res.data); }; -export const getListLogs = async (params?: GetChatListParams): Promise => { +export const getListLogs = async ( + params?: Parameters[0] +): Promise => { const { page_token = 0, page_size = 3000 } = params || {}; return mainApi .get(`/logs`, { @@ -31,7 +35,7 @@ export const getListLogs = async (params?: GetChatListParams): Promise[0] ): Promise => { const { page_token = 0, page_size = 1000 } = params || {}; return await serverFetch(`${CHATS_BASE}`, { diff --git a/web/src/api/buster_rest/dashboards/queryRequests.ts b/web/src/api/buster_rest/dashboards/queryRequests.ts index 07eec42cd..d1fa23295 100644 --- a/web/src/api/buster_rest/dashboards/queryRequests.ts +++ b/web/src/api/buster_rest/dashboards/queryRequests.ts @@ -220,9 +220,9 @@ export const useRemoveItemFromDashboard = () => { if (prevDashboard) { const prevMetricsIds = Object.keys(prevDashboard?.metrics); const newMetricsIds = prevMetricsIds?.filter((t) => !metricId.includes(t)); + console.log('TODO: remove metrics from dashboard', dashboardId, metricId); return updateDashboardMutation({ - id: dashboardId, - metrics: newMetricsIds + id: dashboardId }); } } diff --git a/web/src/api/buster_socket/chats/chatRequests.ts b/web/src/api/buster_socket/chats/chatRequests.ts index c2f58aa2f..59ca4cdee 100644 --- a/web/src/api/buster_socket/chats/chatRequests.ts +++ b/web/src/api/buster_socket/chats/chatRequests.ts @@ -1,12 +1,7 @@ import type { - GetChatParams, - GetChatListParams, CreateNewChatParams, StopChatParams, UnsubscribeFromChatParams, - DeleteChatParams, - UpdateChatParams, - ChatsSearchParams, DuplicateChatParams } from '../../request_interfaces/chats'; import type { BusterSocketRequestBase } from '../base_interfaces'; diff --git a/web/src/api/query_keys/chat.ts b/web/src/api/query_keys/chat.ts index 8a44950d7..8f480e820 100644 --- a/web/src/api/query_keys/chat.ts +++ b/web/src/api/query_keys/chat.ts @@ -1,7 +1,7 @@ import { queryOptions } from '@tanstack/react-query'; import type { BusterMetricData } from '@/api/asset_interfaces/metric'; import { IBusterChat, BusterChatListItem, IBusterChatMessage } from '@/api/asset_interfaces/chat'; -import type { GetChatListParams } from '@/api/request_interfaces/chats'; +import { type getListLogs, type getListChats } from '@/api/buster_rest/chats'; const chatsGetChat = (chatId: string) => queryOptions({ @@ -24,7 +24,7 @@ const chatsMessagesFetchingData = (messageId: string) => enabled: !!messageId }); -const chatsGetList = (filters?: GetChatListParams) => +const chatsGetList = (filters?: Parameters[0]) => queryOptions({ queryKey: ['chats', 'list', filters] as const, staleTime: 60 * 1000, // 1 minute @@ -40,7 +40,7 @@ const chatsBlackBoxMessages = (messageId: string) => queryFn: () => Promise.resolve(null) }); -const logsGetList = (filters?: GetChatListParams) => +const logsGetList = (filters?: Parameters[0]) => queryOptions({ queryKey: ['logs', 'list', filters] as const, staleTime: 60 * 1000, // 1 minute diff --git a/web/src/api/request_interfaces/chats/interfaces.ts b/web/src/api/request_interfaces/chats/interfaces.ts index a59b181af..b6757c23f 100644 --- a/web/src/api/request_interfaces/chats/interfaces.ts +++ b/web/src/api/request_interfaces/chats/interfaces.ts @@ -1,10 +1,3 @@ -export interface GetChatListParams { - /** Pagination token indicating the page number */ - page_token: number; - /** Number of chat items to return per page */ - page_size: number; -} - export interface GetChatParams { /** The unique identifier of the chat to retrieve */ id: string; diff --git a/web/src/components/features/modal/AddTypeModal.tsx b/web/src/components/features/modal/AddTypeModal.tsx index 963e3f9f1..536b9d0e9 100644 --- a/web/src/components/features/modal/AddTypeModal.tsx +++ b/web/src/components/features/modal/AddTypeModal.tsx @@ -212,9 +212,10 @@ export const AddTypeModal: React.FC<{ assets }); } else if (type === 'dashboard') { + console.log('TODO: add metrics to dashboard', dashboard!.id, selectedIds); await updateDashboard({ - id: dashboard!.id, - metrics: selectedIds + id: dashboard!.id + // metrics: selectedIds }); } setSubmitting(false); diff --git a/web/src/controllers/ChatsListController/ChatListController.tsx b/web/src/controllers/ChatsListController/ChatListController.tsx index 105958515..67c1c30b8 100644 --- a/web/src/controllers/ChatsListController/ChatListController.tsx +++ b/web/src/controllers/ChatsListController/ChatListController.tsx @@ -2,8 +2,12 @@ import React, { useState } from 'react'; import { ChatItemsContainer } from './ChatItemsContainer'; -import { useGetListChats, useGetListLogs } from '@/api/buster_rest/chats'; -import type { GetChatListParams } from '@/api/request_interfaces/chats'; +import { + type getListChats, + type getListLogs, + useGetListChats, + useGetListLogs +} from '@/api/buster_rest/chats'; import { useUserConfigContextSelector } from '@/context/Users'; export const ChatListContainer: React.FC<{ @@ -19,7 +23,7 @@ export const ChatListContainer: React.FC<{ }; const ChatsContainer: React.FC<{}> = ({}) => { - const [filters, setFilters] = useState>({}); + const [filters, setFilters] = useState[0]>>({}); const { data: list, isFetched } = useGetListChats(filters); @@ -27,7 +31,7 @@ const ChatsContainer: React.FC<{}> = ({}) => { }; const LogsContainer: React.FC<{}> = ({}) => { - const [filters, setFilters] = useState>({}); + const [filters, setFilters] = useState[0]>>({}); const { data: list, isFetched } = useGetListLogs(filters);