Skip to content

Commit 7cc56d6

Browse files
committed
add: multiple windows cache
1 parent 131e531 commit 7cc56d6

File tree

7 files changed

+481
-61
lines changed

7 files changed

+481
-61
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<h1 align="center">
2-
<img src="icon.png" alt="System Performance Monitor" width="100" height="100"/>
2+
<img src="https://raw.githubusercontent.com/bubablue/system-performance-extension/master/icon.png" alt="System Performance Monitor" width="100" height="100"/>
33
<br/>
44
System Performance Monitor
55
</h1>

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"publisher": "bubablue00",
44
"displayName": "System Performance",
55
"description": "Real-time system performance monitoring with animated CPU, memory, and resource usage graphs in VSCode",
6-
"version": "0.0.3",
6+
"version": "0.0.4",
77
"icon": "icon.png",
88
"keywords": [
99
"system",
@@ -33,12 +33,12 @@
3333
],
3434
"repository": {
3535
"type": "git",
36-
"url": "https://github.com/yourusername/system-performance-extension.git"
36+
"url": "https://github.com/bubablue/system-performance-extension.git"
3737
},
3838
"bugs": {
39-
"url": "https://github.com/yourusername/system-performance-extension/issues"
39+
"url": "https://github.com/bubablue/system-performance-extension/issues"
4040
},
41-
"homepage": "https://github.com/yourusername/system-performance-extension#readme",
41+
"homepage": "https://github.com/bubablue/system-performance-extension#readme",
4242
"license": "MIT",
4343
"activationEvents": [
4444
"onStartupFinished"
@@ -63,6 +63,10 @@
6363
"command": "system-performance.toggleMonitoring",
6464
"title": "Toggle Monitoring",
6565
"icon": "$(eye)"
66+
},
67+
{
68+
"command": "system-performance.resetPermissions",
69+
"title": "Reset System Permissions"
6670
}
6771
],
6872
"views": {

src/extension.ts

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,36 @@ let statusBarManager: StatusBarManager;
99
let systemMonitor: SystemMonitor;
1010
let provider: SystemResourcesProvider;
1111

12-
async function requestSystemPermissions(): Promise<boolean> {
12+
async function requestSystemPermissions(context: vscode.ExtensionContext): Promise<boolean> {
13+
const permissionsGranted = context.globalState.get<boolean>('systemPermissionsGranted');
14+
15+
if (permissionsGranted === true) {
16+
return true;
17+
}
18+
19+
if (permissionsGranted === false) {
20+
return false;
21+
}
22+
1323
const result = await vscode.window.showInformationMessage(
14-
"System Performance Extension needs access to system resources (CPU, memory, network) to provide monitoring functionality. Grant access?",
24+
"System Performance Extension needs access to system resources (CPU, memory, network) to provide monitoring functionality. This permission is only requested once.",
1525
{ modal: true },
1626
"Grant Access",
1727
"Deny"
1828
);
1929

20-
return result === "Grant Access";
30+
const granted = result === "Grant Access";
31+
32+
await context.globalState.update('systemPermissionsGranted', granted);
33+
34+
return granted;
2135
}
2236

2337
export function activate(context: vscode.ExtensionContext) {
24-
requestSystemPermissions().then((granted) => {
38+
requestSystemPermissions(context).then((granted) => {
2539
if (!granted) {
2640
vscode.window.showErrorMessage(
27-
"System Performance Extension requires system access permissions to monitor CPU, memory, and network usage. Please restart VS Code and grant permissions when prompted."
41+
"System Performance Extension requires system access permissions to monitor CPU, memory, and network usage. You can enable this later in the extension settings or by reinstalling the extension."
2842
);
2943
return;
3044
}
@@ -75,11 +89,27 @@ export function activate(context: vscode.ExtensionContext) {
7589
}
7690
);
7791

92+
const resetPermissionsDisposable = vscode.commands.registerCommand(
93+
"system-performance.resetPermissions",
94+
async () => {
95+
await context.globalState.update('systemPermissionsGranted', undefined);
96+
vscode.window.showInformationMessage(
97+
"System permissions have been reset. Please reload the window to be prompted again.",
98+
"Reload Window"
99+
).then((selection) => {
100+
if (selection === "Reload Window") {
101+
vscode.commands.executeCommand("workbench.action.reloadWindow");
102+
}
103+
});
104+
}
105+
);
106+
78107
context.subscriptions.push(
79108
showGraphDisposable,
80109
toggleGraphDisposable,
81110
refreshDisposable,
82-
toggleMonitoringDisposable
111+
toggleMonitoringDisposable,
112+
resetPermissionsDisposable
83113
);
84114

85115
if (statusBarItems) {
@@ -97,7 +127,9 @@ export function activate(context: vscode.ExtensionContext) {
97127
}
98128

99129
export function deactivate() {
100-
systemMonitor.stopSystemMonitoring();
130+
if (systemMonitor) {
131+
systemMonitor.dispose();
132+
}
101133
if (statusBarItems) {
102134
statusBarManager.disposeStatusBarItems(statusBarItems);
103135
}

0 commit comments

Comments
 (0)