Skip to content

Commit f4c8f86

Browse files
committed
Initialize lastActiveTimestamp on extension startup
1 parent 615046f commit f4c8f86

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

patched-vscode/extensions/sagemaker-idle-extension/src/extension.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ function initializeIdleFilePath() {
3030
return;
3131
}
3232
idleFilePath = path.join(homeDirectory, ".sagemaker-last-active-timestamp");
33+
34+
// Set initial lastActivetimestamp
35+
updateLastActivityTimestamp()
3336
}
3437

3538
/**
@@ -103,8 +106,9 @@ const checkTerminalActivity = () => {
103106
});
104107
};
105108

106-
/**
107-
* Updates the last activity timestamp by writing the current timestamp to the idle file.
109+
/**
110+
* Updates the last activity timestamp by recording the current timestamp in the idle file and
111+
* refreshing the status bar. The timestamp should be in ISO 8601 format and set to the UTC timezone.
108112
*/
109113
function updateLastActivityTimestamp() {
110114
const timestamp = new Date().toISOString();

patches/sagemaker-idle-extension.patch

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/exte
147147
===================================================================
148148
--- /dev/null
149149
+++ sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/extension.ts
150-
@@ -0,0 +1,112 @@
150+
@@ -0,0 +1,116 @@
151151
+import * as vscode from "vscode";
152152
+import * as fs from "fs";
153153
+import * as path from "path";
@@ -180,6 +180,9 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/exte
180180
+ return;
181181
+ }
182182
+ idleFilePath = path.join(homeDirectory, ".sagemaker-last-active-timestamp");
183+
+
184+
+ // Set initial lastActivetimestamp
185+
+ updateLastActivityTimestamp()
183186
+}
184187
+
185188
+/**
@@ -242,7 +245,7 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/exte
242245
+ const mtime = new Date(stats.mtime).getTime();
243246
+ return now - mtime < CHECK_INTERVAL;
244247
+ } catch (error) {
245-
+ console.error(`${LOG_PREFIX}}Error reading file stats:`, error);
248+
+ console.error(`${LOG_PREFIX} Error reading file stats:`, error);
246249
+ return false;
247250
+ }
248251
+ });
@@ -254,7 +257,8 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-idle-extension/src/exte
254257
+};
255258
+
256259
+/**
257-
+ * Updates the last activity timestamp by writing the current timestamp to the idle file.
260+
+ * Updates the last activity timestamp by recording the current timestamp in the idle file and
261+
+ * refreshing the status bar. The timestamp should be in ISO 8601 format and set to the UTC timezone.
258262
+ */
259263
+function updateLastActivityTimestamp() {
260264
+ const timestamp = new Date().toISOString();

0 commit comments

Comments
 (0)