Skip to content

Commit da4f2fb

Browse files
committed
Rename the title field to status in API manager progress messages and clean up progress component styles
- extract common logic to a hook `packages/ui/src/hooks` - show the 'progress' at the top. remove shadow and animations - each item should have its own border, separate each with 8px gap, don't alternate background colors
1 parent 8b6f5df commit da4f2fb

8 files changed

Lines changed: 85 additions & 148 deletions

File tree

‎apps/editor/src/services/api-manager.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class ApiManager {
8484
this.broadcast_message({
8585
command: 'SHOW_API_MANAGER_PROGRESS',
8686
id: request_id,
87-
title: is_queued ? 'Queued...' : 'Waiting for server...',
87+
status: is_queued ? 'Queued...' : 'Waiting for server...',
8888
provider_name: params.provider_name,
8989
model: params.model,
9090
reasoning_effort: params.reasoning_effort
@@ -102,7 +102,7 @@ export class ApiManager {
102102
this.broadcast_message({
103103
command: 'SHOW_API_MANAGER_PROGRESS',
104104
id: request_id,
105-
title: 'Waiting for server...',
105+
status: 'Waiting for server...',
106106
provider_name: params.provider_name,
107107
model: params.model,
108108
reasoning_effort: params.reasoning_effort
@@ -119,7 +119,7 @@ export class ApiManager {
119119
this.broadcast_message({
120120
command: 'SHOW_API_MANAGER_PROGRESS',
121121
id: request_id,
122-
title: 'Thinking...',
122+
status: 'Thinking...',
123123
provider_name: params.provider_name,
124124
model: params.model,
125125
reasoning_effort: params.reasoning_effort
@@ -130,7 +130,7 @@ export class ApiManager {
130130
this.broadcast_message({
131131
command: 'SHOW_API_MANAGER_PROGRESS',
132132
id: request_id,
133-
title: 'Receiving...',
133+
status: 'Receiving...',
134134
tokens_per_second,
135135
total_tokens,
136136
provider_name: params.provider_name,

‎apps/editor/src/views/api-manager/frontend/ApiManager.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export const ApiManager = () => {
99
Record<
1010
string,
1111
{
12-
title: string
12+
status: string
1313
tokens_per_second?: number
1414
total_tokens?: number
1515
cancellable?: boolean
@@ -27,7 +27,7 @@ export const ApiManager = () => {
2727
set_api_manager_progress_state((prev) => ({
2828
...prev,
2929
[message.id]: {
30-
title: message.title,
30+
status: message.status,
3131
tokens_per_second: message.tokens_per_second,
3232
total_tokens: message.total_tokens,
3333
provider_name: message.provider_name,

‎apps/editor/src/views/panel/frontend/hooks/use-modal-manager.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const use_modal_manager = () => {
1515
Record<
1616
string,
1717
{
18-
title: string
18+
status: string
1919
tokens_per_second?: number
2020
total_tokens?: number
2121
cancellable?: boolean
@@ -58,7 +58,7 @@ export const use_modal_manager = () => {
5858
set_api_manager_progress_state((prev) => ({
5959
...prev,
6060
[message.id]: {
61-
title: message.title,
61+
status: message.status,
6262
tokens_per_second: message.tokens_per_second,
6363
total_tokens: message.total_tokens,
6464
provider_name: message.provider_name,

‎apps/editor/src/views/shared/types/messages.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export interface CancelApiManagerRequestMessage extends BaseMessage {
1010
export interface ShowApiManagerProgressMessage extends BaseMessage {
1111
command: 'SHOW_API_MANAGER_PROGRESS'
1212
id: string
13-
title: string
13+
status: string
1414
tokens_per_second?: number
1515
total_tokens?: number
1616
provider_name: string
Lines changed: 17 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,40 @@
1-
.overlay {
2-
position: absolute;
3-
top: 0;
4-
left: 0;
5-
width: 100%;
6-
height: 100%;
7-
display: flex;
8-
align-items: flex-end;
9-
justify-content: flex-end;
10-
padding: 0 12px 48px 8px;
11-
pointer-events: none;
12-
}
13-
14-
@keyframes slideIn {
15-
from {
16-
opacity: 0;
17-
transform: translateY(8px);
18-
}
19-
to {
20-
opacity: 1;
21-
transform: translateY(0);
22-
}
23-
}
24-
251
.container {
262
display: flex;
273
flex-direction: column;
284
position: relative;
29-
pointer-events: all;
305
z-index: 1;
31-
border-radius: 8px;
32-
color: var(--vscode-editorWidget-foreground);
33-
background-color: var(--vscode-editorWidget-background);
34-
border: 1px solid var(--vscode-editorWidget-border);
35-
box-shadow: 0 4px 10px var(--vscode-widget-shadow);
366
width: 100%;
37-
max-width: min(260px, 70vw);
38-
overflow: hidden;
39-
animation: slideIn var(--transition-duration-250)
40-
var(--transition-timing-function);
41-
}
42-
43-
.requests-container {
44-
display: flex;
45-
flex-direction: column;
46-
padding-bottom: 4px;
7+
padding: 12px;
8+
gap: 8px;
479
}
4810

4911
.item {
5012
display: flex;
5113
flex-direction: column;
5214
width: 100%;
5315
position: relative;
54-
55-
&:nth-child(even) {
56-
background-color: var(--cwc-bg-tertiary);
57-
}
16+
border-radius: 8px;
17+
color: var(--vscode-editorWidget-foreground);
18+
background-color: var(--vscode-editorWidget-background);
19+
border: 1px solid var(--vscode-editorWidget-border);
20+
padding: 4px 0;
21+
overflow: hidden;
5822

5923
&__top {
6024
display: flex;
6125
align-items: center;
6226
justify-content: space-between;
63-
padding: 0 26px 0 8px;
27+
padding: 0 8px;
6428
height: 22px;
65-
position: relative;
29+
gap: 8px;
6630

6731
&__left {
6832
overflow: hidden;
6933
white-space: nowrap;
7034
text-overflow: ellipsis;
7135
line-height: 1.2;
36+
flex: 1;
37+
min-width: 0;
7238

7339
> span:nth-child(2) {
7440
color: var(--cwc-text-color-dimmed);
@@ -84,14 +50,15 @@
8450
justify-content: space-between;
8551
padding: 0 12px 0 8px;
8652
height: 18px;
87-
font-size: 0.9em;
8853
color: var(--cwc-text-color-dimmed);
8954

9055
&__status {
9156
overflow: hidden;
9257
white-space: nowrap;
9358
text-overflow: ellipsis;
9459
margin-right: 8px;
60+
flex: 1;
61+
min-width: 0;
9562
}
9663

9764
&__right {
@@ -104,19 +71,11 @@
10471
}
10572

10673
&__close {
107-
position: absolute;
10874
display: flex;
109-
height: 100%;
11075
align-items: center;
111-
right: 0;
112-
top: 0;
113-
padding-left: 30px;
114-
pointer-events: none;
115-
padding-right: 8px;
11676

11777
&__button {
11878
appearance: none;
119-
pointer-events: all;
12079
background: none;
12180
border: none;
12281
padding: 0;
@@ -125,9 +84,10 @@
12584
width: 15px;
12685
color: var(--vscode-icon-foreground);
12786
opacity: var(--dimmed-opacity);
128-
position: relative;
12987
cursor: pointer;
130-
flex-shrink: 0;
88+
display: flex;
89+
align-items: center;
90+
justify-content: center;
13191

13292
&:focus {
13393
outline: none;
@@ -141,15 +101,7 @@
141101
font-family: 'codicon';
142102
font-size: 13px;
143103
content: '\ea76';
144-
position: absolute;
145-
top: 50%;
146-
left: 50%;
147-
transform: translate(-50%, -50%);
148104
}
149105
}
150106
}
151-
152-
&:nth-child(odd) &__close {
153-
background: transparent;
154-
}
155107
}

‎packages/ui/src/components/editor/api-manager/Progress/Progress.tsx‎

Lines changed: 40 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import styles from './Progress.module.scss'
44
type Props = {
55
progress_items: {
66
id: string
7-
title: string
7+
status: string
8+
provider_name: string
89
tokens_per_second?: number
910
total_tokens?: number
10-
provider_name: string
1111
model?: string
1212
reasoning_effort?: string
1313
}[]
@@ -26,62 +26,47 @@ export const Progress: React.FC<Props> = (props) => {
2626
const { start_times, now } = use_progress_times(props.progress_items)
2727

2828
return (
29-
<div
30-
className={styles.overlay}
31-
onKeyDown={(e) => {
32-
if (e.key == 'Escape') {
33-
e.stopPropagation()
34-
}
35-
}}
36-
>
37-
<div className={styles.container}>
38-
<div className={styles['requests-container']}>
39-
{props.progress_items.map((item) => {
40-
const item_start_time = start_times[item.id]
41-
const current_start_time = item_start_time || Date.now()
42-
const elapsed_ms = now - current_start_time
29+
<div className={styles.container}>
30+
{props.progress_items.map((item) => {
31+
const item_start_time = start_times[item.id]
32+
const current_start_time = item_start_time || Date.now()
33+
const elapsed_ms = now - current_start_time
4334

44-
const description_parts = [item.provider_name]
45-
if (item.reasoning_effort) {
46-
description_parts.push(item.reasoning_effort)
47-
}
48-
const description = description_parts.join(' · ')
35+
const description_parts = [item.provider_name]
36+
if (item.reasoning_effort) {
37+
description_parts.push(item.reasoning_effort)
38+
}
39+
const description = description_parts.join(' · ')
4940

50-
return (
51-
<div key={item.id} className={styles.item}>
52-
<div className={styles.item__top}>
53-
<div className={styles.item__top__left}>
54-
<span>{item.model}</span>
55-
<span>{description}</span>
56-
</div>
57-
<div className={styles.item__close}>
58-
<button
59-
className={styles.item__close__button}
60-
onClick={() => props.on_cancel(item.id)}
61-
/>
62-
</div>
63-
</div>
64-
<div className={styles.item__bottom}>
65-
<div className={styles.item__bottom__status}>
66-
{item.title}
67-
</div>
68-
<div className={styles.item__bottom__right}>
69-
{item.tokens_per_second !== undefined && (
70-
<div>
71-
{format_tokens(item.tokens_per_second)} tokens/s
72-
</div>
73-
)}
74-
{item.total_tokens !== undefined && (
75-
<div>({format_tokens(item.total_tokens)})</div>
76-
)}
77-
<div>{(elapsed_ms / 1000).toFixed(1)}s</div>
78-
</div>
79-
</div>
41+
return (
42+
<div key={item.id} className={styles.item}>
43+
<div className={styles.item__top}>
44+
<div className={styles.item__top__left}>
45+
<span>{item.model}</span>
46+
<span>{description}</span>
47+
</div>
48+
<div className={styles.item__close}>
49+
<button
50+
className={styles.item__close__button}
51+
onClick={() => props.on_cancel(item.id)}
52+
/>
53+
</div>
54+
</div>
55+
<div className={styles.item__bottom}>
56+
<div className={styles.item__bottom__status}>{item.status}</div>
57+
<div className={styles.item__bottom__right}>
58+
{item.tokens_per_second !== undefined && (
59+
<div>{format_tokens(item.tokens_per_second)} tokens/s</div>
60+
)}
61+
{item.total_tokens !== undefined && (
62+
<div>({format_tokens(item.total_tokens)})</div>
63+
)}
64+
<div>{(elapsed_ms / 1000).toFixed(1)}s</div>
8065
</div>
81-
)
82-
})}
83-
</div>
84-
</div>
66+
</div>
67+
</div>
68+
)
69+
})}
8570
</div>
8671
)
8772
}

0 commit comments

Comments
 (0)