@@ -345,11 +345,56 @@ export async function activate(context: vscode.ExtensionContext) {
345345 // This line of code will only be executed once when your extension is activated
346346 console . log ( 'Congratulations, your extension "lm-writing-tool" is now active!' ) ;
347347
348+ // Create status bar item for model selection
349+ const modelStatusBarItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right , 100 ) ;
350+ modelStatusBarItem . command = 'lm-writing-tool.selectModel' ;
351+ modelStatusBarItem . tooltip = 'Click to select LLM model' ;
352+ modelStatusBarItem . text = "$(robot) No model selected" ;
353+ modelStatusBarItem . show ( ) ;
354+ context . subscriptions . push ( modelStatusBarItem ) ;
355+
356+ // Create status bar item for text check status
357+ const textCheckStatusBarItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Right , 99 ) ;
358+ textCheckStatusBarItem . command = 'lm-writing-tool.toggleTextCheck' ;
359+ textCheckStatusBarItem . tooltip = 'Click to toggle text checking for current document' ;
360+ textCheckStatusBarItem . text = "$(eye-closed) Text check: Off" ;
361+ textCheckStatusBarItem . show ( ) ;
362+ context . subscriptions . push ( textCheckStatusBarItem ) ;
363+
348364 let _lmwt : LMWritingTool | undefined ;
365+ let _currentModel : vscode . LanguageModelChat | undefined ;
366+
367+ function updateStatusBar ( ) {
368+ if ( _currentModel ) {
369+ modelStatusBarItem . text = `$(robot) ${ _currentModel . vendor } : ${ _currentModel . family } ` ;
370+ } else {
371+ modelStatusBarItem . text = "$(robot) No model selected" ;
372+ }
373+ }
374+
375+ function updateTextCheckStatusBar ( ) {
376+ const activeEditor = vscode . window . activeTextEditor ;
377+ if ( ! activeEditor ) {
378+ textCheckStatusBarItem . text = "$(eye-closed) Text check: Off" ;
379+ textCheckStatusBarItem . tooltip = 'No active document' ;
380+ return ;
381+ }
382+
383+ const isActive = textCheckJobs . has ( activeEditor ) ;
384+ if ( isActive ) {
385+ textCheckStatusBarItem . text = "$(eye) Text check: On" ;
386+ textCheckStatusBarItem . tooltip = 'Click to stop text checking for current document' ;
387+ } else {
388+ textCheckStatusBarItem . text = "$(eye-closed) Text check: Off" ;
389+ textCheckStatusBarItem . tooltip = 'Click to start text checking for current document' ;
390+ }
391+ }
349392 async function getLMWT ( ) {
350393 if ( ! _lmwt ) {
351394 const model = await selectModel ( ) ;
352395 _lmwt = new LMWritingTool ( model , splitTextByLine , dc ) ;
396+ _currentModel = model ;
397+ updateStatusBar ( ) ;
353398 }
354399 return _lmwt ;
355400 }
@@ -384,11 +429,50 @@ export async function activate(context: vscode.ExtensionContext) {
384429 return model ;
385430 }
386431 context . subscriptions . push (
387- vscode . commands . registerTextEditorCommand ( 'lm-writing-tool.selectModel' , async ( te ) => {
432+ vscode . commands . registerCommand ( 'lm-writing-tool.selectModel' , async ( ) => {
388433 const model = await selectModel ( ) ;
389434 stopAllJobs ( ) ;
390435 _lmwt = new LMWritingTool ( model , splitTextByLine , dc ) ;
436+ _currentModel = model ;
437+ updateStatusBar ( ) ;
438+ } )
439+ ) ;
440+
441+ context . subscriptions . push (
442+ vscode . commands . registerCommand ( 'lm-writing-tool.toggleTextCheck' , async ( ) => {
443+ const activeEditor = vscode . window . activeTextEditor ;
444+ if ( ! activeEditor ) {
445+ vscode . window . showInformationMessage ( 'No active document to check' ) ;
446+ return ;
447+ }
391448
449+ const isActive = textCheckJobs . has ( activeEditor ) ;
450+ if ( isActive ) {
451+ // Stop text checking
452+ const interval = textCheckJobs . get ( activeEditor ) ;
453+ if ( interval ) {
454+ clearInterval ( interval ) ;
455+ textCheckJobs . delete ( activeEditor ) ;
456+ }
457+ const lmwt = await getLMWT ( ) ;
458+ lmwt . taskScheduler . setTasks ( new Map ( ) , activeEditor . document . uri . toString ( ) ) ;
459+ lmwt . dc . set ( activeEditor . document . uri , [ ] ) ;
460+ lmwt . corrections . delete ( activeEditor . document . uri . toString ( ) ) ;
461+ vscode . window . showInformationMessage ( 'Text checking stopped for current document' ) ;
462+ } else {
463+ // Start text checking
464+ const openTextDocument = activeEditor . document ;
465+ const lmwt = await getLMWT ( ) ;
466+ textCheckJobs . set ( activeEditor , setInterval ( async ( ) => {
467+ console . info ( 'Checking document' ) ;
468+ lmwt . sendLLMRequestsForDocument ( openTextDocument ) ;
469+ } , 5000 ) ) ;
470+
471+ // Register code actions provider if not already registered
472+ context . subscriptions . push ( vscode . languages . registerCodeActionsProvider ( '*' , new WritingToolCodeActionsProvider ( lmwt ) , { } ) ) ;
473+ vscode . window . showInformationMessage ( 'Text checking started for current document' ) ;
474+ }
475+ updateTextCheckStatusBar ( ) ;
392476 } )
393477 ) ;
394478
@@ -406,6 +490,7 @@ export async function activate(context: vscode.ExtensionContext) {
406490 } , 5000 ) ) ;
407491
408492 context . subscriptions . push ( vscode . languages . registerCodeActionsProvider ( '*' , new WritingToolCodeActionsProvider ( lmwt ) , { } ) ) ;
493+ updateTextCheckStatusBar ( ) ;
409494 } )
410495 ) ;
411496
@@ -505,8 +590,19 @@ export async function activate(context: vscode.ExtensionContext) {
505590 lmwt . taskScheduler . setTasks ( new Map ( ) , te . document . uri . toString ( ) ) ;
506591 lmwt . dc . set ( te . document . uri , [ ] ) ;
507592 lmwt . corrections . delete ( te . document . uri . toString ( ) ) ;
593+ updateTextCheckStatusBar ( ) ;
594+ } )
595+ ) ;
596+ // Update status bars when active editor changes
597+ context . subscriptions . push (
598+ vscode . window . onDidChangeActiveTextEditor ( ( ) => {
599+ updateTextCheckStatusBar ( ) ;
508600 } )
509601 ) ;
602+
603+ // Initialize status bars
604+ updateTextCheckStatusBar ( ) ;
605+
510606 // Cleanup the interval on extension deactivation
511607 async function stopAllJobs ( ) {
512608 for ( const [ te , interval ] of textCheckJobs . entries ( ) ) {
@@ -517,6 +613,7 @@ export async function activate(context: vscode.ExtensionContext) {
517613 lmwt . taskScheduler . abortAll ( ) ;
518614 lmwt . dc . clear ( ) ;
519615 lmwt . corrections . clear ( ) ;
616+ updateTextCheckStatusBar ( ) ;
520617 }
521618 context . subscriptions . push ( {
522619 dispose : stopAllJobs
0 commit comments