From 6c011f502118e5246aabd29a30494c669d917fb1 Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 11 Jun 2025 12:15:39 -0400 Subject: don't autoTag text docs until they're dropped onto a scrapbook. don't re-tag a text box that has not changed. --- .../views/nodes/formattedText/FormattedTextBox.tsx | 23 +++++++++++----------- src/client/views/nodes/scrapbook/ScrapbookBox.tsx | 5 ++++- 2 files changed, 16 insertions(+), 12 deletions(-) (limited to 'src/client/views/nodes') diff --git a/src/client/views/nodes/formattedText/FormattedTextBox.tsx b/src/client/views/nodes/formattedText/FormattedTextBox.tsx index 1768eb08d..d700ce9f8 100644 --- a/src/client/views/nodes/formattedText/FormattedTextBox.tsx +++ b/src/client/views/nodes/formattedText/FormattedTextBox.tsx @@ -310,15 +310,17 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent { const rawText = RTFCast(this.Document[this.fieldKey])?.Text ?? StrCast(this.Document[this.fieldKey]); - const callType = rawText.includes('[placeholder]') ? GPTCallType.CLASSIFYTEXTMINIMAL : GPTCallType.CLASSIFYTEXTFULL; - - gptAPICall(rawText, callType).then( - action(desc => { - // Split GPT response into tokens and push individually & clear existing tags - this.Document.$tags_chat = new List(desc.trim().split(/\s+/)); - this.Document._layout_showTags = true; - }) - ); + if (rawText && !this.Document.$tags_chat) { + const callType = rawText.includes('[placeholder]') ? GPTCallType.CLASSIFYTEXTMINIMAL : GPTCallType.CLASSIFYTEXTFULL; + + gptAPICall(rawText, callType).then( + action(desc => { + // Split GPT response into tokens and push individually & clear existing tags + this.Document.$tags_chat = new List(desc.trim().split(/\s+/)); + this.Document._layout_showTags = true; + }) + ); + } }; leafText = (node: Node) => { @@ -382,6 +384,7 @@ export class FormattedTextBox extends ViewBoxAnnotatableComponent ({ title: this.Document.title, sel: this._props.isSelected() }), this.autoTag, { fireImmediately: true }); - if (!this._props.dontRegisterView) { this._disposers.record = reaction( () => this.recordingDictation, diff --git a/src/client/views/nodes/scrapbook/ScrapbookBox.tsx b/src/client/views/nodes/scrapbook/ScrapbookBox.tsx index fcb82a6ba..94522c979 100644 --- a/src/client/views/nodes/scrapbook/ScrapbookBox.tsx +++ b/src/client/views/nodes/scrapbook/ScrapbookBox.tsx @@ -57,7 +57,10 @@ export function buildPlaceholdersFromConfigs(configs: ScrapbookItemConfig[]) { return createMessagePlaceholder(cfg); }); } -export function slotRealDocIntoPlaceholders(realDoc: Doc, placeholders: Doc[]): boolean { +export async function slotRealDocIntoPlaceholders(realDoc: Doc, placeholders: Doc[]) { + if (!realDoc.$tags_chart) { + await DocumentView.getFirstDocumentView(realDoc)?.ComponentView?.autoTag?.(); + } const realTags = new Set(StrListCast(realDoc.$tags_chat).map(t => t.toLowerCase?.() ?? '')); // Find placeholder with most matching tags -- cgit v1.2.3-70-g09d2