Skip to content

refactor(machine): share machine list loading - #1714

Merged
skevetter merged 1 commit into
mainfrom
refactor/machine-share-list-loading
Oct 28, 2026
Merged

skevetter merged 1 commit into
mainfrom
refactor/machine-share-list-loading

Conversation

@skevetter

@skevetter skevetter commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add private loadSortedMachines in cmd/machine/list.go: loads each machine config once via provider.LoadMachineConfig, wraps errors as load machine config: %w, and stable-sorts by ID.
  • printMachinesPlain and printMachinesJSON both consume that result; their duplicated loop, error wrapping, and sort are removed.
  • Output, errors, field set, duplicate-ID ordering and JSON bytes are unchanged (empty listing still marshals to []).

Why

Plain and JSON machine listing duplicate config loading and ID sorting, so their behavior can drift. A shared loader will provide one sorted inventory to both renderers. This is a narrow cleanup in an otherwise untouched Engine path.

Validation

  • mise run cli:format
  • mise run cli:lint:ci: 0 issues
  • mkdir -p dist && go build ./cmd/machine/...
  • go vet ./cmd/machine/
  • go test ./cmd/machine/... ./pkg/provider/...: pass
  • Throwaway old-vs-new test (not committed, removed): copied origin/main renderers and compared stdout and errors for plain and JSON on unsorted fixtures with duplicate IDs, an empty machines dir, and a malformed machine.json. All identical.

CodeRabbit CLI

coderabbit review --agent --committed --base-commit dd1a36088de23f80ee3ea3ad6acec9ecb59b3712: completed, 0 findings, reviewed cmd/machine/list.go.

Auto-merge

Eligible: yes. Behaviour-preserving; 48 changed non-test lines (27 added, 21 removed); 1 non-test file; no tests touched; no lint rule or nolint changed.

Next

None.

Summary by CodeRabbit

  • Bug Fixes
    • Machine lists are now sorted consistently in plain-text and JSON output.
    • Errors loading machine configuration are reported instead of silently producing incomplete output.

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

netlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

❌ Deploy Preview for devsydev failed.

Name Link
🔨 Latest commit 8b90163
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6adf96939f15ee2654565d83

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6aab438d-69c2-4df2-bf97-4518ff1759df
Commits

Reviewing files that changed from the base of the PR and between c9a7e55 and 8b90163.

Files selected for processing: 1
  • cmd/machine/list.go

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

Walkthrough

Machine config loading and ID sorting now use a shared function for plain-text and JSON output. Both paths return errors from that function.

Changes: Machine list output

Layer / File(s) Summary
Shared loading and output paths
cmd/machine/list.go
A shared function loads machine configs, wraps loading errors, and sorts machines by ID. Plain-text output builds rows from the sorted machines, and JSON output marshals them.

Priority: Low

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

Change: Refactor

Merge Risk: Minimal · up to 8b901

No actionable issue is identified; the change 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 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title uses Conventional Commits format and clearly describes the main refactor: sharing machine list loading.
Description check Passed The description clearly explains what changed, why it changed, behavior-preservation expectations, and validation results. It omits several template sections, including the change-type selection, AI-a…
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.
Full details: Description check

Explanation

The description clearly explains what changed, why it changed, behavior-preservation expectations, and validation results. It omits several template sections, including the change-type selection, AI-assistance disclosure, checklist confirmations, and explicit issue reference, but the core information is complete.

Finishing Touches: 💡 1
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
✨ Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

CI annotation context is incomplete: annotation collection unavailable or limited

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 26, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit 8b90163
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6adf96931d398d11b9848346

@skevetter
skevetter marked this pull request as ready for review October 26, 2026 06:15
@mergify

mergify Bot commented Oct 26, 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.

Copy link
Copy Markdown
Contributor Author

@greptileai review

@skevetter
skevetter marked this pull request as draft October 26, 2026 18:03
@greptile-apps

greptile-apps Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Low impact] The PR appears safe to merge.

Summary

Both machine-list formats now use loadSortedMachines to load configs and sort them by ID.

  • Machine list output uses one shared, ID-sorted inventory.

Reviews (2) · Last reviewed commit: "refactor(machine): share machine list lo..." · Reviewed by Greptile

@skevetter
skevetter force-pushed the refactor/machine-share-list-loading branch from 6760435 to 8b90163 Compare October 26, 2026 18:06
@skevetter
skevetter marked this pull request as ready for review October 26, 2026 19:03

Copy link
Copy Markdown
Contributor Author

@greptileai review

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

No files to review.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 11 minutes.

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
✅ Action performed

Full review finished.

@skevetter
skevetter merged commit 61b3c83 into main Oct 28, 2026
111 of 115 checks passed
@skevetter
skevetter deleted the refactor/machine-share-list-loading branch October 28, 2026 05:15
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/s

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant