11import * as vscode from 'vscode'
22import * as path from 'path'
3- import {
4- WorkspaceProvider ,
5- FileItem ,
6- ContextFolderItem
7- } from './providers/workspace-provider'
3+ import { WorkspaceProvider , FileItem } from './providers/workspace-provider'
84import { FilesCollector } from '../utils/files-collector'
95import { OpenEditorsProvider } from './providers/open-editors-provider'
106import { WebsitesProvider , WebsiteItem } from './providers/websites-provider'
@@ -13,6 +9,7 @@ import { marked } from 'marked'
139import { EventEmitter } from 'events'
1410import { apply_context_command } from '../commands/apply-context-command'
1511import { dictionary } from '@shared/constants/dictionary'
12+ import { ContextProvider } from './providers/context-provider'
1613
1714export const token_count_emitter = new EventEmitter ( )
1815
@@ -23,14 +20,15 @@ export function context_initialization(context: vscode.ExtensionContext): {
2320} {
2421 const workspace_folders = vscode . workspace . workspaceFolders ?? [ ]
2522
26- let workspace_view : vscode . TreeView < FileItem | ContextFolderItem >
23+ let workspace_view : vscode . TreeView < FileItem >
2724
2825 const websites_provider = new WebsitesProvider ( context )
2926 const workspace_provider = new WorkspaceProvider (
3027 workspace_folders as any ,
3128 context
3229 )
33- context . subscriptions . push ( websites_provider )
30+ const context_provider = new ContextProvider ( workspace_provider )
31+ context . subscriptions . push ( websites_provider , context_provider )
3432
3533 const open_editors_provider = new OpenEditorsProvider (
3634 workspace_folders as any ,
@@ -43,14 +41,14 @@ export function context_initialization(context: vscode.ExtensionContext): {
4341 websites_provider
4442 )
4543
46- const update_activity_bar_badge_token_count = async ( ) => {
47- if ( workspace_provider && workspace_view ) {
48- const workspace_token_count =
44+ const update_view_badges = async ( ) => {
45+ if ( context_provider && context_view ) {
46+ const context_token_count =
4947 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`
48+ context_view . badge = {
49+ value : context_token_count ,
50+ tooltip : context_token_count
51+ ? `About ${ context_token_count } tokens in context`
5452 : ''
5553 }
5654 }
@@ -79,7 +77,7 @@ export function context_initialization(context: vscode.ExtensionContext): {
7977 } )
8078
8179 const register_workspace_view_handlers = (
82- view : vscode . TreeView < FileItem | ContextFolderItem >
80+ view : vscode . TreeView < FileItem >
8381 ) => {
8482 view . onDidChangeCheckboxState ( async ( e ) => {
8583 for ( const [ item , state ] of e . items ) {
@@ -98,7 +96,13 @@ export function context_initialization(context: vscode.ExtensionContext): {
9896 manageCheckboxStateManually : true
9997 } )
10098
99+ const context_view = vscode . window . createTreeView ( 'codeWebChatViewContext' , {
100+ treeDataProvider : context_provider ,
101+ manageCheckboxStateManually : true
102+ } )
103+
101104 register_workspace_view_handlers ( workspace_view )
105+ register_workspace_view_handlers ( context_view )
102106
103107 const open_editors_view = vscode . window . createTreeView (
104108 'codeWebChatViewOpenEditors' ,
@@ -137,6 +141,7 @@ export function context_initialization(context: vscode.ExtensionContext): {
137141 workspace_provider ,
138142 open_editors_provider ,
139143 workspace_view ,
144+ context_view ,
140145 open_editors_view ,
141146 websites_view
142147 )
@@ -314,7 +319,7 @@ export function context_initialization(context: vscode.ExtensionContext): {
314319 apply_context_command (
315320 workspace_provider ,
316321 ( ) => {
317- update_activity_bar_badge_token_count ( )
322+ update_view_badges ( )
318323 } ,
319324 context
320325 )
@@ -328,17 +333,17 @@ export function context_initialization(context: vscode.ExtensionContext): {
328333
329334 context . subscriptions . push (
330335 workspace_provider . onDidChangeCheckedFiles ( ( ) => {
331- update_activity_bar_badge_token_count ( )
336+ update_view_badges ( )
332337 } ) ,
333338 open_editors_provider . onDidChangeCheckedFiles ( ( ) => {
334- update_activity_bar_badge_token_count ( )
339+ update_view_badges ( )
335340 } ) ,
336341 websites_provider . onDidChangeCheckedWebsites ( ( ) => {
337- update_activity_bar_badge_token_count ( )
342+ update_view_badges ( )
338343 } ) ,
339344 // Fixes badge not updating when websites list changes
340345 websites_provider . onDidChangeTreeData ( ( ) => {
341- update_activity_bar_badge_token_count ( )
346+ update_view_badges ( )
342347 update_websites_view_message ( )
343348 } )
344349 )
@@ -351,7 +356,7 @@ export function context_initialization(context: vscode.ExtensionContext): {
351356 clearTimeout ( tab_change_timeout )
352357 }
353358 tab_change_timeout = setTimeout ( ( ) => {
354- update_activity_bar_badge_token_count ( )
359+ update_view_badges ( )
355360 tab_change_timeout = null
356361 } , 100 ) // 100ms debounce
357362 } )
@@ -367,7 +372,7 @@ export function context_initialization(context: vscode.ExtensionContext): {
367372 vscode . workspace . workspaceFolders
368373 )
369374 shared_state . set_providers ( workspace_provider , open_editors_provider )
370- update_activity_bar_badge_token_count ( )
375+ update_view_badges ( )
371376 }
372377 } )
373378 )
@@ -379,14 +384,14 @@ export function context_initialization(context: vscode.ExtensionContext): {
379384 context . subscriptions . push (
380385 open_editors_provider . onDidChangeTreeData ( ( ) => {
381386 if ( open_editors_provider ! . is_initialized ( ) ) {
382- update_activity_bar_badge_token_count ( )
387+ update_view_badges ( )
383388 }
384389 } )
385390 )
386391
387392 // Also schedule a delayed update for initial badge display
388393 setTimeout ( ( ) => {
389- update_activity_bar_badge_token_count ( )
394+ update_view_badges ( )
390395 } , 1000 ) // Wait for 1 second to ensure VS Code has fully loaded
391396
392397 return {
0 commit comments