Skip to content

Commit 48183b0

Browse files
committed
Remove attachOpenFiles setting and related logic
1 parent 90d0e35 commit 48183b0

6 files changed

Lines changed: 17 additions & 359 deletions

File tree

packages/vscode/package.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,11 +591,6 @@
591591
"description": "The prompt text used when generating commit messages.",
592592
"default": "Write a brief and precise summary for the following diff, limited to a single sentence if possible and nothing else. Use an imperative tone to ensure clarity and focus on the primary change or purpose."
593593
},
594-
"codeWebChat.attachOpenFiles": {
595-
"type": "boolean",
596-
"default": true,
597-
"description": "Attach open files to the context."
598-
},
599594
"codeWebChat.ignoredExtensions": {
600595
"type": "array",
601596
"description": "List of file extensions to ignore in the context.",

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

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -273,28 +273,6 @@ export function context_initialization(context: vscode.ExtensionContext): {
273273
})
274274
)
275275

276-
// Update badge when configuration changes
277-
context.subscriptions.push(
278-
vscode.workspace.onDidChangeConfiguration((event) => {
279-
if (event.affectsConfiguration('codeWebChat')) {
280-
// If attachOpenFiles setting changed, refresh the tree views
281-
if (event.affectsConfiguration('codeWebChat.attachOpenFiles')) {
282-
const config = vscode.workspace.getConfiguration('codeWebChat')
283-
const attachOpenFiles = config.get('attachOpenFiles', true)
284-
285-
// Update the OpenEditorsProvider with the new setting value
286-
if (open_editors_provider) {
287-
open_editors_provider.update_attach_open_files_setting(
288-
attachOpenFiles
289-
)
290-
}
291-
}
292-
293-
update_activity_bar_badge_token_count()
294-
}
295-
})
296-
)
297-
298276
// Update badge when tabs change with debouncing to avoid multiple updates
299277
let tab_change_timeout: NodeJS.Timeout | null = null
300278
context.subscriptions.push(

packages/vscode/src/context/providers/open-editors-provider.ts

Lines changed: 6 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export class OpenEditorsProvider
2323
private _tab_change_handler: vscode.Disposable
2424
private _file_change_watcher: vscode.Disposable
2525
private _ignored_extensions: Set<string> = new Set()
26-
private _attach_open_files: boolean = true
2726
private _initialized: boolean = false
2827
// Track files opened from workspace view
2928
private _opened_from_workspace_view: Set<string> = new Set()
@@ -46,10 +45,6 @@ export class OpenEditorsProvider
4645
// Load ignored extensions
4746
this._load_ignored_extensions()
4847

49-
// Load user preference for automatically attaching open files
50-
const config = vscode.workspace.getConfiguration('codeWebChat')
51-
this._attach_open_files = config.get('attachOpenFiles', true)
52-
5348
// Initialize the preview tabs map with current tabs
5449
this._update_preview_tabs_state()
5550

@@ -74,27 +69,18 @@ export class OpenEditorsProvider
7469
// Listen for configuration changes
7570
this._config_change_handler = vscode.workspace.onDidChangeConfiguration(
7671
(event) => {
77-
if (event.affectsConfiguration('codeWebChat')) {
78-
if (event.affectsConfiguration('codeWebChat.attachOpenFiles')) {
79-
const config = vscode.workspace.getConfiguration('codeWebChat')
80-
this.update_attach_open_files_setting(
81-
config.get('attachOpenFiles', true)
82-
)
83-
}
84-
if (event.affectsConfiguration('codeWebChat.ignoredExtensions')) {
85-
const old_ignored_extensions = new Set(this._ignored_extensions)
86-
this._load_ignored_extensions()
87-
this._uncheck_ignored_files(old_ignored_extensions)
88-
this.refresh()
89-
}
72+
if (event.affectsConfiguration('codeWebChat.ignoredExtensions')) {
73+
const old_ignored_extensions = new Set(this._ignored_extensions)
74+
this._load_ignored_extensions()
75+
this._uncheck_ignored_files(old_ignored_extensions)
76+
this.refresh()
9077
}
9178
}
9279
)
9380

9481
// Initial auto-check of all open editors
9582
// We'll use setTimeout to ensure VS Code has fully loaded editors
9683
setTimeout(() => {
97-
this._auto_check_open_editors()
9884
this._initialized = true
9985
this._on_did_change_tree_data.fire() // Fire event to refresh view
10086
}, 500) // Small delay to ensure VS Code has loaded all editors
@@ -181,14 +167,8 @@ export class OpenEditorsProvider
181167
// Only track text tabs
182168
if (tab.input instanceof vscode.TabInputText) {
183169
const file_path = tab.input.uri.fsPath
184-
const was_preview = this._preview_tabs.get(file_path)
185170
const is_now_preview = !!tab.isPreview
186171

187-
// If the file was in preview mode and now is not
188-
if (was_preview && !is_now_preview) {
189-
this._handle_file_out_of_preview_state(file_path)
190-
}
191-
192172
// Update preview state
193173
this._preview_tabs.set(file_path, is_now_preview)
194174
}
@@ -209,38 +189,6 @@ export class OpenEditorsProvider
209189
}
210190
}
211191

212-
private _handle_file_out_of_preview_state(file_path: string): void {
213-
// Only proceed if the setting is enabled
214-
if (!this._attach_open_files) return
215-
216-
// Skip files not in any workspace
217-
if (!this._is_file_in_any_workspace(file_path)) return
218-
219-
if (should_ignore_file(file_path, this._ignored_extensions)) return
220-
221-
// Skip if already checked
222-
if (
223-
this._checked_items.get(file_path) ===
224-
vscode.TreeItemCheckboxState.Checked
225-
)
226-
return
227-
228-
// Check if this file was opened from workspace view
229-
const was_opened_from_workspace_view =
230-
this._opened_from_workspace_view.has(file_path)
231-
232-
// Remove from tracking set - we'll process it now regardless
233-
if (was_opened_from_workspace_view) {
234-
this._opened_from_workspace_view.delete(file_path)
235-
}
236-
237-
// Mark as checked when file is unpinned - even if it was opened from workspace view
238-
this._checked_items.set(file_path, vscode.TreeItemCheckboxState.Checked)
239-
240-
// Clear token count to recalculate
241-
this._file_token_counts.delete(file_path)
242-
}
243-
244192
// Mark files opened from workspace view
245193
mark_opened_from_workspace_view(file_path: string): void {
246194
this._opened_from_workspace_view.add(file_path)
@@ -257,71 +205,10 @@ export class OpenEditorsProvider
257205
// Clean up closed files from checked_items
258206
this._clean_up_closed_files()
259207

260-
// Handle newly opened files (this is the new part)
261-
this._handle_newly_opened_files()
262-
263208
// Trigger view update
264209
this._on_did_change_tree_data.fire()
265210
}
266211

267-
// Modified method to handle newly opened files
268-
private _handle_newly_opened_files(): void {
269-
// Only auto-check new files if the setting is enabled
270-
if (!this._attach_open_files) return
271-
272-
const open_file_paths = this._get_open_editors()
273-
274-
for (const uri of open_file_paths) {
275-
const file_path = uri.fsPath
276-
277-
// Skip files not in any workspace
278-
if (!this._is_file_in_any_workspace(file_path)) continue
279-
280-
if (should_ignore_file(file_path, this._ignored_extensions)) continue
281-
282-
// Check if this is a new file that isn't in our map yet
283-
if (!this._checked_items.has(file_path)) {
284-
// First, check if this file is already checked in the workspace view
285-
const is_checked_in_workspace =
286-
this._is_file_checked_in_workspace(file_path)
287-
288-
if (is_checked_in_workspace) {
289-
// If checked in workspace view, use that state
290-
this._checked_items.set(
291-
file_path,
292-
vscode.TreeItemCheckboxState.Checked
293-
)
294-
} else if (
295-
this._opened_from_workspace_view.has(file_path) ||
296-
this._preview_tabs.get(file_path)
297-
) {
298-
// Don't auto-check if the file was opened from workspace view or is in preview mode
299-
this._checked_items.set(
300-
file_path,
301-
vscode.TreeItemCheckboxState.Unchecked
302-
)
303-
304-
// Only remove from set if not in preview mode - keep tracking preview files
305-
if (!this._preview_tabs.get(file_path)) {
306-
this._opened_from_workspace_view.delete(file_path)
307-
}
308-
} else {
309-
// Auto-check new files opened through other means and not in preview mode
310-
this._checked_items.set(
311-
file_path,
312-
vscode.TreeItemCheckboxState.Checked
313-
)
314-
}
315-
316-
// Clear token count for this file to force recalculation
317-
this._file_token_counts.delete(file_path)
318-
}
319-
}
320-
321-
// Force a complete tree refresh
322-
this._on_did_change_tree_data.fire()
323-
}
324-
325212
// New method to check if a file is checked in workspace view
326213
private _is_file_checked_in_workspace(file_path: string): boolean {
327214
// Get checked files from workspace provider through SharedFileState
@@ -486,12 +373,7 @@ export class OpenEditorsProvider
486373
// If it's checked in workspace view, use that state
487374
checkbox_state = vscode.TreeItemCheckboxState.Checked
488375
} else {
489-
const is_preview = this._preview_tabs.get(file_path)
490-
// Only auto-check if attach_open_files is enabled and file is not in preview mode
491-
checkbox_state =
492-
this._attach_open_files && !is_preview
493-
? vscode.TreeItemCheckboxState.Checked
494-
: vscode.TreeItemCheckboxState.Unchecked
376+
checkbox_state = vscode.TreeItemCheckboxState.Unchecked
495377
}
496378

497379
this._checked_items.set(file_path, checkbox_state)
@@ -671,46 +553,6 @@ export class OpenEditorsProvider
671553
this._on_did_change_checked_files.fire()
672554
}
673555

674-
update_attach_open_files_setting(value: boolean): void {
675-
if (this._attach_open_files == value) {
676-
return
677-
}
678-
this._attach_open_files = value
679-
this.refresh()
680-
}
681-
682-
private async _auto_check_open_editors(): Promise<void> {
683-
if (!this._attach_open_files) return
684-
685-
const open_files = this._get_open_editors()
686-
// Get checked workspace files for reference
687-
const workspace_checked_files = this._shared_state.get_checked_files()
688-
689-
for (const uri of open_files) {
690-
const file_path = uri.fsPath
691-
692-
// Skip files not in any workspace
693-
if (!this._is_file_in_any_workspace(file_path)) continue
694-
695-
if (should_ignore_file(file_path, this._ignored_extensions)) continue
696-
697-
// Check if the file is in preview mode
698-
const is_preview = this._preview_tabs.get(file_path)
699-
700-
// If the file is checked in workspace view, reflect that state
701-
if (workspace_checked_files.includes(file_path)) {
702-
this._checked_items.set(file_path, vscode.TreeItemCheckboxState.Checked)
703-
}
704-
// Only auto-check if not already set by user, not in preview mode, and not checked in workspace
705-
else if (!this._checked_items.has(file_path) && !is_preview) {
706-
this._checked_items.set(file_path, vscode.TreeItemCheckboxState.Checked)
707-
}
708-
}
709-
710-
// Fire the checked files change event to trigger synchronization
711-
this._on_did_change_checked_files.fire()
712-
}
713-
714556
is_initialized(): boolean {
715557
return this._initialized
716558
}

0 commit comments

Comments
 (0)