Skip to content

Commit d6b0321

Browse files
committed
Remove relevant files support from response processing and preview components
- because we no longer use panel UI for 'relvant files' responses, code should be ajusted appropriately ├── apps │ └── editor │ └── src │ ├── commands │ │ └── apply-response-command │ │ ├── apply-response-command.ts │ │ ├── handlers │ │ │ ├── diff-handler.ts │ │ │ ├── fast-replace-handler.ts │ │ │ ├── restore-preview-handler.ts │ │ │ ├── search-replace-handler.ts │ │ │ └── truncated-handler.ts │ │ ├── response-processor.ts │ │ ├── types │ │ │ └── original-file-state.ts │ │ └── utils │ │ ├── file-checks.ts │ │ ├── file-operations.ts │ │ ├── preview │ │ │ ├── diff-utils.ts │ │ │ ├── file-preparer.ts │ │ │ ├── index.ts │ │ │ ├── preview.ts │ │ │ ├── temp-file-manager.ts │ │ │ ├── types.ts │ │ │ ├── virtual-document-provider.ts │ │ │ ├── vscode-ui.ts │ │ │ └── workspace-listener.ts │ │ ├── preview-handler.ts │ │ └── state-manager.ts │ └── views │ └── prompt │ ├── backend │ │ ├── message-handlers │ │ │ └── handle-apply-response-from-history.ts │ │ └── prompt-view-provider.ts │ ├── frontend │ │ ├── Prompt.tsx │ │ └── hooks │ │ └── use-preview-manager.ts │ └── types │ └── messages.ts └── packages ├── shared │ └── src │ └── types │ ├── file-in-preview.ts │ └── response-history-item.ts └── ui └── src └── components └── editor └── prompt └── ResponsePreview ├── ResponsePreview.module.scss ├── ResponsePreview.stories.tsx ├── ResponsePreview.tsx ├── components │ ├── FileItem │ │ ├── FileItem.module.scss │ │ ├── FileItem.tsx │ │ └── index.ts │ ├── InlineFileItem │ │ ├── InlineFileItem.module.scss │ │ ├── InlineFileItem.tsx │ │ └── index.ts │ ├── TextItem │ │ ├── TextItem.module.scss │ │ ├── TextItem.tsx │ │ └── index.ts │ └── index.ts └── index.ts
1 parent 4a0bc46 commit d6b0321

14 files changed

Lines changed: 24 additions & 276 deletions

File tree

‎apps/editor/src/commands/apply-response-command/apply-response-command.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ export const apply_response_command = (params: {
210210

211211
const has_valid_blocks =
212212
(args?.files_with_content && args.files_with_content.length > 0) ||
213-
(args?.relevant_files && args.relevant_files.length > 0) ||
214213
response_items.some(
215214
(item) =>
216215
item.type == 'file' ||

‎apps/editor/src/commands/apply-response-command/response-processor.ts‎

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import { handle_truncated_edit } from './handlers/truncated-handler'
2828
import { WorkspaceProvider } from '@/context/providers/workspace/workspace-provider'
2929
import { natural_sort } from '@/utils/natural-sort'
3030
import { t } from '@/i18n'
31-
import { RelevantFileInPreview } from '@shared/types/file-in-preview'
3231
import { is_truncation_line } from '@/utils/changes-integration/truncations-processor/utils/is-truncation-line'
3332

3433
export type PreviewData = {
@@ -44,7 +43,6 @@ export type ApplyResponseCommandArgs = {
4443
position: { line: number; character: number }
4544
}
4645
files_with_content?: FileInPreview[]
47-
relevant_files?: RelevantFileInPreview[]
4846
created_at?: number
4947
url?: string
5048
recent_api_configuration?: RecentApiConfiguration
@@ -113,7 +111,11 @@ export const process_response = async (params: {
113111

114112
const workspace_roots = params.workspace_provider.get_workspace_roots()
115113

116-
const files_for_preview: RelevantFileInPreview[] = []
114+
const files_for_preview: {
115+
file_path: string
116+
absolute_path: string
117+
is_checked: boolean
118+
}[] = []
117119

118120
for (const item of params.response_items) {
119121
if (item.type == 'relevant-files') {
@@ -122,7 +124,11 @@ export const process_response = async (params: {
122124
relevant_files_item.file_paths
123125
)
124126

125-
const local_files: RelevantFileInPreview[] = []
127+
const local_files: {
128+
file_path: string
129+
absolute_path: string
130+
is_checked: boolean
131+
}[] = []
126132

127133
for (const rel_path of Array.from(all_paths_to_process)) {
128134
let absolute_path: string | undefined
@@ -137,37 +143,12 @@ export const process_response = async (params: {
137143
}
138144

139145
if (absolute_path && matched_workspace_root) {
140-
const count =
141-
await params.workspace_provider.calculate_file_tokens(
142-
absolute_path
143-
)
144-
145-
let workspace_name: string | undefined
146-
if (workspace_roots.length > 1) {
147-
workspace_name = params.workspace_provider.get_workspace_name(
148-
matched_workspace_root
149-
)
150-
}
151-
152-
let is_checked = current_checked_files.includes(absolute_path)
153-
if (params.args?.relevant_files) {
154-
const history_file = params.args.relevant_files.find(
155-
(f) =>
156-
f.file_path === rel_path &&
157-
f.workspace_name === workspace_name
158-
)
159-
if (history_file) {
160-
is_checked = history_file.is_checked
161-
}
162-
}
146+
const is_checked = current_checked_files.includes(absolute_path)
163147

164148
local_files.push({
165-
type: 'relevant-file',
166149
file_path: rel_path,
167150
absolute_path: absolute_path,
168-
workspace_name,
169-
is_checked,
170-
token_count: count.total
151+
is_checked
171152
})
172153
}
173154
}

‎apps/editor/src/commands/apply-response-command/utils/preview/types.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import {
2-
FileInPreview,
3-
RelevantFileInPreview
4-
} from '@shared/types/file-in-preview'
1+
import { FileInPreview } from '@shared/types/file-in-preview'
52
import * as vscode from 'vscode'
63

74
export type PreviewDecision =
85
| { jump_to: { file_path: string; workspace_name?: string } }
96
| {
10-
accepted_files: (FileInPreview | RelevantFileInPreview)[]
7+
accepted_files: FileInPreview[]
118
created_at?: number
129
}
1310

‎apps/editor/src/views/prompt/backend/message-handlers/handle-apply-response-from-history.ts‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ export const handle_apply_response_from_history = async (
88
response: message.response,
99
raw_instructions: message.raw_instructions,
1010
files_with_content: message.files,
11-
relevant_files: message.relevant_files,
1211
created_at: message.created_at,
1312
url: message.url,
1413
recent_api_configuration: message.recent_api_configuration

‎apps/editor/src/views/prompt/backend/prompt-view-provider.ts‎

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
695695

696696
public show_preview_ongoing_modal() {
697697
const items_without_files_count = this.response_history.filter(
698-
(item) => item.files === undefined && item.relevant_files === undefined
698+
(item) => item.files === undefined
699699
).length
700700

701701
if (items_without_files_count > 1) {
@@ -850,27 +850,6 @@ export class PromptViewProvider implements vscode.WebviewViewProvider {
850850
} else if (message.command == 'FOCUS_ON_FILE_IN_PREVIEW') {
851851
handle_focus_on_file_in_preview(message)
852852
} else if (message.command == 'TOGGLE_FILE_IN_PREVIEW') {
853-
const item = this.response_history.find((i) =>
854-
i.relevant_files?.some(
855-
(f) =>
856-
f.file_path == message.file_path &&
857-
f.workspace_name == message.workspace_name
858-
)
859-
)
860-
if (item && item.relevant_files) {
861-
const file = item.relevant_files.find(
862-
(f) =>
863-
f.file_path == message.file_path &&
864-
f.workspace_name == message.workspace_name
865-
)
866-
if (file && file.type == 'relevant-file') {
867-
file.is_checked = message.is_checked
868-
this.send_message({
869-
command: 'RESPONSE_HISTORY',
870-
history: this.response_history
871-
})
872-
}
873-
}
874853
await handle_toggle_file_in_preview(message)
875854
} else if (message.command == 'DISCARD_USER_CHANGES_IN_PREVIEW') {
876855
await handle_discard_user_changes_in_preview(message)

‎apps/editor/src/views/prompt/frontend/Prompt.tsx‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ export const Prompt = () => {
260260
response: item.response,
261261
raw_instructions: item.raw_instructions,
262262
files: item.files,
263-
relevant_files: item.relevant_files,
264263
created_at: item.created_at,
265264
url: item.url,
266265
recent_api_configuration: item.recent_api_configuration
@@ -653,9 +652,7 @@ export const Prompt = () => {
653652
}}
654653
on_accept={() => {
655654
const accepted_files = items_in_preview.filter(
656-
(f) =>
657-
(f.type == 'file' || f.type == 'relevant-file') &&
658-
f.is_checked
655+
(f) => f.type == 'file' && f.is_checked
659656
) as any
660657
set_response_history([])
661658
set_selected_history_item_created_at(undefined)
@@ -667,9 +664,7 @@ export const Prompt = () => {
667664
}}
668665
is_accept_disabled={
669666
items_in_preview.filter(
670-
(f) =>
671-
(f.type == 'file' || f.type == 'relevant-file') &&
672-
f.is_checked
667+
(f) => f.type == 'file' && f.is_checked
673668
).length == 0 ||
674669
items_in_preview.some(
675670
(f) => f.type == 'file' && f.is_applying
@@ -700,7 +695,7 @@ export const Prompt = () => {
700695
on_toggle_file={(file) => {
701696
set_items_in_preview((current_items) =>
702697
current_items?.map((f) =>
703-
(f.type == 'file' || f.type == 'relevant-file') &&
698+
f.type == 'file' &&
704699
f.file_path == file.file_path &&
705700
f.workspace_name == file.workspace_name
706701
? { ...f, is_checked: file.is_checked }

‎apps/editor/src/views/prompt/types/messages.ts‎

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
import { EditFormat } from '@shared/types/edit-format'
2-
import {
3-
FileInPreview,
4-
RelevantFileInPreview,
5-
ItemInPreview
6-
} from '@shared/types/file-in-preview'
2+
import { FileInPreview, ItemInPreview } from '@shared/types/file-in-preview'
73
import {
84
ResponseHistoryItem,
95
RecentApiConfiguration
@@ -294,7 +290,7 @@ export interface RequestCurrentlyOpenFileTextMessage extends BaseMessage {
294290

295291
export interface ResponsePreviewMessage extends BaseMessage {
296292
command: 'RESPONSE_PREVIEW'
297-
files: (FileInPreview | RelevantFileInPreview)[]
293+
files: FileInPreview[]
298294
created_at?: number
299295
}
300296

@@ -378,7 +374,6 @@ export interface ApplyResponseFromHistoryMessage extends BaseMessage {
378374
response: string
379375
raw_instructions?: string
380376
files?: FileInPreview[]
381-
relevant_files?: RelevantFileInPreview[]
382377
created_at: number
383378
url?: string
384379
recent_api_configuration?: RecentApiConfiguration

‎packages/shared/src/types/file-in-preview.ts‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,7 @@ export type InlineFileInPreview = {
2929
language?: string
3030
}
3131

32-
export type RelevantFileInPreview = {
33-
type: 'relevant-file'
34-
file_path: string
35-
absolute_path?: string
36-
workspace_name?: string
37-
is_checked: boolean
38-
token_count?: number
39-
}
40-
4132
export type ItemInPreview =
4233
| FileInPreview
4334
| TextContentInPreview
4435
| InlineFileInPreview
45-
| RelevantFileInPreview

‎packages/shared/src/types/response-history-item.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FileInPreview, RelevantFileInPreview } from './file-in-preview'
1+
import { FileInPreview } from './file-in-preview'
22

33
export type RecentApiConfiguration = {
44
provider: string
@@ -13,7 +13,6 @@ export type ResponseHistoryItem = {
1313
lines_added?: number
1414
lines_removed?: number
1515
files?: FileInPreview[]
16-
relevant_files?: RelevantFileInPreview[]
1716
url?: string
1817
recent_api_configuration?: RecentApiConfiguration
1918
is_not_looked_at?: boolean

‎packages/ui/src/components/editor/prompt/ResponsePreview/ResponsePreview.tsx‎

Lines changed: 3 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,10 @@
11
import { FC, useRef, useState, useMemo, useEffect } from 'react'
2-
import {
3-
FileInPreview,
4-
RelevantFileInPreview,
5-
ItemInPreview
6-
} from '@shared/types/file-in-preview'
2+
import { FileInPreview, ItemInPreview } from '@shared/types/file-in-preview'
73
import { RecentApiConfiguration } from '@shared/types/response-history-item'
84
import { simplify_prompt_symbols } from '@shared/utils/simplify-prompt-symbols'
95
import cn from 'classnames'
106
import styles from './ResponsePreview.module.scss'
11-
import {
12-
TextItem,
13-
InlineFileItem,
14-
FileItem,
15-
RelevantFileItem
16-
} from './components'
7+
import { TextItem, InlineFileItem, FileItem } from './components'
178
import { Scrollable } from '../../common/Scrollable'
189

1910
type Props = {
@@ -101,10 +92,7 @@ export const ResponsePreview: FC<Props> = (props) => {
10192
}
10293

10394
const files_in_preview = useMemo(
104-
() =>
105-
props.items.filter(
106-
(i) => i.type == 'file' || i.type == 'relevant-file'
107-
) as (FileInPreview | RelevantFileInPreview)[],
95+
() => props.items.filter((i) => i.type == 'file') as FileInPreview[],
10896
[props.items]
10997
)
11098

@@ -398,31 +386,6 @@ export const ResponsePreview: FC<Props> = (props) => {
398386
}
399387
/>
400388
)
401-
} else if (item.type == 'relevant-file') {
402-
const file = item
403-
return (
404-
<RelevantFileItem
405-
key={index}
406-
file={file}
407-
is_selected={index === last_clicked_file_index}
408-
has_multiple_workspaces={props.has_multiple_workspaces}
409-
total_files_count={files_in_preview.length}
410-
on_click={() => {}}
411-
on_toggle={(checked) =>
412-
props.on_toggle_file({
413-
file_path: file.file_path,
414-
workspace_name: file.workspace_name,
415-
is_checked: checked
416-
})
417-
}
418-
on_go_to_file={() =>
419-
props.on_go_to_file({
420-
file_path: file.file_path,
421-
workspace_name: file.workspace_name
422-
})
423-
}
424-
/>
425-
)
426389
} else if (item.type == 'inline-file') {
427390
return (
428391
<InlineFileItem

0 commit comments

Comments
 (0)