Skip to content

Commit

Permalink
Remove onKeyPress on AccordionTrigger (#5993)
Browse files Browse the repository at this point in the history
context:
https://sourcegraph.slack.com/archives/C05AGQYD528/p1729773000841009

Somehow `onKeyPress` causing an infinite loop of telemetry records. Also
with the most recent changes the `context items opened` event is getting
recorded even when the context menu is closed.

This PR makes it so that the event is only getting recorded once. 

## Test plan
- Contact Piotr, even I don't know. 

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
  • Loading branch information
thenamankumar authored Oct 24, 2024
1 parent 55a5e8b commit 30fde3d
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions vscode/webviews/chat/cells/contextCell/ContextCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,17 @@ export const ContextCell: FunctionComponent<{
)

const triggerAccordion = useCallback(() => {
setAccordionValue(prev => (prev ? '' : 'item-1'))
telemetryRecorder.recordEvent('cody.contextCell', 'opened', {
metadata: {
fileCount: new Set(usedContext.map(file => file.uri.toString())).size,
excludedAtContext: excludedContext.length,
},
setAccordionValue(prev => {
if (!prev) {
telemetryRecorder.recordEvent('cody.contextCell', 'opened', {
metadata: {
fileCount: new Set(usedContext.map(file => file.uri.toString())).size,
excludedAtContext: excludedContext.length,
},
})
}

return prev ? '' : 'item-1'
})
}, [excludedContext.length, usedContext])

Expand Down Expand Up @@ -150,7 +155,6 @@ export const ContextCell: FunctionComponent<{
header={
<AccordionTrigger
onClick={triggerAccordion}
onKeyUp={triggerAccordion}
title={itemCountLabel}
className="tw-flex tw-items-center tw-gap-4"
disabled={isContextLoading}
Expand Down

0 comments on commit 30fde3d

Please sign in to comment.