mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
Show Cody walkthrough help text (#54175)
This commit is contained in:
parent
8938538cf5
commit
e881424beb
@ -2,6 +2,14 @@ import { marked } from 'marked'
|
||||
|
||||
import { registerHighlightContributions, renderMarkdown as renderMarkdownCommon } from '@sourcegraph/common'
|
||||
|
||||
/**
|
||||
* Supported URIs to render as links in outputted markdown.
|
||||
* - https?: Web
|
||||
* - vscode: VS Code URL scheme (open in editor)
|
||||
* - command:cody.welcome: VS Code command scheme exception we add to support directly linking to the welcome guide from within the chat.
|
||||
*/
|
||||
const ALLOWED_URI_REGEXP = /^((https?|vscode):\/\/[^\s#$./?].\S*|command:cody.welcome)$/i
|
||||
|
||||
const DOMPURIFY_CONFIG = {
|
||||
ALLOWED_TAGS: [
|
||||
'p',
|
||||
@ -35,7 +43,7 @@ const DOMPURIFY_CONFIG = {
|
||||
's',
|
||||
'u',
|
||||
],
|
||||
ALLOWED_URI_REGEXP: /^(https?|vscode):\/\/[^\s#$./?].\S*$/i,
|
||||
ALLOWED_URI_REGEXP,
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -30,7 +30,8 @@ interface ChatProps extends ChatClassNames {
|
||||
submitButtonComponent: React.FunctionComponent<ChatUISubmitButtonProps>
|
||||
suggestionButtonComponent?: React.FunctionComponent<ChatUISuggestionButtonProps>
|
||||
fileLinkComponent: React.FunctionComponent<FileLinkProps>
|
||||
afterTips?: string
|
||||
helpMarkdown?: string
|
||||
afterMarkdown?: string
|
||||
className?: string
|
||||
EditButtonContainer?: React.FunctionComponent<EditButtonProps>
|
||||
editButtonOnSubmit?: (text: string) => void
|
||||
@ -110,7 +111,8 @@ export const Chat: React.FunctionComponent<ChatProps> = ({
|
||||
submitButtonComponent: SubmitButton,
|
||||
suggestionButtonComponent: SuggestionButton,
|
||||
fileLinkComponent,
|
||||
afterTips,
|
||||
helpMarkdown,
|
||||
afterMarkdown,
|
||||
className,
|
||||
codeBlocksCopyButtonClassName,
|
||||
codeBlocksInsertButtonClassName,
|
||||
@ -227,11 +229,11 @@ export const Chat: React.FunctionComponent<ChatProps> = ({
|
||||
() => [
|
||||
{
|
||||
speaker: 'assistant',
|
||||
displayText: welcomeText(afterTips),
|
||||
displayText: welcomeText({ helpMarkdown, afterMarkdown }),
|
||||
},
|
||||
...transcript,
|
||||
],
|
||||
[afterTips, transcript]
|
||||
[helpMarkdown, afterMarkdown, transcript]
|
||||
)
|
||||
|
||||
return (
|
||||
@ -317,11 +319,18 @@ export const Chat: React.FunctionComponent<ChatProps> = ({
|
||||
)
|
||||
}
|
||||
|
||||
function welcomeText(afterTips?: string): string {
|
||||
return [
|
||||
"Hello! I'm Cody. I can write code and answer questions for you. See [Cody documentation](https://docs.sourcegraph.com/cody) for help and tips.",
|
||||
afterTips,
|
||||
]
|
||||
interface WelcomeTextOptions {
|
||||
/** Provide users with a way to quickly access Cody docs/help.*/
|
||||
helpMarkdown?: string
|
||||
/** Provide additional content to supplement the original message. Example: tips, privacy policy. */
|
||||
afterMarkdown?: string
|
||||
}
|
||||
|
||||
function welcomeText({
|
||||
helpMarkdown = 'See [Cody documentation](https://docs.sourcegraph.com/cody) for help and tips.',
|
||||
afterMarkdown,
|
||||
}: WelcomeTextOptions): string {
|
||||
return ["Hello! I'm Cody. I can write code and answer questions for you. " + helpMarkdown, afterMarkdown]
|
||||
.filter(isDefined)
|
||||
.join('\n\n')
|
||||
}
|
||||
|
||||
@ -42,7 +42,7 @@ export const Chat: React.FunctionComponent<
|
||||
textAreaComponent={TextArea}
|
||||
submitButtonComponent={SubmitButton}
|
||||
fileLinkComponent={FileLink}
|
||||
afterTips={CODY_TERMS_MARKDOWN}
|
||||
afterMarkdown={CODY_TERMS_MARKDOWN}
|
||||
transcriptItemClassName={styles.transcriptItem}
|
||||
humanTranscriptItemClassName={styles.humanTranscriptItem}
|
||||
transcriptItemParticipantClassName={styles.transcriptItemParticipant}
|
||||
|
||||
@ -37,6 +37,7 @@ Starting from `0.2.0`, Cody is using `major.EVEN_NUMBER.patch` for release versi
|
||||
- New sign-in and sign-out flow. [pull/53434](https://github.com/sourcegraph/sourcegraph/pull/53434)
|
||||
- Analytical logs are now displayed in the Output view. [pull/53870](https://github.com/sourcegraph/sourcegraph/pull/53870)
|
||||
- Renamed Inline Assist to Inline Chat. [pull/53725](https://github.com/sourcegraph/sourcegraph/pull/53725)
|
||||
- Chat: Link to the "Getting Started" guide directly from the first chat message instead of the external documentation website. [pull/54175](https://github.com/sourcegraph/sourcegraph/pull/54175)
|
||||
|
||||
## [0.2.5]
|
||||
|
||||
|
||||
@ -833,6 +833,7 @@ export class ChatViewProvider implements vscode.WebviewViewProvider, vscode.Disp
|
||||
webviewView.webview.options = {
|
||||
enableScripts: true,
|
||||
localResourceRoots: [webviewPath],
|
||||
enableCommandUris: true,
|
||||
}
|
||||
|
||||
// Create Webview using client/cody/index.html
|
||||
|
||||
@ -242,7 +242,17 @@ const register = async (
|
||||
vscode.commands.registerCommand('cody.feedback', () =>
|
||||
vscode.env.openExternal(vscode.Uri.parse(CODY_FEEDBACK_URL.href))
|
||||
),
|
||||
vscode.commands.registerCommand('cody.welcome', () =>
|
||||
vscode.commands.registerCommand('cody.welcome', async () => {
|
||||
// Hack: We have to run this twice to force VS Code to register the walkthrough
|
||||
// Open issue: https://github.com/microsoft/vscode/issues/186165
|
||||
await vscode.commands.executeCommand('workbench.action.openWalkthrough')
|
||||
return vscode.commands.executeCommand(
|
||||
'workbench.action.openWalkthrough',
|
||||
'sourcegraph.cody-ai#welcome',
|
||||
false
|
||||
)
|
||||
}),
|
||||
vscode.commands.registerCommand('cody.welcome-mock', () =>
|
||||
vscode.commands.executeCommand('workbench.action.openWalkthrough', 'sourcegraph.cody-ai#welcome', false)
|
||||
),
|
||||
vscode.commands.registerCommand('cody.walkthrough.showLogin', () =>
|
||||
|
||||
@ -128,6 +128,7 @@ export const Chat: React.FunctionComponent<React.PropsWithChildren<ChatboxProps>
|
||||
// down here to render cody is disabled on the instance nicely.
|
||||
isCodyEnabled={true}
|
||||
codyNotEnabledNotice={undefined}
|
||||
helpMarkdown="See [Getting Started](command:cody.welcome) for help and tips."
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ export const ChatUI: React.FC<IChatUIProps> = ({ codyChatStore, isSourcegraphApp
|
||||
submitButtonComponent={SubmitButton}
|
||||
fileLinkComponent={isSourcegraphApp ? AppFileLink : FileLink}
|
||||
className={styles.container}
|
||||
afterTips={transcriptHistory.length > 1 ? '' : CODY_TERMS_MARKDOWN}
|
||||
afterMarkdown={transcriptHistory.length > 1 ? '' : CODY_TERMS_MARKDOWN}
|
||||
transcriptItemClassName={styles.transcriptItem}
|
||||
humanTranscriptItemClassName={styles.humanTranscriptItem}
|
||||
transcriptItemParticipantClassName="text-muted"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user