Skip to content

Commit

Permalink
remove lastStoredEditorValue
Browse files Browse the repository at this point in the history
  • Loading branch information
abeatrix committed Oct 9, 2024
1 parent b527447 commit 8e8759f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 11 deletions.
3 changes: 0 additions & 3 deletions lib/shared/src/chat/transcript/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import type { ContextItem } from '../../codebase-context/messages'
import type { Message } from '../../sourcegraph-api'

import type { SerializedChatTranscript } from '.'
import type { SerializedPromptEditorValue } from '../..'

/**
* The list of context items (most important first) along with
Expand Down Expand Up @@ -30,8 +29,6 @@ export interface ChatMessage extends Message {
*/
editorState?: unknown

lastStoredEditorValue?: SerializedPromptEditorValue

/**
* The model used to generate this chat message response. Not set on human messages.
*/
Expand Down
1 change: 0 additions & 1 deletion vscode/webviews/Chat.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ interface ChatboxProps {
showIDESnippetActions?: boolean
setView: (view: View) => void
smartApplyEnabled?: boolean

updateEditorStateOnChange: (index: number, state: SerializedPromptEditorValue) => void
}

Expand Down
6 changes: 3 additions & 3 deletions vscode/webviews/CodyPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,17 @@ export const CodyPanel: FunctionComponent<
}) => {
const tabContainerRef = useRef<HTMLDivElement>(null)

const [activeTranscript, setActiveTranscript] = useState<ChatMessage[] | undefined>(undefined)
const [activeTranscript, setActiveTranscript] = useState<ChatMessage[] | undefined>(transcript)
const [storedTranscriptState, setStoredTranscriptState] = useState(transcript)

// Update the lastEditor in transcriptState on every input box changes for chat message associated with the index.
// Update the Transcript State for each input box value change.
const updateEditorStateOnChange = useCallback(
(index: number, newEditorValue: SerializedPromptEditorValue) => {
setStoredTranscriptState(prev => {
const updated = [...prev]
updated[index] = {
...updated[index],
lastStoredEditorValue: newEditorValue,
editorState: newEditorValue.editorState,
speaker: 'human',
}
return updated
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,8 @@ export const HumanMessageCell: FunctionComponent<{
}) => {
const messageJSON = JSON.stringify(message)
const initialEditorState = useMemo(
() =>
message.lastStoredEditorValue?.editorState ??
serializedPromptEditorStateFromChatMessage(JSON.parse(messageJSON)),
[message.lastStoredEditorValue?.editorState, messageJSON]
() => serializedPromptEditorStateFromChatMessage(JSON.parse(messageJSON)),
[messageJSON]
)

return (
Expand Down

0 comments on commit 8e8759f

Please sign in to comment.