Port-forward command fails with multiple agents instead of defaulting to primary agent
- Dominant language
- Go
- Stars
- 14.5k
- Forks
- 1.5k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 601
Description
### Problem
The `coder port-forward` CLI command throws an error when multiple agents are present in a workspace, rather than defaulting to the most common primary agents (`main`/`dev`).
```
Encountered an error running "coder port-forward", see "coder port-forward --help" for more information
error: multiple agents found, please specify the agent name, available agents: [custom-agent main]
```
### Proposed Resolution
**Primary:** Update the usage examples in [`cli/portforward.go`](https://github.com/coder/coder/blob/84b7a0364d62705c0afcd88c2f3e7c2ac913a381/cli/portforward.go#L57) to clarify agent specification and reduce confusion.
Update usage from:
```
coder port-forward [flags]
```
to:
```
coder port-forward [flags] [.agent]
```
**Alternative:** Print a helpful message and assume `main`/`dev` as the intended endpoint when multiple agents exist.
Contributor guide
Assessment
This issue has not been assessed yet.