From bfbce28437d2f6647408c57384288eb18e1ba85a Mon Sep 17 00:00:00 2001 From: hwen Date: Wed, 10 Jul 2024 17:41:59 +0800 Subject: [PATCH 1/2] Improve heartbeat activity detection on `onDidChangeWindowState` event --- package.json | 2 +- src/heartbeat.ts | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index c8a31d3..111c723 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "Gitpod", "description": "Gitpod Support", "publisher": "gitpod", - "version": "0.0.168", + "version": "0.0.169", "license": "MIT", "icon": "resources/gitpod.png", "repository": { diff --git a/src/heartbeat.ts b/src/heartbeat.ts index 7ce9314..8cb2f39 100644 --- a/src/heartbeat.ts +++ b/src/heartbeat.ts @@ -76,8 +76,13 @@ export class HeartbeatManager extends Disposable { this._register(vscode.window.onDidCloseTerminal(() => this.updateLastActivity('onDidCloseTerminal'))); this._register(vscode.window.onDidChangeTerminalState(() => this.updateLastActivity('onDidChangeTerminalState'))); this._register(vscode.window.onDidChangeWindowState((e) => { - this.focused = e.focused; - this.updateLastActivity('onDidChangeWindowState'); + // active property was introduced in 1.89, but not exist in 1.75 + // https://code.visualstudio.com/api/references/vscode-api#WindowState + const isActive: Boolean | undefined = (e as any).active; + if (isActive === true || e.focused !== this.focused) { + this.focused = e.focused; + this.updateLastActivity('onDidChangeWindowState'); + } })); this._register(vscode.window.onDidChangeActiveColorTheme(() => this.updateLastActivity('onDidChangeActiveColorTheme'))); this._register(vscode.authentication.onDidChangeSessions(() => this.updateLastActivity('onDidChangeSessions'))); From 92194de583668d252e31987a737eb56879a10e08 Mon Sep 17 00:00:00 2001 From: Huiwen Date: Wed, 10 Jul 2024 16:37:39 +0000 Subject: [PATCH 2/2] Don't check `active` as it's buggy --- src/heartbeat.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/heartbeat.ts b/src/heartbeat.ts index 8cb2f39..bec107a 100644 --- a/src/heartbeat.ts +++ b/src/heartbeat.ts @@ -76,10 +76,7 @@ export class HeartbeatManager extends Disposable { this._register(vscode.window.onDidCloseTerminal(() => this.updateLastActivity('onDidCloseTerminal'))); this._register(vscode.window.onDidChangeTerminalState(() => this.updateLastActivity('onDidChangeTerminalState'))); this._register(vscode.window.onDidChangeWindowState((e) => { - // active property was introduced in 1.89, but not exist in 1.75 - // https://code.visualstudio.com/api/references/vscode-api#WindowState - const isActive: Boolean | undefined = (e as any).active; - if (isActive === true || e.focused !== this.focused) { + if (e.focused !== this.focused) { this.focused = e.focused; this.updateLastActivity('onDidChangeWindowState'); }