Skip to content

Commit 37a5d34

Browse files
Copilotalexr00
andauthored
Add "View Session" button next to "Cancel Coding Agent" button (#7086)
* Initial plan * Add View Session button next to Cancel Coding Agent button Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Fix: Replace 'in' check with proper type cast for sessionLink Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Move View Session button to the left of Cancel button Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent 92971a8 commit 37a5d34

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

webviews/components/header.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import React, { useContext, useState } from 'react';
77
import { copilotEventToStatus, CopilotPRStatus, mostRecentCopilotEvent } from '../../src/common/copilot';
8-
import { TimelineEvent } from '../../src/common/timelineEvent';
8+
import { CopilotStartedEvent, TimelineEvent } from '../../src/common/timelineEvent';
99
import { GithubItemStateEnum } from '../../src/github/interface';
1010
import { PullRequest } from '../../src/github/views';
1111
import PullRequestContext from '../common/context';
@@ -134,7 +134,7 @@ function ButtonGroup({ isCurrentlyCheckedOut, canEdit, isIssue, repositoryDefaul
134134
}
135135

136136
function CancelCodingAgentButton({ canEdit, codingAgentEvent }: { canEdit: boolean, codingAgentEvent: TimelineEvent | undefined }) {
137-
const { cancelCodingAgent, updatePR } = useContext(PullRequestContext);
137+
const { cancelCodingAgent, updatePR, openSessionLog } = useContext(PullRequestContext);
138138
const [isBusy, setBusy] = useState(false);
139139

140140
const cancel = async () => {
@@ -149,8 +149,16 @@ function CancelCodingAgentButton({ canEdit, codingAgentEvent }: { canEdit: boole
149149
setBusy(false);
150150
};
151151

152+
// Extract sessionLink from the coding agent event
153+
const sessionLink = (codingAgentEvent as CopilotStartedEvent)?.sessionLink;
154+
152155
return (canEdit && codingAgentEvent && copilotEventToStatus(codingAgentEvent) === CopilotPRStatus.Started)
153156
? <div className="button-group">
157+
{sessionLink && (
158+
<button title="View Session" className="secondary small-button" onClick={() => openSessionLog(sessionLink)}>
159+
View Session
160+
</button>
161+
)}
154162
<button title="Cancel Coding Agent" disabled={isBusy} className="small-button danger" onClick={cancel}>
155163
Cancel Coding Agent
156164
</button>

0 commit comments

Comments
 (0)