Skip to content

Commit 18921dd

Browse files
committed
Add support for "compared" edit format with conflict markers handling
1 parent ee227d5 commit 18921dd

35 files changed

Lines changed: 1087 additions & 177 deletions

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Context-first AI coding for VS Code, Cursor, and others. Free, open-source, and
99
- Chatbots—_ChatGPT, Claude, Gemini, Grok, DeepSeek, etc._
1010
- Model providers—_Gemini API, OpenRouter, local Ollama, etc._
1111

12-
**Apply responses**—changes integration in whole, truncated and diff edit formats \
12+
**Apply responses**—changes integration in whole, truncated, compared and diff edit formats \
1313
**Fully featured**—code completions, commit messages, checkpoints, and more
1414

1515
<p>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export type EditFormat = 'whole' | 'truncated' | 'diff'
1+
export type EditFormat = 'whole' | 'truncated' | 'compared' | 'diff'

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type FileInPreview = {
77
lines_added: number
88
lines_removed: number
99
is_replaced?: boolean
10+
is_edited_by_conflict_markers?: boolean
1011
diff_application_method?: 'recount' | 'search_and_replace'
1112
content?: string
1213
}

packages/ui/src/components/editor/panel/PromptField/PromptField.stories.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export const WithEditFormatSelector = () => {
206206
edit_format_instructions={{
207207
whole: 'Use the whole...',
208208
truncated: 'Use truncated...',
209+
compared: 'Use compared...',
209210
diff: 'Use diff...'
210211
}}
211212
context_file_paths={[]}

packages/ui/src/components/editor/panel/PromptField/PromptField.tsx

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { use_ghost_text } from './hooks/use-ghost-text'
99
import { use_drag_drop } from './hooks/use-drag-drop'
1010
import { DropdownMenu } from '../../common/DropdownMenu'
1111
import { use_is_narrow_viewport, use_is_mac } from '@shared/hooks'
12-
import { get_display_text } from './utils/get-display-text'
1312
import {
1413
get_caret_position_from_div,
1514
set_caret_position_for_div
@@ -42,7 +41,7 @@ const Tooltip: React.FC<{
4241
</div>
4342
)
4443

45-
export type EditFormat = 'whole' | 'truncated' | 'diff'
44+
export type EditFormat = 'whole' | 'truncated' | 'diff' | 'compared'
4645

4746
export type PromptFieldProps = {
4847
value: string
@@ -105,6 +104,9 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
105104
case 'KeyT':
106105
format = 'truncated'
107106
break
107+
case 'KeyC':
108+
format = 'compared'
109+
break
108110
case 'KeyD':
109111
format = 'diff'
110112
break
@@ -309,6 +311,7 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
309311
return {
310312
whole: `(${modifier}W)`,
311313
truncated: `(${modifier}T)`,
314+
compared: `(${modifier}C)`,
312315
diff: `(${modifier}D)`
313316
}
314317
}, [is_mac])
@@ -466,55 +469,57 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
466469
>
467470
{props.show_edit_format_selector && (
468471
<div className={styles['footer__right__edit-format']}>
469-
{(['whole', 'truncated', 'diff'] as const).map((format) => {
470-
const button_text = is_narrow_viewport
471-
? format.charAt(0).toUpperCase()
472-
: format
473-
const is_selected = props.edit_format == format
474-
const should_underline = is_alt_pressed && !is_selected
472+
{(['whole', 'truncated', 'compared', 'diff'] as const).map(
473+
(format) => {
474+
const button_text = is_narrow_viewport
475+
? format.charAt(0).toUpperCase()
476+
: format
477+
const is_selected = props.edit_format == format
478+
const should_underline = is_alt_pressed && !is_selected
475479

476-
return (
477-
<button
478-
key={format}
479-
className={cn(
480-
styles['footer__right__edit-format__button'],
481-
{
482-
[styles[
483-
'footer__right__edit-format__button--selected'
484-
]]: is_selected
485-
}
486-
)}
487-
title={`Edit format instructions to include with the prompt ${edit_format_shortcuts[format]}\n\n${
488-
props.edit_format_instructions?.[format]
489-
}`}
490-
onClick={() => props.on_edit_format_change?.(format)}
491-
>
492-
<span
493-
className={
494-
styles['footer__right__edit-format__button__spacer']
495-
}
496-
>
497-
{button_text}
498-
</span>
499-
<span
500-
className={
501-
styles['footer__right__edit-format__button__text']
502-
}
503-
>
504-
{should_underline ? (
505-
<>
506-
<span className={styles['underlined']}>
507-
{button_text.charAt(0)}
508-
</span>
509-
{button_text.substring(1)}
510-
</>
511-
) : (
512-
button_text
480+
return (
481+
<button
482+
key={format}
483+
className={cn(
484+
styles['footer__right__edit-format__button'],
485+
{
486+
[styles[
487+
'footer__right__edit-format__button--selected'
488+
]]: is_selected
489+
}
513490
)}
514-
</span>
515-
</button>
516-
)
517-
})}
491+
title={`Edit format instructions to include with the prompt ${edit_format_shortcuts[format]}\n\n${
492+
props.edit_format_instructions?.[format]
493+
}`}
494+
onClick={() => props.on_edit_format_change?.(format)}
495+
>
496+
<span
497+
className={
498+
styles['footer__right__edit-format__button__spacer']
499+
}
500+
>
501+
{button_text}
502+
</span>
503+
<span
504+
className={
505+
styles['footer__right__edit-format__button__text']
506+
}
507+
>
508+
{should_underline ? (
509+
<>
510+
<span className={styles['underlined']}>
511+
{button_text.charAt(0)}
512+
</span>
513+
{button_text.substring(1)}
514+
</>
515+
) : (
516+
button_text
517+
)}
518+
</span>
519+
</button>
520+
)
521+
}
522+
)}
518523
</div>
519524
)}
520525

packages/ui/src/components/editor/panel/PromptField/utils/get-display-text.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,9 @@ export const ResponsePreview: FC<Props> = (props) => {
185185
</div>
186186
<div className={styles.list__file__right}>
187187
<div className={styles['list__file__actions']}>
188-
{(file.diff_application_method || file.is_replaced) && (
188+
{(file.diff_application_method ||
189+
file.is_replaced ||
190+
file.is_edited_by_conflict_markers) && (
189191
<IconButton
190192
codicon_icon="sparkle"
191193
title={`Call Intelligent Update API tool${

packages/vscode/package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,10 @@
597597
"type": "string",
598598
"scope": "resource"
599599
},
600+
"codeWebChat.editFormatInstructionsCompared": {
601+
"type": "string",
602+
"scope": "resource"
603+
},
600604
"codeWebChat.editFormatInstructionsDiff": {
601605
"type": "string",
602606
"scope": "resource"

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ export const apply_chat_response_command = (params: {
211211
lines_added: diff_stats.lines_added,
212212
lines_removed: diff_stats.lines_removed,
213213
is_replaced: state.is_replaced,
214+
is_edited_by_conflict_markers:
215+
state.is_edited_by_conflict_markers,
214216
diff_application_method: state.diff_application_method,
215217
content: current_content,
216218
is_checked: true

0 commit comments

Comments
 (0)