From 11e1c018472154966d38c54cac0cb2fb038b77e5 Mon Sep 17 00:00:00 2001 From: CREDO23 Date: Fri, 13 Feb 2026 16:25:19 +0200 Subject: [PATCH] Add delete_from_db checkbox and update ApprovalCard UI for delete tool --- .../components/tool-ui/delete-notion-page.tsx | 69 +++- .../components/tool-ui/update-notion-page.tsx | 363 +++++++++--------- 2 files changed, 248 insertions(+), 184 deletions(-) diff --git a/surfsense_web/components/tool-ui/delete-notion-page.tsx b/surfsense_web/components/tool-ui/delete-notion-page.tsx index 1defe72a4..59d04f2b7 100644 --- a/surfsense_web/components/tool-ui/delete-notion-page.tsx +++ b/surfsense_web/components/tool-ui/delete-notion-page.tsx @@ -17,6 +17,20 @@ interface InterruptResult { action_name: string; allowed_decisions: Array<"approve" | "reject">; }>; + context?: { + account?: { + id: number; + name: string; + workspace_id: string | null; + workspace_name: string; + workspace_icon: string; + }; + page_id?: string; + current_title?: string; + document_id?: number; + indexed_at?: string; + error?: string; + }; } interface SuccessResult { @@ -57,11 +71,16 @@ function ApprovalCard({ }: { args: Record; interruptData: InterruptResult; - onDecision: (decision: { type: "approve" | "reject"; message?: string }) => void; + onDecision: (decision: { + type: "approve" | "reject"; + message?: string; + edited_action?: { name: string; args: Record }; + }) => void; }) { const [decided, setDecided] = useState<"approve" | "reject" | null>( interruptData.__decided__ ?? null ); + const [deleteFromDb, setDeleteFromDb] = useState(false); return (
- {args.page_id != null && ( + {interruptData.context?.account && (
-

Page ID

-

{String(args.page_id)}

+

Notion Account

+

+ {interruptData.context.account.workspace_icon}{" "} + {interruptData.context.account.workspace_name} +

+
+ )} + {interruptData.context?.current_title && ( +
+

Page

+

📄 {interruptData.context.current_title}

)}
+ {/* Checkbox for deleting from knowledge base */} + {!decided && ( +
+ +
+ )} +
{ setDecided("approve"); - onDecision({ type: "approve" }); + onDecision({ + type: "approve", + edited_action: { + name: interruptData.action_requests[0].name, + args: { + ...interruptData.action_requests[0].args, + delete_from_db: deleteFromDb, + }, + }, + }); }} > @@ -198,7 +255,7 @@ function SuccessCard({ result }: { result: SuccessResult }) { } export const DeleteNotionPageToolUI = makeAssistantToolUI< - { page_id: string }, + { page_title: string; delete_from_db?: boolean }, DeleteNotionPageResult >({ toolName: "delete_notion_page", diff --git a/surfsense_web/components/tool-ui/update-notion-page.tsx b/surfsense_web/components/tool-ui/update-notion-page.tsx index e84c6622b..0242057ff 100644 --- a/surfsense_web/components/tool-ui/update-notion-page.tsx +++ b/surfsense_web/components/tool-ui/update-notion-page.tsx @@ -125,198 +125,170 @@ function ApprovalCard({ <> {/* Backdrop for full-screen mode */} {isFullScreen && ( -
setIsFullScreen(false)} /> +
setIsFullScreen(false)} + /> )} - +
-
- -
-
-

- Update Notion Page -

-

- {isEditing ? "You can edit the arguments below" : "Requires your approval to proceed"} -

-
- {isEditing && ( - - )} -
- - {/* Context section - READ ONLY account and page info */} - {!decided && interruptData.context && ( -
- {interruptData.context.error ? ( -

{interruptData.context.error}

- ) : ( - <> - {account && ( -
-
Notion Account
-
- {account.workspace_icon} {account.workspace_name} -
-
+ +
+
+

+ Update Notion Page +

+

+ {isEditing ? "You can edit the arguments below" : "Requires your approval to proceed"} +

+
+ {isEditing && ( + )}
- )} - {/* Display mode - show proposed changes as read-only */} - {!isEditing && ( -
- {args.content != null && ( -
-

New Content

-

- {String(args.content)} -

-
- )} - {args.content == null && ( -

No content update specified

- )} -
- )} - - {/* Edit mode - show editable form fields */} - {isEditing && !decided && ( -
- -