From 7e21c12cb171b29619fd9120074912e9e38d6eee Mon Sep 17 00:00:00 2001
From: Henry Fontanier
Date: Fri, 13 Dec 2024 13:35:07 +0100
Subject: [PATCH] feat: allow kill switch to disable saving agent configs and
dsviews (#9356)
* feat: allow kill switch to disable saving agent configs and dsviews
* block at endpoint level
* fix
* add assistant builder tooltip
* ds views tooltips
---------
Co-authored-by: Henry Fontanier
---
.../assistant_builder/AssistantBuilder.tsx | 11 +-
.../EditSpaceManagedDatasourcesViews.tsx | 53 +-
.../EditSpaceStaticDatasourcesViews.tsx | 36 +-
front/components/sparkle/AppLayoutTitle.tsx | 3 +
front/lib/resources/kill_switch_resource.ts | 6 +-
front/lib/swr/kill.ts | 22 +
front/package-lock.json | 1469 +++++++++--------
front/package.json | 2 +-
front/pages/api/kill.ts | 21 +
front/pages/api/poke/kill.ts | 6 +-
.../assistant/agent_configurations/index.ts | 12 +
.../data_source_views/[dsvId]/index.ts | 13 +
.../[spaceId]/data_source_views/index.ts | 13 +
13 files changed, 956 insertions(+), 711 deletions(-)
create mode 100644 front/lib/swr/kill.ts
create mode 100644 front/pages/api/kill.ts
diff --git a/front/components/assistant_builder/AssistantBuilder.tsx b/front/components/assistant_builder/AssistantBuilder.tsx
index bda114636a67..508ea6c29c43 100644
--- a/front/components/assistant_builder/AssistantBuilder.tsx
+++ b/front/components/assistant_builder/AssistantBuilder.tsx
@@ -65,6 +65,7 @@ import {
AppLayoutSimpleSaveCancelTitle,
} from "@app/components/sparkle/AppLayoutTitle";
import { isUpgraded } from "@app/lib/plans/plan_codes";
+import { useKillSwitches } from "@app/lib/swr/kill";
function isValidTab(tab: string): tab is BuilderScreen {
return BUILDER_SCREENS.includes(tab as BuilderScreen);
@@ -85,6 +86,9 @@ export default function AssistantBuilder({
const router = useRouter();
const sendNotification = useSendNotification();
+ const { killSwitches } = useKillSwitches();
+ const isSavingDisabled = killSwitches?.includes("save_agent_configurations");
+
const defaultScope =
flow === "workspace_assistants" ? "workspace" : "private";
const [currentTab, setCurrentTab] = useHashParam(
@@ -380,8 +384,13 @@ export default function AssistantBuilder({
onCancel={async () => {
await appLayoutBack(owner, router);
}}
- onSave={onAssistantSave}
+ onSave={isSavingDisabled ? undefined : onAssistantSave}
isSaving={isSavingOrDeleting}
+ saveTooltip={
+ isSavingDisabled
+ ? "Saving assistants is temporarily disabled and will be re-enabled shortly."
+ : undefined
+ }
/>
)
}
diff --git a/front/components/spaces/EditSpaceManagedDatasourcesViews.tsx b/front/components/spaces/EditSpaceManagedDatasourcesViews.tsx
index 4c6ffe67e3b0..3cb1e766e3e6 100644
--- a/front/components/spaces/EditSpaceManagedDatasourcesViews.tsx
+++ b/front/components/spaces/EditSpaceManagedDatasourcesViews.tsx
@@ -4,6 +4,7 @@ import {
Dialog,
InformationCircleIcon,
PlusIcon,
+ Tooltip,
} from "@dust-tt/sparkle";
import { useSendNotification } from "@dust-tt/sparkle";
import type {
@@ -23,6 +24,7 @@ import { RequestDataSourceModal } from "@app/components/data_source/RequestDataS
import SpaceManagedDatasourcesViewsModal from "@app/components/spaces/SpaceManagedDatasourcesViewsModal";
import { useAwaitableDialog } from "@app/hooks/useAwaitableDialog";
import { getDisplayNameForDataSource, isManaged } from "@app/lib/data_sources";
+import { useKillSwitches } from "@app/lib/swr/kill";
import {
useSpaceDataSourceViews,
useSpaceDataSourceViewsWithDetails,
@@ -54,6 +56,10 @@ export function EditSpaceManagedDataSourcesViews({
const { AwaitableDialog, showDialog } = useAwaitableDialog();
+ const { killSwitches } = useKillSwitches();
+
+ const isSavingDisabled = killSwitches?.includes("save_data_source_views");
+
// DataSources Views of the current space.
const {
spaceDataSourceViews,
@@ -264,6 +270,28 @@ export function EditSpaceManagedDataSourcesViews({
if (isSystemSpaceDataSourceViewsLoading || isSpaceDataSourceViewsLoading) {
return false;
}
+
+ const addToSpaceButton = (
+
-