Skip to content

Commit

Permalink
feat(onebox): Use new prompt editor when onebox is enabled (#6288)
Browse files Browse the repository at this point in the history
This updates HumanMessageEditor to use the new prompt editor when onebox
is enabled.

## Test plan

Tested locally by enabling the feature flag for myself on S2.
  • Loading branch information
fkling authored Dec 21, 2024
1 parent abf27bb commit b1dbde1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions lib/shared/src/experimentation/FeatureFlagProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export enum FeatureFlag {
CodyExperimentalOneBox = 'cody-experimental-one-box',
/** Enable debug mode for One Box feature in Cody */
CodyExperimentalOneBoxDebug = 'cody-experimental-one-box-debug',
/** Enable use of new prosemirror prompt editor */
CodyExperimentalPromptEditor = 'cody-experimental-prompt-editor',

/** Show Edit Code option in the Cody message submit dropdown */
CodyExperimentalShowEditCodeIntent = 'cody-experimental-show-edit-code-intent',
Expand Down
11 changes: 10 additions & 1 deletion vscode/webviews/AppWrapperForTest.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
type ContextItemSymbol,
EMPTY,
FILE_CONTEXT_MENTION_PROVIDER,
FeatureFlag,
type ModelsData,
type ResolvedConfiguration,
SYMBOL_CONTEXT_MENTION_PROVIDER,
Expand Down Expand Up @@ -79,7 +80,15 @@ export const AppWrapperForTest: FunctionComponent<{ children: ReactNode }> = ({
].filter(f => f.uri.path.includes(queryTextLower)),
}
}),
evaluatedFeatureFlag: _flag => Observable.of(true),
evaluatedFeatureFlag: flag => {
switch (flag) {
case FeatureFlag.CodyExperimentalPromptEditor:
// Do not enable the experimental prompt editor in tests (yet).
return Observable.of(false)
default:
return Observable.of(true)
}
},
prompts: makePromptsAPIWithData({
prompts: FIXTURE_PROMPTS,
commands: FIXTURE_COMMANDS,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
type ChatMessage,
FAST_CHAT_INPUT_TOKEN_BUDGET,
FeatureFlag,
type Model,
ModelTag,
type SerializedPromptEditorState,
Expand All @@ -12,6 +13,7 @@ import {
import {
PromptEditor,
type PromptEditorRefAPI,
PromptEditorV2,
useDefaultContextForChat,
useExtensionAPI,
} from '@sourcegraph/prompt-editor'
Expand All @@ -31,6 +33,7 @@ import { type ClientActionListener, useClientActionListener } from '../../../../
import { promptModeToIntent } from '../../../../../prompts/PromptsTab'
import { useTelemetryRecorder } from '../../../../../utils/telemetry'
import { useExperimentalOneBox } from '../../../../../utils/useExperimentalOneBox'
import { useFeatureFlag } from '../../../../../utils/useFeatureFlags'
import styles from './HumanMessageEditor.module.css'
import type { SubmitButtonState } from './toolbar/SubmitButton'
import { Toolbar } from './toolbar/Toolbar'
Expand Down Expand Up @@ -118,6 +121,7 @@ export const HumanMessageEditor: FunctionComponent<{
? 'emptyEditorValue'
: 'submittable'

const experimentalPromptEditorEnabled = useFeatureFlag(FeatureFlag.CodyExperimentalPromptEditor)
const experimentalOneBoxEnabled = useExperimentalOneBox()
const [submitIntent, setSubmitIntent] = useState<ChatMessage['intent'] | undefined>(
initialIntent || (experimentalOneBoxEnabled ? undefined : 'chat')
Expand Down Expand Up @@ -417,6 +421,7 @@ export const HumanMessageEditor: FunctionComponent<{
currentChatModel?.contextWindow?.context?.user ||
currentChatModel?.contextWindow?.input ||
FAST_CHAT_INPUT_TOKEN_BUDGET
const Editor = experimentalPromptEditorEnabled ? PromptEditorV2 : PromptEditor

return (
// biome-ignore lint/a11y/useKeyWithClickEvents: only relevant to click areas
Expand All @@ -436,7 +441,7 @@ export const HumanMessageEditor: FunctionComponent<{
onFocus={onFocus}
onBlur={onBlur}
>
<PromptEditor
<Editor
seamless={true}
placeholder={placeholder}
initialEditorState={initialEditorState}
Expand Down

0 comments on commit b1dbde1

Please sign in to comment.