Skip to content

refactor: consolidate duplicated buildAgentCommand and spawnWithTimeout across watch capabilities #994

Closed

Description

@tamirdresher

Context

PR #988 fixed the --message flag across 8 files, but the underlying pattern (same command-building logic copy-pasted everywhere) is still there. Flagged by @diberry in her review.

What

  1. Extract a shared buildAgentCommand() into a single location (e.g., watch/utils.ts)
  2. Consolidate spawnWithTimeout() which appears in 4 places with identical implementation
  3. Update docs/comments that still reference gh copilot (code now calls copilot directly)

Why

Prevents this class of bug from recurring. Next time the Copilot CLI changes a flag, it is one file to update instead of 8.

Follow-up from PR #988. Credit: @diberry review.

Activity

  1. omercangumus commented on Jul 2, 2026

    @omercangumus
    Contributor

    Hi! I'd like to work on this. Looking at the code, execute.ts and wave-dispatch.ts still carry their own copies of buildAgentCommand() and a spawn-with-timeout helper (identical to each other, diverging from the shared agent-spawn.ts module added for #920/#923 because they need the withAdditionalMcpConfig wiring). My plan is to extend agent-spawn.ts with a Copilot-flavored command builder and a pid-tracking-aware spawnAgent variant, then have both capabilities import from there instead of keeping local copies. Will open a PR shortly.

  2. added a commit that references this issue on Jul 13, 2026
    d476cb1
  3. added a commit that references this issue on Aug 13, 2026
    54f699f
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or improvementtriagedIssue has been triagedwave:2-soonWave 2 — next 2-4 weeks

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions