Skip to content

refactor(machine): extract diagnostics daemon render steps - #1582

Merged
skevetter merged 1 commit into
mainfrom
refactor/machine-diagnostics-render-steps
Oct 19, 2026
Merged

skevetter merged 1 commit into
mainfrom
refactor/machine-diagnostics-render-steps

Conversation

@skevetter

@skevetter skevetter commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Split renderDiagnosticsText in cmd/machine/diagnostics.go into renderDaemonDiagnostics, renderLastDaemonError, and renderShutdownCandidate; removes the //nolint:nestif block.
  • Centralize local time formatting in formatLocalTime / optionalLocalTime with a localTimeLayout const; replaces 5 inline format sites.
  • Add table-driven tests for renderDiagnosticsText (TestRenderDiagnosticsTextWithoutDaemon, TestRenderDiagnosticsTextWithDaemon, TestRenderDiagnosticsTextFullReport) written against the unmodified code first.

Verification

  • go vet clean; gofmt clean.
  • go test ./cmd/machine/ ./pkg/machinediagnostics/ -count=1 passes; TestRenderDiagnosticsText* also pass under TZ=America/New_York and TZ=Asia/Kolkata.
  • golangci-lint run ./cmd/machine/... ./pkg/machinediagnostics/...: 3 findings, all pre-existing in untouched code (status.go forbidigo, ssh.go funlen, ssh.go modernize). No new findings.
  • Repo-wide mise run cli:lint reports 275 pre-existing issues on the base branch, unrelated to this change.
  • CodeRabbit CLI: review could not run; connection fails with WebSocket closed in --agent, plain, and --dir modes, although coderabbit doctor passes. No CLI findings were obtained.

Notes

  • Commit e85ba7401 is signed.
  • Diff: cmd/machine/diagnostics.go ~100 changed lines; the rest is test code.

Summary by CodeRabbit

  • Chores
    • Updated diagnostic report handling and added coverage for reports with and without daemon information. Displayed values and fallback messages remain unchanged.

Split renderDiagnosticsText into renderDaemonDiagnostics, renderLastDaemonError, and renderShutdownCandidate, removing the nestif nolint. Centralize local time formatting in formatLocalTime/optionalLocalTime. Add table-driven tests covering the render output.
@netlify

netlify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for images-devsy-sh canceled.

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

@netlify

netlify Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit e85ba74
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6ad5ecb7fa20532cb1979dc5

@skevetter skevetter added the auto-refactor Automated refactor PR label Oct 19, 2026
@coderabbitai

coderabbitai Bot commented Oct 19, 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: 287b3340-0e35-45fe-9d2e-530387b1d2fd
📥 Commits

Reviewing files that changed from the base of the PR and between 91c3655 and e85ba74.

📒 Files selected for processing: 2
  • cmd/machine/diagnostics.go
  • cmd/machine/diagnostics_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

The diagnostics renderer now uses helpers for daemon details and local-time formatting. New exact-output tests cover reports without daemon data, healthy daemon reports, and a full report.

Changes: Diagnostics text rendering

Layer / File(s) Summary
Rendering and output coverage
cmd/machine/diagnostics.go, cmd/machine/diagnostics_test.go
The renderer delegates daemon details to helper functions and uses shared local-time formatting for daemon and workspace timestamps. Existing fallback text remains unchanged. Exact-output tests cover reports with and without daemon data.

Priority: ⬇️ Low

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

Change: Refactor

Merge Risk: ⚪ Minimal · up to e85ba

No actionable diagnostics-output risk is identified; the change is mergeable after normal 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 19 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
Title check Passed The title is concise, follows Conventional Commits form, and accurately describes the diagnostics rendering refactor.
Description check Passed The description explains the refactor and reports unit tests, formatting, vetting, and lint results. It omits several template fields, including the issue reference, change type, AI-assistance disclos…
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 explains the refactor and reports unit tests, formatting, vetting, and lint results. It omits several template fields, including the issue reference, change type, AI-assistance disclosure, and checklist, but provides enough context for review.

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

@skevetter
skevetter marked this pull request as ready for review October 19, 2026 12:08
@mergify

mergify Bot commented Oct 19, 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 962c192 into main Oct 19, 2026
111 checks passed
@skevetter
skevetter deleted the refactor/machine-diagnostics-render-steps branch October 19, 2026 12:14
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