Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
fix: auto-approve internal RAG tools for embedded documents (#7809)
Claytonfe6fc58a9cf8
diff --git a/web-app/src/containers/ChatInput.tsx b/web-app/src/containers/ChatInput.tsxindex 4c71f67a9..82427a6d4 100644--- a/web-app/src/containers/ChatInput.tsx+++ b/web-app/src/containers/ChatInput.tsx@@ -74,6 +74,7 @@ import { toast } from 'sonner'import { isPlatformTauri } from '@/lib/platform/utils'import { processAttachmentsForSend } from '@/lib/attachmentProcessing'import { useAttachmentIngestionPrompt } from '@/hooks/useAttachmentIngestionPrompt'+import { useToolApproval } from '@/hooks/useToolApproval'import {NEW_THREAD_ATTACHMENT_KEY,useChatAttachments,@@ -725,6 +726,11 @@ const ChatInput = memo(function ChatInput({}if (hasEmbeddedDocuments) {+ const toolApproval = useToolApproval.getState()+ const ragTools = useAppState.getState().ragToolNames+ for (const toolName of ragTools) {+ toolApproval.approveToolForThread(currentThreadId, toolName)+ }useThreads.getState().updateThread(currentThreadId, {metadata: { hasDocuments: true },})diff --git a/web-app/src/routes/threads/$threadId.tsx b/web-app/src/routes/threads/$threadId.tsxindex 92bfbc315..d2af43836 100644--- a/web-app/src/routes/threads/$threadId.tsx+++ b/web-app/src/routes/threads/$threadId.tsx@@ -274,10 +274,12 @@ function ThreadDetail() {try {const toolName = toolCall.toolName- // Request approval if needed (unless auto-approve is enabled)- const approved = await useToolApproval- .getState()- .showApprovalModal(toolName, threadId, toolCall.input)+ // Built-in RAG tools are internal and should not require approval.+ const approved = ragToolNames.has(toolName)+ ? true+ : await useToolApproval+ .getState()+ .showApprovalModal(toolName, threadId, toolCall.input)if (!approved) {// User denied the tool call@@ -525,6 +527,11 @@ function ThreadDetail() {// Update thread metadata if documents were embeddedif (result.hasEmbeddedDocuments) {+ const toolApproval = useToolApproval.getState()+ const ragTools = useAppState.getState().ragToolNames+ for (const toolName of ragTools) {+ toolApproval.approveToolForThread(threadId, toolName)+ }useThreads.getState().updateThread(threadId, {metadata: { hasDocuments: true },})