Skip to content

Commit e353cd1

Browse files
committed
Refresh web page when instanceId changed
1 parent f8e204b commit e353cd1

File tree

1 file changed

+12
-1
lines changed
  • components/supervisor/frontend/src

1 file changed

+12
-1
lines changed

components/supervisor/frontend/src/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,20 @@ const toStop = new DisposableCollection();
108108
//#region current-frame
109109
let current: HTMLElement = loading.frame;
110110
let desktopRedirected = false;
111+
let currentInstanceId = "";
111112
const nextFrame = () => {
112113
const instance = gitpodServiceClient.info.latestInstance;
113114
if (instance) {
115+
// refresh web page when instanceId changed
116+
if (currentInstanceId !== "") {
117+
if (instance.id !== currentInstanceId && instance.ideUrl !== "") {
118+
currentInstanceId = instance.id;
119+
window.location.href = instance.ideUrl;
120+
return;
121+
}
122+
} else {
123+
currentInstanceId = instance.id;
124+
}
114125
if (instance.status.phase === 'running') {
115126
if (!hideDesktopIde) {
116127
if (isDesktopIde == undefined) {
@@ -148,7 +159,7 @@ const toStop = new DisposableCollection();
148159
}
149160
const updateCurrentFrame = () => {
150161
const newCurrent = nextFrame();
151-
if (current === newCurrent) {
162+
if (newCurrent == null || current === newCurrent) {
152163
return;
153164
}
154165
current.style.visibility = 'hidden';

0 commit comments

Comments
 (0)