aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
diff options
context:
space:
mode:
authorsharkiecodes <lanyi_stroud@brown.edu>2025-07-02 20:33:37 -0400
committersharkiecodes <lanyi_stroud@brown.edu>2025-07-02 20:33:37 -0400
commitf0807c6f6c31ac9ae2e6fb581f19a760f8e5687e (patch)
tree2e12315621bb361210ce5b6beaa7165da7ddc5ab /src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
parentf49fa5010ac53eb87925d1cd40e3be145d441ea6 (diff)
Implementing replacement of GPTPopup
Diffstat (limited to 'src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx')
-rw-r--r--src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
index 636b77b38..f84a4cd2a 100644
--- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
+++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx
@@ -111,8 +111,16 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
super(props);
makeObservable(this);
+ // At mount time, find the DocumentView whose .Document is the collection container.
+ const parentView = DocumentView.Selected().lastElement();
+ if (!parentView) {
+ console.warn("GPT ChatBox not inside a DocumentView – cannot sort.");
+ }
+
+
+
this.messagesRef = React.createRef();
- this.docManager = new AgentDocumentManager(this);
+ this.docManager = new AgentDocumentManager(this, parentView);
// Initialize OpenAI client
this.initializeOpenAI();
@@ -154,6 +162,25 @@ export class ChatBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
}
);
+ /*
+ reaction(
+ () => ({ selDoc: DocumentView.Selected().lastElement(), visible: SnappingManager.ChatVisible }),
+ ({ selDoc, visible }) => {
+ const hasChildDocs = visible && selDoc?.ComponentView?.hasChildDocs;
+ if (hasChildDocs) {
+ this._textToDocMap.clear();
+ this.setCollectionContext(selDoc.Document);
+ this.onGptResponse = (sortResult: string, questionType: GPTDocCommand) => this.processGptResponse(selDoc, this._textToDocMap, sortResult, questionType);
+ this.onQuizRandom = () => this.randomlyChooseDoc(selDoc.Document, hasChildDocs());
+ this._documentDescriptions = Promise.all(hasChildDocs().map(doc =>
+ Doc.getDescription(doc).then(text => this._textToDocMap.set(text.replace(/\n/g, ' ').trim(), doc) && `${DescriptionSeperator}${text}${DescriptionSeperator}`)
+ )).then(docDescriptions => docDescriptions.join()); // prettier-ignore
+ }
+ },
+ { fireImmediately: true }
+ );
+ }*/
+
// Initialize font size from saved preference
this.initFontSize();
}