Skip to content

Commit 74251eb

Browse files
committed
Implement no-context mode to hide selection checkboxes in workspace and open editors views when enabled
- The workspace/open editors panels should not show checkboxes in 'no context' prompt type.
1 parent 0bd9f2c commit 74251eb

3 files changed

Lines changed: 33 additions & 9 deletions

File tree

‎apps/editor/src/context/providers/open-editors/open-editors-provider.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export class OpenEditorsProvider
4444
private _config_change_handler: vscode.Disposable
4545
private _workspace_provider: WorkspaceProvider
4646
private _use_shrink_token_count: boolean = false
47+
private _is_no_context_mode = false
4748

4849
public set_use_shrink_token_count(use_shrink: boolean) {
4950
if (this._use_shrink_token_count != use_shrink) {
@@ -52,6 +53,12 @@ export class OpenEditorsProvider
5253
}
5354
}
5455

56+
public set_no_context_mode(is_no_context: boolean) {
57+
if (this._is_no_context_mode == is_no_context) return
58+
this._is_no_context_mode = is_no_context
59+
this.refresh()
60+
}
61+
5562
public switch_context_state(is_frf: boolean) {
5663
if (this._is_frf_mode == is_frf) return
5764
this._is_frf_mode = is_frf
@@ -223,8 +230,9 @@ export class OpenEditorsProvider
223230
}
224231
getTreeItem(element: FileItem): vscode.TreeItem {
225232
const key = element.resourceUri.fsPath
226-
const checkbox_state =
227-
this._checked_items.get(key) ?? vscode.TreeItemCheckboxState.Unchecked
233+
const checkbox_state = this._is_no_context_mode
234+
? undefined
235+
: (this._checked_items.get(key) ?? vscode.TreeItemCheckboxState.Unchecked)
228236

229237
element.checkboxState = checkbox_state
230238

@@ -342,7 +350,7 @@ export class OpenEditorsProvider
342350
file_uri,
343351
vscode.TreeItemCollapsibleState.None,
344352
false,
345-
checkbox_state,
353+
this._is_no_context_mode ? undefined : checkbox_state,
346354
false,
347355
true,
348356
tokens.total,

‎apps/editor/src/context/providers/workspace/workspace-provider.ts‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export class WorkspaceProvider
6565
partially_checked_dirs: new Set<string>()
6666
}
6767
private _is_frf_mode: boolean = false
68+
private _is_no_context_mode: boolean = false
6869

6970
public get is_frf_mode(): boolean {
7071
return this._is_frf_mode
@@ -136,6 +137,12 @@ export class WorkspaceProvider
136137
this._workspace_view_collapsible_state = state
137138
}
138139

140+
public set_no_context_mode(is_no_context: boolean) {
141+
if (this._is_no_context_mode == is_no_context) return
142+
this._is_no_context_mode = is_no_context
143+
this.refresh()
144+
}
145+
139146
public set_use_shrink_token_count(use_shrink: boolean) {
140147
if (this.use_shrink_token_count != use_shrink) {
141148
this.use_shrink_token_count = use_shrink
@@ -682,8 +689,9 @@ export class WorkspaceProvider
682689

683690
async getTreeItem(element: FileItem): Promise<vscode.TreeItem> {
684691
const key = element.resourceUri.fsPath
685-
const checkbox_state =
686-
this._checked_items.get(key) ?? vscode.TreeItemCheckboxState.Unchecked
692+
const checkbox_state = this._is_no_context_mode
693+
? undefined
694+
: (this._checked_items.get(key) ?? vscode.TreeItemCheckboxState.Unchecked)
687695

688696
element.checkboxState = checkbox_state
689697

@@ -876,8 +884,10 @@ export class WorkspaceProvider
876884
? this._context_view_collapsible_state
877885
: this._workspace_view_collapsible_state,
878886
true,
879-
this._checked_items.get(root) ??
880-
vscode.TreeItemCheckboxState.Unchecked,
887+
this._is_no_context_mode
888+
? undefined
889+
: (this._checked_items.get(root) ??
890+
vscode.TreeItemCheckboxState.Unchecked),
881891
false,
882892
false,
883893
total_tokens.total,
@@ -1143,7 +1153,7 @@ export class WorkspaceProvider
11431153
: this._workspace_view_collapsible_state
11441154
: vscode.TreeItemCollapsibleState.None,
11451155
is_directory,
1146-
checkbox_state,
1156+
this._is_no_context_mode ? undefined : checkbox_state,
11471157
is_symbolic_link,
11481158
false,
11491159
tokens.total,
@@ -1810,7 +1820,7 @@ export class FileItem extends vscode.TreeItem {
18101820
public readonly resourceUri: vscode.Uri,
18111821
public collapsibleState: vscode.TreeItemCollapsibleState,
18121822
public isDirectory: boolean,
1813-
public checkboxState: vscode.TreeItemCheckboxState,
1823+
public checkboxState: vscode.TreeItemCheckboxState | undefined,
18141824
public isSymbolicLink: boolean = false,
18151825
public isOpenFile: boolean = false,
18161826
public tokenCount?: number,

‎apps/editor/src/views/panel/backend/panel-provider.ts‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,13 @@ export class PanelProvider implements vscode.WebviewViewProvider {
279279
this.web_prompt_type == 'find-relevant-files') ||
280280
(this.mode == MODE.API && this.api_prompt_type == 'find-relevant-files')
281281

282+
const is_no_context =
283+
this.mode == MODE.WEB && this.web_prompt_type == 'no-context'
284+
282285
SharedFileState.get_instance().switch_context_state(is_find_relevant_files)
286+
287+
this.workspace_provider.set_no_context_mode(is_no_context)
288+
this.open_editors_provider.set_no_context_mode(is_no_context)
283289
}
284290

285291
public async switch_to_edit_context() {

0 commit comments

Comments
 (0)