- Notifications
You must be signed in to change notification settings - Fork920
feat(agent/agentcontainers): fall back to workspace folder name#18466
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Conversation
This PR changes the logic for how we decide on an agent name.Previously it followed these steps:1. Use a name from `customizations.coder.name`2. Use a name from the terraform resource `coder_devcontainer`3. Use the dev container's friendly nameWith this change it now does:1. Use a name from `customizations.coder.name`2. Use a name from the terraform resource `coder_devcontainer`3. Use a name from the workspace folder4. Use the dev container's friendly nameWe now attempt to construct a valid agent name from the workspacefolder. Should we fail to construct a valid agent name from theworkspace folder, we will fall back to the dev container's friendlyname.
Appease the linter and make a test case for `safeAgentName`.
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.
Pull Request Overview
This PR enhances agent naming by falling back to the workspace folder name before using the container’s friendly name, and cleans up oldpwd
-based logic.
- Adds
Workspace
info toDevcontainerConfig
and readsWorkspaceFolder
- Introduces
safeAgentName
(plus regex) to sanitize folder names and updates naming logic - Removes exec-based workspace detection and updates tests accordingly, plus adds unit tests for
safeAgentName
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
agent/agentcontainers/devcontainercli.go | AddedWorkspace field andDevcontainerWorkspace struct |
agent/agentcontainers/devcontainer.go | Removed default workspace constant and exec-based logic |
agent/agentcontainers/api.go | Importedregexp , addedsafeAgentName and collapsed hyphens |
agent/agentcontainers/api_test.go | Updated expected agent names/directories in container tests |
agent/agentcontainers/api_internal_test.go | New unit tests coveringsafeAgentName transformations |
Comments suppressed due to low confidence (2)
agent/agentcontainers/api.go:635
- [nitpick] Add a comment explaining that this regex collapses multiple consecutive hyphens into a single hyphen for improved clarity.
var consecutiveHyphenRegex = regexp.MustCompile("-+")
agent/agentcontainers/devcontainercli.go:28
- [nitpick] Consider adding a brief doc comment for
DevcontainerWorkspace
and itsWorkspaceFolder
field to explain how the workspace folder is used in naming.
type DevcontainerWorkspace struct {
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This PR changes the logic for how we decide on an agent name.
Previously it followed these steps:
customizations.coder.name
coder_devcontainer
With this change it now does:
customizations.coder.name
coder_devcontainer
We now attempt to construct a valid agent name from the workspace folder. Should we fail to construct a valid agent name from the workspace folder, we will fall back to the dev container's friendly name.