Skip to content

Commit

Permalink
different agentIDE for Cody Web vs. this repo's standalone web/
Browse files Browse the repository at this point in the history
`CodyIDE.Web` previously referred to both (1) Cody Web, i.e., the Cody sidebar in Sourcegraph Code Search and the Cody chat page, and (2) this repo's `web/` demo app. They are different and have different needs. It is generally bad to change behavior based on the identity (as opposed to capabilities) of the client, which will be addressed in #5889 and beyond, but for now, it's helpful for them to report different client identities.
  • Loading branch information
sqs committed Oct 15, 2024
1 parent d21f7c0 commit 5f7580f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions agent/src/AgentWorkspaceConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class AgentWorkspaceConfiguration implements vscode.WorkspaceConfiguratio
return CodyIDE.VisualStudio
case 'eclipse':
return CodyIDE.Eclipse
case 'standalone-web':
return CodyIDE.StandaloneWeb
default:
return undefined
}
Expand Down
2 changes: 1 addition & 1 deletion lib/shared/src/auth/referral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { clientCapabilities } from '../configuration/clientCapabilities'
* Use "CODY" as the default referral code for fallback.
*/
export function getCodyAuthReferralCode(uriScheme: string): string | undefined {
const referralCodes: Record<CodyIDE, string> = {
const referralCodes: Partial<Record<CodyIDE, string>> = {
[CodyIDE.JetBrains]: 'JETBRAINS',
[CodyIDE.Neovim]: 'NEOVIM',
[CodyIDE.Emacs]: 'CODY',
Expand Down
5 changes: 5 additions & 0 deletions lib/shared/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,11 @@ export enum CodyIDE {
Web = 'Web',
VisualStudio = 'VisualStudio',
Eclipse = 'Eclipse',

/**
* The standalone web client in the Cody repository's `web/` tree.
*/
StandaloneWeb = 'StandaloneWeb',
}

export type AutocompleteProviderID = keyof typeof AUTOCOMPLETE_PROVIDER_ID
Expand Down
10 changes: 2 additions & 8 deletions vscode/webviews/components/MarkdownFromCody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,22 +77,16 @@ function wrapLinksWithCodyOpenCommand(url: string): string {
return `command:_cody.vscode.open?${encodedURL}`
}

const URL_PROCESSORS: Record<CodyIDE, UrlTransform> = {
[CodyIDE.Web]: defaultUrlProcessor,
[CodyIDE.JetBrains]: defaultUrlProcessor,
[CodyIDE.Neovim]: defaultUrlProcessor,
[CodyIDE.Emacs]: defaultUrlProcessor,
const URL_PROCESSORS: Partial<Record<CodyIDE, UrlTransform>> = {
[CodyIDE.VSCode]: wrapLinksWithCodyOpenCommand,
[CodyIDE.VisualStudio]: defaultUrlProcessor,
[CodyIDE.Eclipse]: defaultUrlProcessor,
}

export const MarkdownFromCody: FunctionComponent<{ className?: string; children: string }> = ({
className,
children,
}) => {
const clientType = useConfig().clientCapabilities.agentIDE
const urlTransform = useMemo(() => URL_PROCESSORS[clientType], [clientType])
const urlTransform = useMemo(() => URL_PROCESSORS[clientType] ?? defaultUrlProcessor, [clientType])

return (
<Markdown className={className} {...markdownPluginProps()} urlTransform={urlTransform}>
Expand Down
3 changes: 2 additions & 1 deletion web/lib/agent/agent.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ export async function createAgentClient({

// Initialize
const serverInfo: ServerInfo = await rpc.sendRequest('initialize', {
name: 'web',
name: 'standalone-web',
version: '0.0.1',
workspaceRootUri,
capabilities: {
completions: 'none',
webview: 'agentic',
disabledMentionsProviders: [FILE_CONTEXT_MENTION_PROVIDER.id],
authentication: 'none',
},
extensionConfiguration: {
accessToken,
Expand Down

0 comments on commit 5f7580f

Please sign in to comment.