From 71f4f77f26671f752706c66965e36f99629e52f2 Mon Sep 17 00:00:00 2001 From: Anish Sarkar <104695310+AnishSarkar22@users.noreply.github.com> Date: Mon, 13 Apr 2026 20:25:49 +0530 Subject: [PATCH] refactor: unify interrupt handling in various tools Refactored the context types for create, delete, and update functionalities across multiple tools including Confluence, Dropbox, Gmail, Google Calendar, Jira, Linear, Notion, and OneDrive to utilize a consistent type definition. This change enhances code clarity and maintains uniformity in handling user approvals by integrating the useHitlDecision hook for decision dispatching. --- .../components/tool-ui/confluence/create-confluence-page.tsx | 2 +- .../components/tool-ui/confluence/delete-confluence-page.tsx | 2 +- .../components/tool-ui/confluence/update-confluence-page.tsx | 2 +- surfsense_web/components/tool-ui/dropbox/create-file.tsx | 2 +- surfsense_web/components/tool-ui/dropbox/trash-file.tsx | 2 +- surfsense_web/components/tool-ui/gmail/create-draft.tsx | 2 +- surfsense_web/components/tool-ui/gmail/send-email.tsx | 2 +- surfsense_web/components/tool-ui/gmail/trash-email.tsx | 2 +- surfsense_web/components/tool-ui/gmail/update-draft.tsx | 2 +- .../components/tool-ui/google-calendar/create-event.tsx | 2 +- .../components/tool-ui/google-calendar/delete-event.tsx | 2 +- .../components/tool-ui/google-calendar/update-event.tsx | 2 +- surfsense_web/components/tool-ui/google-drive/create-file.tsx | 2 +- surfsense_web/components/tool-ui/google-drive/trash-file.tsx | 2 +- surfsense_web/components/tool-ui/jira/create-jira-issue.tsx | 2 +- surfsense_web/components/tool-ui/jira/delete-jira-issue.tsx | 2 +- surfsense_web/components/tool-ui/jira/update-jira-issue.tsx | 2 +- surfsense_web/components/tool-ui/linear/create-linear-issue.tsx | 2 +- surfsense_web/components/tool-ui/linear/delete-linear-issue.tsx | 2 +- surfsense_web/components/tool-ui/linear/update-linear-issue.tsx | 2 +- surfsense_web/components/tool-ui/notion/create-notion-page.tsx | 2 +- surfsense_web/components/tool-ui/notion/delete-notion-page.tsx | 2 +- surfsense_web/components/tool-ui/notion/update-notion-page.tsx | 2 +- surfsense_web/components/tool-ui/onedrive/create-file.tsx | 2 +- surfsense_web/components/tool-ui/onedrive/trash-file.tsx | 2 +- 25 files changed, 25 insertions(+), 25 deletions(-) diff --git a/surfsense_web/components/tool-ui/confluence/create-confluence-page.tsx b/surfsense_web/components/tool-ui/confluence/create-confluence-page.tsx index b60817536..f8cd6ee15 100644 --- a/surfsense_web/components/tool-ui/confluence/create-confluence-page.tsx +++ b/surfsense_web/components/tool-ui/confluence/create-confluence-page.tsx @@ -32,7 +32,7 @@ interface ConfluenceSpace { name: string; } -interface CreateConfluencePageInterruptContext { +type CreateConfluencePageInterruptContext = { accounts?: ConfluenceAccount[]; spaces?: ConfluenceSpace[]; error?: string; diff --git a/surfsense_web/components/tool-ui/confluence/delete-confluence-page.tsx b/surfsense_web/components/tool-ui/confluence/delete-confluence-page.tsx index ca45e26ee..37d73377e 100644 --- a/surfsense_web/components/tool-ui/confluence/delete-confluence-page.tsx +++ b/surfsense_web/components/tool-ui/confluence/delete-confluence-page.tsx @@ -10,7 +10,7 @@ import { isInterruptResult, useHitlDecision } from "@/lib/hitl"; import type { InterruptResult, HitlDecision } from "@/lib/hitl"; import { useHitlPhase } from "@/hooks/use-hitl-phase"; -interface DeleteConfluencePageInterruptContext { +type DeleteConfluencePageInterruptContext = { account?: { id: number; name: string; diff --git a/surfsense_web/components/tool-ui/confluence/update-confluence-page.tsx b/surfsense_web/components/tool-ui/confluence/update-confluence-page.tsx index 7f75f9ac8..76df10e40 100644 --- a/surfsense_web/components/tool-ui/confluence/update-confluence-page.tsx +++ b/surfsense_web/components/tool-ui/confluence/update-confluence-page.tsx @@ -12,7 +12,7 @@ import { isInterruptResult, useHitlDecision } from "@/lib/hitl"; import type { InterruptResult, HitlDecision } from "@/lib/hitl"; import { useHitlPhase } from "@/hooks/use-hitl-phase"; -interface UpdateConfluencePageInterruptContext { +type UpdateConfluencePageInterruptContext = { account?: { id: number; name: string; diff --git a/surfsense_web/components/tool-ui/dropbox/create-file.tsx b/surfsense_web/components/tool-ui/dropbox/create-file.tsx index 70daf491c..15d454c76 100644 --- a/surfsense_web/components/tool-ui/dropbox/create-file.tsx +++ b/surfsense_web/components/tool-ui/dropbox/create-file.tsx @@ -31,7 +31,7 @@ interface SupportedType { label: string; } -interface DropboxCreateFileContext { +type DropboxCreateFileContext = { accounts?: DropboxAccount[]; parent_folders?: Record>; supported_types?: SupportedType[]; diff --git a/surfsense_web/components/tool-ui/dropbox/trash-file.tsx b/surfsense_web/components/tool-ui/dropbox/trash-file.tsx index 3d4ad8a94..a2fadd20f 100644 --- a/surfsense_web/components/tool-ui/dropbox/trash-file.tsx +++ b/surfsense_web/components/tool-ui/dropbox/trash-file.tsx @@ -24,7 +24,7 @@ interface DropboxFile { document_id?: number; } -interface DropboxTrashFileContext { +type DropboxTrashFileContext = { account?: DropboxAccount; file?: DropboxFile; error?: string; diff --git a/surfsense_web/components/tool-ui/gmail/create-draft.tsx b/surfsense_web/components/tool-ui/gmail/create-draft.tsx index 73e5bcd61..d13ee2d94 100644 --- a/surfsense_web/components/tool-ui/gmail/create-draft.tsx +++ b/surfsense_web/components/tool-ui/gmail/create-draft.tsx @@ -27,7 +27,7 @@ interface GmailAccount { auth_expired?: boolean; } -interface GmailCreateDraftContext { +type GmailCreateDraftContext = { accounts?: GmailAccount[]; error?: string; } diff --git a/surfsense_web/components/tool-ui/gmail/send-email.tsx b/surfsense_web/components/tool-ui/gmail/send-email.tsx index c95e67d6e..8a632e582 100644 --- a/surfsense_web/components/tool-ui/gmail/send-email.tsx +++ b/surfsense_web/components/tool-ui/gmail/send-email.tsx @@ -27,7 +27,7 @@ interface GmailAccount { auth_expired?: boolean; } -interface GmailSendEmailContext { +type GmailSendEmailContext = { accounts?: GmailAccount[]; error?: string; } diff --git a/surfsense_web/components/tool-ui/gmail/trash-email.tsx b/surfsense_web/components/tool-ui/gmail/trash-email.tsx index b3090a364..ca2f8f074 100644 --- a/surfsense_web/components/tool-ui/gmail/trash-email.tsx +++ b/surfsense_web/components/tool-ui/gmail/trash-email.tsx @@ -27,7 +27,7 @@ interface GmailMessage { document_id: number; } -interface GmailTrashEmailContext { +type GmailTrashEmailContext = { account?: GmailAccount; email?: GmailMessage; error?: string; diff --git a/surfsense_web/components/tool-ui/gmail/update-draft.tsx b/surfsense_web/components/tool-ui/gmail/update-draft.tsx index 431744463..512808344 100644 --- a/surfsense_web/components/tool-ui/gmail/update-draft.tsx +++ b/surfsense_web/components/tool-ui/gmail/update-draft.tsx @@ -30,7 +30,7 @@ interface GmailMessage { document_id: number; } -interface GmailUpdateDraftContext { +type GmailUpdateDraftContext = { account?: GmailAccount; email?: GmailMessage; draft_id?: string; diff --git a/surfsense_web/components/tool-ui/google-calendar/create-event.tsx b/surfsense_web/components/tool-ui/google-calendar/create-event.tsx index e45c51775..71a78d826 100644 --- a/surfsense_web/components/tool-ui/google-calendar/create-event.tsx +++ b/surfsense_web/components/tool-ui/google-calendar/create-event.tsx @@ -32,7 +32,7 @@ interface CalendarEntry { primary?: boolean; } -interface CalendarCreateEventContext { +type CalendarCreateEventContext = { accounts?: GoogleCalendarAccount[]; calendars?: CalendarEntry[]; timezone?: string; diff --git a/surfsense_web/components/tool-ui/google-calendar/delete-event.tsx b/surfsense_web/components/tool-ui/google-calendar/delete-event.tsx index 16e0a4112..1d3186a2f 100644 --- a/surfsense_web/components/tool-ui/google-calendar/delete-event.tsx +++ b/surfsense_web/components/tool-ui/google-calendar/delete-event.tsx @@ -29,7 +29,7 @@ interface CalendarEvent { indexed_at?: string; } -interface CalendarDeleteEventContext { +type CalendarDeleteEventContext = { account?: GoogleCalendarAccount; event?: CalendarEvent; error?: string; diff --git a/surfsense_web/components/tool-ui/google-calendar/update-event.tsx b/surfsense_web/components/tool-ui/google-calendar/update-event.tsx index 541c59378..1489a7da0 100644 --- a/surfsense_web/components/tool-ui/google-calendar/update-event.tsx +++ b/surfsense_web/components/tool-ui/google-calendar/update-event.tsx @@ -39,7 +39,7 @@ interface CalendarEvent { indexed_at?: string; } -interface CalendarUpdateEventContext { +type CalendarUpdateEventContext = { account?: GoogleCalendarAccount; event?: CalendarEvent; error?: string; diff --git a/surfsense_web/components/tool-ui/google-drive/create-file.tsx b/surfsense_web/components/tool-ui/google-drive/create-file.tsx index 2b77d5028..dba06c64d 100644 --- a/surfsense_web/components/tool-ui/google-drive/create-file.tsx +++ b/surfsense_web/components/tool-ui/google-drive/create-file.tsx @@ -25,7 +25,7 @@ interface GoogleDriveAccount { auth_expired?: boolean; } -interface DriveCreateFileContext { +type DriveCreateFileContext = { accounts?: GoogleDriveAccount[]; supported_types?: string[]; parent_folders?: Record>; diff --git a/surfsense_web/components/tool-ui/google-drive/trash-file.tsx b/surfsense_web/components/tool-ui/google-drive/trash-file.tsx index fa0bfc3bd..e28855570 100644 --- a/surfsense_web/components/tool-ui/google-drive/trash-file.tsx +++ b/surfsense_web/components/tool-ui/google-drive/trash-file.tsx @@ -23,7 +23,7 @@ interface GoogleDriveFile { web_view_link: string; } -interface DriveTrashFileContext { +type DriveTrashFileContext = { account?: GoogleDriveAccount; file?: GoogleDriveFile; error?: string; diff --git a/surfsense_web/components/tool-ui/jira/create-jira-issue.tsx b/surfsense_web/components/tool-ui/jira/create-jira-issue.tsx index 4561cd9dd..ecac504da 100644 --- a/surfsense_web/components/tool-ui/jira/create-jira-issue.tsx +++ b/surfsense_web/components/tool-ui/jira/create-jira-issue.tsx @@ -42,7 +42,7 @@ interface JiraPriority { name: string; } -interface CreateJiraIssueInterruptContext { +type CreateJiraIssueInterruptContext = { accounts?: JiraAccount[]; projects?: JiraProject[]; issue_types?: JiraIssueType[]; diff --git a/surfsense_web/components/tool-ui/jira/delete-jira-issue.tsx b/surfsense_web/components/tool-ui/jira/delete-jira-issue.tsx index cb8da37ea..99d84e023 100644 --- a/surfsense_web/components/tool-ui/jira/delete-jira-issue.tsx +++ b/surfsense_web/components/tool-ui/jira/delete-jira-issue.tsx @@ -25,7 +25,7 @@ interface JiraIssue { document_id?: number; } -interface DeleteJiraIssueInterruptContext { +type DeleteJiraIssueInterruptContext = { account?: JiraAccount; issue?: JiraIssue; error?: string; diff --git a/surfsense_web/components/tool-ui/jira/update-jira-issue.tsx b/surfsense_web/components/tool-ui/jira/update-jira-issue.tsx index 24643b542..dd9dbe123 100644 --- a/surfsense_web/components/tool-ui/jira/update-jira-issue.tsx +++ b/surfsense_web/components/tool-ui/jira/update-jira-issue.tsx @@ -45,7 +45,7 @@ interface JiraPriority { name: string; } -interface UpdateJiraIssueInterruptContext { +type UpdateJiraIssueInterruptContext = { account?: JiraAccount; issue?: JiraIssue; priorities?: JiraPriority[]; diff --git a/surfsense_web/components/tool-ui/linear/create-linear-issue.tsx b/surfsense_web/components/tool-ui/linear/create-linear-issue.tsx index 156cdb5ca..bbb5b0fef 100644 --- a/surfsense_web/components/tool-ui/linear/create-linear-issue.tsx +++ b/surfsense_web/components/tool-ui/linear/create-linear-issue.tsx @@ -66,7 +66,7 @@ interface LinearWorkspace { auth_expired?: boolean; } -interface LinearCreateIssueContext { +type LinearCreateIssueContext = { workspaces?: LinearWorkspace[]; error?: string; } diff --git a/surfsense_web/components/tool-ui/linear/delete-linear-issue.tsx b/surfsense_web/components/tool-ui/linear/delete-linear-issue.tsx index f033240de..67c9aa78c 100644 --- a/surfsense_web/components/tool-ui/linear/delete-linear-issue.tsx +++ b/surfsense_web/components/tool-ui/linear/delete-linear-issue.tsx @@ -10,7 +10,7 @@ import { useHitlPhase } from "@/hooks/use-hitl-phase"; import { isInterruptResult, useHitlDecision } from "@/lib/hitl"; import type { InterruptResult, HitlDecision } from "@/lib/hitl"; -interface LinearDeleteIssueContext { +type LinearDeleteIssueContext = { workspace?: { id: number; organization_name: string }; issue?: { id: string; diff --git a/surfsense_web/components/tool-ui/linear/update-linear-issue.tsx b/surfsense_web/components/tool-ui/linear/update-linear-issue.tsx index 4ff5b6e75..a03b605eb 100644 --- a/surfsense_web/components/tool-ui/linear/update-linear-issue.tsx +++ b/surfsense_web/components/tool-ui/linear/update-linear-issue.tsx @@ -47,7 +47,7 @@ interface LinearPriority { label: string; } -interface LinearUpdateIssueContext { +type LinearUpdateIssueContext = { workspace?: { id: number; organization_name: string }; priorities?: LinearPriority[]; issue?: { diff --git a/surfsense_web/components/tool-ui/notion/create-notion-page.tsx b/surfsense_web/components/tool-ui/notion/create-notion-page.tsx index 9a05dbc94..906b41c8a 100644 --- a/surfsense_web/components/tool-ui/notion/create-notion-page.tsx +++ b/surfsense_web/components/tool-ui/notion/create-notion-page.tsx @@ -19,7 +19,7 @@ import { useHitlPhase } from "@/hooks/use-hitl-phase"; import { isInterruptResult, useHitlDecision } from "@/lib/hitl"; import type { InterruptResult, HitlDecision } from "@/lib/hitl"; -interface NotionCreatePageContext { +type NotionCreatePageContext = { accounts?: Array<{ id: number; name: string; diff --git a/surfsense_web/components/tool-ui/notion/delete-notion-page.tsx b/surfsense_web/components/tool-ui/notion/delete-notion-page.tsx index 5f30c7efd..7f3aa62af 100644 --- a/surfsense_web/components/tool-ui/notion/delete-notion-page.tsx +++ b/surfsense_web/components/tool-ui/notion/delete-notion-page.tsx @@ -10,7 +10,7 @@ import { useHitlPhase } from "@/hooks/use-hitl-phase"; import { isInterruptResult, useHitlDecision } from "@/lib/hitl"; import type { InterruptResult, HitlDecision } from "@/lib/hitl"; -interface NotionDeletePageContext { +type NotionDeletePageContext = { account?: { id: number; name: string; diff --git a/surfsense_web/components/tool-ui/notion/update-notion-page.tsx b/surfsense_web/components/tool-ui/notion/update-notion-page.tsx index d07c6592b..c8221c586 100644 --- a/surfsense_web/components/tool-ui/notion/update-notion-page.tsx +++ b/surfsense_web/components/tool-ui/notion/update-notion-page.tsx @@ -12,7 +12,7 @@ import { useHitlPhase } from "@/hooks/use-hitl-phase"; import { isInterruptResult, useHitlDecision } from "@/lib/hitl"; import type { InterruptResult, HitlDecision } from "@/lib/hitl"; -interface NotionUpdatePageContext { +type NotionUpdatePageContext = { account?: { id: number; name: string; diff --git a/surfsense_web/components/tool-ui/onedrive/create-file.tsx b/surfsense_web/components/tool-ui/onedrive/create-file.tsx index 502394986..285a873e7 100644 --- a/surfsense_web/components/tool-ui/onedrive/create-file.tsx +++ b/surfsense_web/components/tool-ui/onedrive/create-file.tsx @@ -26,7 +26,7 @@ interface OneDriveAccount { auth_expired?: boolean; } -interface OneDriveCreateFileContext { +type OneDriveCreateFileContext = { accounts?: OneDriveAccount[]; parent_folders?: Record>; error?: string; diff --git a/surfsense_web/components/tool-ui/onedrive/trash-file.tsx b/surfsense_web/components/tool-ui/onedrive/trash-file.tsx index 5735363c0..447022be2 100644 --- a/surfsense_web/components/tool-ui/onedrive/trash-file.tsx +++ b/surfsense_web/components/tool-ui/onedrive/trash-file.tsx @@ -24,7 +24,7 @@ interface OneDriveFile { web_url?: string; } -interface OneDriveTrashFileContext { +type OneDriveTrashFileContext = { account?: OneDriveAccount; file?: OneDriveFile; error?: string;