From a6c9b5f089c8443960403b434a04258cee7854e7 Mon Sep 17 00:00:00 2001 From: Mathew Pareles Date: Sun, 2 Mar 2025 00:04:41 -0800 Subject: [PATCH] edit message bug fixes --- .../contrib/void/browser/chatThreadService.ts | 32 +++++++++++++++++++ .../react/src/sidebar-tsx/SidebarChat.tsx | 16 ++++++++-- .../contrib/void/common/voidSettingsTypes.ts | 2 +- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/void/browser/chatThreadService.ts b/src/vs/workbench/contrib/void/browser/chatThreadService.ts index 8003a02e..b4a74d3c 100644 --- a/src/vs/workbench/contrib/void/browser/chatThreadService.ts +++ b/src/vs/workbench/contrib/void/browser/chatThreadService.ts @@ -176,6 +176,9 @@ export interface IChatThreadService { getCurrentThreadState: () => ThreadType['state'] setCurrentThreadState: (newState: Partial) => void + closeStagingSelectionsInCurrentThread(): void; + closeStagingSelectionsInMessage(messageIdx: number): void; + // call to edit a message editUserMessageAndStreamResponse({ userMessage, chatMode, messageIdx }: { userMessage: string, chatMode: ChatMode, messageIdx: number }): Promise; @@ -657,6 +660,35 @@ class ChatThreadService extends Disposable implements IChatThreadService { } + + closeStagingSelectionsInCurrentThread = () => { + const currThread = this.getCurrentThreadState() + + // close all stagingSelections + const closedStagingSelections = currThread.stagingSelections.map(s => ({ ...s, state: { ...s.state, isOpened: false } })) + + const newThread = currThread + newThread.stagingSelections = closedStagingSelections + + this.setCurrentThreadState(newThread) + + } + + closeStagingSelectionsInMessage = (messageIdx: number) => { + const currMessage = this.getCurrentMessageState(messageIdx) + + // close all stagingSelections + const closedStagingSelections = currMessage.stagingSelections.map(s => ({ ...s, state: { ...s.state, isOpened: false } })) + + const newMessage = currMessage + newMessage.stagingSelections = closedStagingSelections + + this.setCurrentMessageState(messageIdx, newMessage) + + } + + + getCurrentThreadState = () => { const currentThread = this.getCurrentThread() return currentThread.state diff --git a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx index 1feeee03..e8e5ba1d 100644 --- a/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx +++ b/src/vs/workbench/contrib/void/browser/react/src/sidebar-tsx/SidebarChat.tsx @@ -418,7 +418,7 @@ export const SelectedFiles = ( {allSelections.map((selection, i) => { - const isThisSelectionOpened = (!!selection.selectionStr && selection.state.isOpened) //!!(selection.selectionStr && selectionIsOpened[i]) + const isThisSelectionOpened = (!!selection.selectionStr && selection.state.isOpened && type === 'staging') const isThisSelectionAFile = selection.selectionStr === null const isThisSelectionProspective = i > selections.length - 1 @@ -501,7 +501,7 @@ export const SelectedFiles = ( {isThisSelectionOpened ?
{ @@ -923,9 +923,10 @@ const ChatBubble = ({ chatMessage, isLoading, messageIdx }: { chatMessage: ChatM const thread = chatThreadsService.getCurrentThread() chatThreadsService.cancelStreaming(thread.id) - // reset state + // update state setIsBeingEdited(false) chatThreadsService.setFocusedMessageIdx(undefined) + chatThreadsService.closeStagingSelectionsInMessage(messageIdx) // stream the edit const userMessage = textAreaRefState.value; @@ -1064,7 +1065,13 @@ const ChatBubble = ({ chatMessage, isLoading, messageIdx }: { chatMessage: ChatM : role === 'user' ? 'p-2 flex flex-col gap-1 bg-void-bg-1 text-void-fg-1 overflow-x-auto' : role === 'assistant' ? 'px-2 overflow-x-auto' : '' } + ${role === 'user' && mode === 'display' ? 'cursor-pointer' : ''} `} + onClick={() => { + if (role === 'user' && mode === 'display') { + onOpenEdit() + } + }} > {chatbubbleContents} {isLoading && } @@ -1155,6 +1162,9 @@ export const SidebarChat = () => { if (isDisabled) return if (isStreaming) return + // update state + chatThreadsService.closeStagingSelectionsInCurrentThread() // close all selections + // send message to LLM const userMessage = textAreaRef.current?.value ?? '' await chatThreadsService.addUserMessageAndStreamResponse({ userMessage, chatMode: 'agent' }) diff --git a/src/vs/workbench/contrib/void/common/voidSettingsTypes.ts b/src/vs/workbench/contrib/void/common/voidSettingsTypes.ts index 29963ec9..a933fae5 100644 --- a/src/vs/workbench/contrib/void/common/voidSettingsTypes.ts +++ b/src/vs/workbench/contrib/void/common/voidSettingsTypes.ts @@ -57,7 +57,7 @@ export const defaultModelsOfProvider = { ], anthropic: [ // https://docs.anthropic.com/en/docs/about-claude/models 'claude-3-7-sonnet-latest', - // 'claude-3-5-sonnet-latest', + 'claude-3-5-sonnet-latest', 'claude-3-5-haiku-latest', 'claude-3-opus-latest', ],