Skip to content

Commit 921115c

Browse files
committed
Add back button support to patch repair configuration flows and update response preview to use StatusBar
- in apply response, when some file failed, the quick pick for patch repair auto-closes briefly after showing up - should use status bar instead of [Pasted text] - add close button to 'patch repair' quick pick ├── apps │ └── editor │ └── src │ ├── constants │ │ └── state-keys.ts │ ├── features │ │ └── apply-response │ │ ├── apply-response.ts │ │ ├── response-processor │ │ │ └── response-processor.ts │ │ ├── types │ │ │ └── original-file-state.ts │ │ └── utils │ │ ├── preview │ │ │ ├── file-preparer.ts │ │ │ └── preview.ts │ │ └── state-manager.ts │ ├── i18n │ │ └── translations │ │ └── common.ts │ ├── utils │ │ ├── agentic-cli-invocation │ │ │ └── invoke-agentic-cli.ts │ │ ├── get-api-configuration.ts │ │ └── show-configurations-quick-pick.ts │ └── views │ └── prompt │ ├── backend │ │ ├── message-handlers │ │ │ ├── handle-apply-from.ts │ │ │ ├── handle-patch-repair.ts │ │ │ ├── index.ts │ │ │ └── utils │ │ │ └── patch-repair-utils.ts │ │ └── prompt-view-provider.ts │ ├── frontend │ │ ├── Main │ │ │ └── MainView │ │ │ ├── MainView.tsx │ │ │ └── components │ │ │ ├── BrowserConnectionStatus │ │ │ │ └── BrowserConnectionStatus.tsx │ │ │ ├── Header │ │ │ │ └── Header.tsx │ │ │ └── PromptAttachments │ │ │ └── PromptAttachments.tsx │ │ └── Prompt.tsx │ └── types │ └── messages.ts └── packages ├── shared │ └── src │ └── types │ └── file-in-preview.ts └── ui └── src └── components └── editor └── prompt-view ├── ResponsePreview │ ├── ResponsePreview.module.scss │ ├── ResponsePreview.stories.tsx │ ├── ResponsePreview.tsx │ ├── components │ │ ├── FileItem │ │ │ ├── FileItem.module.scss │ │ │ ├── FileItem.tsx │ │ │ └── index.ts │ │ ├── InlineFileItem │ │ │ ├── InlineFileItem.module.scss │ │ │ ├── InlineFileItem.tsx │ │ │ └── index.ts │ │ ├── TextItem │ │ │ ├── TextItem.module.scss │ │ │ ├── TextItem.tsx │ │ │ └── index.ts │ │ └── index.ts │ └── index.ts └── StatusBar └── StatusBar.tsx
1 parent 1749c6c commit 921115c

4 files changed

Lines changed: 80 additions & 124 deletions

File tree

‎apps/editor/src/views/prompt/backend/message-handlers/handle-patch-repair.ts‎

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ export const handle_patch_repair = async (params: {
149149
'views.prompt.handlers.handle-patch-repair.some-changes-unable-to-apply'
150150
)
151151
)
152+
return
152153
}
153154
}
154155

@@ -210,9 +211,16 @@ export const handle_patch_repair = async (params: {
210211
quick_pick.placeholder = t(
211212
'common.action-quick-pick.placeholder.no-tokens'
212213
)
214+
quick_pick.buttons = [
215+
{ iconPath: new vscode.ThemeIcon('close'), tooltip: t('common.close') }
216+
]
213217

214218
let is_resolved = false
215219

220+
quick_pick.onDidTriggerButton(() => {
221+
quick_pick.hide()
222+
})
223+
216224
quick_pick.onDidAccept(() => {
217225
is_resolved = true
218226
resolve(quick_pick.selectedItems[0]?.id)
@@ -278,7 +286,11 @@ export const handle_patch_repair = async (params: {
278286
})
279287

280288
if (invoke_cli_result === 'back') {
281-
return handle_patch_repair({ ...params, show_quick_pick: true })
289+
return handle_patch_repair({
290+
...params,
291+
show_quick_pick: false,
292+
is_auto_run: false
293+
})
282294
}
283295

284296
if (!invoke_cli_result) {
@@ -351,10 +363,18 @@ export const handle_patch_repair = async (params: {
351363
items: valid_web_configurations,
352364
type: 'web',
353365
last_selected_id: last_selected_name,
354-
show_back_button: false
366+
show_back_button: true
355367
})
356368

357-
if (!result || result === 'back') {
369+
if (result === 'back') {
370+
return handle_patch_repair({
371+
...params,
372+
show_quick_pick: false,
373+
is_auto_run: false
374+
})
375+
}
376+
377+
if (!result) {
358378
return
359379
}
360380
selected_web_configuration_name = result.item.name
@@ -407,8 +427,18 @@ export const handle_patch_repair = async (params: {
407427
const api_configuration_result = await get_patch_repair_config({
408428
providers_manager,
409429
show_quick_pick: params.show_quick_pick ?? false,
410-
extension_context: params.prompt_view_provider.extension_context
430+
extension_context: params.prompt_view_provider.extension_context,
431+
show_back_button: !skip_action_quick_pick
411432
})
433+
434+
if (api_configuration_result === 'back') {
435+
return handle_patch_repair({
436+
...params,
437+
show_quick_pick: false,
438+
is_auto_run: false
439+
})
440+
}
441+
412442
if (!api_configuration_result) return
413443

414444
const {

‎apps/editor/src/views/prompt/backend/message-handlers/utils/patch-repair-utils.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ export const get_patch_repair_config = async (params: {
1717
providers_manager: ProvidersManager
1818
show_quick_pick?: boolean
1919
extension_context: vscode.ExtensionContext
20+
show_back_button?: boolean
2021
}): Promise<
21-
{ provider: Provider; api_configuration: ApiConfiguration } | undefined
22+
| { provider: Provider; api_configuration: ApiConfiguration }
23+
| 'back'
24+
| undefined
2225
> => {
2326
const result = await get_api_configuration({
2427
providers_manager: params.providers_manager,
@@ -28,11 +31,12 @@ export const get_patch_repair_config = async (params: {
2831
default_api_configuration:
2932
await params.providers_manager.get_default_patch_repair_api_configuration(),
3033
caller_name: 'get_patch_repair_config',
31-
auto_select_last_used: false
34+
auto_select_last_used: false,
35+
show_back_button: params.show_back_button
3236
})
3337

3438
if (!result || result === 'back') {
35-
return undefined
39+
return result
3640
}
3741

3842
return {

‎packages/ui/src/components/editor/prompt-view/ResponsePreview/ResponsePreview.module.scss‎

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -9,73 +9,6 @@
99
}
1010
}
1111

12-
.info {
13-
display: flex;
14-
justify-content: space-between;
15-
gap: 4px;
16-
color: var(--cwc-text-color-dimmed);
17-
font-size: 12px;
18-
margin: 0 12px;
19-
border-radius: 8px;
20-
overflow: hidden;
21-
22-
@include modern-ui {
23-
margin: 0 10px;
24-
}
25-
26-
&--error {
27-
color: var(--cwc-red-foreground);
28-
background-color: var(--cwc-red-background);
29-
30-
.info__action:hover {
31-
background-color: var(--cwc-red-background);
32-
}
33-
}
34-
35-
&--warning {
36-
color: var(--cwc-yellow-foreground);
37-
background-color: var(--cwc-yellow-background);
38-
39-
.info__action:hover {
40-
background-color: var(--cwc-yellow-background);
41-
}
42-
}
43-
44-
&__content {
45-
gap: 6px;
46-
flex: 1;
47-
overflow: hidden;
48-
text-overflow: ellipsis;
49-
white-space: nowrap;
50-
padding: 4px 0 4px 7px;
51-
52-
> span:first-child {
53-
font-size: 12px;
54-
transform: translateY(2px);
55-
margin-right: 4px;
56-
}
57-
58-
&--without-button {
59-
padding-right: 7px;
60-
}
61-
}
62-
63-
&__action {
64-
display: flex;
65-
font-size: 12px;
66-
align-items: center;
67-
gap: 4px;
68-
cursor: pointer;
69-
white-space: nowrap;
70-
color: var(--vscode-textLink-foreground);
71-
padding: 0 7px 0 4px;
72-
73-
&:hover {
74-
background-color: var(--vscode-list-hoverBackground);
75-
}
76-
}
77-
}
78-
7912
.instructions {
8013
position: relative;
8114
margin: 0 12px;

‎packages/ui/src/components/editor/prompt-view/ResponsePreview/ResponsePreview.tsx‎

Lines changed: 39 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import cn from 'classnames'
1010
import styles from './ResponsePreview.module.scss'
1111
import { TextItem, InlineFileItem, FileItem } from './components'
1212
import { Scrollable } from '../../common/Scrollable'
13+
import { StatusBar } from '../StatusBar'
1314

1415
type Props = {
1516
items: ItemInPreview[]
@@ -289,63 +290,51 @@ export const ResponsePreview: FC<Props> = (props) => {
289290
)}
290291

291292
{error_count > 0 && (
292-
<div
293-
className={cn(styles.info, styles['info--error'])}
294-
title={
293+
<StatusBar
294+
theme="error"
295+
icon="codicon-error"
296+
label={
295297
files_in_preview.length > 1
296298
? `${error_count} of ${files_in_preview.length} files failed to apply changes`
297299
: 'Failed to apply changes to the file'
298300
}
299-
>
300-
<div className={styles.info__content}>
301-
<span className="codicon codicon-error" />
302-
<span>
303-
{files_in_preview.length > 1
304-
? `${error_count} of ${files_in_preview.length} files failed to apply changes`
305-
: 'Failed to apply changes to the file'}
306-
</span>
307-
</div>
308-
{!props.is_from_agentic_cli && (
309-
<div
310-
className={styles.info__action}
311-
onClick={() => {
312-
set_is_fixing_all(true)
313-
const files_to_fix = files_in_preview
314-
.filter(
315-
(f) =>
316-
f.type === 'file' &&
317-
f.apply_failed &&
318-
!f.applied_with_patch_repair &&
319-
!f.is_applying
320-
)
321-
.map((f) => ({
322-
file_path: f.file_path,
323-
workspace_name: f.workspace_name
324-
}))
325-
props.on_fix_all_failed(files_to_fix, false)
326-
}}
327-
>
328-
<span className="codicon codicon-sparkle" />
329-
<span>{error_count > 1 ? 'Fix all' : 'Fix'}</span>
330-
</div>
331-
)}
332-
</div>
301+
actions={
302+
!props.is_from_agentic_cli
303+
? [
304+
{
305+
id: 'fix',
306+
icon: 'codicon-sparkle',
307+
label: error_count > 1 ? 'Fix all' : 'Fix',
308+
on_click: () => {
309+
set_is_fixing_all(true)
310+
const files_to_fix = files_in_preview
311+
.filter(
312+
(f) =>
313+
f.type === 'file' &&
314+
f.apply_failed &&
315+
!f.applied_with_patch_repair &&
316+
!f.is_applying
317+
)
318+
.map((f) => ({
319+
file_path: f.file_path,
320+
workspace_name: f.workspace_name
321+
}))
322+
props.on_fix_all_failed(files_to_fix, false)
323+
}
324+
}
325+
]
326+
: undefined
327+
}
328+
/>
333329
)}
334330

335331
{aggressive_fallback_count > 1 && (
336-
<div
337-
className={cn(styles.info, styles['info--warning'])}
338-
title={`${aggressive_fallback_count} of ${files_in_preview.length} files applied with fallback method`}
339-
>
340-
<div
341-
className={cn(
342-
styles.info__content,
343-
styles['info__content--without-button']
344-
)}
345-
>
346-
<span className="codicon codicon-warning" />
347-
{`${aggressive_fallback_count} of ${files_in_preview.length} files applied with fallback method`}
348-
</div>
332+
<div className={styles.status}>
333+
<StatusBar
334+
theme="warning"
335+
icon="codicon-warning"
336+
label={`${aggressive_fallback_count} of ${files_in_preview.length} files applied with fallback method`}
337+
/>
349338
</div>
350339
)}
351340

0 commit comments

Comments
 (0)