Skip to content

Commit 20d99ff

Browse files
committed
Refactor clipboard parsing to correctly extract file paths from XML-style headings preceding code blocks and update chatbot configurations to include LMArena
1 parent c51670c commit 20d99ff

9 files changed

Lines changed: 99 additions & 30 deletions

File tree

‎packages/browser/src/manifest.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"https://github.com/copilot",
3636
"https://grok.com/",
3737
"https://huggingface.co/chat/",
38+
"https://lmarena.ai/",
3839
"https://www.kimi.com/",
3940
"https://agent.minimax.io/",
4041
"https://chat.mistral.ai/chat",

‎packages/shared/src/constants/chatbots.ts‎

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
type Chatbot = {
2-
url: string
3-
supports_custom_temperature?: boolean
4-
supports_system_instructions?: boolean
5-
supports_user_provided_model?: boolean
6-
supports_user_provided_port?: boolean
7-
supports_reasoning_effort?: boolean
8-
supports_thinking_budget?: boolean
9-
supports_url_override?: boolean
10-
url_override_label?: string
11-
default_system_instructions?: string
12-
default_top_p?: number
13-
supported_options?: {
14-
[option: string]: string
15-
}
16-
models?: {
17-
[model: string]: {
18-
label: string
19-
disabled_options?: string[]
20-
supported_reasoning_efforts?: string[]
21-
}
2+
url: string
3+
supports_custom_temperature?: boolean
4+
supports_system_instructions?: boolean
5+
supports_user_provided_model?: boolean
6+
supports_user_provided_port?: boolean
7+
supports_reasoning_effort?: boolean
8+
supports_thinking_budget?: boolean
9+
supports_url_override?: boolean
10+
url_override_label?: string
11+
default_system_instructions?: string
12+
default_top_p?: number
13+
supported_options?: {
14+
[option: string]: string
15+
}
16+
models?: {
17+
[model: string]: {
18+
label: string
19+
disabled_options?: string[]
20+
supported_reasoning_efforts?: string[]
2221
}
2322
}
23+
}
2424

2525
export const CHATBOTS = {
2626
'AI Studio': {
@@ -121,10 +121,6 @@ export const CHATBOTS = {
121121
'gemini-2.5-pro': { label: 'Gemini 2.5 Pro' }
122122
}
123123
} as Chatbot,
124-
HuggingChat: {
125-
url: 'https://huggingface.co/chat/',
126-
supports_user_provided_model: true
127-
} as Chatbot,
128124
Grok: {
129125
url: 'https://grok.com/',
130126
supported_options: { private: 'Private' },
@@ -136,9 +132,16 @@ export const CHATBOTS = {
136132
heavy: { label: 'Heavy' }
137133
}
138134
} as Chatbot,
135+
HuggingChat: {
136+
url: 'https://huggingface.co/chat/',
137+
supports_user_provided_model: true
138+
} as Chatbot,
139139
Kimi: {
140140
url: 'https://www.kimi.com/'
141141
} as Chatbot,
142+
LMArena: {
143+
url: 'https://lmarena.ai/'
144+
} as Chatbot,
142145
Minimax: {
143146
url: 'https://agent.minimax.io/'
144147
} as Chatbot,
@@ -235,5 +238,5 @@ export const CHATBOTS = {
235238
supported_options: {
236239
'deep-think': 'Deep Think'
237240
}
238-
} as Chatbot,
241+
} as Chatbot
239242
}

‎packages/vscode/package.json‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "gemini-coder",
33
"displayName": "Code Web Chat",
44
"description": "Superfast AI coding (CWC)",
5-
"version": "1.610.0",
5+
"version": "1.611.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",
@@ -582,9 +582,9 @@
582582
"scope": "resource",
583583
"description": "Style of generated code blocks in \"Edit context\" mode.",
584584
"default": {
585-
"whole": "Whenever showing a new or updated file, include a brief explanation of changes and its path. Print files in full because I have a disability which means I can't type and need to be able to just copy and paste.",
586-
"truncated": "Whenever showing a new or updated file, include a brief explanation of changes and its path. Unchanged parts should be truncated with ellipsis comments, e.g. \"// ...\".",
587-
"diff": "Whenever showing a new or updated file, include a brief explanation of changes. Print files in the Unified Diff format (that's compatible with the git apply command)."
585+
"whole": "Whenever showing a new or updated file, include a brief explanation of changes, the path and a Markdown Code Block with full contents—because I have a disability which means I can't type and need to be able to just copy and paste.",
586+
"truncated": "Whenever showing a new or updated file, include a brief explanation of changes, the path and a Markdown Code Block with truncated contents—unchanged parts should be replaced by ellipsis comments, e.g. \"// ...\".",
587+
"diff": "Whenever showing a new or updated file, include a brief explanation of changes, and print them in the Unified Diff format (that's compatible with the git apply command)."
588588
},
589589
"properties": {
590590
"whole": {

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,31 @@ describe('clipboard-parser', () => {
12391239
})
12401240
})
12411241

1242+
it('parses a mix of a new file from an XML tag heading and code block, and a separate diff block', () => {
1243+
const test_case = 'diff-mix-new-file-from-xml-tag-heading-and-diff'
1244+
const text = load_test_case_file(test_case, `${test_case}.txt`)
1245+
const result = parse_response({
1246+
response: text,
1247+
is_single_root_folder_workspace: true
1248+
})
1249+
1250+
expect(result).toHaveLength(3)
1251+
expect(result[0]).toMatchObject({
1252+
type: 'text',
1253+
content: load_test_case_file(test_case, '1-text.txt')
1254+
})
1255+
expect(result[1]).toMatchObject({
1256+
type: 'diff',
1257+
file_path: 'src/lorem.html',
1258+
content: load_test_case_file(test_case, '2-file.txt')
1259+
})
1260+
expect(result[2]).toMatchObject({
1261+
type: 'diff',
1262+
file_path: 'src/ipsum.ts',
1263+
content: load_test_case_file(test_case, '3-file.txt')
1264+
})
1265+
})
1266+
12421267
it('parses multiple files with text between the markdown code blocks', () => {
12431268
const test_case = 'text-between'
12441269
const text = load_test_case_file(test_case, `${test_case}.txt`)

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// packages/vscode/src/commands/apply-chat-response-command/utils/clipboard-parser/extract-diff-patches/extract-diffs.ts
21
import { Logger } from '@shared/utils/logger'
32
import { extract_path_from_line_of_code } from '@shared/utils/extract-path-from-line-of-code'
43
import { extract_workspace_and_path } from '../clipboard-parser'
@@ -592,6 +591,22 @@ const extract_all_code_block_patches = (params: {
592591
if (!prev_line) continue
593592

594593
let extracted = extract_path_from_line_of_code(prev_line)
594+
if (!extracted) {
595+
const xml_match = prev_line.match(/^<[^>]+>([^<]+)<\/[^>]+>$/)
596+
if (xml_match && xml_match[1]) {
597+
const potential_path = xml_match[1].trim()
598+
if (
599+
potential_path &&
600+
(potential_path.includes('/') ||
601+
potential_path.includes('\\') ||
602+
potential_path.includes('.')) &&
603+
!potential_path.includes(' ')
604+
) {
605+
extracted = potential_path
606+
}
607+
}
608+
}
609+
595610
if (!extracted) {
596611
const match = prev_line.match(/`([^`]+)`/)
597612
if (match && match[1]) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<summary>src/lorem.html</summary>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
--- /dev/null
2+
+++ b/src/lorem.html
3+
@@ -0,0 +1,1 @@
4+
+<div>lorem ipsum</div>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--- a/src/ipsum.ts
2+
+++ b/src/ipsum.ts
3+
@@ -1,3 +1,3 @@
4+
console.log("hello")
5+
-console.log("old ipsum")
6+
+console.log("new ipsum")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<summary>src/lorem.html</summary>
2+
3+
```html
4+
<div>lorem ipsum</div>
5+
```
6+
7+
```diff
8+
--- src/ipsum.ts
9+
+++ src/ipsum.ts
10+
@@ -1,3 +1,3 @@
11+
console.log("hello")
12+
-console.log("old ipsum")
13+
+console.log("new ipsum")
14+
```

0 commit comments

Comments
 (0)