@@ -5,17 +5,20 @@ import { SummaryViewProvider } from './summaryView';
55
66export class StatusBar implements vscode . Disposable {
77 private statusBarItem : vscode . StatusBarItem ;
8+ private notificationItem : vscode . StatusBarItem ;
89 private timeTracker : TimeTracker ;
910 private summaryView : SummaryViewProvider ;
1011 private updateInterval : NodeJS . Timeout ;
1112 private readonly commandId = 'simpleCodingTimeTracker.manualSave' ;
13+ private readonly notificationCommandId = 'simpleCodingTimeTracker.toggleNotifications' ;
1214
1315 constructor ( timeTracker : TimeTracker , summaryView : SummaryViewProvider ) {
1416 this . timeTracker = timeTracker ;
1517 this . summaryView = summaryView ;
1618 this . statusBarItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left , 100 ) ;
19+ this . notificationItem = vscode . window . createStatusBarItem ( vscode . StatusBarAlignment . Left , 99.9999 ) ;
1720
18- // Register manual save command first
21+ // Register manual save command (clicking anywhere saves session)
1922 const commandDisposable = vscode . commands . registerCommand ( this . commandId , ( ) => {
2023 if ( this . timeTracker . isActive ( ) ) {
2124 // Save current session with manual save reason
@@ -29,27 +32,41 @@ export class StatusBar implements vscode.Disposable {
2932 }
3033 } ) ;
3134
32- // Set up status bar item
35+ // Register notification toggle command
36+ const notificationCommandDisposable = vscode . commands . registerCommand ( this . notificationCommandId , ( ) => {
37+ this . toggleNotifications ( ) ;
38+ } ) ;
39+
40+
41+ // Set up main status bar item
3342 this . statusBarItem . command = this . commandId ;
3443 this . statusBarItem . tooltip = 'Click to save current session and show summary' ;
3544 this . statusBarItem . backgroundColor = new vscode . ThemeColor ( 'statusBarItem.warningBackground' ) ;
3645 this . statusBarItem . show ( ) ;
3746
47+ // Set up notification status bar item
48+ this . notificationItem . command = this . notificationCommandId ;
49+ this . notificationItem . tooltip = 'Click to toggle health notifications' ;
50+ this . notificationItem . backgroundColor = new vscode . ThemeColor ( 'statusBarItem.warningBackground' ) ;
51+ this . notificationItem . show ( ) ;
52+
3853 void this . updateStatusBar ( ) ;
3954 this . updateInterval = setInterval ( ( ) => void this . updateStatusBar ( ) , 1000 ) ; // Update every second
4055 } private async updateStatusBar ( ) {
4156 const todayTotal = await this . timeTracker . getTodayTotal ( ) ;
4257 const currentProjectTime = await this . timeTracker . getCurrentProjectTime ( ) ;
4358 const isActive = this . timeTracker . isActive ( ) ;
4459
45- // Check health notification status
46- const config = vscode . workspace . getConfiguration ( 'simpleCodingTimeTracker' ) ;
47- const healthEnabled = config . get ( 'health.enableNotifications' , true ) ;
48- const healthIcon = healthEnabled ? '🔔' : '🔕' ;
60+ // Update main status bar (time tracker only)
61+ this . statusBarItem . text = `${ isActive ? '💻' : '⏸️' } ${ this . formatTime ( todayTotal ) } ` ;
62+ this . statusBarItem . tooltip = await this . getTooltipText ( isActive , currentProjectTime ) ;
4963
50- // Show status with health notification indicator
51- this . statusBarItem . text = `${ isActive ? '💻' : '⏸️' } ${ this . formatTime ( todayTotal ) } ${ healthIcon } ` ;
52- this . statusBarItem . tooltip = await this . getTooltipText ( isActive , currentProjectTime , healthEnabled ) ;
64+ // Update notification status bar
65+ const config = vscode . workspace . getConfiguration ( 'simpleCodingTimeTracker' ) ;
66+ const notificationsEnabled = config . get ( 'health.enableNotifications' , true ) ;
67+ const notificationIcon = notificationsEnabled ? '🔔' : '🔕' ;
68+ this . notificationItem . text = notificationIcon ;
69+ this . notificationItem . tooltip = `Health Notifications: ${ notificationsEnabled ? 'ON' : 'OFF' } (Click to toggle)` ;
5370 }
5471
5572 private formatTime ( minutes : number ) : string {
@@ -59,24 +76,44 @@ export class StatusBar implements vscode.Disposable {
5976 return `${ hours . toString ( ) . padStart ( 2 , '0' ) } :${ mins . toString ( ) . padStart ( 2 , '0' ) } :${ secs . toString ( ) . padStart ( 2 , '0' ) } ` ;
6077 }
6178
62- private async getTooltipText ( isActive : boolean , currentProjectTime : number , healthEnabled : boolean ) : Promise < string > {
79+ private async getTooltipText ( isActive : boolean , currentProjectTime : number ) : Promise < string > {
6380 const weeklyTotal = await this . timeTracker . getWeeklyTotal ( ) ;
6481 const monthlyTotal = await this . timeTracker . getMonthlyTotal ( ) ;
6582 const allTimeTotal = await this . timeTracker . getAllTimeTotal ( ) ;
6683 const currentBranch = this . timeTracker . getCurrentBranch ( ) ;
6784 const currentProject = this . timeTracker . getCurrentProject ( ) ;
6885
69- const healthStatus = healthEnabled ? 'Health notifications: ON 🔔' : 'Health notifications: OFF 🔕' ;
70-
86+ const config = vscode . workspace . getConfiguration ( 'simpleCodingTimeTracker' ) ;
87+ const notificationsEnabled = config . get ( 'health.enableNotifications' , true ) ;
88+ const notificationStatus = notificationsEnabled ? 'ON' : 'OFF' ;
89+
7190 return `${ isActive ? 'Active' : 'Paused' } - Coding Time
7291Project: ${ currentProject }
7392Branch: ${ currentBranch }
7493Current Project Today: ${ formatTime ( currentProjectTime ) }
7594This week total: ${ formatTime ( weeklyTotal ) }
7695This month total: ${ formatTime ( monthlyTotal ) }
7796All Time total: ${ formatTime ( allTimeTotal ) }
78- ${ healthStatus }
79- Click to show summary` ;
97+ Notifications: ${ notificationStatus }
98+ Click to save session and show summary` ;
99+ }
100+
101+
102+ // Toggle notifications method
103+ private async toggleNotifications ( ) : Promise < void > {
104+ const config = vscode . workspace . getConfiguration ( 'simpleCodingTimeTracker' ) ;
105+ const currentEnabled = config . get ( 'health.enableNotifications' , true ) ;
106+
107+ // Toggle the setting
108+ await config . update ( 'health.enableNotifications' , ! currentEnabled , vscode . ConfigurationTarget . Global ) ;
109+
110+ // Update the visual state
111+ await this . updateStatusBar ( ) ;
112+
113+ // Show brief feedback message
114+ const status = ! currentEnabled ? 'enabled' : 'disabled' ;
115+ const icon = ! currentEnabled ? '🔔' : '🔕' ;
116+ vscode . window . showInformationMessage ( `${ icon } Health notifications ${ status } ` ) ;
80117 }
81118
82119 // Public method to force immediate update
@@ -86,6 +123,7 @@ Click to show summary`;
86123
87124 dispose ( ) {
88125 this . statusBarItem . dispose ( ) ;
126+ this . notificationItem . dispose ( ) ;
89127 clearInterval ( this . updateInterval ) ;
90128 }
91129}
0 commit comments