Skip to content

Commit

Permalink
change: display codeblock actions while message in progress (#2737)
Browse files Browse the repository at this point in the history
CLOSE #2720

Display codeblock actions while message in progress to allow users to
copy and insert code before the answer is completed.

## Test plan

<!-- Required. See
https://sourcegraph.com/docs/dev/background-information/testing_principles.
-->

- ask cody to generate a unit test
- you should be able to copy the test code before the message is
completed by cody
  • Loading branch information
abeatrix authored Jan 16, 2024
1 parent c088988 commit 69cc664
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 10 deletions.
9 changes: 0 additions & 9 deletions lib/ui/src/chat/CodeBlocks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
import styles from './CodeBlocks.module.css'

interface CodeBlocksProps {
inProgress: boolean

displayText: string

copyButtonClassName?: string
Expand Down Expand Up @@ -161,17 +159,11 @@ export const CodeBlocks: React.FunctionComponent<CodeBlocksProps> = React.memo(f
insertButtonClassName,
insertButtonOnSubmit,
metadata,
inProgress,
guardrails,
}) {
const rootRef = useRef<HTMLDivElement>(null)

useEffect(() => {
// Attach code block actions only when the message is completed
if (inProgress) {
return
}

const preElements = rootRef.current?.querySelectorAll('pre')
if (!preElements?.length || !copyButtonOnSubmit) {
return
Expand Down Expand Up @@ -248,7 +240,6 @@ export const CodeBlocks: React.FunctionComponent<CodeBlocksProps> = React.memo(f
insertButtonOnSubmit,
metadata?.requestID,
metadata?.source,
inProgress,
guardrails,
])

Expand Down
1 change: 0 additions & 1 deletion lib/ui/src/chat/TranscriptItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ export const TranscriptItem: React.FunctionComponent<
insertButtonClassName={codeBlocksInsertButtonClassName}
insertButtonOnSubmit={insertButtonOnSubmit}
metadata={message.metadata}
inProgress={inProgress}
guardrails={guardrails}
/>
)
Expand Down
1 change: 1 addition & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a

### Changed

- Changed code block UI to show actions immediately instead of waiting for Cody's response to be completed. [pull/2737](https://github.com/sourcegraph/cody/pull/2737)
- Removed recipes, which were replaced by commands in November 2023 (version 0.18.0).
- Edit: Updated the codelens display to be more descriptive. [pull/2710](https://github.com/sourcegraph/cody/pull/2710)
- [Internal] New generate unit test available behind `cody.internal.unstable`. [pull/2646](https://github.com/sourcegraph/cody/pull/2646)
Expand Down

0 comments on commit 69cc664

Please sign in to comment.