You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
refactor(agent): share workspace dir resolution - #1545
Share the skeleton of GetAgentBinariesDir, GetAgentWorkspaceDir, and CreateAgentWorkspaceDir in pkg/agent/workspace.go behind a private resolveAgentWorkspaceDir. The three public functions keep their signatures and become thin wrappers.
Why
The three functions repeated the host/container dispatch and the home lookup. The resolver keeps one copy of that logic. Host and container layouts differ, so they stay separate branches. Find vs Prepare home lookup is preserved: Get* uses FindAgentHomeDir, Create* uses PrepareAgentHomeDir.
Validation
Table tests added first in pkg/agent/workspace_test.go. They passed on the pre-refactor code and pass on the refactored code. They cover both modes, the default context, missing directories, and Find vs Prepare.
mise run cli:format and mise run cli:lint:ci: 0 issues.
golangci-lint run --new-from-rev=origin/main ./pkg/...: 0 issues.
eligible: yes; 1 file + tests; no behaviour change.
Summary by CodeRabbit
Improvements
Agent workspace and binaries directory lookups and creation now use the appropriate paths for host and container environments, including when a default context is used. Missing workspace paths continue to return an error during lookup; creating a workspace prepares the required directory.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 2508775a-4732-4117-9ae7-366cceafa844
📥 Commits
Reviewing files that changed from the base of the PR and between 69b82de and 88fadbd.
📒 Files selected for processing: 2
pkg/agent/workspace.go
pkg/agent/workspace_test.go
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
📝 Walkthrough
Workspace path resolution is centralized for host and container invocations. Workspace and binaries lookup use the shared resolver. Workspace creation uses its preparation mode. Tests cover explicit and default contexts, missing directories, and container homes without a contexts/ directory.
Changes: Agent workspace paths
Layer / File(s)
Summary
Shared resolution and lookup pkg/agent/workspace.go, pkg/agent/workspace_test.go
A shared resolver selects the provider layout for host invocations and the agent-home path for container invocations. Workspace and binaries lookup use this resolver. Tests cover explicit and default contexts, existing and missing workspaces, and a missing binaries directory.
Workspace creation uses the resolver in preparation mode and creates the resolved directory. Tests cover host and container modes, including container lookup errors and workspace creation when the root lacks contexts/.
No merge-blocking issue is established; the workspace path refactor is ready for normal merge checks.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 13 functions across 2 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: refactoring workspace directory resolution into shared logic.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Fix all pre-merge checks with AI
✨ Finishing Touches
✨ Simplify code
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Share the skeleton of
GetAgentBinariesDir,GetAgentWorkspaceDir, andCreateAgentWorkspaceDirinpkg/agent/workspace.gobehind a privateresolveAgentWorkspaceDir. The three public functions keep their signatures and become thin wrappers.Why
The three functions repeated the host/container dispatch and the home lookup. The resolver keeps one copy of that logic. Host and container layouts differ, so they stay separate branches. Find vs Prepare home lookup is preserved:
Get*usesFindAgentHomeDir,Create*usesPrepareAgentHomeDir.Validation
pkg/agent/workspace_test.go. They passed on the pre-refactor code and pass on the refactored code. They cover both modes, the default context, missing directories, and Find vs Prepare.mise run cli:formatandmise run cli:lint:ci: 0 issues.golangci-lint run --new-from-rev=origin/main ./pkg/...: 0 issues.go test ./pkg/agent/...: ok.go build ./...: ok.CodeRabbit CLI
coderabbit review --agent --committed --base-commit 69b82de4: 0 findings, 2 files reviewed.Auto-merge
eligible: yes; 1 file + tests; no behaviour change.
Summary by CodeRabbit