From bcf6e91f489de3dc296dae9287ceb7dc28d1a0e5 Mon Sep 17 00:00:00 2001 From: Red Adaya Date: Wed, 8 May 2024 22:42:01 +0800 Subject: [PATCH] save work --- src/app/sidebar/aichat.tsx | 4 +--- src/app/workspace/cmdinput/cmdinput.tsx | 8 +++---- src/models/input.ts | 28 +++++++++++++++++++------ 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/app/sidebar/aichat.tsx b/src/app/sidebar/aichat.tsx index 7edc78665..6d64cb644 100644 --- a/src/app/sidebar/aichat.tsx +++ b/src/app/sidebar/aichat.tsx @@ -63,9 +63,7 @@ class ChatContent extends React.Component<{ chatWindowRef }, {}> { componentDidUpdate() { this.chatListKeyCount = 0; if (this.containerRef?.current && this.osInstance) { - const { viewport, scrollOffsetElement } = this.osInstance.elements(); - const { scrollTop } = scrollOffsetElement; - console.log("this.props.chatWindowRef.current.scrollTop", scrollTop); + const { viewport } = this.osInstance.elements(); viewport.scrollTo({ behavior: "auto", top: this.props.chatWindowRef.current.scrollHeight, diff --git a/src/app/workspace/cmdinput/cmdinput.tsx b/src/app/workspace/cmdinput/cmdinput.tsx index cdf403871..87d81cb2d 100644 --- a/src/app/workspace/cmdinput/cmdinput.tsx +++ b/src/app/workspace/cmdinput/cmdinput.tsx @@ -86,9 +86,9 @@ class CmdInput extends React.Component<{}, {}> { e.stopPropagation(); const inputModel = GlobalModel.inputModel; if (inputModel.getActiveAuxView() === appconst.InputAuxView_AIChat) { - inputModel.closeAuxView(); + // inputModel.closeAuxView(); } else { - inputModel.openAIAssistantChat(); + // inputModel.openAIAssistantChat(); } } @@ -191,10 +191,10 @@ class CmdInput extends React.Component<{}, {}> {
- + {/*
-
+
*/} diff --git a/src/models/input.ts b/src/models/input.ts index 1480921bd..c87fe94be 100644 --- a/src/models/input.ts +++ b/src/models/input.ts @@ -578,10 +578,10 @@ class InputModel { let rtn = -1; // Why is codeSelectBlockRefArray being reset here? This causes a bug where multiple code blocks are highlighted // because multiple code blocks have the same index. - if (uuid != this.codeSelectUuid) { - // this.codeSelectUuid = uuid; - // this.codeSelectBlockRefArray = []; - } + // if (uuid != this.codeSelectUuid) { + // this.codeSelectUuid = uuid; + // this.codeSelectBlockRefArray = []; + // } rtn = this.codeSelectBlockRefArray.length; this.codeSelectBlockRefArray.push(blockRef); return rtn; @@ -597,13 +597,29 @@ class InputModel { this.codeSelectSelectedIndex.set(blockIndex); const currentRef = this.codeSelectBlockRefArray[blockIndex].current; if (currentRef != null && this.aiChatWindowRef?.current != null) { - const chatWindowTop = this.aiChatWindowRef.current.scrollTop; + // const chatWindowTop = this.aiChatWindowRef.current.scrollTop; + const { viewport, scrollOffsetElement } = this.chatOsInstance.elements(); + const chatWindowTop = scrollOffsetElement.scrollTop; + + console.log("chatWindowTop", chatWindowTop); const chatWindowBottom = chatWindowTop + this.aiChatWindowRef.current.clientHeight - 100; + console.log("chatWindowTop", chatWindowTop); + console.log("this.aiChatWindowRef.current.clientHeight", this.aiChatWindowRef.current.clientHeight); const elemTop = currentRef.offsetTop; let elemBottom = elemTop - currentRef.offsetHeight; const elementIsInView = elemBottom < chatWindowBottom && elemTop > chatWindowTop; if (!elementIsInView) { - this.aiChatWindowRef.current.scrollTop = elemBottom - this.aiChatWindowRef.current.clientHeight / 3; + console.log("elemBottom", elemBottom); + console.log( + "this.aiChatWindowRef.current.clientHeight", + this.aiChatWindowRef.current.clientHeight, + this.aiChatWindowRef.current.clientHeight / 2 + ); + // this.aiChatWindowRef.current.scrollTop = elemBottom - this.aiChatWindowRef.current.clientHeight / 3; + viewport.scrollTo({ + behavior: "auto", + top: elemTop - 20, + }); } } }