Skip to content

Commit 39c307d

Browse files
committed
Review comment: return a disposables array when creating the statusbar
1 parent 7583f28 commit 39c307d

File tree

2 files changed

+26
-27
lines changed

2 files changed

+26
-27
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
- Update `/openDevContainer` to support all dev container features when hostPath
66
and configFile are provided.
7+
- Added an agent metadata monitor status bar item, so you can view your active
8+
agent metadata at a glance.
79

810
## [v1.9.2](https://github.com/coder/vscode-coder/releases/tag/v1.9.2) 2025-06-25
911

src/remote.ts

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,9 @@ export class Remote {
639639
}),
640640
);
641641

642-
this.createAgentMetadataStatusBar(agent, workspaceRestClient, disposables);
642+
disposables.push(
643+
...this.createAgentMetadataStatusBar(agent, workspaceRestClient),
644+
);
643645

644646
this.storage.writeToCoderOutputChannel("Remote setup complete");
645647

@@ -990,40 +992,35 @@ export class Remote {
990992
private createAgentMetadataStatusBar(
991993
agent: WorkspaceAgent,
992994
restClient: Api,
993-
disposables: vscode.Disposable[],
994-
): void {
995+
): vscode.Disposable[] {
995996
const statusBarItem = vscode.window.createStatusBarItem(
996997
"agentMetadata",
997998
vscode.StatusBarAlignment.Left,
998999
);
999-
disposables.push(statusBarItem);
10001000

10011001
const agentWatcher = createAgentMetadataWatcher(agent.id, restClient);
1002-
disposables.push(agentWatcher);
10031002

1004-
agentWatcher.onChange(
1005-
() => {
1006-
if (agentWatcher.error) {
1007-
this.storage.writeToCoderOutputChannel(
1008-
formatMetadataError(agentWatcher.error),
1009-
);
1010-
statusBarItem.hide();
1011-
return;
1012-
}
1003+
const onChangeDisposable = agentWatcher.onChange(() => {
1004+
if (agentWatcher.error) {
1005+
this.storage.writeToCoderOutputChannel(
1006+
formatMetadataError(agentWatcher.error),
1007+
);
1008+
statusBarItem.hide();
1009+
return;
1010+
}
10131011

1014-
if (agentWatcher.metadata && agentWatcher.metadata.length > 0) {
1015-
statusBarItem.text = getEventValue(agentWatcher.metadata[0]);
1016-
statusBarItem.tooltip = agentWatcher.metadata
1017-
.map((metadata) => formatEventLabel(metadata))
1018-
.join("\n");
1019-
statusBarItem.show();
1020-
} else {
1021-
statusBarItem.hide();
1022-
}
1023-
},
1024-
undefined,
1025-
disposables,
1026-
);
1012+
if (agentWatcher.metadata && agentWatcher.metadata.length > 0) {
1013+
statusBarItem.text = getEventValue(agentWatcher.metadata[0]);
1014+
statusBarItem.tooltip = agentWatcher.metadata
1015+
.map((metadata) => formatEventLabel(metadata))
1016+
.join("\n");
1017+
statusBarItem.show();
1018+
} else {
1019+
statusBarItem.hide();
1020+
}
1021+
});
1022+
1023+
return [statusBarItem, agentWatcher, onChangeDisposable];
10271024
}
10281025

10291026
// closeRemote ends the current remote session.

0 commit comments

Comments
 (0)