diff --git a/src/app/common/elements/markdown.tsx b/src/app/common/elements/markdown.tsx index e4e96dc80..59ab1132c 100644 --- a/src/app/common/elements/markdown.tsx +++ b/src/app/common/elements/markdown.tsx @@ -45,12 +45,12 @@ class CodeBlockMarkdown extends React.Component< @boundMethod handleClick(e: React.MouseEvent) { - console.log("this.blockIndex", this.blockIndex); + // console.log("this.blockIndex", this.blockIndex); GlobalModel.inputModel.setCodeSelectSelectedCodeBlock(this.blockIndex); } render() { - console.log("this.blockIndex", this.blockIndex); + // console.log("this.blockIndex", this.blockIndex); let selected = this.blockIndex == this.props.codeSelectSelectedIndex; return (
diff --git a/src/app/sidebar/aichat.tsx b/src/app/sidebar/aichat.tsx
index 6d64cb644..69b2711cd 100644
--- a/src/app/sidebar/aichat.tsx
+++ b/src/app/sidebar/aichat.tsx
@@ -64,10 +64,10 @@ class ChatContent extends React.Component<{ chatWindowRef }, {}> {
         this.chatListKeyCount = 0;
         if (this.containerRef?.current && this.osInstance) {
             const { viewport } = this.osInstance.elements();
-            viewport.scrollTo({
-                behavior: "auto",
-                top: this.props.chatWindowRef.current.scrollHeight,
-            });
+            // viewport.scrollTo({
+            //     behavior: "auto",
+            //     top: this.props.chatWindowRef.current.scrollHeight,
+            // });
         }
     }
 
@@ -274,15 +274,18 @@ class AIChat extends React.Component<{}, {}> {
     }
 
     onArrowUpPressed(): boolean {
+        console.log("arrow up pressed==================");
         const currentRef = this.textAreaRef.current;
+        console.log("inputModel.getCodeSelectSelectedIndex()", GlobalModel.inputModel.getCodeSelectSelectedIndex());
         if (currentRef == null) {
             return false;
         }
-        if (this.getLinePos(currentRef).linePos > 1) {
-            // normal up arrow
-            GlobalModel.inputModel.codeSelectDeselectAll();
-            return false;
-        }
+        // if (this.getLinePos(currentRef).linePos > 1) {
+        //     // normal up arrow
+        //     // GlobalModel.inputModel.codeSelectDeselectAll();
+        //     // return false;
+        // }
+
         GlobalModel.inputModel.codeSelectSelectNextOldestCodeBlock();
         return true;
     }
diff --git a/src/models/input.ts b/src/models/input.ts
index c87fe94be..ed658a5f3 100644
--- a/src/models/input.ts
+++ b/src/models/input.ts
@@ -32,16 +32,15 @@ class InputModel {
     aiChatWindowRef: React.RefObject;
     chatOsInstance: OverlayScrollbars;
     codeSelectBlockRefArray: Array>;
-    codeSelectSelectedIndex: OV = mobx.observable.box(-1);
+    codeSelectSelectedIndex: OV = mobx.observable.box(null, {
+        name: "codeSelectSelectedIndex",
+    });
     codeSelectUuid: string;
     inputPopUpType: OV = mobx.observable.box("none");
 
     AICmdInfoChatItems: mobx.IObservableArray = mobx.observable.array([], {
         name: "aicmdinfo-chat",
     });
-    readonly codeSelectTop: number = -2;
-    readonly codeSelectBottom: number = -1;
-
     historyType: mobx.IObservableValue = mobx.observable.box("screen");
     historyLoading: mobx.IObservableValue = mobx.observable.box(false);
     historyAfterLoadIndex: number = 0;
@@ -665,18 +664,21 @@ class InputModel {
     codeSelectSelectNextNewestCodeBlock() {
         // oldest code block = index 0 in array
         // this decrements codeSelectSelected index
-        if (this.codeSelectSelectedIndex.get() == this.codeSelectTop) {
-            this.codeSelectSelectedIndex.set(this.codeSelectBottom);
-        } else if (this.codeSelectSelectedIndex.get() == this.codeSelectBottom) {
-            return;
-        }
+        // if (this.codeSelectSelectedIndex.get() == this.codeSelectTop) {
+
+        //     this.codeSelectSelectedIndex.set(this.codeSelectBottom);
+        // } else if (this.codeSelectSelectedIndex.get() == this.codeSelectBottom) {
+        //     return;
+        // }
         const incBlockIndex = this.codeSelectSelectedIndex.get() + 1;
-        if (this.codeSelectSelectedIndex.get() == this.codeSelectBlockRefArray.length - 1) {
-            this.codeSelectDeselectAll();
-            if (this.aiChatWindowRef?.current != null) {
-                this.aiChatWindowRef.current.scrollTop = this.aiChatWindowRef.current.scrollHeight;
-            }
-        }
+        // if (this.codeSelectSelectedIndex.get() == this.codeSelectBlockRefArray.length - 1) {
+        //     // this.codeSelectDeselectAll();
+        //     // if (this.aiChatWindowRef?.current != null) {
+        //     //     this.aiChatWindowRef.current.scrollTop = this.aiChatWindowRef.current.scrollHeight;
+        //     // }
+        // }
+        // console.log("incBlockIndex", incBlockIndex);
+        // console.log("this.codeSelectBlockRefArray.length", this.codeSelectBlockRefArray.length);
         if (incBlockIndex >= 0 && incBlockIndex < this.codeSelectBlockRefArray.length) {
             this.setCodeSelectSelectedCodeBlock(incBlockIndex);
         }
@@ -684,23 +686,29 @@ class InputModel {
 
     @mobx.action
     codeSelectSelectNextOldestCodeBlock() {
-        if (this.codeSelectSelectedIndex.get() == this.codeSelectBottom) {
-            if (this.codeSelectBlockRefArray.length > 0) {
-                this.codeSelectSelectedIndex.set(this.codeSelectBlockRefArray.length);
-            } else {
-                return;
-            }
-        } else if (this.codeSelectSelectedIndex.get() == this.codeSelectTop) {
+        if (this.codeSelectSelectedIndex.get() == null && this.codeSelectBlockRefArray.length > 0) {
+            console.log("triggered====== 1");
+            // if (this.codeSelectBlockRefArray.length > 0) {
+            //     this.codeSelectSelectedIndex.set(this.codeSelectBlockRefArray.length - 1);
+            // }
+            this.setCodeSelectSelectedCodeBlock(this.codeSelectBlockRefArray.length - 1);
             return;
+            // } else if (this.codeSelectSelectedIndex.get() == this.codeSelectTop) {
+            //     console.log("triggered====== 2");
+            //     return;
         }
         const decBlockIndex = this.codeSelectSelectedIndex.get() - 1;
-        if (decBlockIndex < 0) {
-            this.codeSelectDeselectAll(this.codeSelectTop);
-            if (this.aiChatWindowRef?.current != null) {
-                this.aiChatWindowRef.current.scrollTop = 0;
-            }
-        }
+        // if (decBlockIndex < 0) {
+        //     console.log("triggered====== 3");
+
+        //     this.codeSelectDeselectAll(this.codeSelectTop);
+        //     if (this.aiChatWindowRef?.current != null) {
+        //         this.aiChatWindowRef.current.scrollTop = 0;
+        //     }
+        // }
         if (decBlockIndex >= 0 && decBlockIndex < this.codeSelectBlockRefArray.length) {
+            console.log("triggered====== 4");
+
             this.setCodeSelectSelectedCodeBlock(decBlockIndex);
         }
     }
@@ -717,7 +725,7 @@ class InputModel {
         return blockIndex == this.codeSelectSelectedIndex.get();
     }
 
-    codeSelectDeselectAll(direction: number = this.codeSelectBottom) {
+    codeSelectDeselectAll(direction: number) {
         if (this.codeSelectSelectedIndex.get() == direction) {
             return;
         }