Skip to content

Implement follow-up detection for active coding agent PRs #7180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jul 1, 2025

Summary

This PR enhances the copilot remote agent functionality to automatically detect when the currently checked out PR is a coding agent PR and initiate follow-ups accordingly, improving the user experience by making follow-ups more context-aware.

Problem

Previously, follow-up mode was only initiated when an explicit follow-up parameter was provided in the chat stream. This meant users had to manually specify follow-up information even when they were already working on an active coding agent PR.

Solution

Enhanced the commandImpl method in CopilotRemoteAgentManager to:

  1. Detect active coding agent PRs: After checking for explicit follow-up parameters, the code now checks if the currently active PR is tracked as a coding agent PR
  2. Maintain priority: Explicit follow-up parameters still take precedence over automatic detection
  3. Use existing infrastructure: Leverages CopilotStateModel to determine PR status and FolderRepositoryManager.activePullRequest to get the current PR

Implementation Details

// Check if the currently active PR is a coding agent PR
if (!followUpPR) {
    const activePR = repoInfo.fm.activePullRequest;
    if (activePR && this._stateModel.get(owner, repo, activePR.number) !== CopilotPRStatus.None) {
        followUpPR = activePR.number;
    }
}

The logic considers a PR to be a coding agent PR if it has any status other than CopilotPRStatus.None (i.e., Started, Completed, or Failed).

Benefits

  • Improved UX: Users no longer need to manually specify follow-up information when working on active coding agent PRs
  • Context awareness: The extension automatically recognizes when you're continuing work on an existing coding agent session
  • Backward compatibility: All existing functionality is preserved, with explicit follow-ups taking priority

Testing

The implementation was verified to:

  • ✅ Detect active coding agent PRs correctly
  • ✅ Prioritize explicit follow-up parameters over active PR detection
  • ✅ Preserve all existing functionality
  • ✅ Follow existing code patterns and conventions

Changes

  • Modified src/github/copilotRemoteAgent.ts to add active PR detection logic
  • Added import for CopilotPRStatus enum
  • 6 lines of new logic, minimal and surgical changes

Fixes the issue where follow-up mode wasn't automatically activated when working on active coding agent PRs.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] Implementing Follow-Up Detection for Active Coding Agent PRs Implement follow-up detection for active coding agent PRs Jul 1, 2025
@Copilot Copilot AI requested a review from joshspicer July 1, 2025 18:01
Copilot finished work on behalf of joshspicer July 1, 2025 18:01
@joshspicer
Copy link
Member

@copilot fff


TITLE: Implementing Follow-Up Detection for Active Coding Agent PRs

USER INTENT: The user aims to enhance the functionality of the PR extension to ensure that follow-ups are initiated not only when explicitly provided but also when an active coding agent PR is checked out.

TASK DESCRIPTION: The user wants to modify the existing code to detect when the currently checked out PR is a coding agent PR and initiate follow-ups accordingly. This involves checking the state of the PR and ensuring that follow-up actions are triggered under the specified conditions.

EXISTING: The current implementation only initiates follow-ups if they are parsed from the chat stream. The assistant identified how the extension detects coding agent PRs using the CopilotStateModel and CopilotPRWatcher, as well as how to check the currently active PR through FolderRepositoryManager.

PENDING: The user has requested the implementation of the proposed changes to the commandImpl method in copilotRemoteAgent.ts to include the new follow-up detection logic.

CODE STATE:

  • File Modified: src/github/copilotRemoteAgent.ts
  • Key Code Snippet:
async commandImpl(args?: ICopilotRemoteAgentCommandArgs): Promise<string | undefined> {
    // ...existing code...
    // Check if the currently active PR is a coding agent PR
    if (!followUpPR) {
        const activePR = repoInfo.fm.activePullRequest;
        if (activePR && this._stateModel.get(owner, repo, activePR.number)) {
            // The active PR is a coding agent PR, treat this as a follow-up
            followUpPR = activePR.number;
        }
    }
    // ...existing code...
}

RELEVANT CODE/DOCUMENTATION SNIPPETS:

  • Detection Method:
private _queriesIncludeCopilot(): string | undefined {
    const queries = vscode.workspace.getConfiguration(PR_SETTINGS_NAMESPACE).get<{ label: string; query: string }[]>(QUERIES, []);
    return queries.find(query => isCopilotQuery(query.query))?.query;
}
  • Active PR Check:
const folderManager = reposManager.getManagerForIssueModel(prNode.pullRequestModel);
if (folderManager && prNode.pullRequestModel.equals(folderManager?.activePullRequest)) {
    // This PR is currently checked out
}

OTHER NOTES: The user confirmed that the follow-up mode should be activated if either an active coding agent PR is checked out or a valid follow-up string is provided. The assistant has initiated the implementation of these changes in the relevant pull request (#7180).

Copy link
Contributor Author

Copilot AI commented Jul 1, 2025

@copilot fff

--- ...

Updated the implementation to use the simpler truthy check approach as suggested. The logic now uses this._stateModel.get(owner, repo, activePR.number) which is more concise and functionally equivalent since CopilotPRStatus.None=0 (falsy) while other statuses are truthy. Commit: 74a0b45

Copilot finished work on behalf of joshspicer July 1, 2025 19:08
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.

2 participants