Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions webviews/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import React, { useContext, useState } from 'react';
import { copilotEventToStatus, CopilotPRStatus, mostRecentCopilotEvent } from '../../src/common/copilot';
import { TimelineEvent } from '../../src/common/timelineEvent';
import { CopilotStartedEvent, TimelineEvent } from '../../src/common/timelineEvent';
import { GithubItemStateEnum } from '../../src/github/interface';
import { PullRequest } from '../../src/github/views';
import PullRequestContext from '../common/context';
Expand Down Expand Up @@ -134,7 +134,7 @@ function ButtonGroup({ isCurrentlyCheckedOut, canEdit, isIssue, repositoryDefaul
}

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

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

// Extract sessionLink from the coding agent event
const sessionLink = (codingAgentEvent as CopilotStartedEvent)?.sessionLink;

return (canEdit && codingAgentEvent && copilotEventToStatus(codingAgentEvent) === CopilotPRStatus.Started)
? <div className="button-group">
{sessionLink && (
<button title="View Session" className="secondary small-button" onClick={() => openSessionLog(sessionLink)}>
View Session
</button>
)}
<button title="Cancel Coding Agent" disabled={isBusy} className="small-button danger" onClick={cancel}>
Cancel Coding Agent
</button>
Expand Down