Skip to content

Commit 7882437

Browse files
committed
Integrate WebSocket manager into file search and selection commands to support chatbot autofill
- add missing translations [Fragment] - 'Intelligent' search should allow options: "Make API call", "Autofill in chatbot", "Copy prompt". Make sure files are formatted using markdown, not xml. For "Autofill in chatbot", "Copy prompt" use 'for prompt view' instructions. - in some cases 'websocket manager' is not provided to 'search_files' - last used chatbot configuration for the intelligent search autofill should use separate state key - it's been reported that there are too many empty lines above "# Output formatting" └── apps └── editor └── src ├── commands │ ├── generate-commit-message-commands │ │ ├── actions │ │ │ ├── get-prompt-data.ts │ │ │ └── run-generate-action.ts │ │ ├── generate-commit-message-commands.ts │ │ ├── index.ts │ │ └── utils │ │ ├── build-commit-message-prompt.ts │ │ ├── generate-commit-message-with-api.ts │ │ ├── get-commit-message-config.ts │ │ └── strip-wrapping-quotes.ts │ ├── search-files-commands.ts │ ├── select-changed-files-command.ts │ ├── select-clipboard-paths-command.ts │ ├── select-commit-files-command.ts │ ├── select-imported-files-command.ts │ ├── select-imported-files-for-selected-command.ts │ ├── select-referencing-files-commands │ │ ├── index.ts │ │ ├── select-referencing-files-commands.ts │ │ └── utils │ │ ├── get-referencing-files-for-position.ts │ │ ├── get-referencing-files-for-uris.ts │ │ └── prompt-for-referencing-files.ts │ └── select-unstaged-files-command.ts ├── constants │ ├── instructions.ts │ └── state-keys.ts ├── extension.ts ├── features │ ├── imported-files │ │ ├── index.ts │ │ └── utils │ │ ├── get-imports-for-uri.ts │ │ ├── is-valid-uri.ts │ │ └── prompt-for-imported-files.ts │ └── search-files │ ├── index.ts │ ├── search-files.ts │ ├── search-modes │ │ ├── perform-intelligent-search-mode.ts │ │ ├── perform-keywords-search-mode.ts │ │ ├── perform-phrase-search-mode.ts │ │ └── perform-semantic-search-mode.ts │ └── utils │ ├── analyze-files.ts │ ├── check-matches-condition.ts │ ├── create-search-regex.ts │ ├── group-quick-pick-items.ts │ ├── handle-parent-folder-result.ts │ ├── map-files-to-quick-pick-items.ts │ ├── prompt-for-config.ts │ ├── prompt-for-intelligent-search-results.ts │ ├── prompt-for-keywords-match-mode.ts │ ├── prompt-for-keywords-target.ts │ ├── prompt-for-provided-results.ts │ ├── prompt-for-search-mode.ts │ ├── prompt-for-search-results.ts │ ├── prompt-for-search-term.ts │ ├── prompt-for-shrink-mode.ts │ ├── search-files-by-intelligent.ts │ ├── search-files-by-keywords.ts │ ├── search-files-by-phrase.ts │ └── search-files-by-semantic.ts ├── i18n │ └── translations │ ├── commands │ │ ├── generate-commit-message.ts │ │ └── search-files.ts │ └── features │ └── search-files.ts ├── utils │ └── files-collector.ts └── views └── prompt └── backend └── message-handlers └── handle-copy-prompt.ts
1 parent bcc871e commit 7882437

15 files changed

Lines changed: 442 additions & 122 deletions

‎apps/editor/src/commands/search-files-commands.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { WorkspaceProvider } from '../context/providers/workspace/workspace-prov
55
import { Logger } from '@shared/utils/logger'
66
import { t } from '@/i18n'
77
import { search_files } from '@/features/search-files'
8+
import { WebSocketManager } from '@/services/websocket-manager'
89
import { prompt_for_provided_results } from '@/features/search-files/utils/prompt-for-provided-results'
910

1011
export const get_target_folder_path = async (
@@ -26,7 +27,8 @@ export const get_target_folder_path = async (
2627

2728
export const search_files_commands = (
2829
workspace_provider: WorkspaceProvider,
29-
extension_context: vscode.ExtensionContext
30+
extension_context: vscode.ExtensionContext,
31+
websocket_manager: WebSocketManager
3032
) => {
3133
const search_handler = async (item?: any) => {
3234
const folder_path = await get_target_folder_path(item)
@@ -53,7 +55,8 @@ export const search_files_commands = (
5355
const result = await search_files({
5456
get_files: get_files_lazy,
5557
workspace_provider,
56-
extension_context
58+
extension_context,
59+
websocket_manager
5760
})
5861

5962
if (!result || result == 'back') return
@@ -132,6 +135,7 @@ export const search_files_commands = (
132135
get_files: async () => result.matched_paths,
133136
workspace_provider,
134137
extension_context,
138+
websocket_manager,
135139
show_back_button: true,
136140
is_sub_search: true
137141
})

‎apps/editor/src/commands/select-changed-files-command.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,12 @@ import { dictionary } from '@shared/constants/dictionary'
99
import { t } from '@/i18n'
1010
import { display_token_count } from '@/utils/display-token-count'
1111
import { search_files } from '@/features/search-files'
12+
import { WebSocketManager } from '@/services/websocket-manager'
1213

1314
export const select_changed_files_command = (
1415
workspace_provider: WorkspaceProvider,
15-
extension_context: vscode.ExtensionContext
16+
extension_context: vscode.ExtensionContext,
17+
websocket_manager: WebSocketManager
1618
): vscode.Disposable => {
1719
return vscode.commands.registerCommand(
1820
'codeWebChat.selectChangedFiles',
@@ -293,6 +295,7 @@ export const select_changed_files_command = (
293295
get_files: async () => valid_files.map((f) => f.absolute_path),
294296
workspace_provider,
295297
extension_context,
298+
websocket_manager,
296299
show_back_button: true,
297300
disable_semantic: true
298301
})

‎apps/editor/src/commands/select-clipboard-paths-command.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ import { t } from '@/i18n'
88
import { Logger } from '@shared/utils/logger'
99
import { extract_paths_from_text } from '@/utils/extract-paths-from-text'
1010
import { search_files } from '@/features/search-files'
11+
import { WebSocketManager } from '@/services/websocket-manager'
1112

1213
export const select_clipboard_paths_command = (
1314
workspace_provider: WorkspaceProvider,
14-
extension_context: vscode.ExtensionContext
15+
extension_context: vscode.ExtensionContext,
16+
websocket_manager: WebSocketManager
1517
) => {
1618
return vscode.commands.registerCommand(
1719
'codeWebChat.selectClipboardPaths',
@@ -280,6 +282,7 @@ export const select_clipboard_paths_command = (
280282
get_files: async () => absolute_paths,
281283
workspace_provider,
282284
extension_context,
285+
websocket_manager,
283286
show_back_button: true,
284287
disable_semantic: true
285288
})

‎apps/editor/src/commands/select-commit-files-command.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ import { t } from '@/i18n'
1111
import { display_token_count } from '@/utils/display-token-count'
1212
import { search_files } from '@/features/search-files'
1313
import { AsciiTree } from '@/utils/ascii-tree'
14+
import { WebSocketManager } from '@/services/websocket-manager'
1415

1516
export const select_commit_files_command = (
1617
workspace_provider: WorkspaceProvider,
17-
extension_context: vscode.ExtensionContext
18+
extension_context: vscode.ExtensionContext,
19+
websocket_manager: WebSocketManager
1820
): vscode.Disposable => {
1921
return vscode.commands.registerCommand(
2022
'codeWebChat.selectCommitFiles',
@@ -288,6 +290,7 @@ export const select_commit_files_command = (
288290
get_files: async () => valid_files.map((f) => f.absolute_path),
289291
workspace_provider,
290292
extension_context,
293+
websocket_manager,
291294
show_back_button: true,
292295
disable_semantic: true
293296
})

‎apps/editor/src/commands/select-imported-files-command.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import * as vscode from 'vscode'
22
import { WorkspaceProvider } from '../context/providers/workspace/workspace-provider'
33
import { prompt_for_imported_files } from '@/features/imported-files'
44
import { t } from '@/i18n'
5+
import { WebSocketManager } from '@/services/websocket-manager'
56

67
export const select_imported_files_command = (
78
workspace_provider: WorkspaceProvider,
8-
extension_context: vscode.ExtensionContext
9+
extension_context: vscode.ExtensionContext,
10+
websocket_manager: WebSocketManager
911
) => {
1012
return vscode.commands.registerCommand(
1113
'codeWebChat.selectImportedFiles',
@@ -41,7 +43,8 @@ export const select_imported_files_command = (
4143
const result = await prompt_for_imported_files({
4244
starting_uris,
4345
workspace_provider,
44-
extension_context
46+
extension_context,
47+
websocket_manager
4548
})
4649

4750
if (result) {

‎apps/editor/src/commands/select-imported-files-for-selected-command.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ import * as vscode from 'vscode'
22
import { WorkspaceProvider } from '../context/providers/workspace/workspace-provider'
33
import { prompt_for_imported_files } from '@/features/imported-files'
44
import { t } from '@/i18n'
5+
import { WebSocketManager } from '@/services/websocket-manager'
56

67
export const select_imported_files_for_selected_command = (
78
workspace_provider: WorkspaceProvider,
8-
extension_context: vscode.ExtensionContext
9+
extension_context: vscode.ExtensionContext,
10+
websocket_manager: WebSocketManager
911
) => {
1012
return vscode.commands.registerCommand(
1113
'codeWebChat.selectImportedFilesForSelected',
@@ -26,7 +28,8 @@ export const select_imported_files_for_selected_command = (
2628
const result = await prompt_for_imported_files({
2729
starting_uris,
2830
workspace_provider,
29-
extension_context
31+
extension_context,
32+
websocket_manager
3033
})
3134

3235
if (result) {

‎apps/editor/src/commands/select-referencing-files-commands/select-referencing-files-commands.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { t } from '../../i18n'
55
import { get_referencing_files_for_position } from './utils/get-referencing-files-for-position'
66
import { get_referencing_files_for_uris } from './utils/get-referencing-files-for-uris'
77
import { prompt_for_referencing_files } from './utils/prompt-for-referencing-files'
8+
import { WebSocketManager } from '@/services/websocket-manager'
89

910
const handle_reference_selection = async (params: {
1011
matched_files: { file_path: string; range: vscode.Range }[]
1112
workspace_provider: WorkspaceProvider
1213
extension_context: vscode.ExtensionContext
14+
websocket_manager: WebSocketManager
1315
}) => {
1416
const { matched_files, workspace_provider, extension_context } = params
1517

@@ -23,7 +25,8 @@ const handle_reference_selection = async (params: {
2325
const selected_paths = await prompt_for_referencing_files({
2426
matched_files,
2527
workspace_provider,
26-
extension_context
28+
extension_context,
29+
websocket_manager: params.websocket_manager
2730
})
2831

2932
if (!selected_paths) {
@@ -54,7 +57,8 @@ const handle_reference_selection = async (params: {
5457

5558
export const select_referencing_files_commands = (
5659
workspace_provider: WorkspaceProvider,
57-
extension_context: vscode.ExtensionContext
60+
extension_context: vscode.ExtensionContext,
61+
websocket_manager: WebSocketManager
5862
) => {
5963
const select_referencing_files_command = vscode.commands.registerCommand(
6064
'codeWebChat.selectReferencingFiles',
@@ -176,7 +180,8 @@ export const select_referencing_files_commands = (
176180
await handle_reference_selection({
177181
matched_files,
178182
workspace_provider,
179-
extension_context
183+
extension_context,
184+
websocket_manager
180185
})
181186
} catch (error) {
182187
vscode.window.showErrorMessage(
@@ -239,7 +244,8 @@ export const select_referencing_files_commands = (
239244
await handle_reference_selection({
240245
matched_files,
241246
workspace_provider,
242-
extension_context
247+
extension_context,
248+
websocket_manager
243249
})
244250
} catch (error) {
245251
vscode.window.showErrorMessage(

‎apps/editor/src/commands/select-referencing-files-commands/utils/prompt-for-referencing-files.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import { display_token_count } from '@/utils/display-token-count'
55
import { t } from '@/i18n'
66
import { show_parent_folder_quick_pick } from '@/utils/show-parent-folder-quick-pick'
77
import { search_files } from '@/features/search-files'
8+
import { WebSocketManager } from '@/services/websocket-manager'
89

910
export const prompt_for_referencing_files = async (params: {
1011
matched_files: { file_path: string; range: vscode.Range }[]
1112
workspace_provider: WorkspaceProvider
1213
extension_context: vscode.ExtensionContext
14+
websocket_manager: WebSocketManager
1315
}): Promise<string[] | undefined> => {
1416
const matched_files = params.matched_files
1517
let selected_paths: string[] = []
@@ -199,6 +201,7 @@ export const prompt_for_referencing_files = async (params: {
199201
get_files: async () => matched_files.map((m) => m.file_path),
200202
workspace_provider: params.workspace_provider,
201203
extension_context: params.extension_context,
204+
websocket_manager: params.websocket_manager,
202205
show_back_button: true,
203206
disable_semantic: true
204207
})

‎apps/editor/src/commands/select-unstaged-files-command.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@ import { Logger } from '@shared/utils/logger'
77
import { display_token_count } from '../utils/display-token-count'
88
import { t } from '@/i18n'
99
import { search_files } from '@/features/search-files'
10+
import { WebSocketManager } from '@/services/websocket-manager'
1011

1112
export const select_unstaged_files_command = (
1213
workspace_provider: WorkspaceProvider,
13-
extension_context: vscode.ExtensionContext
14+
extension_context: vscode.ExtensionContext,
15+
websocket_manager: WebSocketManager
1416
): vscode.Disposable => {
1517
return vscode.commands.registerCommand(
1618
'codeWebChat.selectUnstagedFiles',
@@ -194,6 +196,7 @@ export const select_unstaged_files_command = (
194196
get_files: async () => existing_unstaged_files,
195197
workspace_provider,
196198
extension_context,
199+
websocket_manager,
197200
show_back_button: true,
198201
disable_semantic: true
199202
})

‎apps/editor/src/constants/state-keys.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ export const LAST_USED_COMMIT_MESSAGES_CONFIG_ID_STATE_KEY =
7373
'last-used-commit-messages-config-id'
7474
export const LAST_USED_COMMIT_MESSAGE_ACTION_STATE_KEY =
7575
'last-used-commit-message-action'
76+
export const LAST_USED_INTELLIGENT_SEARCH_ACTION_STATE_KEY =
77+
'last-used-intelligent-search-action'
7678
export const LAST_USED_INTELLIGENT_UPDATE_CONFIG_ID_STATE_KEY =
7779
'last-used-intelligent-update-config-id'
7880
export const LAST_USED_VOICE_INPUT_CONFIG_ID_STATE_KEY =

0 commit comments

Comments
 (0)