From 8a938a6ad76dea002eecd38b6c4295e7608ea5dd Mon Sep 17 00:00:00 2001 From: Vova Kulikov Date: Fri, 15 Nov 2024 13:04:53 -0300 Subject: [PATCH 1/6] Fix Cody Web workspace URI (provide non-empty mock value) --- web/lib/agent/agent.client.ts | 7 ++++--- web/lib/components/CodyWebChat.tsx | 2 +- web/lib/components/use-cody-agent.ts | 1 - 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/web/lib/agent/agent.client.ts b/web/lib/agent/agent.client.ts index 5edf09abd454..26311041872c 100644 --- a/web/lib/agent/agent.client.ts +++ b/web/lib/agent/agent.client.ts @@ -19,7 +19,6 @@ interface AgentClientOptions { serverEndpoint: string accessToken: string createAgentWorker: () => Worker - workspaceRootUri: string telemetryClientName?: string customHeaders?: Record debug?: boolean @@ -30,7 +29,6 @@ export async function createAgentClient({ serverEndpoint, accessToken, createAgentWorker, - workspaceRootUri, customHeaders, telemetryClientName, debug = true, @@ -70,8 +68,11 @@ export async function createAgentClient({ const serverInfo: ServerInfo = await rpc.sendRequest('initialize', { name: process.env.CODY_WEB_DEMO ? 'standalone-web' : 'web', version: '0.0.1', - workspaceRootUri, + // Empty root URI leads to openctx configuration resolution failure, any non-empty + // mock value (Cody Web doesn't really use any workspace related features) + workspaceRootUri: 'sourcegraph/cody', capabilities: { + edit: 'none', completions: 'none', webview: 'agentic', disabledMentionsProviders: [FILE_CONTEXT_MENTION_PROVIDER.id], diff --git a/web/lib/components/CodyWebChat.tsx b/web/lib/components/CodyWebChat.tsx index f72640ca0267..ea93c84a784b 100644 --- a/web/lib/components/CodyWebChat.tsx +++ b/web/lib/components/CodyWebChat.tsx @@ -39,7 +39,7 @@ import { ChatSkeleton } from './skeleton/ChatSkeleton' // the cody agent properly (completely mock data) setDisplayPathEnvInfo({ isWindows: false, - workspaceFolders: [URI.file('/tmp/foo')], + workspaceFolders: [], }) export interface CodyWebChatProps { diff --git a/web/lib/components/use-cody-agent.ts b/web/lib/components/use-cody-agent.ts index 90bddf46021f..8c84d501f5e2 100644 --- a/web/lib/components/use-cody-agent.ts +++ b/web/lib/components/use-cody-agent.ts @@ -62,7 +62,6 @@ export function useCodyWebAgent(input: UseCodyWebAgentInput): UseCodyWebAgentRes customHeaders, telemetryClientName, createAgentWorker, - workspaceRootUri: '', serverEndpoint: serverEndpoint, accessToken: accessToken ?? '', }) From 22471ef63edced898e2f38c5ef0a0eb04fa36931 Mon Sep 17 00:00:00 2001 From: Vova Kulikov Date: Fri, 15 Nov 2024 13:12:22 -0300 Subject: [PATCH 2/6] Fix prompt editor placeholder text --- lib/prompt-editor/src/PromptEditor.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/prompt-editor/src/PromptEditor.tsx b/lib/prompt-editor/src/PromptEditor.tsx index 5d7da092b745..74681e3cc85b 100644 --- a/lib/prompt-editor/src/PromptEditor.tsx +++ b/lib/prompt-editor/src/PromptEditor.tsx @@ -256,7 +256,12 @@ export const PromptEditor: FunctionComponent = ({ const nodesToInsert = lexicalNodesForContextItems(items, { isFromInitialContext: true, }) - nodesToInsert.push($createTextNode(' ')) + + // Add whitespace after initial context items chips + if (items.length > 0) { + nodesToInsert.push($createTextNode(' ')) + } + $setSelection($getRoot().selectStart()) // insert at start $insertNodes(nodesToInsert) $selectEnd() From dc152ffcecea0ea54906cc240ca0eac296b5d58d Mon Sep 17 00:00:00 2001 From: Vova Kulikov Date: Fri, 15 Nov 2024 13:40:04 -0300 Subject: [PATCH 3/6] Disabled non-runnable edit-like prompts if edit is disabled --- lib/shared/src/configuration/clientCapabilities.ts | 2 +- vscode/webviews/chat/components/WelcomeMessage.tsx | 6 +++--- vscode/webviews/components/promptList/ActionItem.tsx | 7 +++++++ vscode/webviews/components/promptList/PromptList.tsx | 2 +- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/shared/src/configuration/clientCapabilities.ts b/lib/shared/src/configuration/clientCapabilities.ts index 8667728f9912..0fdeba5282a1 100644 --- a/lib/shared/src/configuration/clientCapabilities.ts +++ b/lib/shared/src/configuration/clientCapabilities.ts @@ -9,7 +9,7 @@ import type { ContextMentionProviderID } from '../mentions/api' * {@link ClientCapabilitiesWithLegacyFields.agentIDE} that are inferred in an ad-hoc way from the * environment and aren't self-reported by the client. */ -export interface ClientCapabilitiesWithLegacyFields { +export interface ClientCapabilitiesWithLegacyFields extends ClientCapabilities { /** * The `agentIDE` value, which is the editor that Cody is being used with. If not set, it * defaults to {@link CodyIDE.VSCode} to match the previous behavior. diff --git a/vscode/webviews/chat/components/WelcomeMessage.tsx b/vscode/webviews/chat/components/WelcomeMessage.tsx index f8c9a113a097..ab66232359cf 100644 --- a/vscode/webviews/chat/components/WelcomeMessage.tsx +++ b/vscode/webviews/chat/components/WelcomeMessage.tsx @@ -40,12 +40,12 @@ export const WelcomeMessage: FunctionComponent = ({ runAction(item, setView)} /> diff --git a/vscode/webviews/components/promptList/ActionItem.tsx b/vscode/webviews/components/promptList/ActionItem.tsx index e4726caf20b5..b02d98112fe6 100644 --- a/vscode/webviews/components/promptList/ActionItem.tsx +++ b/vscode/webviews/components/promptList/ActionItem.tsx @@ -26,6 +26,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '../../components/shadcn import { commandRowValue } from './utils' import styles from './ActionItem.module.css' +import { useConfig } from '../../utils/useConfig'; interface ActionItemProps { action: Action @@ -35,10 +36,16 @@ interface ActionItemProps { export const ActionItem: FC = props => { const { action, className, onSelect } = props + const { clientCapabilities } = useConfig() + const isEditEnabled = clientCapabilities.edit !== 'none' + const isActionEditLike = action.actionType === 'prompt' + ? action.mode !== 'CHAT' + : action.mode !== 'ask' return ( diff --git a/vscode/webviews/components/promptList/PromptList.tsx b/vscode/webviews/components/promptList/PromptList.tsx index 7f41b789a0cc..5a0382edf48c 100644 --- a/vscode/webviews/components/promptList/PromptList.tsx +++ b/vscode/webviews/components/promptList/PromptList.tsx @@ -24,7 +24,7 @@ import styles from './PromptList.module.css' interface PromptListProps { showSearch: boolean showFirstNItems?: number - telemetryLocation: 'PromptSelectField' | 'PromptsTab' + telemetryLocation: 'PromptSelectField' | 'PromptsTab' | 'WelcomeAreaPrompts' showOnlyPromptInsertableCommands?: boolean showCommandOrigins?: boolean showPromptLibraryUnsupportedMessage?: boolean From 857febbd8510a59e06383c86952c990fd20fd4fa Mon Sep 17 00:00:00 2001 From: Vova Kulikov Date: Fri, 15 Nov 2024 17:00:41 -0300 Subject: [PATCH 4/6] Run pnpm biome --- vscode/webviews/components/promptList/ActionItem.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/vscode/webviews/components/promptList/ActionItem.tsx b/vscode/webviews/components/promptList/ActionItem.tsx index b02d98112fe6..e470eebad7fc 100644 --- a/vscode/webviews/components/promptList/ActionItem.tsx +++ b/vscode/webviews/components/promptList/ActionItem.tsx @@ -25,8 +25,8 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '../../components/shadcn import { commandRowValue } from './utils' +import { useConfig } from '../../utils/useConfig' import styles from './ActionItem.module.css' -import { useConfig } from '../../utils/useConfig'; interface ActionItemProps { action: Action @@ -38,9 +38,8 @@ export const ActionItem: FC = props => { const { action, className, onSelect } = props const { clientCapabilities } = useConfig() const isEditEnabled = clientCapabilities.edit !== 'none' - const isActionEditLike = action.actionType === 'prompt' - ? action.mode !== 'CHAT' - : action.mode !== 'ask' + const isActionEditLike = + action.actionType === 'prompt' ? action.mode !== 'CHAT' : action.mode !== 'ask' return ( Date: Fri, 15 Nov 2024 17:24:04 -0300 Subject: [PATCH 5/6] Add tooltip support for disabled actions/prompts --- .../components/promptList/ActionItem.module.css | 11 +++++++++++ vscode/webviews/components/promptList/ActionItem.tsx | 8 +++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/vscode/webviews/components/promptList/ActionItem.module.css b/vscode/webviews/components/promptList/ActionItem.module.css index 2b969b0c3688..a50d6422f753 100644 --- a/vscode/webviews/components/promptList/ActionItem.module.css +++ b/vscode/webviews/components/promptList/ActionItem.module.css @@ -19,6 +19,17 @@ color: inherit; } } + + &[data-disabled="true"] { + /* + In order to override internal cmdk styles for disabled item. + We need to have events over element to have a tooltip over the + element on hover/focus. + */ + pointer-events: auto !important; + background-color: transparent; + cursor: not-allowed; + } } .prompt { diff --git a/vscode/webviews/components/promptList/ActionItem.tsx b/vscode/webviews/components/promptList/ActionItem.tsx index e470eebad7fc..0f25be141d87 100644 --- a/vscode/webviews/components/promptList/ActionItem.tsx +++ b/vscode/webviews/components/promptList/ActionItem.tsx @@ -40,12 +40,18 @@ export const ActionItem: FC = props => { const isEditEnabled = clientCapabilities.edit !== 'none' const isActionEditLike = action.actionType === 'prompt' ? action.mode !== 'CHAT' : action.mode !== 'ask' + const isDisabled = !isEditEnabled && isActionEditLike return ( {action.actionType === 'prompt' ? ( From 0de738debd1e77b90c97b99e6ef2b5ead878bdf2 Mon Sep 17 00:00:00 2001 From: Vova Kulikov Date: Fri, 15 Nov 2024 17:24:13 -0300 Subject: [PATCH 6/6] Update version --- web/CHANGELOG.md | 5 +++++ web/package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/web/CHANGELOG.md b/web/CHANGELOG.md index 3e43da7dd748..30eadb63b01b 100644 --- a/web/CHANGELOG.md +++ b/web/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.13.0 +- Fix openctx mention by mocking Cody Web workspace root +- Disable non-runnable prompts in Cody Web +- Fix prompt editor placeholder + ## 0.11.0 - Support an external API for Cody Panel functionality (now you can trigger running prompts outside of Cody Web component) diff --git a/web/package.json b/web/package.json index 3c05fce76526..3bb1830049e0 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "@sourcegraph/cody-web", - "version": "0.12.0", + "version": "0.13.0", "description": "Cody standalone web app", "license": "Apache-2.0", "repository": {