Skip to content

Commit 64ff87f

Browse files
committed
Merge branch 'dev'
2 parents 9f3501d + 10f2462 commit 64ff87f

23 files changed

Lines changed: 119 additions & 94 deletions

File tree

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export type FileInPreview = {
2+
type: 'file'
23
file_path: string
34
is_checked: boolean
45
workspace_name?: string

‎packages/ui/src/components/editor/panel/ResponsePreview/ResponsePreview.stories.tsx‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ export default {
88

99
const base_files = [
1010
{
11+
type: 'file',
1112
file_path: 'src/components/Button/Button.tsx',
1213
lines_added: 10,
1314
lines_removed: 2
1415
},
1516
{
17+
type: 'file',
1618
file_path: 'src/components/Input/Input.module.scss',
1719
lines_added: 5,
1820
lines_removed: 5
1921
},
2022
{
23+
type: 'file',
2124
file_path: 'src/utils/helpers.ts',
2225
lines_added: 20,
2326
lines_removed: 0
@@ -26,25 +29,29 @@ const base_files = [
2629

2730
const files_using_fallbacks = [
2831
{
32+
type: 'file',
2933
file_path: 'src/new-feature.ts',
3034
is_new: true,
3135
lines_added: 50,
3236
lines_removed: 0
3337
},
3438
{
39+
type: 'file',
3540
file_path: 'src/old-component.tsx',
3641
is_deleted: true,
3742
lines_added: 0,
3843
lines_removed: 100
3944
},
4045
{
46+
type: 'file',
4147
file_path: 'src/complex-logic.js',
4248
is_fallback: true,
4349
diff_fallback_method: 'recount',
4450
lines_added: 15,
4551
lines_removed: 12
4652
},
4753
{
54+
type: 'file',
4855
file_path: 'src/aggressive-fallback.css',
4956
is_fallback: true,
5057
diff_fallback_method: 'search_and_replace',
@@ -62,7 +69,7 @@ const log_action =
6269
const InteractiveResponsePreview = (props: any) => {
6370
const [items, set_items] = useState(
6471
props.items.map((f: any) =>
65-
'file_path' in f ? { ...f, is_checked: true } : f
72+
f.type == 'file' ? { ...f, is_checked: true } : f
6673
)
6774
)
6875

@@ -77,9 +84,9 @@ const InteractiveResponsePreview = (props: any) => {
7784
}) => {
7885
set_items(
7986
items.map((f: any) =>
80-
'file_path' in f &&
81-
f.file_path === file_path &&
82-
f.workspace_name === workspace_name
87+
f.type == 'file' &&
88+
f.file_path == file_path &&
89+
f.workspace_name == workspace_name
8390
? { ...f, is_checked }
8491
: f
8592
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const ResponsePreview: FC<Props> = (props) => {
6868
}
6969

7070
const files_in_preview = props.items.filter(
71-
(i) => 'file_path' in i
71+
(i) => i.type == 'file'
7272
) as FileInPreview[]
7373
const fallback_count = files_in_preview.filter((f) => f.is_fallback).length
7474

@@ -118,7 +118,7 @@ export const ResponsePreview: FC<Props> = (props) => {
118118
)}
119119
<div className={styles.list}>
120120
{props.items.map((item, index) => {
121-
if ('file_path' in item) {
121+
if (item.type === 'file') {
122122
const file = item
123123
const last_slash_index = file.file_path.lastIndexOf('/')
124124
const file_name = file.file_path.substring(last_slash_index + 1)

‎packages/ui/src/components/editor/panel/ResponsePreviewFooter/ResponsePreviewFooter.tsx‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ import { Button } from '../Button'
22
import styles from './ResponsePreviewFooter.module.scss'
33

44
type Props = {
5-
on_discard: () => void
6-
on_approve: () => void
7-
is_approve_disabled: boolean
5+
on_reject: () => void
6+
on_accept: () => void
7+
is_accept_disabled: boolean
88
}
99

1010
export const ResponsePreviewFooter: React.FC<Props> = ({
11-
on_discard,
12-
on_approve,
13-
is_approve_disabled
11+
on_reject,
12+
on_accept,
13+
is_accept_disabled
1414
}) => {
1515
return (
1616
<div className={styles.container}>
17-
<Button on_click={on_discard} is_secondary>
18-
Discard
17+
<Button on_click={on_reject} is_secondary>
18+
Reject
1919
</Button>
20-
<Button on_click={on_approve} disabled={is_approve_disabled}>
21-
Approve
20+
<Button on_click={on_accept} disabled={is_accept_disabled}>
21+
Accept
2222
</Button>
2323
</div>
2424
)

‎packages/vscode/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "AI coding without agents (CWC)",
5-
"version": "1.517.0",
5+
"version": "1.518.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",

‎packages/vscode/src/commands/apply-chat-response-command/apply-chat-response-command.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ export const apply_chat_response_command = (
154154
!state.is_new && current_content === '' && state.content !== ''
155155

156156
files_for_history.push({
157+
type: 'file',
157158
file_path: state.file_path,
158159
workspace_name: state.workspace_name,
159160
is_new: state.is_new,

‎packages/vscode/src/commands/apply-chat-response-command/handlers/fast-replace-handler.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import * as fs from 'fs'
44
import { Logger } from '@shared/utils/logger'
55
import { dictionary } from '@shared/constants/dictionary'
66
import { create_safe_path, sanitize_file_name } from '@/utils/path-sanitizer'
7-
import { ClipboardFile } from '../utils/clipboard-parser'
7+
import { FileItem } from '../utils/clipboard-parser'
88
import { OriginalFileState } from '@/commands/apply-chat-response-command/types/original-file-state'
99

1010
export const handle_fast_replace = async (
11-
files: ClipboardFile[]
11+
files: FileItem[]
1212
): Promise<{ success: boolean; original_states?: OriginalFileState[] }> => {
1313
Logger.info({
1414
function_name: 'handle_fast_replace',
1515
message: 'start',
1616
data: { file_count: files.length }
1717
})
1818
try {
19-
const safe_files: ClipboardFile[] = []
19+
const safe_files: FileItem[] = []
2020
const unsafe_files: string[] = []
2121

2222
if (

‎packages/vscode/src/commands/apply-chat-response-command/handlers/intelligent-update-handler.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as vscode from 'vscode'
22
import axios from 'axios'
33
import * as path from 'path'
44
import * as fs from 'fs'
5-
import { ClipboardFile } from '../utils/clipboard-parser'
5+
import { FileItem } from '../utils/clipboard-parser'
66
import { sanitize_file_name, create_safe_path } from '@/utils/path-sanitizer'
77
import { Logger } from '@shared/utils/logger'
88
import { OriginalFileState } from '@/commands/apply-chat-response-command/types/original-file-state'
@@ -53,10 +53,10 @@ export const handle_intelligent_update = async (params: {
5353
})
5454

5555
const raw_files = raw_items.filter(
56-
(item): item is ClipboardFile => 'file_path' in item
56+
(item): item is FileItem => item.type == 'file'
5757
)
5858

59-
const files: ClipboardFile[] = []
59+
const files: FileItem[] = []
6060
const skipped_files: string[] = []
6161

6262
for (const file of raw_files) {
@@ -120,8 +120,8 @@ export const handle_intelligent_update = async (params: {
120120
return null
121121
}
122122

123-
const new_files: ClipboardFile[] = []
124-
const existing_files: ClipboardFile[] = []
123+
const new_files: FileItem[] = []
124+
const existing_files: FileItem[] = []
125125

126126
for (const file of files) {
127127
let file_exists = false

‎packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/clipboard-parser.ts‎

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,6 @@
11
import { extract_diffs } from './extract-diff-patches'
22
import { parse_code_completion, parse_multiple_files } from './parsers'
33

4-
export interface ClipboardFile {
5-
file_path: string
6-
content: string
7-
workspace_name?: string
8-
}
9-
10-
export interface ClipboardCodeCompletion {
11-
file_path: string
12-
content: string
13-
line: number
14-
character: number
15-
workspace_name?: string
16-
}
17-
184
export interface FileItem {
195
type: 'file'
206
file_path: string
@@ -98,7 +84,7 @@ export const parse_response = (params: {
9884
is_single_root_folder_workspace
9985
})
10086
if (code_completion) {
101-
return [{ type: 'completion', ...code_completion }]
87+
return [code_completion]
10288
}
10389

10490
const processed_response = params.response.replace(/``````/g, '```\n```')
@@ -129,10 +115,5 @@ export const parse_response = (params: {
129115
is_single_root_folder_workspace
130116
})
131117

132-
return items.map((item) => {
133-
if ('file_path' in item) {
134-
return { type: 'file', ...item }
135-
}
136-
return item
137-
})
118+
return items
138119
}

‎packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/parsers/code-completion-parser.ts‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import { cleanup_api_response } from '@/utils/cleanup-api-response'
2-
import {
3-
ClipboardCodeCompletion,
4-
extract_workspace_and_path
5-
} from '../clipboard-parser'
2+
import { CompletionItem, extract_workspace_and_path } from '../clipboard-parser'
63

74
const extract_path_and_position = (
85
line: string
@@ -31,7 +28,7 @@ const extract_path_and_position = (
3128
export const parse_code_completion = (params: {
3229
response: string
3330
is_single_root_folder_workspace: boolean
34-
}): ClipboardCodeCompletion | null => {
31+
}): CompletionItem | null => {
3532
const lines = params.response.split('\n')
3633
let in_code_block = false
3734
let first_line_of_block: string | null = null
@@ -50,6 +47,7 @@ export const parse_code_completion = (params: {
5047
params.is_single_root_folder_workspace
5148
})
5249
return {
50+
type: 'completion',
5351
file_path: relative_path,
5452
content: cleanup_api_response({
5553
content: content_lines.join('\n')

0 commit comments

Comments
 (0)