@@ -3,7 +3,7 @@ import * as path from 'path'
33import {
44 WorkspaceProvider ,
55 FileItem ,
6- WebsitesFolderItem
6+ ContextFolderItem
77} from './providers/workspace-provider'
88import { FilesCollector } from '../utils/files-collector'
99import { OpenEditorsProvider } from './providers/open-editors-provider'
@@ -23,15 +23,12 @@ export function context_initialization(context: vscode.ExtensionContext): {
2323} {
2424 const workspace_folders = vscode . workspace . workspaceFolders ?? [ ]
2525
26- let workspace_view : vscode . TreeView <
27- FileItem | WebsiteItem | WebsitesFolderItem
28- >
26+ let workspace_view : vscode . TreeView < FileItem | ContextFolderItem >
2927
3028 const websites_provider = new WebsitesProvider ( context )
3129 const workspace_provider = new WorkspaceProvider (
3230 workspace_folders as any ,
33- context ,
34- websites_provider
31+ context
3532 )
3633 context . subscriptions . push ( websites_provider )
3734
@@ -47,22 +44,24 @@ export function context_initialization(context: vscode.ExtensionContext): {
4744 )
4845
4946 const update_activity_bar_badge_token_count = async ( ) => {
50- let total_token_count = 0
51-
52- if ( workspace_provider ) {
53- total_token_count +=
47+ if ( workspace_provider && workspace_view ) {
48+ const workspace_token_count =
5449 await workspace_provider . get_checked_files_token_count ( )
50+ workspace_view . badge = {
51+ value : workspace_token_count ,
52+ tooltip : workspace_token_count
53+ ? `About ${ workspace_token_count } tokens in context`
54+ : ''
55+ }
5556 }
5657
57- if ( websites_provider ) {
58- total_token_count += websites_provider . get_checked_websites_token_count ( )
59- }
60-
61- if ( workspace_view ) {
62- workspace_view . badge = {
63- value : total_token_count ,
64- tooltip : total_token_count
65- ? `About ${ total_token_count } tokens in context`
58+ if ( websites_provider && websites_view ) {
59+ const websites_token_count =
60+ websites_provider . get_checked_websites_token_count ( )
61+ websites_view . badge = {
62+ value : websites_token_count ,
63+ tooltip : websites_token_count
64+ ? `About ${ websites_token_count } tokens in context`
6665 : ''
6766 }
6867 }
@@ -80,7 +79,7 @@ export function context_initialization(context: vscode.ExtensionContext): {
8079 } )
8180
8281 const register_workspace_view_handlers = (
83- view : vscode . TreeView < FileItem | WebsiteItem | WebsitesFolderItem >
82+ view : vscode . TreeView < FileItem | ContextFolderItem >
8483 ) => {
8584 view . onDidChangeCheckboxState ( async ( e ) => {
8685 for ( const [ item , state ] of e . items ) {
@@ -109,11 +108,37 @@ export function context_initialization(context: vscode.ExtensionContext): {
109108 }
110109 )
111110
111+ const websites_view = vscode . window . createTreeView (
112+ 'codeWebChatViewWebsites' ,
113+ {
114+ treeDataProvider : websites_provider ,
115+ manageCheckboxStateManually : true
116+ }
117+ )
118+
119+ const update_websites_view_message = ( ) => {
120+ websites_view . message =
121+ websites_provider . get_websites_count ( ) > 0
122+ ? undefined
123+ : 'Websites added with the browser extension appear here.'
124+ }
125+
126+ update_websites_view_message ( )
127+
128+ websites_view . onDidChangeCheckboxState ( async ( e ) => {
129+ for ( const [ item , state ] of e . items ) {
130+ if ( item instanceof WebsiteItem ) {
131+ await websites_provider . update_check_state ( item , state )
132+ }
133+ }
134+ } )
135+
112136 context . subscriptions . push (
113137 workspace_provider ,
114138 open_editors_provider ,
115139 workspace_view ,
116- open_editors_view
140+ open_editors_view ,
141+ websites_view
117142 )
118143
119144 context . subscriptions . push (
@@ -242,6 +267,12 @@ export function context_initialization(context: vscode.ExtensionContext): {
242267 await open_editors_provider ! . check_all ( )
243268 }
244269 ) ,
270+ vscode . commands . registerCommand ( 'codeWebChat.checkAllWebsites' , ( ) => {
271+ websites_provider . check_all ( )
272+ } ) ,
273+ vscode . commands . registerCommand ( 'codeWebChat.clearChecksWebsites' , ( ) => {
274+ websites_provider . clear_checks ( )
275+ } ) ,
245276 vscode . commands . registerCommand (
246277 'codeWebChat.previewWebsite' ,
247278 async ( website : WebsiteItem ) => {
@@ -308,6 +339,7 @@ export function context_initialization(context: vscode.ExtensionContext): {
308339 // Fixes badge not updating when websites list changes
309340 websites_provider . onDidChangeTreeData ( ( ) => {
310341 update_activity_bar_badge_token_count ( )
342+ update_websites_view_message ( )
311343 } )
312344 )
313345
0 commit comments