Consolidate multi-step delegate confirmation into single upfront check #2087
+305
−32
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Users previously faced a two-step confirmation dance (
'create'→'uncommitted-changes') with separate auth handling, making it unclear what permissions were needed upfront. The flow also mixed modal dialogs with chat confirmations.Changes
New Single Confirmation Flow
prepareAndShowDelegateConfirmation()- Checks git state (uncommitted changes) and auth state (permissive session) upfront before showing confirmationDelegate,CancelCommit and Delegate,Delegate without committing,CancelAllow and Delegate,CancelCommit and Allow,Allow without committing,CancelButton-Based Action Routing
Updated
handleConfirmationData()to extract action fromrequest.prompt(format:"ButtonText: \"Title\""):Flow Simplification
chatParticipantImpl()- CallsprepareAndShowDelegateConfirmation()for new sessions (untitled and normal chat)'create'andUncommittedChangesStephandling for in-flight sessionsType Updates
Testing
Added unit tests covering button generation logic for all state combinations and button text detection patterns.
Original prompt
implement this plan
The user has attached the following uncommitted or modified files as relevant context:
Untitled-1
Single Confirmation Flow Refactoring Plan
Overview
Consolidate the multi-step confirmation flow into a single unified confirmation that checks all prerequisites upfront and presents dynamic buttons based on the current state (git changes, auth requirements).
Current Problems
'create'→'uncommitted-changes'authPermissionPromptedflagNew Design
Single Confirmation Step
Replace
'create'andUncommittedChangesStepwith a singleDelegateConfirmationStepconstant.Upfront State Checking
Before showing confirmation, check:
Dynamic Button Generation
Based on state combination, show appropriate buttons (this is just an example):
Delegate,CancelAllow and Delegate,CancelCommit and Delegate,Delegate without committing,CancelCommit and Allow,Allow without committing,CancelButton-Based Action Routing
In
handleConfirmationData(), determine action based on which button was clicked:autoPushAndCommit = trueImplementation Changes
1. Update Type Definitions (lines 28-34)
2. New Method:
prepareAndShowDelegateConfirmation()Replaces:
tryHandleUncommittedChanges()Responsibilities:
IGitServiceIAuthenticationChatUpgradeService.shouldRequestPermissiveSessionUpgrade()stream.confirmation()once with all state3. Simplified
handleConfirmationData()(lines ~570-603)Single switch case for
DelegateConfirmationStep:getPermissiveGitHubSession({ createIfNone: true })metadata.autoPushAndCommit = truedoUntitledCreation()orcreateDelegatedChatSession()4. Update
chatParticipantImpl()(lines ~765-900)Simplify to three paths:
handleConfirmationData()prepareAndShowDelegateConfirmation()Remove:
tryHandleUncommittedChanges()calls5. Methods to Remove
tryHandleUncommittedChanges()(lines ~650-737) - logic moves toprepareAndShowDelegateConfirmation()Backward Compatibility
Keep fallback for old-style auth confirmations with
authPermissionPromptedflag for any in-flight sessions.Benefits
Testing Considerations
Test matrix for button combinations:
Edge Cases
Untitled-1
[Chronological Review: The conversation began with the user requesting the implementation of a refactoring plan for a confirmation flow. The user provided an overview of the current problems and a new design for a single confirmation step. The user then requested to implement this plan, followed by a command to delegate the task to a cloud agent.][Intent Mapping:
Created from VS Code.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.