Skip to content

refactor: split logs_orchestrator.go (1284 lines) into 5 focused modules#44051

Open
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/file-diet-refactor-logs-orchestrator
Open

refactor: split logs_orchestrator.go (1284 lines) into 5 focused modules#44051
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/file-diet-refactor-logs-orchestrator

Conversation

Copilot AI commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

pkg/cli/logs_orchestrator.go had grown to 1284 lines mixing orchestration, filter logic, type definitions, output rendering, and stdin processing — with ~150 lines of run-filter and ProcessedRun construction duplicated between DownloadWorkflowLogs and DownloadWorkflowLogsFromStdin.

Changes

  • logs_orchestrator_types.go (87 lines) — pure type declarations: LogsDownloadOptions, StdinLogsOptions, continuationOptions, renderLogsOutputOptions
  • logs_orchestrator_filters.go (184 lines) — filter logic with two new shared helpers:
    • applyRunFilters(result, opts, verbose) bool — consolidates engine / staged / firewall / safe-output / DIFC filter blocks that were duplicated across both download paths
    • buildProcessedRun(result, verbose) ProcessedRun — consolidates ProcessedRun{...} construction (duration, action minutes, effective tokens, job counts)
  • logs_orchestrator_render.go (158 lines) — renderLogsOutput + renderLogsArtifactHint
  • logs_orchestrator_stdin.go (229 lines) — DownloadWorkflowLogsFromStdin
  • logs_orchestrator.go trimmed from 1284 → 603 lines; retains only the pagination loop, DownloadWorkflowLogs, and small utilities
  • logs_orchestrator_filters_test.go — unit tests for applyRunFilters and buildProcessedRun

Example: deduplicated filter call

Before (identical block existed in both DownloadWorkflowLogs and DownloadWorkflowLogsFromStdin, ~80 lines each):

if engine != "" {
    engineMatches, detectedEngineID := matchEngineFilter(awInfo, awInfoErr, engine)
    if !engineMatches { ... continue }
}
if noStaged { ... continue }
if firewallOnly || noFirewall { ... continue }
if safeOutputType != "" { ... continue }
if filteredIntegrity { ... continue }

After (one call, both paths):

if applyRunFilters(result, filters, verbose) {
    continue
}

Public API (DownloadWorkflowLogs, DownloadWorkflowLogsFromStdin, LogsDownloadOptions, StdinLogsOptions) is unchanged.

Copilot AI and others added 2 commits July 7, 2026 14:56
- Extract types into logs_orchestrator_types.go (87 lines)
- Extract filter logic and ProcessedRun builder into logs_orchestrator_filters.go (184 lines)
  including new applyRunFilters and buildProcessedRun helpers that eliminate ~250 lines of duplication
- Extract rendering into logs_orchestrator_render.go (158 lines)
- Extract stdin processing into logs_orchestrator_stdin.go (229 lines)
- Trim logs_orchestrator.go from 1284 to 603 lines
- Add logs_orchestrator_filters_test.go with tests for new helpers

Closes #44036

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Refactor logs_orchestrator.go into focused modules refactor: split logs_orchestrator.go (1284 lines) into 5 focused modules Jul 7, 2026
Copilot AI requested a review from pelikhan July 7, 2026 14:58
@pelikhan pelikhan marked this pull request as ready for review July 7, 2026 16:53
Copilot AI review requested due to automatic review settings July 7, 2026 16:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[file-diet] Refactor pkg/cli/logs_orchestrator.go (1284 lines) into focused modules

2 participants