Skip to content

Commit e31678d

Browse files
committed
Rename the workspace setting and associated messages for clearing checks from clearChecksInWorkspace to clearChecksInWorkspaceBehavior for improved clarity and consistency
1 parent 71e5f67 commit e31678d

4 files changed

Lines changed: 73 additions & 57 deletions

File tree

‎packages/vscode/src/context/providers/workspace-provider.ts‎

Lines changed: 51 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -394,57 +394,70 @@ export class WorkspaceProvider
394394
}, 1000) // Debounce refresh to handle bulk file changes like builds
395395
}
396396
public clear_checks(): void {
397-
// Get a list of currently open files to preserve their check state
398-
const open_files = new Set(
399-
this._get_open_editors().map((uri) => uri.fsPath)
397+
const config = vscode.workspace.getConfiguration('codeWebChat')
398+
const clear_checks_in_workspace_behavior = config.get<string>(
399+
'clearChecksInWorkspaceBehavior'
400400
)
401401

402-
const checked_open_files = Array.from(this.checked_items.entries())
403-
.filter(
404-
([path, state]) =>
405-
open_files.has(path) && state == vscode.TreeItemCheckboxState.Checked
402+
if (clear_checks_in_workspace_behavior == 'uncheck-all') {
403+
this.checked_items.clear()
404+
this.partially_checked_dirs.clear()
405+
this.directory_selected_token_counts.clear()
406+
} else {
407+
// Get a list of currently open files to preserve their check state
408+
const open_files = new Set(
409+
this._get_open_editors().map((uri) => uri.fsPath)
406410
)
407-
.map(([path]) => path)
408411

409-
const new_checked_items = new Map<string, vscode.TreeItemCheckboxState>()
412+
const checked_open_files = Array.from(this.checked_items.entries())
413+
.filter(
414+
([path, state]) =>
415+
open_files.has(path) &&
416+
state == vscode.TreeItemCheckboxState.Checked
417+
)
418+
.map(([path]) => path)
419+
420+
const new_checked_items = new Map<string, vscode.TreeItemCheckboxState>()
410421

411-
for (const [path, state] of this.checked_items.entries()) {
412-
if (open_files.has(path)) {
413-
new_checked_items.set(path, state)
422+
for (const [path, state] of this.checked_items.entries()) {
423+
if (open_files.has(path)) {
424+
new_checked_items.set(path, state)
425+
}
414426
}
415-
}
416427

417-
this.checked_items = new_checked_items
428+
this.checked_items = new_checked_items
418429

419-
this.partially_checked_dirs.clear()
420-
this.directory_selected_token_counts.clear()
430+
this.partially_checked_dirs.clear()
431+
this.directory_selected_token_counts.clear()
421432

422-
for (const file_path of open_files) {
423-
if (this.checked_items.has(file_path)) {
424-
let dir_path = path.dirname(file_path)
425-
const workspace_root = this.get_workspace_root_for_file(file_path)
426-
while (workspace_root && dir_path.startsWith(workspace_root)) {
427-
this._update_parent_state(dir_path)
428-
dir_path = path.dirname(dir_path)
433+
for (const file_path of open_files) {
434+
if (this.checked_items.has(file_path)) {
435+
let dir_path = path.dirname(file_path)
436+
const workspace_root = this.get_workspace_root_for_file(file_path)
437+
while (workspace_root && dir_path.startsWith(workspace_root)) {
438+
this._update_parent_state(dir_path)
439+
dir_path = path.dirname(dir_path)
440+
}
429441
}
430442
}
431-
}
432443

433-
if (checked_open_files.length > 0) {
434-
vscode.window
435-
.showInformationMessage(
436-
`${checked_open_files.length} file${
437-
checked_open_files.length == 1 ? '' : 's'
438-
} remain${checked_open_files.length == 1 ? 's' : ''} checked.`,
439-
'Clear open editors'
440-
)
441-
.then((selection) => {
442-
if (selection == 'Clear open editors') {
443-
vscode.commands.executeCommand('codeWebChat.clearChecksOpenEditors')
444-
}
445-
})
444+
if (checked_open_files.length > 0) {
445+
vscode.window
446+
.showInformationMessage(
447+
`${checked_open_files.length} file${
448+
checked_open_files.length == 1 ? '' : 's'
449+
} remain${checked_open_files.length == 1 ? 's' : ''} checked.`,
450+
'Clear open editors'
451+
)
452+
.then((selection) => {
453+
if (selection == 'Clear open editors') {
454+
vscode.commands.executeCommand(
455+
'codeWebChat.clearChecksOpenEditors'
456+
)
457+
}
458+
})
459+
}
446460
}
447-
448461
this.refresh()
449462
this._on_did_change_checked_files.fire()
450463
}

‎packages/vscode/src/views/settings/backend/settings-provider.ts‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,20 +222,23 @@ export class SettingsProvider {
222222
case 'UPDATE_CONTEXT_SIZE_WARNING_THRESHOLD':
223223
await handle_update_context_size_warning_threshold(this, message)
224224
break
225-
case 'GET_CLEAR_CHECKS_IN_WORKSPACE': {
225+
case 'GET_CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR': {
226226
const config = vscode.workspace.getConfiguration('codeWebChat')
227227
const value = config.get<'ignore-open-editors' | 'uncheck-all'>(
228-
'clearChecksInWorkspace',
228+
'clearChecksInWorkspaceBehavior',
229229
'ignore-open-editors'
230230
)
231-
this.postMessage({ command: 'CLEAR_CHECKS_IN_WORKSPACE', value })
231+
this.postMessage({
232+
command: 'CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR',
233+
value
234+
})
232235
break
233236
}
234-
case 'UPDATE_CLEAR_CHECKS_IN_WORKSPACE':
237+
case 'UPDATE_CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR':
235238
await vscode.workspace
236239
.getConfiguration('codeWebChat')
237240
.update(
238-
'clearChecksInWorkspace',
241+
'clearChecksInWorkspaceBehavior',
239242
message.value,
240243
vscode.ConfigurationTarget.Global
241244
)
@@ -282,10 +285,10 @@ export class SettingsProvider {
282285
{
283286
const config = vscode.workspace.getConfiguration('codeWebChat')
284287
this.postMessage({
285-
command: 'CLEAR_CHECKS_IN_WORKSPACE',
288+
command: 'CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR',
286289
value:
287290
config.get<'ignore-open-editors' | 'uncheck-all'>(
288-
'clearChecksInWorkspace'
291+
'clearChecksInWorkspaceBehavior'
289292
) ?? 'ignore-open-editors'
290293
})
291294
}

‎packages/vscode/src/views/settings/frontend/hooks/use-settings.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const use_settings = (vscode: any) => {
4444
post_message(vscode, { command: 'GET_COMMIT_MESSAGE_INSTRUCTIONS' })
4545
post_message(vscode, { command: 'GET_CONTEXT_SIZE_WARNING_THRESHOLD' })
4646
post_message(vscode, { command: 'GET_GEMINI_USER_ID' })
47-
post_message(vscode, { command: 'GET_CLEAR_CHECKS_IN_WORKSPACE' })
47+
post_message(vscode, { command: 'GET_CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR' })
4848
}, [vscode])
4949

5050
useEffect(() => {
@@ -75,7 +75,7 @@ export const use_settings = (vscode: any) => {
7575
case 'GEMINI_USER_ID':
7676
set_gemini_user_id(message.geminiUserId)
7777
break
78-
case 'CLEAR_CHECKS_IN_WORKSPACE':
78+
case 'CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR':
7979
set_clear_checks_in_workspace(message.value)
8080
break
8181
}
@@ -198,7 +198,7 @@ export const use_settings = (vscode: any) => {
198198
value: 'ignore-open-editors' | 'uncheck-all'
199199
) =>
200200
post_message(vscode, {
201-
command: 'UPDATE_CLEAR_CHECKS_IN_WORKSPACE',
201+
command: 'UPDATE_CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR',
202202
value
203203
})
204204

‎packages/vscode/src/views/settings/types/messages.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ export interface UpdateGeminiUserIdMessage {
185185
geminiUserId: number | null
186186
}
187187

188-
export interface GetClearChecksInWorkspaceMessage {
189-
command: 'GET_CLEAR_CHECKS_IN_WORKSPACE'
188+
export interface GetClearChecksInWorkspaceBehaviorMessage {
189+
command: 'GET_CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR'
190190
}
191191

192-
export interface UpdateClearChecksInWorkspaceMessage {
193-
command: 'UPDATE_CLEAR_CHECKS_IN_WORKSPACE'
192+
export interface UpdateClearChecksInWorkspaceBehaviorMessage {
193+
command: 'UPDATE_CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR'
194194
value: 'ignore-open-editors' | 'uncheck-all'
195195
}
196196

@@ -231,8 +231,8 @@ export type FrontendMessage =
231231
| UpdateContextSizeWarningThresholdMessage
232232
| GetGeminiUserIdMessage
233233
| UpdateGeminiUserIdMessage
234-
| GetClearChecksInWorkspaceMessage
235-
| UpdateClearChecksInWorkspaceMessage
234+
| GetClearChecksInWorkspaceBehaviorMessage
235+
| UpdateClearChecksInWorkspaceBehaviorMessage
236236
| OpenEditorSettingsMessage
237237

238238
// === FROM BACKEND TO FRONTEND ===
@@ -273,8 +273,8 @@ export interface GeminiUserIdMessage {
273273
geminiUserId: number | null
274274
}
275275

276-
export interface ClearChecksInWorkspaceMessage {
277-
command: 'CLEAR_CHECKS_IN_WORKSPACE'
276+
export interface ClearChecksInWorkspaceBehaviorMessage {
277+
command: 'CLEAR_CHECKS_IN_WORKSPACE_BEHAVIOR'
278278
value: 'ignore-open-editors' | 'uncheck-all'
279279
}
280280

@@ -292,5 +292,5 @@ export type BackendMessage =
292292
| CommitMessageInstructionsMessage
293293
| ContextSizeWarningThresholdMessage
294294
| GeminiUserIdMessage
295-
| ClearChecksInWorkspaceMessage
295+
| ClearChecksInWorkspaceBehaviorMessage
296296
| ShowSectionMessage

0 commit comments

Comments
 (0)