diff --git a/client/cody-ui/src/Chat.tsx b/client/cody-ui/src/Chat.tsx index ad5239b5aac..e9296795ab2 100644 --- a/client/cody-ui/src/Chat.tsx +++ b/client/cody-ui/src/Chat.tsx @@ -37,6 +37,8 @@ interface ChatProps extends ChatClassNames { copyButtonOnSubmit?: CopyButtonProps['copyButtonOnSubmit'] suggestions?: string[] setSuggestions?: (suggestions: undefined | []) => void + needsEmailVerification?: boolean + needsEmailVerificationNotice?: React.FunctionComponent } interface ChatClassNames extends TranscriptItemClassNames { @@ -51,6 +53,7 @@ export interface ChatUITextAreaProps { autoFocus: boolean value: string required: boolean + disabled?: boolean onInput: React.FormEventHandler onKeyDown?: (event: React.KeyboardEvent, caretPosition: number | null) => void } @@ -117,6 +120,8 @@ export const Chat: React.FunctionComponent = ({ copyButtonOnSubmit, suggestions, setSuggestions, + needsEmailVerification = false, + needsEmailVerificationNotice: NeedsEmailVerificationNotice, }) => { const [inputRows, setInputRows] = useState(5) const [historyIndex, setHistoryIndex] = useState(inputHistory.length) @@ -198,33 +203,45 @@ export const Chat: React.FunctionComponent = ({ ) const transcriptWithWelcome = useMemo( - () => [{ speaker: 'assistant', displayText: welcomeText(afterTips) }, ...transcript], + () => [ + { + speaker: 'assistant', + displayText: welcomeText(afterTips), + }, + ...transcript, + ], [afterTips, transcript] ) return (
- + {needsEmailVerification && NeedsEmailVerificationNotice ? ( +
+ +
+ ) : ( + + )}
{suggestions !== undefined && suggestions.length !== 0 && SuggestionButton ? ( @@ -247,6 +264,7 @@ export const Chat: React.FunctionComponent = ({ value={formInput} autoFocus={true} required={true} + disabled={needsEmailVerification} onInput={({ target }) => { const { value } = target as HTMLInputElement inputHandler(value) @@ -256,7 +274,7 @@ export const Chat: React.FunctionComponent = ({
{contextStatus && ( diff --git a/client/web/src/LegacyLayout.tsx b/client/web/src/LegacyLayout.tsx index 3e105a4bbd4..3ed806fbffc 100644 --- a/client/web/src/LegacyLayout.tsx +++ b/client/web/src/LegacyLayout.tsx @@ -187,18 +187,15 @@ export const LegacyLayout: FC = props => { /> )} - {!isCodyStandalonePage && ( - - )} + {!isCodyStandalonePage && } {!isSiteInit && !isSignInOrUp && !props.isSourcegraphDotCom && !disableFeedbackSurvey && !isCodyStandalonePage && } - {props.isSourcegraphDotCom && props.authenticatedUser && } + {props.isSourcegraphDotCom && props.authenticatedUser && ( + + )} {!isSiteInit && !isSignInOrUp && !isCodyStandalonePage && ( { transcriptId, transcriptHistory, } = useChatStoreState() + const { needsEmailVerification } = useIsCodyEnabled() const [formInput, setFormInput] = useState('') const [inputHistory, setInputHistory] = useState(() => @@ -75,6 +78,8 @@ export const ChatUI = (): JSX.Element => { transcriptActionClassName={styles.transcriptAction} FeedbackButtonsContainer={FeedbackButtons} feedbackButtonsOnSubmit={onFeedbackSubmit} + needsEmailVerification={needsEmailVerification} + needsEmailVerificationNotice={NeedsEmailVerificationNotice} /> ) } @@ -164,8 +169,10 @@ export const AutoResizableTextArea: React.FC = ({ onInput, onKeyDown, className, + disabled = false, }) => { const { inputNeedsFocus, setFocusProvided } = useCodySidebarStore() + const { needsEmailVerification } = useIsCodyEnabled() const textAreaRef = useRef(null) const { width = 0 } = useResizeObserver({ ref: textAreaRef }) @@ -202,16 +209,37 @@ export const AutoResizableTextArea: React.FC = ({ } return ( -