Skip to content

Commit 9d0d610

Browse files
committed
Review comment: return a disposables array when creating the statusbar
1 parent 4ba5773 commit 9d0d610

File tree

2 files changed

+24
-25
lines changed

2 files changed

+24
-25
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
update notifications.
99
- Coder output panel enhancements: All log entries now include timestamps, and you
1010
can filter messages by log level in the panel.
11+
- Added an agent metadata monitor status bar item, so you can view your active
12+
agent metadata at a glance.
1113

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

src/remote.ts

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,9 @@ export class Remote {
630630
}),
631631
);
632632

633-
this.createAgentMetadataStatusBar(agent, workspaceRestClient, disposables);
633+
disposables.push(
634+
...this.createAgentMetadataStatusBar(agent, workspaceRestClient),
635+
);
634636

635637
this.storage.output.info("Remote setup complete");
636638

@@ -982,38 +984,33 @@ export class Remote {
982984
private createAgentMetadataStatusBar(
983985
agent: WorkspaceAgent,
984986
restClient: Api,
985-
disposables: vscode.Disposable[],
986-
): void {
987+
): vscode.Disposable[] {
987988
const statusBarItem = vscode.window.createStatusBarItem(
988989
"agentMetadata",
989990
vscode.StatusBarAlignment.Left,
990991
);
991-
disposables.push(statusBarItem);
992992

993993
const agentWatcher = createAgentMetadataWatcher(agent.id, restClient);
994-
disposables.push(agentWatcher);
995994

996-
agentWatcher.onChange(
997-
() => {
998-
if (agentWatcher.error) {
999-
this.storage.output.warn(formatMetadataError(agentWatcher.error));
1000-
statusBarItem.hide();
1001-
return;
1002-
}
995+
const onChangeDisposable = agentWatcher.onChange(() => {
996+
if (agentWatcher.error) {
997+
this.storage.output.warn(formatMetadataError(agentWatcher.error));
998+
statusBarItem.hide();
999+
return;
1000+
}
10031001

1004-
if (agentWatcher.metadata && agentWatcher.metadata.length > 0) {
1005-
statusBarItem.text = getEventValue(agentWatcher.metadata[0]);
1006-
statusBarItem.tooltip = agentWatcher.metadata
1007-
.map((metadata) => formatEventLabel(metadata))
1008-
.join("\n");
1009-
statusBarItem.show();
1010-
} else {
1011-
statusBarItem.hide();
1012-
}
1013-
},
1014-
undefined,
1015-
disposables,
1016-
);
1002+
if (agentWatcher.metadata && agentWatcher.metadata.length > 0) {
1003+
statusBarItem.text = getEventValue(agentWatcher.metadata[0]);
1004+
statusBarItem.tooltip = agentWatcher.metadata
1005+
.map((metadata) => formatEventLabel(metadata))
1006+
.join("\n");
1007+
statusBarItem.show();
1008+
} else {
1009+
statusBarItem.hide();
1010+
}
1011+
});
1012+
1013+
return [statusBarItem, agentWatcher, onChangeDisposable];
10171014
}
10181015

10191016
// closeRemote ends the current remote session.

0 commit comments

Comments
 (0)