From ffd2214ec18082ab88d3d07065448351d83a716f Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 14 Nov 2024 17:03:01 -0800 Subject: [PATCH 1/2] Update handler.ts --- .../vscode/src/diff/vertical/handler.ts | 41 +++++++++++-------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/extensions/vscode/src/diff/vertical/handler.ts b/extensions/vscode/src/diff/vertical/handler.ts index 1ec5a60b6..f2bf20ef6 100644 --- a/extensions/vscode/src/diff/vertical/handler.ts +++ b/extensions/vscode/src/diff/vertical/handler.ts @@ -25,9 +25,12 @@ export class VerticalDiffHandler implements vscode.Disposable { private currentLineIndex: number; private cancelled = false; private newLinesAdded = 0; - private get diffBlocks() { - return this.editorToVerticalDiffCodeLens.get(this.filepath) || []; + private deletionBuffer: string[] = []; + private redDecorationManager: DecorationTypeRangeManager; + private get filepath() { + return this.editor.document.uri.fsPath; } + public insertedInCurrentBlock = 0; public get range(): vscode.Range { const startLine = Math.min(this.startLine, this.endLine); const endLine = Math.max(this.startLine, this.endLine); @@ -77,14 +80,6 @@ export class VerticalDiffHandler implements vscode.Disposable { this.disposables.push(disposable); } - private get filepath() { - return this.editor.document.uri.fsPath; - } - - private deletionBuffer: string[] = []; - private redDecorationManager: DecorationTypeRangeManager; - insertedInCurrentBlock = 0; - private async insertDeletionBuffer() { // Don't remove trailing whitespace line const totalDeletedContent = this.deletionBuffer.join("\n"); @@ -98,13 +93,15 @@ export class VerticalDiffHandler implements vscode.Disposable { } if (this.deletionBuffer.length || this.insertedInCurrentBlock > 0) { - this.diffBlocks.push({ + const blocks = this.editorToVerticalDiffCodeLens.get(this.filepath) || []; + + blocks.push({ start: this.currentLineIndex - this.insertedInCurrentBlock, numRed: this.deletionBuffer.length, numGreen: this.insertedInCurrentBlock, }); - this.editorToVerticalDiffCodeLens.set(this.filepath, this.diffBlocks); + this.editorToVerticalDiffCodeLens.set(this.filepath, blocks); } if (this.deletionBuffer.length === 0) { @@ -271,7 +268,10 @@ export class VerticalDiffHandler implements vscode.Disposable { }, ); - this.options.onStatusUpdate("closed", this.diffBlocks.length); + this.options.onStatusUpdate( + "closed", + this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0, + ); this.cancelled = true; this.refreshCodeLens(); @@ -359,7 +359,10 @@ export class VerticalDiffHandler implements vscode.Disposable { this.refreshCodeLens(); - this.options.onStatusUpdate("done", this.diffBlocks.length); + this.options.onStatusUpdate( + "done", + this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0, + ); // Reject on user typing // const listener = vscode.workspace.onDidChangeTextDocument((e) => { @@ -409,8 +412,11 @@ export class VerticalDiffHandler implements vscode.Disposable { // Shift the codelens objects this.shiftCodeLensObjects(startLine, offset); - const status = this.diffBlocks.length === 0 ? "closed" : undefined; - this.options.onStatusUpdate(status, this.diffBlocks.length); + const numDiffs = + this.editorToVerticalDiffCodeLens.get(this.filepath)?.length ?? 0; + + const status = numDiffs === 0 ? "closed" : undefined; + this.options.onStatusUpdate(status, numDiffs); } private shiftCodeLensObjects(startLine: number, offset: number) { @@ -450,6 +456,7 @@ export class VerticalDiffHandler implements vscode.Disposable { } public hasDiffForCurrentFile(): boolean { - return this.diffBlocks.length > 0; + const diffBlocks = this.editorToVerticalDiffCodeLens.get(this.filepath); + return diffBlocks !== undefined && diffBlocks.length > 0; } } From a7a50280833007e8f0a3d908e3dd7544a2557dcb Mon Sep 17 00:00:00 2001 From: Test Date: Thu, 14 Nov 2024 17:03:30 -0800 Subject: [PATCH 2/2] Update StepContainerPreToolbar.tsx --- .../StepContainerPreToolbar.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx index ac13c6d54..0fa57fd08 100644 --- a/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx +++ b/gui/src/components/markdown/StepContainerPreToolbar/StepContainerPreToolbar.tsx @@ -2,7 +2,7 @@ import { ChevronDownIcon } from "@heroicons/react/24/outline"; import { debounce } from "lodash"; import { useContext, useEffect, useRef, useState } from "react"; import { useDispatch, useSelector } from "react-redux"; -import styled, { keyframes } from "styled-components"; +import styled, { css, keyframes } from "styled-components"; import { v4 as uuidv4 } from "uuid"; import { defaultBorderRadius, lightGray, vscEditorBackground } from "../.."; import { IdeMessengerContext } from "../../../context/IdeMessenger"; @@ -26,13 +26,18 @@ const fadeInAnimation = keyframes` } `; -const TopDiv = styled.div` +const TopDiv = styled.div<{ active?: boolean }>` outline: 1px solid rgba(153, 153, 152); outline-offset: -0.5px; border-radius: ${defaultBorderRadius}; margin-bottom: 8px !important; background-color: ${vscEditorBackground}; - animation: ${fadeInAnimation} 300ms ease-out forwards; + ${(props) => + props.active + ? "animation: none;" + : css` + animation: ${fadeInAnimation} 300ms ease-out forwards; + `} `; const ToolbarDiv = styled.div<{ isExpanded: boolean }>` @@ -67,6 +72,7 @@ export default function StepContainerPreToolbar( const isMultifileEdit = useSelector( (state: RootState) => state.state.isInMultifileEdit, ); + const active = useSelector((state: RootState) => state.state.active); const [isExpanded, setIsExpanded] = useState(isMultifileEdit ? false : true); const [codeBlockContent, setCodeBlockContent] = useState(""); const isChatActive = useSelector((state: RootState) => state.state.active); @@ -168,7 +174,7 @@ export default function StepContainerPreToolbar( } return ( - +