Skip to content

Commit c4534bb

Browse files
Copilotalexr00
andauthored
Add loading spinner to Cancel Coding Agent button (#7466)
* Initial plan * Initial plan for adding loading spinner to Cancel Coding Agent button Co-authored-by: alexr00 <[email protected]> * Add loading spinner to Cancel Coding Agent button Co-authored-by: alexr00 <[email protected]> * Fix alignment and shifting --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: alexr00 <[email protected]>
1 parent c03657d commit c4534bb

File tree

6 files changed

+29
-26
lines changed

6 files changed

+29
-26
lines changed

src/@types/vscode.proposed.chatSessionsProvider.d.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ declare module 'vscode' {
88
* Provides a list of information about chat sessions.
99
*/
1010
export interface ChatSessionItemProvider {
11-
/**
12-
* Label of the extension that registers the provider.
13-
*/
14-
readonly label: string; // TODO: move to contribution or registration
15-
1611
/**
1712
* Event that the provider can fire to signal that chat sessions have changed.
1813
*/

webviews/activityBarView/index.css

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,5 @@ button .icon svg {
184184
}
185185

186186
button.split-left {
187-
border-radius: 2px 0 0 2px;
188-
flex-grow: 1;
189-
overflow: hidden;
190-
white-space: nowrap;
191-
text-overflow: ellipsis;
187+
display: block;
192188
}

webviews/common/common.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ button.split-left {
359359
overflow: hidden;
360360
white-space: nowrap;
361361
text-overflow: ellipsis;
362+
display: flex;
362363
}
363364

364365
.split {

webviews/components/contextDropdown.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@
66
import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
77
import { chevronDownIcon } from './icon';
88

9-
interface ContextDropdownProps {
10-
optionsContext: () => string;
11-
defaultOptionLabel: () => string;
12-
defaultOptionValue: () => string;
13-
defaultAction: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
14-
allOptions?: () => { label: string; value: string; action: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void }[];
15-
optionsTitle: string;
16-
disabled?: boolean;
17-
hasSingleAction?: boolean;
18-
spreadable: boolean;
19-
isSecondary?: boolean;
9+
interface ContextDropdownProps {
10+
optionsContext: () => string;
11+
defaultOptionLabel: () => string | React.ReactNode;
12+
defaultOptionValue: () => string;
13+
defaultAction: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
14+
allOptions?: () => { label: string; value: string; action: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void }[];
15+
optionsTitle: string;
16+
disabled?: boolean;
17+
hasSingleAction?: boolean;
18+
spreadable: boolean;
19+
isSecondary?: boolean;
2020
}
2121

2222
function useWindowSize() {
@@ -59,10 +59,10 @@ export const ContextDropdown = ({ optionsContext, defaultOptionLabel, defaultOpt
5959
return <button className='inlined-dropdown' key={value} title={label} disabled={disabled} onClick={action} value={value}>{label}</button>;
6060
})
6161
:
62-
<div className='primary-split-button'>
63-
<button className={`split-left${isSecondary ? ' secondary' : ''}`} disabled={disabled} onClick={defaultAction} value={defaultOptionValue()}
64-
title={defaultOptionLabel()}>
65-
{defaultOptionLabel()}
62+
<div className='primary-split-button'>
63+
<button className={`split-left${isSecondary ? ' secondary' : ''}`} disabled={disabled} onClick={defaultAction} value={defaultOptionValue()}
64+
title={typeof defaultOptionLabel() === 'string' ? defaultOptionLabel() as string : optionsTitle}>
65+
{defaultOptionLabel()}
6666
</button>
6767
{hasSingleAction ? null :
6868
<div className={`split${isSecondary ? ' secondary' : ''}${disabled ? ' disabled' : ''}`}><div className={`separator${disabled ? ' disabled' : ''}`}></div></div>

webviews/components/header.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ function CancelCodingAgentButton({ canEdit, codingAgentEvent }: { canEdit: boole
192192
return <ContextDropdown
193193
optionsContext={() => JSON.stringify(context)}
194194
defaultAction={actions[0].action}
195-
defaultOptionLabel={() => actions[0].label}
195+
defaultOptionLabel={() => isBusy ? (
196+
<>
197+
<span className='loading-button'>{loadingIcon}</span>
198+
{actions[0].label}
199+
</>
200+
) : actions[0].label}
196201
defaultOptionValue={() => actions[0].value}
197202
allOptions={() => {
198203
return actions;

webviews/editorWebview/index.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@ textarea:focus,
6666
transform: translate(-50%, -50%);
6767
}
6868

69+
.loading-button {
70+
display: inline-flex;
71+
align-items: center;
72+
margin-right: 4px;
73+
}
74+
6975
.comment-body li div {
7076
display: inline;
7177
}

0 commit comments

Comments
 (0)