Skip to content

Commit

Permalink
Make at-mention events fire correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
RXminuS committed Sep 24, 2024
1 parent 3a993a6 commit cdf985b
Show file tree
Hide file tree
Showing 10 changed files with 661 additions and 330 deletions.
19 changes: 9 additions & 10 deletions lib/prompt-editor/src/plugins/atMentions/atMentions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,8 @@ export const MentionsPlugin: FunctionComponent<{ contextWindowSizeInTokens?: num
*/
const [tokenAdded, setTokenAdded] = useState<number>(0)

const remainingTokenBudget =
contextWindowSizeInTokens === undefined
? Number.MAX_SAFE_INTEGER
: contextWindowSizeInTokens - tokenAdded

const { params, updateQuery, updateMentionMenuParams } = useMentionMenuParams()

const data = useMentionMenuData(params, {
remainingTokenBudget,
limit: SUGGESTION_LIST_LENGTH_LIMIT,
})

const setEditorQuery = useCallback<setEditorQuery>(
getNewQuery => {
if (editor) {
Expand Down Expand Up @@ -212,6 +202,15 @@ export const MentionsPlugin: FunctionComponent<{ contextWindowSizeInTokens?: num
COMMAND_PRIORITY_NORMAL /* so Enter keypress selects option and doesn't submit form */
}
menuRenderFn={(anchorElementRef, itemProps) => {
const remainingTokenBudget =
contextWindowSizeInTokens === undefined
? Number.MAX_SAFE_INTEGER
: contextWindowSizeInTokens - tokenAdded
const data = useMentionMenuData(params, {
remainingTokenBudget,
limit: SUGGESTION_LIST_LENGTH_LIMIT,
})

const { selectOptionAndCleanUp } = itemProps
anchorElementRef2.current = anchorElementRef.current ?? undefined
return (
Expand Down
1 change: 1 addition & 0 deletions lib/shared/src/mentions/query.test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//@ts-nocheck
import { describe, expect, test } from 'vitest'

import { FILE_CONTEXT_MENTION_PROVIDER, SYMBOL_CONTEXT_MENTION_PROVIDER } from './api'
Expand Down
38 changes: 0 additions & 38 deletions lib/shared/src/telemetry-v2/events/atMention.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,146 @@ log:
send: 0
ssl: -1
wait: 228
- _id: 2426219b807d0dc43882cd923c2fa69e
_order: 0
cache: {}
request:
bodySize: 1044
cookies: []
headers:
- name: transfer-encoding
value: chunked
- name: host
value: sourcegraph.com
- name: connection
value: close
- name: traceparent
value: 00-14481744aa715da81e97014175902b82-9f52ebffe6e56fa2-01
- name: authorization
value: token
REDACTED_5313821e901984ba7bbf1999deafb5f6f722c05ed13b6dfa6cffbd6128089e39
- name: accept-encoding
value: identity
- name: content-type
value: application/json
- name: x-mitm-proxy-name
value: sourcegraph.dotcom
- name: x-mitm-auth-token-name
value: sourcegraph.dotcom
headersSize: 576
httpVersion: HTTP/1.1
method: POST
postData:
mimeType: application/json
params: []
textJSON:
maxTokensToSample: 4000
messages:
- speaker: system
text: "You are Cody, an AI coding assistant from Sourcegraph.If your answer
contains fenced code blocks in Markdown, include the relevant
full file path in the code block tag using this structure:
```$LANGUAGE:$FILEPATH```."
- speaker: human
text: |-
Codebase context from file buzz.ts:
```typescript:buzz.ts
export function fizzbuzz() {
const fizzbuzz = []
for (let i = 1; i <= 100; i++) {
if (i % 15 === 0) {
fizzbuzz.push('FizzBuzz')
} else if (i % 3 === 0) {
fizzbuzz.push('Fizz')
} else if (i % 5 === 0) {
fizzbuzz.push('Buzz')
} else {
fizzbuzz.push(i.toString())
}
}
return fizzbuzz
}
```
- speaker: assistant
text: Ok.
- speaker: human
text: >-
You have access to the provided codebase context. Answer
positively without apologizing.
Question: buzz.ts
model: anthropic/claude-3-5-sonnet-20240620
temperature: 0.2
topK: -1
topP: -1
queryString:
- name: api-version
value: "2"
- name: client-name
value: vscode
- name: client-version
value: 1.34.2
url: https://sourcegraph.com/.api/completions/stream?api-version=2&client-name=vscode&client-version=1.34.2
response:
bodySize: 4759
content:
mimeType: text/event-stream
size: 4759
text: >+
event: completion
data: {"deltaText":"Certainly! I'd be happy to discuss the `buzz.ts` file. This file contains a TypeScript implementation of the classic FizzBuzz problem. Here's a breakdown of what the code does:\n\n1. It exports a function called `fizzbuzz()`.\n2. Inside the function, an empty array called `fizzbuzz` is initialized.\n3. The function uses a for loop to iterate from 1 to 100.\n4. For each number, it applies the FizzBuzz rules:\n - If the number is divisible by both 3 and 5 (i.e., divisible by 15), it adds 'FizzBuzz' to the array.\n - If the number is only divisible by 3, it adds 'Fizz' to the array.\n - If the number is only divisible by 5, it adds 'Buzz' to the array.\n - For any other number, it adds the number itself (as a string) to the array.\n5. Finally, the function returns the completed `fizzbuzz` array.\n\nThis implementation is concise and follows the standard FizzBuzz rules. It's a good example of how to solve this common programming challenge in TypeScript. Would you like me to explain any specific part of the code in more detail or suggest any improvements?","stopReason":"end_turn"}
event: done
data: {}
cookies: []
headers:
- name: date
value: Tue, 17 Sep 2024 04:22:28 GMT
- name: content-type
value: text/event-stream
- name: transfer-encoding
value: chunked
- name: connection
value: close
- name: retry-after
value: "496"
- name: access-control-allow-credentials
value: "true"
- name: access-control-allow-origin
value: ""
- name: cache-control
value: no-cache
- name: vary
value: Cookie,Accept-Encoding,Authorization,Cookie, Authorization,
X-Requested-With,Cookie
- name: x-content-type-options
value: nosniff
- name: x-frame-options
value: DENY
- name: x-xss-protection
value: 1; mode=block
- name: strict-transport-security
value: max-age=31536000; includeSubDomains; preload
headersSize: 1386
httpVersion: HTTP/1.1
redirectURL: ""
status: 200
statusText: OK
startedDateTime: 2024-09-17T04:22:25.509Z
time: 5140
timings:
blocked: -1
connect: -1
dns: -1
receive: 0
send: 0
ssl: -1
wait: 5140
- _id: 28c346c4c160958f92e8f989a1737e5e
_order: 0
cache: {}
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
[
{
"event": {
"action": "selected",
"feature": "cody.at-mention",
"parameters": {
"billingMetadata": {
"category": "core",
"product": "cody"
},
"metadata": [
{
"key": "contextSelection",
"value": 10
},
{
"key": "source",
"value": 1
},
{
"key": "tier",
"value": 1
}
],
"privateMetadata": {
"provider": null,
"source": "chat"
},
"version": 0
},
"signature": "cody.at-mention/selected",
"source": {
"client": "VSCode.Cody",
"clientVersion": "<string>"
},
"timestamp": "<string>"
},
"proxyName": "sourcegraph.dotcom"
},
{
"event": {
"action": "selected",
"feature": "cody.at-mention",
"parameters": {
"billingMetadata": {
"category": "core",
"product": "cody"
},
"metadata": [
{
"key": "contextSelection",
"value": 10
},
{
"key": "provider",
"value": 1
},
{
"key": "source",
"value": 1
},
{
"key": "tier",
"value": 1
}
],
"privateMetadata": {
"provider": "file",
"source": "chat"
},
"version": 0
},
"signature": "cody.at-mention/selected",
"source": {
"client": "VSCode.Cody",
"clientVersion": "<string>"
},
"timestamp": "<string>"
},
"proxyName": "sourcegraph.dotcom"
}
]
Loading

0 comments on commit cdf985b

Please sign in to comment.