From de8d5c59c871265bfe38e0edb246a28bb976082d Mon Sep 17 00:00:00 2001 From: Spencer Ng Date: Tue, 7 May 2024 15:17:17 -0700 Subject: [PATCH 1/2] Updated dialog warning handling for getExpiryTime --- patched-vscode/extensions/sagemaker-extension/src/extension.ts | 2 +- patches/sagemaker-extension.diff | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/patched-vscode/extensions/sagemaker-extension/src/extension.ts b/patched-vscode/extensions/sagemaker-extension/src/extension.ts index b85cec6a..ed0ce4c2 100644 --- a/patched-vscode/extensions/sagemaker-extension/src/extension.ts +++ b/patched-vscode/extensions/sagemaker-extension/src/extension.ts @@ -45,7 +45,7 @@ function showWarningDialog() { } }); - } else { + } else if (getExpiryTime(sagemakerCookie) == -1 || remainingTime <=0) { // this means expiryTime cookie is either invalid or <0 signInError(sagemakerCookie); } diff --git a/patches/sagemaker-extension.diff b/patches/sagemaker-extension.diff index 9c2483c8..7c811052 100644 --- a/patches/sagemaker-extension.diff +++ b/patches/sagemaker-extension.diff @@ -50,7 +50,7 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/extension + } + }); + -+ } else { ++ } else if (getExpiryTime(sagemakerCookie) == -1 || remainingTime <=0) { + // this means expiryTime cookie is either invalid or <0 + signInError(sagemakerCookie); + } From cf88ad14bfa99c3ab2712760432ec16c1a7f6b4d Mon Sep 17 00:00:00 2001 From: Spencer Ng Date: Wed, 8 May 2024 15:42:54 -0700 Subject: [PATCH 2/2] Updated fix logic --- .../sagemaker-extension/src/extension.ts | 28 +++++++++-------- patches/sagemaker-extension.diff | 30 ++++++++++--------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/patched-vscode/extensions/sagemaker-extension/src/extension.ts b/patched-vscode/extensions/sagemaker-extension/src/extension.ts index ed0ce4c2..dade3456 100644 --- a/patched-vscode/extensions/sagemaker-extension/src/extension.ts +++ b/patched-vscode/extensions/sagemaker-extension/src/extension.ts @@ -71,19 +71,21 @@ function initialize(sagemakerCookie: SagemakerCookie) { const currentTime = Date.now(); const timeToExpiry = getExpiryTime(sagemakerCookie) - currentTime; - if (timeToExpiry <= 0) { - signInError(sagemakerCookie); - } else if (timeToExpiry >= FIFTEEN_MINUTES_INTERVAL_MILLIS) { - const warningTime = timeToExpiry - FIFTEEN_MINUTES_INTERVAL_MILLIS; - setTimeout(() => { - showWarningDialog(); - }, warningTime); - } else { - // If less than or equal to 15 minutes left, set a timer for the remaining time - const warningTime = timeToExpiry % FIVE_MINUTES_INTERVAL_MILLIS; - setTimeout(() => { - showWarningDialog(); - }, warningTime); + if (getExpiryTime(sagemakerCookie) !== -1) { + if (timeToExpiry <= 0) { + signInError(sagemakerCookie); + } else if (timeToExpiry >= FIFTEEN_MINUTES_INTERVAL_MILLIS) { + const warningTime = timeToExpiry - FIFTEEN_MINUTES_INTERVAL_MILLIS; + setTimeout(() => { + showWarningDialog(); + }, warningTime); + } else { + // If less than or equal to 15 minutes left, set a timer for the remaining time + const warningTime = timeToExpiry % FIVE_MINUTES_INTERVAL_MILLIS; + setTimeout(() => { + showWarningDialog(); + }, warningTime); + } } } diff --git a/patches/sagemaker-extension.diff b/patches/sagemaker-extension.diff index 7c811052..e3f9320c 100644 --- a/patches/sagemaker-extension.diff +++ b/patches/sagemaker-extension.diff @@ -2,7 +2,7 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/extension =================================================================== --- /dev/null +++ sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/extension.ts -@@ -0,0 +1,137 @@ +@@ -0,0 +1,139 @@ +import * as vscode from 'vscode'; +import * as fs from 'fs'; +import { SessionWarning } from "./sessionWarning"; @@ -76,19 +76,21 @@ Index: sagemaker-code-editor/vscode/extensions/sagemaker-extension/src/extension + const currentTime = Date.now(); + const timeToExpiry = getExpiryTime(sagemakerCookie) - currentTime; + -+ if (timeToExpiry <= 0) { -+ signInError(sagemakerCookie); -+ } else if (timeToExpiry >= FIFTEEN_MINUTES_INTERVAL_MILLIS) { -+ const warningTime = timeToExpiry - FIFTEEN_MINUTES_INTERVAL_MILLIS; -+ setTimeout(() => { -+ showWarningDialog(); -+ }, warningTime); -+ } else { -+ // If less than or equal to 15 minutes left, set a timer for the remaining time -+ const warningTime = timeToExpiry % FIVE_MINUTES_INTERVAL_MILLIS; -+ setTimeout(() => { -+ showWarningDialog(); -+ }, warningTime); ++ if (getExpiryTime(sagemakerCookie) !== -1) { ++ if (timeToExpiry <= 0) { ++ signInError(sagemakerCookie); ++ } else if (timeToExpiry >= FIFTEEN_MINUTES_INTERVAL_MILLIS) { ++ const warningTime = timeToExpiry - FIFTEEN_MINUTES_INTERVAL_MILLIS; ++ setTimeout(() => { ++ showWarningDialog(); ++ }, warningTime); ++ } else { ++ // If less than or equal to 15 minutes left, set a timer for the remaining time ++ const warningTime = timeToExpiry % FIVE_MINUTES_INTERVAL_MILLIS; ++ setTimeout(() => { ++ showWarningDialog(); ++ }, warningTime); ++ } + } +} +