Skip to content

Commit

Permalink
Add built-in prompts related fields to prompt select analytic event
Browse files Browse the repository at this point in the history
  • Loading branch information
vovakulikov committed Nov 22, 2024
1 parent 333f40d commit 12c1e76
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/shared/src/sourcegraph-api/graphql/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ export interface Prompt {
description?: string
draft: boolean
autoSubmit?: boolean
builtin?: boolean
mode?: PromptMode
definition: {
text: string
Expand Down
2 changes: 1 addition & 1 deletion vscode/src/prompts/prompts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ async function getLocalCommands(input: LocalCommandsInput): Promise<Action[]> {
// Fetch standards (built-in) prompts from prompts library API
if (remoteBuiltinPrompts) {
const remoteStandardPrompts = await graphqlClient.queryBuiltinPrompts({ query })
return remoteStandardPrompts.map(prompt => ({ ...prompt, actionType: 'prompt' }))
return remoteStandardPrompts.map(prompt => ({ ...prompt, actionType: 'prompt', builtin: true }))
}

// Fallback on local commands (prompts-like or not is controlled by CodyUnifiedPrompts feature flag)
Expand Down
10 changes: 10 additions & 0 deletions vscode/webviews/components/promptList/PromptList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ import type { PromptsInput } from '@sourcegraph/cody-shared'
import { useLocalStorage } from '../../components/hooks'
import styles from './PromptList.module.css'

const BUILT_IN_PROMPTS_CODE: Record<string, number> = {
'document-code': 1,
'explain-code': 2,
'find-code-smells': 3,
'generate-unit-tests': 4,
}

interface PromptListProps {
showSearch: boolean
showFirstNItems?: number
Expand Down Expand Up @@ -91,6 +98,7 @@ export const PromptList: FC<PromptListProps> = props => {
}

const isPrompt = action.actionType === 'prompt'
const isBuiltinPrompt = isPrompt && action.builtin
const isPromptAutoSubmit = action.actionType === 'prompt' && action.autoSubmit
const isCommand = action.actionType === 'command'
const isBuiltInCommand = isCommand && action.type === 'default'
Expand All @@ -99,6 +107,8 @@ export const PromptList: FC<PromptListProps> = props => {
metadata: {
isPrompt: isPrompt ? 1 : 0,
isPromptAutoSubmit: isPromptAutoSubmit ? 1 : 0,
isPromptBuiltin: isBuiltinPrompt ? 1 : 0,
builtinPromptType: isBuiltinPrompt ? BUILT_IN_PROMPTS_CODE[action.name] : 0,
isCommand: isCommand ? 1 : 0,
isCommandBuiltin: isBuiltInCommand ? 1 : 0,
isCommandCustom: !isBuiltInCommand ? 1 : 0,
Expand Down
3 changes: 3 additions & 0 deletions web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 0.14.0
- Add prompts analytics over built-in prompts

## 0.13.0
- Fix openctx mention by mocking Cody Web workspace root
- Disable non-runnable prompts in Cody Web
Expand Down
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sourcegraph/cody-web",
"version": "0.13.0",
"version": "0.14.0",
"description": "Cody standalone web app",
"license": "Apache-2.0",
"repository": {
Expand Down

0 comments on commit 12c1e76

Please sign in to comment.