From 86ba4584f14b6031aea311a0e95bbc6d0d1b7443 Mon Sep 17 00:00:00 2001 From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com> Date: Wed, 22 Apr 2026 20:07:41 +0000 Subject: [PATCH 1/2] fix(site/src): remove agent settings insights page --- site/src/api/queries/chats.ts | 12 ---- .../AgentsPage/AgentSettingsInsightsPage.tsx | 57 ------------------- .../AgentsPage/components/InsightsContent.tsx | 50 ---------------- .../components/Sidebar/AgentsSidebar.tsx | 8 --- site/src/router.tsx | 5 +- 5 files changed, 1 insertion(+), 131 deletions(-) delete mode 100644 site/src/pages/AgentsPage/AgentSettingsInsightsPage.tsx delete mode 100644 site/src/pages/AgentsPage/components/InsightsContent.tsx diff --git a/site/src/api/queries/chats.ts b/site/src/api/queries/chats.ts index 0f206f14a7c28..78563daec470e 100644 --- a/site/src/api/queries/chats.ts +++ b/site/src/api/queries/chats.ts @@ -1432,18 +1432,6 @@ export function paginatedChatCostUsers( }; } -const prInsightsKey = (params?: { start_date?: string; end_date?: string }) => - [...chatsKey, "prInsights", params] as const; - -export const prInsights = (params?: { - start_date?: string; - end_date?: string; -}) => ({ - queryKey: prInsightsKey(params), - queryFn: () => API.experimental.getPRInsights(params), - staleTime: 60_000, -}); - export const chatUsageLimitStatusKey = [ ...chatsKey, "usageLimitStatus", diff --git a/site/src/pages/AgentsPage/AgentSettingsInsightsPage.tsx b/site/src/pages/AgentsPage/AgentSettingsInsightsPage.tsx deleted file mode 100644 index c0e53a1f7f085..0000000000000 --- a/site/src/pages/AgentsPage/AgentSettingsInsightsPage.tsx +++ /dev/null @@ -1,57 +0,0 @@ -import dayjs, { type Dayjs } from "dayjs"; -import { type FC, useState } from "react"; -import { useQuery } from "react-query"; -import { prInsights } from "#/api/queries/chats"; -import { useAuthenticated } from "#/hooks/useAuthenticated"; -import { RequirePermission } from "#/modules/permissions/RequirePermission"; -import { InsightsContent } from "./components/InsightsContent"; -import type { PRInsightsTimeRange } from "./components/PRInsightsView"; - -type TimeRangeSelection = { - timeRange: PRInsightsTimeRange; - anchor: Dayjs; -}; - -function timeRangeToDates(range: PRInsightsTimeRange, anchor: Dayjs) { - const days = Number.parseInt(range, 10); - const start = anchor.subtract(days, "day"); - return { - start_date: start.toISOString(), - end_date: anchor.toISOString(), - }; -} - -const AgentSettingsInsightsPage: FC = () => { - const { permissions } = useAuthenticated(); - - const [selection, setSelection] = useState(() => ({ - timeRange: "30d", - anchor: dayjs(), - })); - const dates = timeRangeToDates(selection.timeRange, selection.anchor); - const { data, isLoading, error } = useQuery(prInsights(dates)); - - const handleTimeRangeChange = (timeRange: PRInsightsTimeRange) => - setSelection((current) => - current.timeRange === timeRange - ? current - : { - timeRange, - anchor: dayjs(), - }, - ); - - return ( - - - - ); -}; - -export default AgentSettingsInsightsPage; diff --git a/site/src/pages/AgentsPage/components/InsightsContent.tsx b/site/src/pages/AgentsPage/components/InsightsContent.tsx deleted file mode 100644 index 51d563848ae19..0000000000000 --- a/site/src/pages/AgentsPage/components/InsightsContent.tsx +++ /dev/null @@ -1,50 +0,0 @@ -import type { FC } from "react"; -import type * as TypesGen from "#/api/typesGenerated"; -import { Spinner } from "#/components/Spinner/Spinner"; -import { type PRInsightsTimeRange, PRInsightsView } from "./PRInsightsView"; - -interface InsightsContentProps { - data: TypesGen.PRInsightsResponse | undefined; - isLoading: boolean; - error: unknown; - timeRange: PRInsightsTimeRange; - onTimeRangeChange: (range: PRInsightsTimeRange) => void; -} - -export const InsightsContent: FC = ({ - data, - isLoading, - error, - timeRange, - onTimeRangeChange, -}) => { - if (isLoading) { - return ( -
- -
- ); - } - - if (error) { - return ( -
-

- Failed to load analytics data. -

-
- ); - } - - if (!data) { - return null; - } - - return ( - - ); -}; diff --git a/site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx b/site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx index 4fe24b6644b71..fafacadc1a585 100644 --- a/site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx +++ b/site/src/pages/AgentsPage/components/Sidebar/AgentsSidebar.tsx @@ -49,7 +49,6 @@ import { SettingsIcon, ShieldIcon, ShrinkIcon, - SparklesIcon, SquarePenIcon, Trash2Icon, UserIcon, @@ -1465,13 +1464,6 @@ export const AgentsSidebar: FC = (props) => { to="/agents/settings/lifecycle" state={location.state} /> - )} diff --git a/site/src/router.tsx b/site/src/router.tsx index a643d3bb5ee2c..283300c796469 100644 --- a/site/src/router.tsx +++ b/site/src/router.tsx @@ -390,9 +390,6 @@ const AgentSettingsMCPServersPage = lazy( const AgentSettingsSpendPage = lazy( () => import("./pages/AgentsPage/AgentSettingsSpendPage"), ); -const AgentSettingsInsightsPage = lazy( - () => import("./pages/AgentsPage/AgentSettingsInsightsPage"), -); const AgentSettingsTemplatesPage = lazy( () => import("./pages/AgentsPage/AgentSettingsTemplatesPage"), ); @@ -749,7 +746,7 @@ export const router = createBrowserRouter( } /> } /> } /> - } /> + } /> } /> } /> From 7003479b24647c5a71ab289246a02bb71b888241 Mon Sep 17 00:00:00 2001 From: Michael Suchacz <203725896+ibetitsmike@users.noreply.github.com> Date: Wed, 22 Apr 2026 20:19:44 +0000 Subject: [PATCH 2/2] fix(site/src): only hide agent settings insights in menu --- site/src/api/queries/chats.ts | 12 ++++ .../AgentsPage/AgentSettingsInsightsPage.tsx | 57 +++++++++++++++++++ .../AgentsPage/components/InsightsContent.tsx | 50 ++++++++++++++++ site/src/router.tsx | 5 +- 4 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 site/src/pages/AgentsPage/AgentSettingsInsightsPage.tsx create mode 100644 site/src/pages/AgentsPage/components/InsightsContent.tsx diff --git a/site/src/api/queries/chats.ts b/site/src/api/queries/chats.ts index 78563daec470e..0f206f14a7c28 100644 --- a/site/src/api/queries/chats.ts +++ b/site/src/api/queries/chats.ts @@ -1432,6 +1432,18 @@ export function paginatedChatCostUsers( }; } +const prInsightsKey = (params?: { start_date?: string; end_date?: string }) => + [...chatsKey, "prInsights", params] as const; + +export const prInsights = (params?: { + start_date?: string; + end_date?: string; +}) => ({ + queryKey: prInsightsKey(params), + queryFn: () => API.experimental.getPRInsights(params), + staleTime: 60_000, +}); + export const chatUsageLimitStatusKey = [ ...chatsKey, "usageLimitStatus", diff --git a/site/src/pages/AgentsPage/AgentSettingsInsightsPage.tsx b/site/src/pages/AgentsPage/AgentSettingsInsightsPage.tsx new file mode 100644 index 0000000000000..c0e53a1f7f085 --- /dev/null +++ b/site/src/pages/AgentsPage/AgentSettingsInsightsPage.tsx @@ -0,0 +1,57 @@ +import dayjs, { type Dayjs } from "dayjs"; +import { type FC, useState } from "react"; +import { useQuery } from "react-query"; +import { prInsights } from "#/api/queries/chats"; +import { useAuthenticated } from "#/hooks/useAuthenticated"; +import { RequirePermission } from "#/modules/permissions/RequirePermission"; +import { InsightsContent } from "./components/InsightsContent"; +import type { PRInsightsTimeRange } from "./components/PRInsightsView"; + +type TimeRangeSelection = { + timeRange: PRInsightsTimeRange; + anchor: Dayjs; +}; + +function timeRangeToDates(range: PRInsightsTimeRange, anchor: Dayjs) { + const days = Number.parseInt(range, 10); + const start = anchor.subtract(days, "day"); + return { + start_date: start.toISOString(), + end_date: anchor.toISOString(), + }; +} + +const AgentSettingsInsightsPage: FC = () => { + const { permissions } = useAuthenticated(); + + const [selection, setSelection] = useState(() => ({ + timeRange: "30d", + anchor: dayjs(), + })); + const dates = timeRangeToDates(selection.timeRange, selection.anchor); + const { data, isLoading, error } = useQuery(prInsights(dates)); + + const handleTimeRangeChange = (timeRange: PRInsightsTimeRange) => + setSelection((current) => + current.timeRange === timeRange + ? current + : { + timeRange, + anchor: dayjs(), + }, + ); + + return ( + + + + ); +}; + +export default AgentSettingsInsightsPage; diff --git a/site/src/pages/AgentsPage/components/InsightsContent.tsx b/site/src/pages/AgentsPage/components/InsightsContent.tsx new file mode 100644 index 0000000000000..51d563848ae19 --- /dev/null +++ b/site/src/pages/AgentsPage/components/InsightsContent.tsx @@ -0,0 +1,50 @@ +import type { FC } from "react"; +import type * as TypesGen from "#/api/typesGenerated"; +import { Spinner } from "#/components/Spinner/Spinner"; +import { type PRInsightsTimeRange, PRInsightsView } from "./PRInsightsView"; + +interface InsightsContentProps { + data: TypesGen.PRInsightsResponse | undefined; + isLoading: boolean; + error: unknown; + timeRange: PRInsightsTimeRange; + onTimeRangeChange: (range: PRInsightsTimeRange) => void; +} + +export const InsightsContent: FC = ({ + data, + isLoading, + error, + timeRange, + onTimeRangeChange, +}) => { + if (isLoading) { + return ( +
+ +
+ ); + } + + if (error) { + return ( +
+

+ Failed to load analytics data. +

+
+ ); + } + + if (!data) { + return null; + } + + return ( + + ); +}; diff --git a/site/src/router.tsx b/site/src/router.tsx index 283300c796469..a643d3bb5ee2c 100644 --- a/site/src/router.tsx +++ b/site/src/router.tsx @@ -390,6 +390,9 @@ const AgentSettingsMCPServersPage = lazy( const AgentSettingsSpendPage = lazy( () => import("./pages/AgentsPage/AgentSettingsSpendPage"), ); +const AgentSettingsInsightsPage = lazy( + () => import("./pages/AgentsPage/AgentSettingsInsightsPage"), +); const AgentSettingsTemplatesPage = lazy( () => import("./pages/AgentsPage/AgentSettingsTemplatesPage"), ); @@ -746,7 +749,7 @@ export const router = createBrowserRouter( } /> } /> } /> - } /> + } /> } /> } />