Skip to content

Refactor add interactive workflow run prompt - #51517

Merged
pelikhan merged 5 commits into
mainfrom
copilot/lint-monster-function-length-refactoring-another-one
Aug 9, 2026
Merged

Refactor add interactive workflow run prompt#51517
pelikhan merged 5 commits into
mainfrom
copilot/lint-monster-function-length-refactoring-another-one

Conversation

Copilot AI commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

The function-length backlog includes long CLI functions that need surgical helper extraction without behavior changes. This slice targets pkg/cli/add_interactive_workflow.go.

  • Split workflow status/run orchestration

    • Extracted status polling from checkStatusAndOfferRun.
    • Kept the top-level flow under the large-function limit.
  • Isolated user-facing branches

    • Added helpers for unavailable status messaging, Codespaces instructions, run confirmation, local branch update, and workflow run URL display.
  • Added focused coverage

    • Added a small table test for the workflow-dispatch gate that controls whether the run prompt is offered.
if !c.shouldOfferAddedWorkflowRun() {
    c.showFinalInstructions()
    return nil
}

Run: https://github.com/github/gh-aw/actions/runs/31310371321> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 4.98 AIC · ⌖ 5.48 AIC · ⊞ 6.1K ·

Comment /souschef to run again

Copilot AI linked an issue Aug 9, 2026 that may be closed by this pull request
11 tasks
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Hey @Copilot - thanks for tackling the function-length refactoring backlog from #51498! This PR is aligned with the projects agentic development workflow and the scope looks good.

Since this is still in WIP status with no file changes yet, here are a few things to keep in mind as you continue:

  • Add test coverage - Once code changes are committed, ensure the refactored functions are covered by existing or new tests. The checklist mentions running targeted tests, so make sure those pass.
  • Run validation - The checklist already accounts for make golint-custom and make fmt, which is great - make sure those all pass before marking as ready for review.

The narrow scope and step-by-step checklist approach look solid. Looking forward to seeing the implementation!

Generated by ✅ Contribution Check · auto · 80.4 AIC · ⌖ 4.92 AIC · ⊞ 8.8K ·

Copilot AI changed the title [WIP] Refactor function lengths for compliance with golint Refactor add interactive workflow run prompt Aug 9, 2026
Copilot AI requested a review from pelikhan August 9, 2026 05:20
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR Triage

  • Category: refactor
  • Risk: low
  • Priority: low
  • Score: 23/100 (impact 10 + urgency 5 + quality 8)
  • Recommended action: defer

Small draft refactor, low urgency.

Generated by 🔧 PR Triage Agent · auto · 58.3 AIC · ⌖ 2.48 AIC · ⊞ 8K ·

@pelikhan
pelikhan marked this pull request as ready for review August 9, 2026 11:08
Copilot AI balanced review requested due to automatic review settings August 9, 2026 11:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors interactive workflow-run orchestration into focused helpers while preserving behavior.

Changes:

  • Extracts status polling, prompting, branch updates, and run URL display.
  • Adds focused coverage for the workflow-dispatch gate.
Show a summary per file
File Description
pkg/cli/add_interactive_workflow.go Splits the workflow-run flow into smaller helpers.
pkg/cli/add_interactive_workflow_test.go Tests run-offer eligibility.

Review details

Tip

Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Lean already. Ship. Reviewed the refactor of add_interactive_workflow.go: each extracted helper (waitForWorkflowStatus, checkWorkflowStatusAttempt, showWorkflowStatusUnavailableInstructions, shouldOfferAddedWorkflowRun, showCodespaceRunInstructions, confirmRunAddedWorkflow, runAddedWorkflowOnce, updateLocalBranchBeforeWorkflowRun, showWorkflowRunURL) is a single-caller split required to bring checkStatusAndOfferRun under the function-length lint limit, not speculative abstraction. No dead code, reinvented stdlib, unneeded deps, or config-nobody-sets flexibility introduced. Added test targets the new testable gate function directly. No over-engineering findings to report.

Generated by Ponytail Reviewer for #51517

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

Warning

Threat Detection Engine Failure — The analysis engine could not complete. This is a tooling failure, not a security finding.

What happened

The threat detection engine failed to produce results.

Review the workflow run logs for details.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • api.individual.githubcopilot.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "api.individual.githubcopilot.com"

See Network Configuration for more information.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

🧪 Test quality analysis by Test Quality Sentinel

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: Refactor add interactive workflow run prompt

Clean refactoring that improves readability and testability by extracting cohesive sub-functions from the monolithic checkStatusAndOfferRun. Behavior is preserved and the new unit test for shouldOfferAddedWorkflowRun adds good coverage.

One minor nit (non-blocking): in waitForWorkflowStatus, the intermediate found variable is redundant — if c.checkWorkflowStatusAttempt(i) { workflowFound = true; break } would be cleaner. No blocking issues.

🧵 Reviewed using Impeccable skills by Impeccable Skills Reviewer · sonnet46 · 17.3 AIC · ⌖ 7.12 AIC · ⊞ 5.5K

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Applied /codebase-design and /tdd — commenting, not requesting changes, as these are refinements rather than blockers.

📋 Key Themes & Highlights

Key Themes

  • Silent error swallow (line 51): confirmRunAddedWorkflow now explicitly returns errors, but the caller still discards the error unconditionally. This is a correctness gap for context-cancellation propagation.
  • Hidden side-effect coupling (line 142): showWorkflowStatusUnavailableInstructions secretly calls showFinalInstructions, making it structurally inconsistent with every other branch in checkStatusAndOfferRun.
  • Underutilised seams (test file): The refactor created independently-callable helpers — checkWorkflowStatusAttempt, confirmRunAddedWorkflow, runAddedWorkflowOnce — that have no new tests despite being newly testable in isolation.

Positive Highlights

  • ✅ The top-level orchestration in checkStatusAndOfferRun is now clear and easy to follow
  • shouldOfferAddedWorkflowRun is a clean boolean predicate with good table-driven tests
  • confirmRunAddedWorkflow correctly returns errors rather than swallowing — the call-site should match this intent

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · sonnet46 · 32.2 AIC · ⌖ 7.85 AIC · ⊞ 7.1K
Comment /matt to run again

Comment thread pkg/cli/add_interactive_workflow.go Outdated

runNow, err := confirmRunAddedWorkflow(ctx)
if err != nil {
return nil // Not critical, just skip

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] Error from confirmRunAddedWorkflow is silently swallowed — this contradicts the refactored function which explicitly returns errors via return false, err.

Before the refactor, the original swallow was understandable. Now that confirmRunAddedWorkflow surfaces errors properly, context-cancellation errors will be discarded instead of propagated.

💡 Suggestion

Distinguish user-cancel from unexpected errors:

runNow, err := confirmRunAddedWorkflow(ctx)
if err != nil {
    if errors.Is(err, huh.ErrUserAborted) {
        c.showFinalInstructions()
        return nil
    }
    return err // propagate context cancellation etc.
}

@copilot please address this.

Comment thread pkg/cli/add_interactive_workflow.go Outdated
func (c *AddInteractiveConfig) showWorkflowStatusUnavailableInstructions() {
fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Could not verify workflow status."))
fmt.Fprintf(os.Stderr, "You can check status with: %s status\n", string(constants.CLIExtensionPrefix))
c.showFinalInstructions()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/codebase-design] showWorkflowStatusUnavailableInstructions calls c.showFinalInstructions() internally, but its caller does not call it again — this works correctly, but it creates a subtle coupling: the method has a side effect (calling another method) that violates the single-responsibility principle and makes the name misleading.

💡 Suggestion

Remove showFinalInstructions from inside showWorkflowStatusUnavailableInstructions and let the top-level flow call it explicitly (as is done in all other branches):

func (c *AddInteractiveConfig) showWorkflowStatusUnavailableInstructions() {
    fmt.Fprintln(os.Stderr, console.FormatWarningMessage("Could not verify workflow status."))
    fmt.Fprintf(os.Stderr, "You can check status with: %s status
", string(constants.CLIExtensionPrefix))
    // caller is responsible for showFinalInstructions
}

Then at the call site (line ~29):

c.showWorkflowStatusUnavailableInstructions()
c.showFinalInstructions()
return nil

This makes all branches in checkStatusAndOfferRun structurally parallel.

@copilot please address this.

@@ -75,3 +75,41 @@ func TestCheckStatusAndOfferRun_ContextCancelled(t *testing.T) {
t.Fatalf("expected context cancellation error, got %v", err)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[/tdd] The new test only covers shouldOfferAddedWorkflowRun — the simplest extracted method. The more complex extracted helpers (waitForWorkflowStatus, checkWorkflowStatusAttempt, confirmRunAddedWorkflow) have no new tests despite being independently callable now.

The refactor created clean seams; the tests don't yet exploit them.

💡 Suggested coverage additions
  • checkWorkflowStatusAttempt: test the verbose/non-verbose branching and the error path when findWorkflowsByFilenamePattern returns an error.
  • confirmRunAddedWorkflow: test context cancellation propagation (was previously un-testable inside the monolith).
  • runAddedWorkflowOnce: test early-return when primaryWorkflowName() is empty.

These are now independently callable and mockable — this is exactly what the refactor enables.

@copilot please address this.

@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Quality Sentinel Report

⚠️ Test Quality Score: 67/100 — Acceptable

Analyzed 3 test(s): 2 design, 1 implementation, 0 violations.

📊 Metrics (3 tests)
Metric Value
Analyzed 3 (Go: 3, JS: 0)
✅ Design 2 (67%)
⚠️ Implementation 1 (33%)
Edge/error coverage 1 (33%)
Duplicate clusters 0
Inflation No
🚨 Violations 0
Test File Classification Issues
TestGetWorkflowStatuses pkg/cli/add_interactive_workflow_test.go:14 implementation_test No real assertions — smoke only
TestCheckStatusAndOfferRun_ContextCancelled pkg/cli/add_interactive_workflow_test.go:67 design_test None
TestShouldOfferAddedWorkflowRun pkg/cli/add_interactive_workflow_test.go:79 design_test None
⚠️ Flagged Tests (1)

TestGetWorkflowStatuses (pkg/cli/add_interactive_workflow_test.go:14) — implementation_detail, low_value.

This test explicitly states its intent: "we just verify the function doesn't panic." The three table rows exercise different parameter combinations but none make meaningful assertions — they accept any error outcome or only check status.Workflow non-empty if the gh CLI happens to succeed (which it never does in CI). The test provides no regression protection for the actual behavior of findWorkflowsByFilenamePattern. Consider either: (a) refactoring the function to accept an injectable command runner so it can be unit-tested with a mock shell, or (b) tagging this test (go/redacted):build integration and running it only in environments with a real gh CLI.

Verdict

Failed. 33% implementation tests (threshold: 30%). TestGetWorkflowStatuses contributes no real behavioral coverage — see flagged tests above.

🧪 Test quality analysis by Test Quality Sentinel · sonnet46 · 40.2 AIC · ⌖ 7.39 AIC · ⊞ 7.7K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ Test Quality Sentinel: 67/100. 33% implementation tests (threshold: 30%). TestGetWorkflowStatuses has no real assertions. Review flagged tests in the comment above.

… workflow

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

🏗️ Design Decision Gate — ADR Required

This PR makes significant changes to core business logic (182 new lines in pkg/) but does not have a linked Architecture Decision Record (ADR).

📄 Draft ADR committed: docs/adr/51517-extract-method-refactoring-add-interactive-workflow.md — review and complete it before merging.

🔒 This PR cannot merge until an ADR is linked in the PR body.

📋 What to do next
  1. Review the draft ADR committed to your branch — it was generated from the PR diff
  2. Complete the missing sections — add context the AI could not infer, refine the decision rationale, and list real alternatives you considered
  3. Commit the finalized ADR to docs/adr/ on your branch
  4. Reference the ADR in this PR body by adding a line such as:

    ADR: ADR-51517: Extract Method Refactoring for Add Interactive Workflow Run Prompt

Once an ADR is linked in the PR body, this gate will re-run and verify the implementation matches the decision.

❓ Why ADRs Matter

"AI made me procrastinate on key design decisions. Because refactoring was cheap, I could always say 'I'll deal with this later.' Deferring decisions corroded my ability to think clearly."

ADRs create a searchable, permanent record of why the codebase looks the way it does. Future contributors (and your future self) will thank you.

📋 Michael Nygard ADR Format Reference

An ADR must contain these four sections to be considered complete:

  • Context — What is the problem? What forces are at play?
  • Decision — What did you decide? Why?
  • Alternatives Considered — What else could have been done?
  • Consequences — What are the trade-offs (positive and negative)?

All ADRs are stored in docs/adr/ as Markdown files numbered by PR number (e.g., 51517-extract-method-refactoring-add-interactive-workflow.md for PR #51517).

🏗️ ADR gate enforced by Design Decision Gate 🏗️ · sonnet46 · 45.8 AIC · ⌖ 16.7 AIC · ⊞ 8.8K ·
Comment /review to run again

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Quick triage nudge for this PR.
Please refresh the branch if GitHub can update it cleanly, address the maintainer-facing follow-up below, and run the pr-finisher skill before handing this back.
Open review context (newest first):

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 4.98 AIC · ⌖ 5.48 AIC · ⊞ 6.1K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Quick triage nudge for this PR.
Please refresh the branch if GitHub can update it cleanly, address the maintainer-facing follow-up below, and run the pr-finisher skill before handing this b...

Done. Addressed all three open review comments in the latest commit:

  1. Error propagation (r3743583668): confirmRunAddedWorkflow errors are no longer swallowed. console.IsCancelled (wrapping huh.ErrUserAborted) triggers showFinalInstructions + nil return; all other errors are propagated.

  2. SRP / structural parity (r3743583674): Removed c.showFinalInstructions() from inside showWorkflowStatusUnavailableInstructions. The call site now calls it explicitly, making the checkStatusAndOfferRun branches structurally parallel.

  3. Test coverage (r3743583678): Added TestCheckWorkflowStatusAttempt, TestConfirmRunAddedWorkflow_ContextCancelled (including an assertion that context.Canceled is not treated as a user-abort), and TestRunAddedWorkflowOnce_EmptyWorkflowName.

Copilot AI requested a review from gh-aw-bot August 9, 2026 11:30
@pelikhan
pelikhan merged commit 74b8762 into main Aug 9, 2026
29 checks passed
@pelikhan
pelikhan deleted the copilot/lint-monster-function-length-refactoring-another-one branch August 9, 2026 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[lint-monster] function-length refactoring backlog

4 participants