diff --git a/surfsense_web/components/assistant-ui/thread.tsx b/surfsense_web/components/assistant-ui/thread.tsx
index 1bdc424cc..7a06f82eb 100644
--- a/surfsense_web/components/assistant-ui/thread.tsx
+++ b/surfsense_web/components/assistant-ui/thread.tsx
@@ -392,10 +392,17 @@ const Composer: FC = () => {
{showDocumentPopover &&
typeof document !== "undefined" &&
createPortal(
-
{
+ setShowDocumentPopover(false);
+ setMentionQuery("");
+ }}
+ initialSelectedDocuments={mentionedDocuments}
+ externalSearch={mentionQuery}
+ containerStyle={{
bottom: editorContainerRef.current
? `${window.innerHeight - editorContainerRef.current.getBoundingClientRect().top + 8}px`
: "200px",
@@ -403,19 +410,7 @@ const Composer: FC = () => {
? `${editorContainerRef.current.getBoundingClientRect().left}px`
: "50%",
}}
- >
- {
- setShowDocumentPopover(false);
- setMentionQuery("");
- }}
- initialSelectedDocuments={mentionedDocuments}
- externalSearch={mentionQuery}
- />
-
,
+ />,
document.body
)}
diff --git a/surfsense_web/components/new-chat/document-mention-picker.tsx b/surfsense_web/components/new-chat/document-mention-picker.tsx
index c7d4d9e84..7e39c6100 100644
--- a/surfsense_web/components/new-chat/document-mention-picker.tsx
+++ b/surfsense_web/components/new-chat/document-mention-picker.tsx
@@ -27,11 +27,13 @@ interface DocumentMentionPickerProps {
onDone: () => void;
initialSelectedDocuments?: Pick[];
externalSearch?: string;
+ /** Positioning styles for the container */
+ containerStyle?: React.CSSProperties;
}
const PAGE_SIZE = 20;
const MIN_SEARCH_LENGTH = 2;
-const DEBOUNCE_MS = 300;
+const DEBOUNCE_MS = 100;
/**
* Debounce hook - waits until user stops typing before firing
@@ -66,7 +68,7 @@ export const DocumentMentionPicker = forwardRef<
DocumentMentionPickerRef,
DocumentMentionPickerProps
>(function DocumentMentionPicker(
- { searchSpaceId, onSelectionChange, onDone, initialSelectedDocuments = [], externalSearch = "" },
+ { searchSpaceId, onSelectionChange, onDone, initialSelectedDocuments = [], externalSearch = "", containerStyle },
ref
) {
const queryClient = useQueryClient();
@@ -426,7 +428,11 @@ export const DocumentMentionPicker = forwardRef<
return (