@@ -18,6 +18,8 @@ export function context_initialization(context: vscode.ExtensionContext): {
1818 open_editors_provider : OpenEditorsProvider
1919 websites_provider : WebsitesProvider
2020} {
21+ let was_above_threshold = false
22+
2123 const workspace_folders = vscode . workspace . workspaceFolders ?? [ ]
2224
2325 let workspace_view : vscode . TreeView < FileItem >
@@ -42,8 +44,9 @@ export function context_initialization(context: vscode.ExtensionContext): {
4244 )
4345
4446 const update_view_badges = async ( ) => {
47+ let context_token_count = 0
4548 if ( context_provider && context_view ) {
46- const context_token_count =
49+ context_token_count =
4750 await workspace_provider . get_checked_files_token_count ( )
4851 context_view . badge = {
4952 value : context_token_count ,
@@ -53,8 +56,9 @@ export function context_initialization(context: vscode.ExtensionContext): {
5356 }
5457 }
5558
59+ let websites_token_count = 0
5660 if ( websites_provider && websites_view ) {
57- const websites_token_count =
61+ websites_token_count =
5862 websites_provider . get_checked_websites_token_count ( )
5963 websites_view . badge = {
6064 value : websites_token_count ,
@@ -64,6 +68,22 @@ export function context_initialization(context: vscode.ExtensionContext): {
6468 }
6569 }
6670 token_count_emitter . emit ( 'token-count-updated' )
71+
72+ const total_token_count = context_token_count + websites_token_count
73+ const config = vscode . workspace . getConfiguration ( 'codeWebChat' )
74+ const threshold = config . get < number > ( 'contextSizeWarningThreshold' )
75+
76+ if ( threshold && threshold > 0 ) {
77+ const is_above_threshold = total_token_count > threshold
78+ if ( is_above_threshold && ! was_above_threshold ) {
79+ vscode . window . showWarningMessage (
80+ dictionary . warning_message . CONTEXT_SIZE_WARNING ( threshold )
81+ )
82+ }
83+ was_above_threshold = is_above_threshold
84+ } else {
85+ was_above_threshold = false
86+ }
6787 }
6888
6989 const shared_state = SharedFileState . get_instance ( )
0 commit comments