@@ -2,22 +2,14 @@ import * as vscode from "vscode";
2
2
import * as fs from "fs" ;
3
3
import * as path from "path" ;
4
4
5
- let idleFilePath : string
6
- let terminalActivityInterval : NodeJS . Timeout | undefined
7
- const LOG_PREFIX = "[sagemaker-idle-extension]"
8
- const CHECK_INTERVAL = 60000 ; // 60 seconds interval
5
+ let idleFilePath : string ;
9
6
10
7
export function activate ( context : vscode . ExtensionContext ) {
11
8
initializeIdleFilePath ( ) ;
12
9
registerEventListeners ( context ) ;
13
- startMonitoringTerminalActivity ( ) ;
14
10
}
15
11
16
- export function deactivate ( ) {
17
- if ( terminalActivityInterval ) {
18
- clearInterval ( terminalActivityInterval )
19
- }
20
- }
12
+ export function deactivate ( ) { }
21
13
22
14
/**
23
15
* Initializes the file path where the idle timestamp will be stored.
@@ -28,7 +20,7 @@ function initializeIdleFilePath() {
28
20
idleFilePath = path . join ( tmpDirectory , ".sagemaker-last-active-timestamp" ) ;
29
21
30
22
// Set initial lastActivetimestamp
31
- updateLastActivityTimestamp ( )
23
+ updateLastActivityTimestamp ( ) ;
32
24
}
33
25
34
26
/**
@@ -56,52 +48,6 @@ function registerEventListeners(context: vscode.ExtensionContext) {
56
48
) ;
57
49
}
58
50
59
- /**
60
- * Starts monitoring terminal activity by setting an interval to check for activity in the /dev/pts directory.
61
- */
62
- const startMonitoringTerminalActivity = ( ) => {
63
- terminalActivityInterval = setInterval ( checkTerminalActivity , CHECK_INTERVAL ) ;
64
- } ;
65
-
66
-
67
- /**
68
- * Checks for terminal activity by reading the /dev/pts directory and comparing modification times of the files.
69
- *
70
- * The /dev/pts directory is used in Unix-like operating systems to represent pseudo-terminal (PTY) devices.
71
- * Each active terminal session is assigned a PTY device. These devices are represented as files within the /dev/pts directory.
72
- * When a terminal session has activity, such as when a user inputs commands or output is written to the terminal,
73
- * the modification time (mtime) of the corresponding PTY device file is updated. By monitoring the modification
74
- * times of the files in the /dev/pts directory, we can detect terminal activity.
75
- *
76
- * If activity is detected (i.e., if any PTY device file was modified within the CHECK_INTERVAL), this function
77
- * updates the last activity timestamp.
78
- */
79
- const checkTerminalActivity = ( ) => {
80
- fs . readdir ( "/dev/pts" , ( err , files ) => {
81
- if ( err ) {
82
- console . error ( `${ LOG_PREFIX } Error reading /dev/pts directory:` , err ) ;
83
- return ;
84
- }
85
-
86
- const now = Date . now ( ) ;
87
- const activityDetected = files . some ( ( file ) => {
88
- const filePath = path . join ( "/dev/pts" , file ) ;
89
- try {
90
- const stats = fs . statSync ( filePath ) ;
91
- const mtime = new Date ( stats . mtime ) . getTime ( ) ;
92
- return now - mtime < CHECK_INTERVAL ;
93
- } catch ( error ) {
94
- console . error ( `${ LOG_PREFIX } Error reading file stats:` , error ) ;
95
- return false ;
96
- }
97
- } ) ;
98
-
99
- if ( activityDetected ) {
100
- updateLastActivityTimestamp ( ) ;
101
- }
102
- } ) ;
103
- } ;
104
-
105
51
/**
106
52
* Updates the last activity timestamp by recording the current timestamp in the idle file and
107
53
* refreshing the status bar. The timestamp should be in ISO 8601 format and set to the UTC timezone.
0 commit comments