Repository navigation
[duplicate-code] refactor(cli): deduplicate logs render option construction - #75992
Conversation
|
✅ PR Specification Reviewer completed successfully! PR Specification ReviewerOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ Ponytail Reviewer completed successfully!
|
|
✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft. Design Decision Gate 🏗️Outcome: The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible. Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.
|
|
✅ PR Code Quality Reviewer completed the code quality review.
|
There was a problem hiding this comment.
What this change does: It shares the common rendering options between single-target and multi-target log downloads. The callers still set their result-specific values.
One small duplication remains in the shared discovery-mode options; see the inline comment.
Verdict: Ship.
Lean: -5 lines possible.
Generated by ✂️ Ponytail Reviewer for #75992 · codex · routed: gpt61 medium · ~5 AIC · ⌖ ~1 AIC · ⊞ 181
Comment /ponytail to run again
| outcomeReports: outcomeReports, | ||
| }) | ||
| renderOpts := newRenderLogsOutputOptions(opts, artifactFilter) | ||
| renderOpts.startDate = opts.StartDate |
There was a problem hiding this comment.
Should fix: Both discovery paths repeat startDate, endDate, checkStaleness, suppressRender, and cachedJSONLWriter; set these five values in newRenderLogsOutputOptions and remove both sets of assignments so future changes only need one edit (about 5 fewer lines).
There was a problem hiding this comment.
Reviewed the three changed files and the refactor preserves the previous field mappings and path-specific behavior. No actionable correctness, performance, or maintainability issues found in the changed lines. The grumpy-coder specialist completed its pass; its suggestions were non-blocking and did not identify a regression.
🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~2 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain, and the change consistently centralizes shared render-option construction while preserving path-specific behavior.
No open issues 🎉
What changed in this PR
This pull request deduplicates shared renderLogsOutputOptions construction across single-target and multi-target discovery log rendering while preserving path-specific behavior.
Changes:
- Added
newRenderLogsOutputOptionsto centralize shared option mapping. - Updated single-target and multi-target rendering paths to use the helper.
- Left stdin rendering unchanged because it uses a different options type.
| File | Description |
|---|---|
pkg/cli/logs_orchestrator.go |
Uses the shared helper for single-target discovery rendering. |
pkg/cli/logs_orchestrator_types.go |
Defines the shared render-option construction helper. |
pkg/cli/logs_multi.go |
Uses the shared helper for multi-target rendering. |
Review effort: Lite (auto)
There was a problem hiding this comment.
Skills-Based Review 🧠
Applied /codebase-design and /tdd. Verdict: the refactor is behavior-preserving, but the shared helper is only partly shared.
📋 Key Themes & Highlights
Verification run
gofmt -lon the three changed files: clean.go vet ./pkg/cli/: clean.go test ./pkg/cli/ -run Logs|logs|RenderLogs: passes. The PR could not run these, so this closes that gap.- All 22
renderLogsOutputOptionsfields are still set on both paths.
Key themes
- Half-extracted helper:
startDate,endDate,checkStaleness,suppressRender, andcachedJSONLWriterare still repeated at both call sites. The doc comment on the helper calls the date range path-specific, but both callers set it the same way. - No direct test: the helper that now holds the mapping has no unit test, so a dropped field would only surface through indirect tests.
Positive highlights
- ✅ Good use of a constructor that takes the options struct and returns a value, so callers keep control of path-specific fields.
- ✅ Net -4 lines and a single place to add future output flags.
- ✅ The PR describes its own validation gaps honestly.
@copilot please address the review comments above.
🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~3 AIC · ⌖ ~2 AIC · ⊞ 6.3K
Comment /matt to run again
| // fields shared by the discovery-mode logs rendering paths (single-target and | ||
| // multi-target). Callers set the path-specific fields (continuations, rate limits, | ||
| // date range, etc.) on the returned value. | ||
| func newRenderLogsOutputOptions(opts LogsDownloadOptions, artifactFilter []string) renderLogsOutputOptions { |
There was a problem hiding this comment.
[/codebase-design] This helper is meant to hold the fields shared by the discovery-mode render paths, but startDate, endDate, checkStaleness, suppressRender, and cachedJSONLWriter are set identically at both call sites (logs_orchestrator.go lines 355-362 and logs_multi.go lines 313-323). Those mappings are still duplicated. The doc comment also calls the date range path-specific, which the code contradicts.
💡 Suggested change
Move those five fields into newRenderLogsOutputOptions, with checkStaleness: true set there too. That matches the struct comment, which says checkStaleness is for discovery-mode only. apiRateLimit and outcomeReports are also identical at both sites, so they can move too if the helper takes them as parameters. Callers would then set only continuation/continuations, countLimitReached, countLimitTargets, and apiRateLimits.
@copilot please address this.
| audit: opts.Audit, | ||
| verbose: opts.Verbose, | ||
| artifactFilter: artifactFilter, | ||
| includeWorkQueue: workQueueEvidenceRequested(opts.ArtifactSets), |
There was a problem hiding this comment.
[/tdd] Nothing tests newRenderLogsOutputOptions directly. The PR names the main risk itself: a field forgotten on one path would silently change that path output. The helper now centralizes that mapping, but nothing checks it.
💡 Suggested test
Add a unit test that sets a distinct non-zero value on every copied LogsDownloadOptions field, calls newRenderLogsOutputOptions, and asserts each matching renderLogsOutputOptions field. Use Arrange, Act, Assert, and name it as a spec, for example TestNewRenderLogsOutputOptionsCopiesSharedFields. This catches a mapping that gets dropped or mis-wired in future edits.
@copilot please address this.
|
Copilot assignment requested for the following outstanding work:
Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI. Sous-chef requested-head: 7bac19b
|
Assignment running:
Sous-chef requested-head: 7bac19b I will not merge the PR or trigger CI. |
…render-options-ca8b6d83f36337be Co-authored-by: gh-aw-bot <[email protected]>
|
🎉 This pull request is included in a new release. Release: |
🔍 Duplicate Code Detected:
renderLogsOutputOptionsconstruction in logs renderingImplementation: Extracted
newRenderLogsOutputOptions(opts LogsDownloadOptions, artifactFilter []string)inpkg/cli/logs_orchestrator_types.go. Both call sites now call it and set only their path-specific fields. Behavior is intended to be unchanged.Summary
Two discovery-mode rendering paths each built a ~25-line
renderLogsOutputOptionsliteral. 13 of those fields were copied one-for-one fromLogsDownloadOptions.Duplication Details
pkg/cli/logs_orchestrator.gorenderCollectedWorkflowLogspkg/cli/logs_multi.goDownloadWorkflowLogsForTargetsoutputDir,summaryFile,format,reportFile,jsonOutput,episodes,toolGraph,train,drain3Weights,audit,verbose,artifactFilter,includeWorkQueueDownloadWorkflowLogsFromStdininpkg/cli/logs_orchestrator_stdin.gohas a similar literal. It takesStdinLogsOptions, a different type, so it was left alone.Impact Analysis
Validation
gofmt -l pkg/cli: clean.errors.Ashint inlogs_multi.go, unrelated to this change. The diagnostics also caught a type mismatch in my first attempt to use the helper from the stdin path, and I reverted that part.go build,go vetandgo test ./pkg/clicould not run in the analysis sandbox. Module downloads from proxy.golang.org failed with a TLS certificate error. Please let CI runmake test-unit, particularly thelogs_*tests.Analysis Metadata
pkg/**/*.go(non-test)