Skip to content

Commit

Permalink
fix issue where natural language search panel disappears instead of s…
Browse files Browse the repository at this point in the history
…howing results (#2981)

It was not initializing its environment with the VS Code workspace root
folders to generate accurate workspace-relative paths. I forgot to add
that to the search webview entrypoint (only added it to the chat webview
entrypoint).

Confirmed working:


![image](https://github.com/sourcegraph/cody/assets/1976/64b79d46-8b85-49c7-a4b4-1bdb3eb70d36)


## Test plan

Run a natural language search and confirm you see results instead of the
webview disappearing.
  • Loading branch information
sqs committed Jan 31, 2024
1 parent 36a46a8 commit eeb4ae6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@ This is a log of all notable changes to Cody for VS Code. [Unreleased] changes a

### Added

- Chat: Display Cody icon in the editor title of the chat panels when `cody.editorTitleCommandIcon` is enabled. [pull/2937](https://github.com/sourcegraph/cody/pull/2937)
- Edit: Improved the input UX. You can now adjust the range of the Edit, select from available symbols in the document, and get quick access to the "Document" and "Test" commands. [pull/2884](https://github.com/sourcegraph/cody/pull/2884)
- Edit: Added new keyboard shortcuts for Edit (`Alt+K`) and Chat (`Alt+L`). [pull/2865](https://github.com/sourcegraph/cody/pull/2865)
- Edit/Chat: Added "ghost" text alongside code to showcase Edit and Chat commands. Enable it by setting `cody.commandHints.enabled` to true. [pull/2865](https://github.com/sourcegraph/cody/pull/2865)
- Autocomplete: local inference support with [deepseek-coder](https://ollama.ai/library/deepseek-coder) powered by ollama. [pull/2966](https://github.com/sourcegraph/cody/pull/2966)
- Autocomplete: Add a new experimental fast-path mode for Cody community users that directly connections to our inference services. [pull/2927](https://github.com/sourcegraph/cody/pull/2927)

### Fixed

- Fixed an issue where the natural language search panel would disappear instead of showing results. [pull/2981](https://github.com/sourcegraph/cody/pull/2981)

### Changed

## [1.2.1]
Expand Down
4 changes: 4 additions & 0 deletions vscode/src/chat/protocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ export type ExtensionMessage =
authStatus: AuthStatus
workspaceFolderUris: string[]
}
| {
type: 'search:config'
workspaceFolderUris: string[]
}
| { type: 'history'; messages: UserLocalHistory | null }
| ({ type: 'transcript' } & ExtensionTranscriptMessage)
| { type: 'view'; messages: View }
Expand Down
10 changes: 9 additions & 1 deletion vscode/src/search/SearchViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
type SearchPanelSnippet,
} from '@sourcegraph/cody-shared'

import type { WebviewMessage } from '../chat/protocol'
import type { ExtensionMessage, WebviewMessage } from '../chat/protocol'
import { getEditor } from '../editor/active-editor'
import type { IndexStartEvent, SymfRunner } from '../local-context/symf'

Expand Down Expand Up @@ -293,6 +293,14 @@ export class SearchViewProvider implements vscode.WebviewViewProvider, vscode.Di
return
}

// Update the config. We could do this on a smarter schedule, but this suffices for when the
// webview needs it for now.
this.webview?.postMessage({
type: 'search:config',
workspaceFolderUris:
vscode.workspace.workspaceFolders?.map(folder => folder.uri.toString()) ?? [],
} satisfies ExtensionMessage)

await vscode.window.withProgress({ location: { viewId: 'cody.search' } }, async () => {
const cumulativeResults: SearchPanelFile[] = []
this.indexManager.showMessageIfIndexingInProgress(scopeDirs)
Expand Down
4 changes: 4 additions & 0 deletions vscode/webviews/SearchPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { displayPathBasename, displayPathDirname, type SearchPanelFile } from '@
import type { VSCodeWrapper } from './utils/VSCodeApi'

import styles from './SearchPanel.module.css'
import { updateDisplayPathEnvInfoForWebview } from './utils/displayPathEnvInfo'

const SEARCH_DEBOUNCE_MS = 400

Expand Down Expand Up @@ -107,6 +108,9 @@ export const SearchPanel: React.FunctionComponent<{ vscodeAPI: VSCodeWrapper }>
resultsCache.clear()
break
}
case 'search:config':
updateDisplayPathEnvInfoForWebview(message.workspaceFolderUris)
break
}
})
}, [vscodeAPI, resultsCache, query])
Expand Down

0 comments on commit eeb4ae6

Please sign in to comment.