Skip to content

refactor(agent): share workspace dir resolution - #1545

Merged
skevetter merged 1 commit into
mainfrom
refactor/agent-workspace-dir-resolution
Oct 18, 2026
Merged

skevetter merged 1 commit into
mainfrom
refactor/agent-workspace-dir-resolution

Conversation

@skevetter

@skevetter skevetter commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

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.
  • 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

  • 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.

@skevetter skevetter added the auto-refactor Automated refactor PR label Oct 18, 2026
@netlify

netlify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 88fadbd
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6ad4b8e7c8f40a52613679fe

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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
pkg/agent/workspace.go, pkg/agent/workspace_test.go
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/.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to 88fad

No merge-blocking issue is established; the workspace path refactor is ready for normal merge checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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 Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: refactoring workspace directory resolution into shared logic.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@netlify

netlify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 88fadbd
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6ad4b8e7bb8fe7eec5b75b8a

@skevetter
skevetter marked this pull request as ready for review October 18, 2026 13:16
@mergify

mergify Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@skevetter
skevetter merged commit 1863b87 into main Oct 18, 2026
111 checks passed
@skevetter
skevetter deleted the refactor/agent-workspace-dir-resolution branch October 18, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-refactor Automated refactor PR size/l

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant