Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add statuses to sidebar #299

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Added

- Workspace and agent statuses now show in the sidebar. These are updated every
five seconds.

## [v1.0.2](https://github.com/coder/vscode-coder/releases/tag/v1.0.2) (2024-06-12)

### Fixed
Expand Down
6 changes: 5 additions & 1 deletion src/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,11 @@ export class Remote {
writeEmitter.fire(log.output + "\r\n")
})
socket.on("error", (error) => {
reject(new Error(`Failed to watch workspace build using ${socketUrlRaw}: ${errToStr(error, "no further details")}`))
reject(
new Error(
`Failed to watch workspace build using ${socketUrlRaw}: ${errToStr(error, "no further details")}`,
),
)
})
socket.on("close", () => {
resolve()
Expand Down
12 changes: 6 additions & 6 deletions src/workspacesProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ export class WorkspaceProvider implements vscode.TreeDataProvider<vscode.TreeIte
private workspaces: WorkspaceTreeItem[] = []
private agentWatchers: Record<WorkspaceAgent["id"], AgentWatcher> = {}
private timeout: NodeJS.Timeout | undefined
private visible = false
private fetching = false

constructor(
Expand Down Expand Up @@ -147,7 +146,6 @@ export class WorkspaceProvider implements vscode.TreeDataProvider<vscode.TreeIte
* Either start or stop the refresh timer based on visibility.
*/
setVisibility(visible: boolean) {
this.visible = visible
if (!visible) {
this.cancelPendingRefresh()
} else {
Expand Down Expand Up @@ -282,6 +280,7 @@ export class OpenableTreeItem extends vscode.TreeItem {
constructor(
label: string,
tooltip: string,
description: string,
collapsibleState: vscode.TreeItemCollapsibleState,

public readonly workspaceOwner: string,
Expand All @@ -294,6 +293,7 @@ export class OpenableTreeItem extends vscode.TreeItem {
super(label, collapsibleState)
this.contextValue = contextValue
this.tooltip = tooltip
this.description = description
}

iconPath = {
Expand All @@ -309,11 +309,10 @@ class AgentTreeItem extends OpenableTreeItem {
workspaceName: string,
watchMetadata = false,
) {
const label = agent.name
const detail = `Status: ${agent.status}`
super(
label,
detail,
agent.name, // label
`Status: ${agent.status}`, // tooltip
agent.status, // description
watchMetadata ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.None,
workspaceOwner,
workspaceName,
Expand All @@ -339,6 +338,7 @@ export class WorkspaceTreeItem extends OpenableTreeItem {
super(
label,
detail,
workspace.latest_build.status, // description
showOwner ? vscode.TreeItemCollapsibleState.Collapsed : vscode.TreeItemCollapsibleState.Expanded,
workspace.owner_name,
workspace.name,
Expand Down