Skip to content

Commit b73ccaa

Browse files
committed
Remove semantic search mode and display live token count totals in file selection quick picks
- remove semantic (semble) search option entirely - as user updates file selection on the results set, update total token count in the title bar - on search results, the selected token count (totalling...) should be shown as suffix to placeholder instead - 'totalling' should be translated └── apps └── editor └── src ├── commands │ ├── search-files-commands │ │ ├── index.ts │ │ ├── search-files-commands.ts │ │ └── utils │ │ ├── get-target-folder-path.ts │ │ └── prompt-for-provided-results.ts │ ├── select-clipboard-paths-command.ts │ ├── select-files-of-commit-command.ts │ ├── select-referencing-files-commands │ │ └── utils │ │ └── prompt-for-referencing-files.ts │ └── select-unstaged-files-command.ts ├── features │ ├── imported-files │ │ └── utils │ │ └── 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 │ └── 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-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 └── i18n └── translations ├── commands │ └── search-files.ts ├── common.ts └── features └── search-files.ts
1 parent 1e5a872 commit b73ccaa

17 files changed

Lines changed: 197 additions & 386 deletions

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ export const search_files_commands = (
262262
workspace_provider,
263263
extension_context,
264264
websocket_manager,
265-
disable_semantic: true,
266265
is_search_in_selected: true,
267266
folder_path
268267
})

‎apps/editor/src/commands/search-files-commands/utils/prompt-for-provided-results.ts‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { show_parent_folder_quick_pick } from '@/utils/show-parent-folder-quick-
55
import { group_quick_pick_items } from '@/features/search-files/utils/group-quick-pick-items'
66
import { map_files_to_quick_pick_items } from '@/features/search-files/utils/map-files-to-quick-pick-items'
77
import { handle_parent_folder_result } from '@/features/search-files/utils/handle-parent-folder-result'
8+
import { display_token_count } from '@/utils/display-token-count'
89

910
export const prompt_for_provided_results = async (params: {
1011
files: { path: string; checked: boolean }[]
@@ -69,10 +70,27 @@ export const prompt_for_provided_results = async (params: {
6970
})
7071
quick_pick.canSelectMany = true
7172
quick_pick.matchOnDescription = true
72-
quick_pick.placeholder = t('feature.search-files.select-files')
73+
const base_title = t('feature.search-files.results.intelligent')
74+
quick_pick.title = base_title
75+
76+
const base_placeholder = t('feature.search-files.select-files')
77+
78+
const update_title = () => {
79+
const total = quick_pick.selectedItems.reduce(
80+
(sum, item) => sum + ((item as any).token_count || 0),
81+
0
82+
)
83+
const total_text =
84+
total > 0
85+
? ` (${t('common.totalling-tokens', {
86+
tokens: display_token_count(total)
87+
})})`
88+
: ''
89+
quick_pick.placeholder = `${base_placeholder}${total_text}`
90+
}
7391

74-
const title = t('feature.search-files.results.intelligent')
75-
quick_pick.title = title
92+
update_title()
93+
quick_pick.onDidChangeSelection(update_title)
7694

7795
quick_pick.ignoreFocusOut = true
7896
quick_pick.buttons = [search_in_results_button, close_button]
@@ -114,7 +132,7 @@ export const prompt_for_provided_results = async (params: {
114132
.map((item) => item.file_path)
115133
.filter((p): p is string => p !== undefined),
116134
matched_paths: params.files.map((f) => f.path),
117-
title
135+
title: base_title
118136
})
119137
quick_pick.hide()
120138
})

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export const select_clipboard_paths_command = (
206206
? `${formatted_token_count} · ${display_dir}`
207207
: formatted_token_count,
208208
file_path,
209+
token_count: token_count.total,
209210
buttons: [
210211
{
211212
iconPath: new vscode.ThemeIcon('go-to-file'),
@@ -226,15 +227,35 @@ export const select_clipboard_paths_command = (
226227
const quick_pick = vscode.window.createQuickPick<
227228
vscode.QuickPickItem & { file_path: string }
228229
>()
230+
229231
quick_pick.title = t('command.select-clipboard-paths.title')
230-
quick_pick.placeholder = t(
232+
233+
const base_placeholder = t(
231234
'command.select-clipboard-paths.include'
232235
)
236+
237+
const update_title = () => {
238+
const total = quick_pick.selectedItems.reduce(
239+
(sum, item) => sum + ((item as any).token_count || 0),
240+
0
241+
)
242+
const total_text =
243+
total > 0
244+
? ` (${t('common.totalling-tokens', {
245+
tokens: display_token_count(total)
246+
})})`
247+
: ''
248+
quick_pick.placeholder = `${base_placeholder}${total_text}`
249+
}
250+
233251
quick_pick.canSelectMany = true
234252
quick_pick.items = quick_pick_items
235253
quick_pick.ignoreFocusOut = true
236254
quick_pick.selectedItems = current_selected_items
237255

256+
update_title()
257+
quick_pick.onDidChangeSelection(update_title)
258+
238259
const close_button = {
239260
iconPath: new vscode.ThemeIcon('close'),
240261
tooltip: t('common.close')
@@ -322,8 +343,7 @@ export const select_clipboard_paths_command = (
322343
workspace_provider,
323344
extension_context,
324345
websocket_manager,
325-
show_back_button: true,
326-
disable_semantic: true
346+
show_back_button: true
327347
})
328348

329349
if (search_result === 'back') {

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

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -407,21 +407,25 @@ export const select_files_of_commit_command = (
407407
})
408408
: t('command.select-files-of-commit.files-modified')
409409

410-
const update_placeholder = () => {
410+
const base_placeholder = t(
411+
'command.select-files-of-commit.select-files'
412+
)
413+
414+
const update_title = () => {
411415
const total = quick_pick_files.selectedItems.reduce(
412416
(sum: number, item: any) => sum + item.token_count,
413417
0
414418
)
415419
const total_text =
416420
total > 0
417-
? ` (totalling ${display_token_count(total)} tokens)`
421+
? ` (${t('common.totalling-tokens', {
422+
tokens: display_token_count(total)
423+
})})`
418424
: ''
419-
quick_pick_files.placeholder = `${t(
420-
'command.select-files-of-commit.select-files'
421-
)}${total_text}`
425+
quick_pick_files.placeholder = `${base_placeholder}${total_text}`
422426
}
423-
update_placeholder()
424-
quick_pick_files.onDidChangeSelection(update_placeholder)
427+
update_title()
428+
quick_pick_files.onDidChangeSelection(update_title)
425429

426430
const search_button = {
427431
iconPath: new vscode.ThemeIcon('search'),
@@ -551,8 +555,7 @@ export const select_files_of_commit_command = (
551555
workspace_provider,
552556
extension_context,
553557
websocket_manager,
554-
show_back_button: true,
555-
disable_semantic: true
558+
show_back_button: true
556559
})
557560

558561
if (search_result === 'back') {

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export const prompt_for_referencing_files = async (params: {
5959
? `${formatted_token_count} · ${display_dir}`
6060
: formatted_token_count,
6161
file_path,
62+
token_count: token_count.total,
6263
range,
6364
buttons
6465
}
@@ -76,8 +77,25 @@ export const prompt_for_referencing_files = async (params: {
7677
quick_pick.items = quick_pick_items
7778
quick_pick.selectedItems = current_selected_items
7879
quick_pick.canSelectMany = true
79-
quick_pick.placeholder = t('command.select-referencing-files.select-files')
8080
quick_pick.title = t('command.select-referencing-files.referencing-files')
81+
82+
const base_placeholder = t('command.select-referencing-files.select-files')
83+
const update_title = () => {
84+
const total = quick_pick.selectedItems.reduce(
85+
(sum, item) => sum + ((item as any).token_count || 0),
86+
0
87+
)
88+
const total_text =
89+
total > 0
90+
? ` (${t('common.totalling-tokens', {
91+
tokens: display_token_count(total)
92+
})})`
93+
: ''
94+
quick_pick.placeholder = `${base_placeholder}${total_text}`
95+
}
96+
update_title()
97+
quick_pick.onDidChangeSelection(update_title)
98+
8199
quick_pick.ignoreFocusOut = true
82100

83101
const close_button = {
@@ -202,8 +220,7 @@ export const prompt_for_referencing_files = async (params: {
202220
workspace_provider: params.workspace_provider,
203221
extension_context: params.extension_context,
204222
websocket_manager: params.websocket_manager,
205-
show_back_button: true,
206-
disable_semantic: true
223+
show_back_button: true
207224
})
208225

209226
if (search_result === 'back') {

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ export const select_unstaged_files_command = (
9898
: formatted_token_count,
9999
picked: currently_checked_set.has(file_path),
100100
file_path,
101+
token_count: token_count.total,
101102
buttons: [
102103
{
103104
iconPath: new vscode.ThemeIcon(
@@ -117,15 +118,35 @@ export const select_unstaged_files_command = (
117118
const quick_pick = vscode.window.createQuickPick<
118119
vscode.QuickPickItem & { file_path: string }
119120
>()
121+
120122
quick_pick.title = t('command.select-unstaged-files.title')
121-
quick_pick.placeholder = t('command.select-unstaged-files.include')
123+
124+
const base_placeholder = t('command.select-unstaged-files.include')
125+
126+
const update_title = () => {
127+
const total = quick_pick.selectedItems.reduce(
128+
(sum, item) => sum + ((item as any).token_count || 0),
129+
0
130+
)
131+
const total_text =
132+
total > 0
133+
? ` (${t('common.totalling-tokens', {
134+
tokens: display_token_count(total)
135+
})})`
136+
: ''
137+
quick_pick.placeholder = `${base_placeholder}${total_text}`
138+
}
139+
122140
quick_pick.canSelectMany = true
123141
quick_pick.items = quick_pick_items
124142
quick_pick.ignoreFocusOut = true
125143
quick_pick.selectedItems = quick_pick_items.filter(
126144
(item) => item.picked
127145
)
128146

147+
update_title()
148+
quick_pick.onDidChangeSelection(update_title)
149+
129150
const search_button = {
130151
iconPath: new vscode.ThemeIcon('search'),
131152
tooltip: t('common.search-in-results')
@@ -197,8 +218,7 @@ export const select_unstaged_files_command = (
197218
workspace_provider,
198219
extension_context,
199220
websocket_manager,
200-
show_back_button: true,
201-
disable_semantic: true
221+
show_back_button: true
202222
})
203223

204224
if (search_result === 'back') {

‎apps/editor/src/features/imported-files/utils/prompt-for-imported-files.ts‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ export const prompt_for_imported_files = async (params: {
159159
: formatted_token_count,
160160
picked: is_picked,
161161
uri: uri,
162+
token_count: token_count.total,
162163
tokens: token_count.total,
163164
buttons
164165
}
@@ -231,8 +232,25 @@ export const prompt_for_imported_files = async (params: {
231232
quick_pick.selectedItems = current_selected_items
232233
quick_pick.canSelectMany = true
233234
quick_pick.matchOnDescription = true
234-
quick_pick.placeholder = t('feature.imported-files.placeholder')
235235
quick_pick.title = t('feature.imported-files.title')
236+
237+
const base_placeholder = t('feature.imported-files.placeholder')
238+
const update_title = () => {
239+
const total = quick_pick.selectedItems.reduce(
240+
(sum, item) => sum + ((item as any).token_count || 0),
241+
0
242+
)
243+
const total_text =
244+
total > 0
245+
? ` (${t('common.totalling-tokens', {
246+
tokens: display_token_count(total)
247+
})})`
248+
: ''
249+
quick_pick.placeholder = `${base_placeholder}${total_text}`
250+
}
251+
update_title()
252+
quick_pick.onDidChangeSelection(update_title)
253+
236254
quick_pick.ignoreFocusOut = true
237255

238256
const buttons: vscode.QuickInputButton[] = [search_button, close_button]
@@ -422,8 +440,7 @@ export const prompt_for_imported_files = async (params: {
422440
workspace_provider,
423441
extension_context,
424442
websocket_manager,
425-
show_back_button: true,
426-
disable_semantic: true
443+
show_back_button: true
427444
})
428445

429446
if (search_result == 'back') {

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

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { LAST_SEARCH_FILES_FOR_CONTEXT_MODE_STATE_KEY } from '@/constants/state-
55
import { prompt_for_search_mode } from './utils/prompt-for-search-mode'
66
import { perform_phrase_search_mode } from './search-modes/perform-phrase-search-mode'
77
import { perform_keywords_search_mode } from './search-modes/perform-keywords-search-mode'
8-
import { perform_semantic_search_mode } from './search-modes/perform-semantic-search-mode'
98
import { perform_intelligent_search_mode } from './search-modes/perform-intelligent-search-mode'
109
import { Logger } from '@shared/utils/logger'
1110
import { WebSocketManager } from '@/services/websocket-manager'
@@ -17,7 +16,6 @@ export const search_files = async (params: {
1716
websocket_manager: WebSocketManager
1817
show_back_button?: boolean
1918
is_sub_search?: boolean
20-
disable_semantic?: boolean
2119
is_search_in_selected?: boolean
2220
folder_path?: string
2321
}): Promise<
@@ -27,7 +25,7 @@ export const search_files = async (params: {
2725
> => {
2826
let initial_search_mode =
2927
params.extension_context.workspaceState.get<
30-
'phrase' | 'keywords' | 'intelligent' | 'semantic'
28+
'phrase' | 'keywords' | 'intelligent'
3129
>(LAST_SEARCH_FILES_FOR_CONTEXT_MODE_STATE_KEY) || 'phrase'
3230

3331
let _resolved_files: string[] | undefined
@@ -55,8 +53,7 @@ export const search_files = async (params: {
5553
try {
5654
const mode_result = await prompt_for_search_mode(
5755
initial_search_mode,
58-
params.show_back_button,
59-
params.disable_semantic || params.is_sub_search
56+
params.show_back_button
6057
)
6158

6259
if (mode_result == 'back') return 'back'
@@ -88,8 +85,6 @@ export const search_files = async (params: {
8885
flow_result = await perform_phrase_search_mode(flow_params)
8986
} else if (search_mode == 'keywords') {
9087
flow_result = await perform_keywords_search_mode(flow_params)
91-
} else if (search_mode == 'semantic') {
92-
flow_result = await perform_semantic_search_mode(flow_params)
9388
} else if (search_mode == 'intelligent') {
9489
const files = await resolve_files()
9590
flow_result = await perform_intelligent_search_mode({

0 commit comments

Comments
 (0)