Skip to content

Commit 64ad04f

Browse files
committed
Refactor progress indicators to use consistent defaults and enable cancellation where appropriate
1 parent ff0fcd6 commit 64ad04f

10 files changed

Lines changed: 23 additions & 18 deletions

File tree

‎apps/editor/src/commands/apply-chat-response-command/apply-chat-response-command.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,7 @@ export const apply_chat_response_command = (params: {
144144
params.panel_provider.send_message({
145145
command: 'SHOW_PROGRESS',
146146
title: 'Preparing response preview...',
147-
show_elapsed_time: false,
148-
delay_visibility: file_count < 5,
149-
cancellable: false
147+
delay_visibility: file_count < 5
150148
})
151149
}
152150

‎apps/editor/src/commands/apply-chat-response-command/handlers/active-editor-intelligent-update-handler.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ export const handle_active_editor_intelligent_update = async (params: {
102102
params.panel_provider.send_message({
103103
command: 'SHOW_PROGRESS',
104104
title: 'Thinking...',
105-
show_elapsed_time: true
105+
show_elapsed_time: true,
106+
cancellable: true
106107
})
107108
}
108109

@@ -147,7 +148,8 @@ export const handle_active_editor_intelligent_update = async (params: {
147148
params.panel_provider.send_message({
148149
command: 'SHOW_PROGRESS',
149150
title: 'Thinking...',
150-
show_elapsed_time: true
151+
show_elapsed_time: true,
152+
cancellable: true
151153
})
152154
}
153155
},
@@ -156,7 +158,8 @@ export const handle_active_editor_intelligent_update = async (params: {
156158
params.panel_provider.send_message({
157159
command: 'SHOW_PROGRESS',
158160
title: 'Retrying...',
159-
show_elapsed_time: true
161+
show_elapsed_time: true,
162+
cancellable: true
160163
})
161164
}
162165
}

‎apps/editor/src/commands/checkpoints-command/actions/create-checkpoint.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,7 @@ export const create_checkpoint = async (
233233
did_show_modal = true
234234
panel_provider.send_message({
235235
command: 'SHOW_PROGRESS',
236-
title: 'Creating checkpoint...',
237-
cancellable: false,
238-
show_elapsed_time: false
236+
title: 'Creating checkpoint...'
239237
})
240238
}, 1000)
241239

‎apps/editor/src/commands/checkpoints-command/actions/restore-checkpoint.ts‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,6 @@ export const restore_checkpoint = async (params: {
425425
command: 'SHOW_PROGRESS',
426426
title,
427427
progress: current_progress,
428-
cancellable: false,
429-
show_elapsed_time: false,
430428
delay_visibility: true
431429
})
432430
const progress: vscode.Progress<{
@@ -440,8 +438,6 @@ export const restore_checkpoint = async (params: {
440438
command: 'SHOW_PROGRESS',
441439
title,
442440
progress: Math.min(current_progress, 100),
443-
cancellable: false,
444-
show_elapsed_time: false,
445441
delay_visibility: true
446442
})
447443
}

‎apps/editor/src/views/panel/backend/message-handlers/handle-voice-input.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ const stop_recording = async (panel_provider: PanelProvider) => {
181181
panel_provider.send_message({
182182
command: 'SHOW_PROGRESS',
183183
title: 'Transcribing...',
184+
show_elapsed_time: true,
184185
cancellable: true
185186
})
186187

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ export const use_panel = (vscode: any) => {
349349
title: message.title,
350350
progress: message.progress,
351351
tokens_per_second: message.tokens_per_second,
352-
cancellable: message.cancellable ?? true,
352+
cancellable: message.cancellable ?? false,
353353
show_elapsed_time: message.show_elapsed_time,
354354
delay_visibility: message.delay_visibility
355355
})

‎packages/ui/src/components/editor/panel/BrowserExtensionMessage/BrowserExtensionMessage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const BrowserExtensionMessage: React.FC = () => {
2525

2626
return (
2727
<div ref={container_ref} className={styles.container}>
28-
<div className={styles.heading}>Enable autofill in your browser</div>
28+
<div className={styles.heading}>Enable autofill in chatbots</div>
2929
<div ref={links_ref} className={styles.links}>
3030
<a href="https://chromewebstore.google.com/detail/code-web-chat-connector/ljookipcanaglfaocjbgdicfbdhhjffp">
3131
{compact_step >= 2 ? 'Chrome' : 'Chrome Web Store'}

‎packages/ui/src/components/editor/panel/PromptField/PromptField.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,9 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
110110
on_copy: props.on_copy,
111111
on_invocation_count_change: props.on_invocation_count_change,
112112
is_invocation_dropdown_open,
113-
on_toggle_invocation_dropdown: toggle_invocation_dropdown
113+
on_toggle_invocation_dropdown: toggle_invocation_dropdown,
114+
is_recording: props.is_recording,
115+
on_recording_finished: props.on_recording_finished
114116
})
115117

116118
const {

‎packages/ui/src/components/editor/panel/PromptField/hooks/use-handlers.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,8 +1514,10 @@ export const use_handlers = (
15141514
}
15151515

15161516
if (key == 'Escape') {
1517-
if (input_ref.current) {
1518-
input_ref.current.blur()
1517+
if (props.is_recording) {
1518+
props.on_recording_finished()
1519+
} else {
1520+
input_ref.current?.blur()
15191521
}
15201522
return
15211523
}

‎packages/ui/src/components/editor/panel/PromptField/hooks/use-keyboard-shortcuts.ts‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ type UseKeyboardShortcutsParams = Pick<
77
| 'on_edit_format_change'
88
| 'on_copy'
99
| 'on_invocation_count_change'
10+
| 'is_recording'
11+
| 'on_recording_finished'
1012
> & {
1113
on_toggle_invocation_dropdown?: () => void
1214
is_invocation_dropdown_open?: boolean
@@ -124,6 +126,9 @@ export const use_keyboard_shortcuts = (params: UseKeyboardShortcutsParams) => {
124126
e: React.KeyboardEvent<HTMLDivElement>
125127
) => {
126128
if (e.key == 'Escape' && !e.ctrlKey && !e.metaKey) {
129+
if (params.is_recording) {
130+
params.on_recording_finished()
131+
}
127132
e.stopPropagation()
128133
return
129134
}

0 commit comments

Comments
 (0)