Skip to content

Commit cc3497a

Browse files
committed
Merge branch 'dev'
2 parents 99f9a12 + 4af7e8b commit cc3497a

26 files changed

Lines changed: 400 additions & 117 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export const ResponsePreview: FC<Props> = (props) => {
185185
{(file.is_fallback || file.is_replaced) && (
186186
<IconButton
187187
codicon_icon="sparkle"
188-
title={`Call Intelligent Update API tool${
188+
title={`Fix the file with Intelligent Update API tool${
189189
file.diff_fallback_method == 'recount'
190190
? ' (fallback used: git apply with --recount flag)'
191191
: file.diff_fallback_method ==

‎packages/ui/src/components/editor/panel/modals/Modal/Modal.module.scss‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
top: 0;
1919
left: 0;
2020
background-color: var(--vscode-sideBar-background);
21-
opacity: 0.7;
21+
opacity: 0.4;
2222
}
2323
}
2424

‎packages/ui/src/components/editor/settings/Section/Section.module.scss‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
var(--padding-60px) + var(--padding-4px)
2323
); // to align with the sidebar title
2424
padding-bottom: var(--padding-10px);
25+
padding-left: var(--padding-12px);
26+
padding-right: var(--padding-12px);
2527
background-color: var(--vscode-editor-background);
2628
transition: box-shadow var(--transition-duration-250)
2729
var(--transition-timing-function);

‎packages/vscode/package.json‎

Lines changed: 8 additions & 3 deletions
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.515.0",
5+
"version": "1.516.0",
66
"scripts": {
77
"build": "npx vsce package --no-dependencies",
88
"vscode:prepublish": "rimraf out && npm run compile",
@@ -270,8 +270,7 @@
270270
{
271271
"command": "codeWebChat.settings",
272272
"title": "Settings",
273-
"category": "Code Web Chat",
274-
"icon": "$(settings-gear)"
273+
"category": "Code Web Chat"
275274
}
276275
],
277276
"menus": {
@@ -571,6 +570,12 @@
571570
}
572571
}
573572
},
573+
"codeWebChat.editContextSystemInstructions": {
574+
"type": "string",
575+
"scope": "resource",
576+
"description": "System instructions for the Edit Context API tool.",
577+
"default": "You're a helpful coding assistant."
578+
},
574579
"codeWebChat.chatPresetsForAskAboutContext": {
575580
"type": "array",
576581
"default": [

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export const extract_workspace_and_path = (params: {
6767
}
6868

6969
export const has_real_code = (content: string): boolean => {
70-
if (content.trim() === '') {
70+
if (content.trim() == '') {
7171
return true
7272
}
7373
const lines = content.split('\n')
@@ -104,21 +104,19 @@ export const parse_response = (params: {
104104
const processed_response = params.response.replace(/``````/g, '```\n```')
105105

106106
const hunk_header_regex = /^(@@\s+-\d+(?:,\d+)?\s+\+\d+(?:,\d+)?\s+@@)/m
107+
const has_diff_lines_regex = /^[+-] /m
107108

108109
if (
109-
processed_response.includes('```diff') ||
110-
processed_response.includes('```patch') ||
111-
processed_response.startsWith('--- ') ||
112-
processed_response.startsWith('diff --git') ||
113-
hunk_header_regex.test(processed_response)
110+
hunk_header_regex.test(processed_response) &&
111+
has_diff_lines_regex.test(processed_response)
114112
) {
115113
const patches_or_text = extract_diffs({
116114
clipboard_text: processed_response,
117115
is_single_root: is_single_root_folder_workspace
118116
})
119117
if (patches_or_text.length) {
120118
return patches_or_text.map((item) => {
121-
if ('type' in item && item.type === 'text') {
119+
if ('type' in item && item.type == 'text') {
122120
return item
123121
}
124122
return { type: 'diff', ...item }
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import * as vscode from 'vscode'
2+
import { WorkspaceProvider } from '../context/providers/workspace-provider'
3+
import { WebsitesProvider } from '../context/providers/websites-provider'
4+
import {
5+
DUPLICATE_WORKSPACE_CONTEXT_STATE_KEY,
6+
type DuplicateWorkspaceContext
7+
} from '../constants/state-keys'
8+
9+
export function duplicate_workspace_command(
10+
workspace_provider: WorkspaceProvider,
11+
websites_provider: WebsitesProvider,
12+
context: vscode.ExtensionContext
13+
) {
14+
return vscode.commands.registerCommand(
15+
'codeWebChat.duplicateWorkspace',
16+
async () => {
17+
const checked_files = workspace_provider.get_all_checked_paths()
18+
const checked_websites = websites_provider
19+
.get_checked_websites()
20+
.map((w) => w.url)
21+
const workspace_root_folders =
22+
vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath) ??
23+
[]
24+
25+
const context_to_save: DuplicateWorkspaceContext = {
26+
checked_files,
27+
checked_websites,
28+
workspace_root_folders,
29+
timestamp: Date.now()
30+
}
31+
32+
await context.globalState.update(
33+
DUPLICATE_WORKSPACE_CONTEXT_STATE_KEY,
34+
context_to_save
35+
)
36+
37+
vscode.commands.executeCommand(
38+
'workbench.action.duplicateWorkspaceInNewWindow'
39+
)
40+
}
41+
)
42+
}

‎packages/vscode/src/commands/index.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export * from './apply-chat-response-command'
22
export * from './close-all-editors-command'
33
export * from './checkpoints-command'
44
export * from './close-editor-command'
5+
export * from './duplicate-workspace-command'
56
export * from './code-completion-commands'
67
export * from './delete-command'
78
export * from './new-file-command'

‎packages/vscode/src/constants/state-keys.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ export const LAST_REFACTOR_INSTRUCTION_STATE_KEY = 'last-refactor-instruction'
3131
export const CHECKPOINTS_STATE_KEY = 'checkpoints'
3232
export const TEMPORARY_CHECKPOINT_STATE_KEY = 'temporary-checkpoint'
3333

34+
export const DUPLICATE_WORKSPACE_CONTEXT_STATE_KEY =
35+
'duplicate-workspace-context'
36+
3437
export const CHAT_EDIT_FORMAT_STATE_KEY = 'chat-edit-format'
3538
export const API_EDIT_FORMAT_STATE_KEY = 'api-edit-format'
3639
export const WEB_MODE_STATE_KEY = 'web-mode'
@@ -67,6 +70,13 @@ export const get_last_selected_preset_key = (web_mode: string) =>
6770
export const get_last_selected_group_state_key = (web_mode: string) =>
6871
`last-selected-group-${web_mode}`
6972

73+
export interface DuplicateWorkspaceContext {
74+
checked_files: string[]
75+
checked_websites: string[]
76+
timestamp: number
77+
workspace_root_folders: string[]
78+
}
79+
7080
export interface HistoryEntry {
7181
text: string
7282
createdAt: number

‎packages/vscode/src/context/context-initialization.ts‎

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ import { marked } from 'marked'
99
import { EventEmitter } from 'events'
1010
import { apply_context_command } from '../commands/apply-context-command/apply-context-command'
1111
import { dictionary } from '@shared/constants/dictionary'
12+
import {
13+
CONTEXT_CHECKED_PATHS_STATE_KEY,
14+
CONTEXT_CHECKED_URLS_STATE_KEY,
15+
DUPLICATE_WORKSPACE_CONTEXT_STATE_KEY,
16+
type DuplicateWorkspaceContext
17+
} from '../constants/state-keys'
1218
import { ContextProvider } from './providers/context-provider'
1319

1420
export const token_count_emitter = new EventEmitter()
@@ -20,13 +26,60 @@ const round_token_count_for_badge = (count: number): number => {
2026
return Math.floor(count / 1000) * 1000
2127
}
2228

23-
export const context_initialization = (
29+
const restore_duplicated_workspace_context = async (
2430
context: vscode.ExtensionContext
25-
): {
31+
) => {
32+
const duplicated_context = context.globalState.get<DuplicateWorkspaceContext>(
33+
DUPLICATE_WORKSPACE_CONTEXT_STATE_KEY
34+
)
35+
36+
if (duplicated_context?.timestamp) {
37+
const now = Date.now()
38+
const age = now - duplicated_context.timestamp
39+
40+
if (age <= 60000) {
41+
const current_workspace_folders =
42+
vscode.workspace.workspaceFolders?.map((folder) => folder.uri.fsPath) ??
43+
[]
44+
45+
const sorted_current_folders = [...current_workspace_folders].sort()
46+
const sorted_saved_folders = [
47+
...(duplicated_context.workspace_root_folders ?? [])
48+
].sort()
49+
50+
const are_workspaces_the_same =
51+
sorted_current_folders.length == sorted_saved_folders.length &&
52+
sorted_current_folders.every(
53+
(value, index) => value == sorted_saved_folders[index]
54+
)
55+
if (are_workspaces_the_same) {
56+
await context.workspaceState.update(
57+
CONTEXT_CHECKED_PATHS_STATE_KEY,
58+
duplicated_context.checked_files
59+
)
60+
await context.workspaceState.update(
61+
CONTEXT_CHECKED_URLS_STATE_KEY,
62+
duplicated_context.checked_websites
63+
)
64+
}
65+
}
66+
67+
await context.globalState.update(
68+
DUPLICATE_WORKSPACE_CONTEXT_STATE_KEY,
69+
undefined
70+
)
71+
}
72+
}
73+
74+
export const context_initialization = async (
75+
context: vscode.ExtensionContext
76+
): Promise<{
2677
workspace_provider: WorkspaceProvider
2778
open_editors_provider: OpenEditorsProvider
2879
websites_provider: WebsitesProvider
29-
} => {
80+
}> => {
81+
await restore_duplicated_workspace_context(context)
82+
3083
let was_above_threshold = false
3184

3285
const workspace_folders = vscode.workspace.workspaceFolders ?? []

‎packages/vscode/src/extension.ts‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
new_file_command,
1818
open_file_from_workspace_command,
1919
new_folder_command,
20+
duplicate_workspace_command,
2021
rename_command,
2122
delete_command,
2223
save_context_command,
@@ -31,7 +32,7 @@ let websocket_server_instance: WebSocketManager | null = null
3132

3233
export async function activate(context: vscode.ExtensionContext) {
3334
const { workspace_provider, open_editors_provider, websites_provider } =
34-
context_initialization(context)
35+
await context_initialization(context)
3536

3637
websocket_server_instance = new WebSocketManager(context, websites_provider)
3738

@@ -89,11 +90,7 @@ export async function activate(context: vscode.ExtensionContext) {
8990
delete_command(),
9091
save_context_command(workspace_provider, context),
9192
...checkpoints_command(workspace_provider, context),
92-
vscode.commands.registerCommand('codeWebChat.duplicateWorkspace', () => {
93-
vscode.commands.executeCommand(
94-
'workbench.action.duplicateWorkspaceInNewWindow'
95-
)
96-
}),
93+
duplicate_workspace_command(workspace_provider, websites_provider, context),
9794
open_url_command({
9895
command: 'codeWebChat.openRepository',
9996
url: 'https://github.com/robertpiosik/CodeWebChat'

0 commit comments

Comments
 (0)