Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jun 25, 2025

This PR adds a "View Session" button next to the existing "Cancel Coding Agent" button in the pull request header. The button uses the secondary button styling as requested and only appears when a session link is available from the coding agent event.

Changes Made

  • Modified CancelCodingAgentButton component in webviews/components/header.tsx
  • Added openSessionLog import from PullRequestContext
  • Added logic to extract sessionLink from copilot events when available
  • Added "View Session" button with secondary small-button CSS classes
  • Button conditionally renders only when both the cancel button conditions are met AND a sessionLink exists

Implementation Details

The button follows existing patterns in the codebase:

  • Uses the same secondary styling (secondary small-button) as other header buttons
  • Only shows when the coding agent is started AND has an associated session
  • Leverages the existing openSessionLog functionality from the context
  • Maintains the same button group layout as the cancel button

The implementation is minimal and surgical, adding only the necessary code without modifying existing functionality.

Fixes #7085.


💡 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.

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Add a "View Session" button next to the "Cancel Coding Agent" button Add "View Session" button next to "Cancel Coding Agent" button Jun 25, 2025
Copilot AI requested a review from alexr00 June 25, 2025 17:23
Copilot finished work on behalf of alexr00 June 25, 2025 17:23
Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

@copilot, one comment

};

// Extract sessionLink from the coding agent event
const sessionLink = codingAgentEvent && 'sessionLink' in codingAgentEvent ? codingAgentEvent.sessionLink : undefined;
Copy link
Member

Choose a reason for hiding this comment

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

Don't use an in check, instead cast to something that has the property then see if the property exists.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 8b1c69e. Replaced the 'sessionLink' in codingAgentEvent check with proper type casting: (codingAgentEvent as CopilotStartedEvent)?.sessionLink.

Copy link
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

@copilot, also, put the button to the left of the "cancel" button.

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI requested a review from alexr00 June 25, 2025 17:34
Copilot finished work on behalf of alexr00 June 25, 2025 17:34
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Jun 25, 2025

@copilot, also, put the button to the left of the "cancel" button.

Done! Moved the "View Session" button to the left of the "Cancel Coding Agent" button in commit 58b4c9a.

Copilot finished work on behalf of alexr00 June 25, 2025 17:42
@alexr00 alexr00 marked this pull request as ready for review June 26, 2025 08:19
@vs-code-engineering vs-code-engineering bot added this to the June 2025 milestone Jun 26, 2025
@alexr00 alexr00 enabled auto-merge (squash) June 26, 2025 09:04
@alexr00 alexr00 merged commit 37a5d34 into main Jun 26, 2025
3 checks passed
@alexr00 alexr00 deleted the copilot/fix-7085 branch June 26, 2025 10:19
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.

Add a "View Session" button next to the "Cancel Coding Agent" button

4 participants