-
Notifications
You must be signed in to change notification settings - Fork 1.1k
feat(cli): add dynamic completions for ssh command #20171
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
Conversation
Adds CompletionHandler to the ssh command that dynamically suggests workspace and agent targets based on the user's running workspaces. Features: - Suggests workspace name for single-agent workspaces - Suggests agent.workspace format for all agents in multi-agent workspaces - Only shows running workspaces (matches immediate availability) - Alphabetically sorted completions for better UX - Graceful error handling (returns error strings for debugging) Tests cover single-agent, multi-agent, and network error scenarios. Amp-Thread-ID: https://ampcode.com/threads/T-d137d343-53f3-4ece-be5a-584249bbd9e8 Co-authored-by: Amp <amp@ampcode.com>
Verify that multi-agent workspaces do not suggest the bare workspace name (only agent.workspace format should be suggested). Amp-Thread-ID: https://ampcode.com/threads/T-d137d343-53f3-4ece-be5a-584249bbd9e8 Co-authored-by: Amp <amp@ampcode.com>
Amp-Thread-ID: https://ampcode.com/threads/T-d137d343-53f3-4ece-be5a-584249bbd9e8 Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really cool, been hoping we could get this since the wildcard switch 😎
Do you know how this is supposed to work in practice? I tried coder completion and it generates a bashrc that says Setup Bash to use the function for completions for '' which seems weird (the empty string) and neither ssh <tab> nor coder ssh <tab> are showing my workspaces. I tried manually sourcing the bashrc but it looks like the call to complete is giving an error.
The code looks good here, so I wonder if it is a problem with Serpent.
Edit: sorry, I see this is in draft, I got overly excited.
It was indeed, fixed in #20448. Thanks for discovering! |
|
@ethanndickson, mind me assigning this to you if you are interested in taking this to completion? |
|
Yep, will do! |
| Owner: codersdk.Me, | ||
| }) | ||
| if err != nil { | ||
| return []string{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Returning an error string here doesn't seem very idiomatic - shells will just autocomplete the error which seems kinda gross. If the user runs coder ls they'll see what the issue is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!! coder ssh <tab> completes wonderfully now.
Adds CompletionHandler to the ssh command that dynamically suggests workspace and agent targets based on the user's running workspaces.
Features:
Tests cover single-agent, multi-agent, and network error scenarios.
Amp-Thread-ID: https://ampcode.com/threads/T-d137d343-53f3-4ece-be5a-584249bbd9e8
closes #20158
Demo:
completiondemo.mov