Skip to content

Implement seamless terminal commit flow for GPG signing and git hooks in Copilot Remote Agent #7146

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

Merged
merged 4 commits into from
Jun 30, 2025

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Jun 28, 2025

Problem

When GitHub Copilot Remote Agent attempts to auto-commit changes but encounters GPG signing requirements or git hooks, the operation would fail abruptly with an error message:

Could not 'git commit' pending changes. If GPG signing or git hooks are enabled, please first commit or stash your changes and try again.

This forced users to:

  1. Manually commit their changes
  2. Restart the entire Copilot Remote Agent process
  3. Deal with a broken workflow experience

Solution

This PR implements a seamless terminal commit flow that automatically handles GPG signing and git hooks without interrupting the user's workflow.

New Flow

When auto-commit fails, the system now:

  1. Shows friendly notification: Explains the situation clearly
  2. Opens VS Code terminal: Automatically creates terminal with correct working directory
  3. Pre-fills command: Includes helpful comments and the git commit command
  4. Waits intelligently: Monitors repository state to detect successful commits
  5. Continues seamlessly: Automatically proceeds with push operation once commit succeeds
  6. Handles cancellation: Gracefully aborts if user closes terminal

Example Terminal Output

# GitHub Copilot Remote Agent - Interactive Commit
# Complete this commit to continue with your coding session
git commit -m "Checkpoint for Copilot Agent async session"

Technical Implementation

Core Method: handleInteractiveCommit()

  • Opens VS Code terminal with vscode.window.createTerminal()
  • Monitors git state changes via repository.state.onDidChange()
  • Detects successful commits by checking HEAD changes and staged files
  • Handles terminal closure via vscode.window.onDidCloseTerminal()
  • Includes 5-minute timeout protection
  • Proper resource cleanup and error handling

Integration

Modified the commit error handling in invokeRemoteAgent():

try {
    await repository.commit(commitMessage);
} catch (e) {
    // NEW: Instead of failing immediately, open interactive terminal
    vscode.window.showInformationMessage(
        'Automatic commit failed due to GPG signing or git hooks. Please complete the commit in the terminal to continue.'
    );
    
    const commitSuccessful = await this.handleInteractiveCommit(repository, commitMessage);
    if (!commitSuccessful) {
        return { error: 'Commit was not completed. GitHub Copilot Remote Agent operation was cancelled.', state: 'error' };
    }
}

Benefits

  • Zero workflow interruption: Process continues exactly where it left off
  • Automatic setup: Terminal opens in correct directory with pre-filled command
  • Smart detection: System knows when to continue without user intervention
  • Graceful handling: Supports cancellation, timeout, and error scenarios
  • User friendly: Clear notifications and guidance throughout

Testing

  • Validated compilation without errors
  • Verified VS Code API usage patterns
  • Ready for manual testing with GPG setup and git hooks

This change transforms a frustrating error scenario into a smooth, guided experience that leverages VS Code's terminal capabilities to bridge automatic operations with interactive requirements.

Fixes microsoft/vscode#252263


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 2 commits June 28, 2025 21:50
Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com>
Co-authored-by: joshspicer <23246594+joshspicer@users.noreply.github.com>
@Copilot Copilot AI changed the title [WIP] Summary of GPG Warnings in Copilot Remote Agent Implement seamless terminal commit flow for GPG signing and git hooks in Copilot Remote Agent Jun 28, 2025
@Copilot Copilot AI requested a review from joshspicer June 28, 2025 21:53
Copilot finished work on behalf of joshspicer June 28, 2025 21:53
@joshspicer joshspicer marked this pull request as ready for review June 30, 2025 19:17
@vs-code-engineering vs-code-engineering bot added this to the July 2025 milestone Jun 30, 2025
@joshspicer joshspicer modified the milestones: July 2025, June 2025 Jun 30, 2025
@joshspicer joshspicer merged commit d6128ba into main Jun 30, 2025
3 checks passed
@joshspicer joshspicer deleted the copilot/fix-1085781a-851c-4fd0-a58d-ee4667ea69f0 branch June 30, 2025 21:12
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.

3 participants