Skip to content

Commit 90c47e4

Browse files
committed
Standardize progress modal usage by replacing ActiveEditorIntelligentUpdateModal with the unified ProgressModal component
1 parent 5b03a7e commit 90c47e4

13 files changed

Lines changed: 64 additions & 301 deletions

File tree

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

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ export const handle_active_editor_intelligent_update = async (params: {
9191
if (params.panel_provider) {
9292
params.panel_provider.api_call_cancel_token_source = cancel_token_source
9393
params.panel_provider.send_message({
94-
command: 'SHOW_ACTIVE_EDITOR_INTELLIGENT_UPDATE_MODAL',
95-
title: 'Updating file...',
96-
status: 'thinking'
94+
command: 'SHOW_PROGRESS',
95+
title: 'Thinking...',
96+
show_elapsed_time: true
9797
})
9898
}
9999

@@ -126,30 +126,28 @@ export const handle_active_editor_intelligent_update = async (params: {
126126
}
127127

128128
params.panel_provider.send_message({
129-
command: 'SHOW_ACTIVE_EDITOR_INTELLIGENT_UPDATE_MODAL',
130-
title: 'Updating file...',
131-
status: 'receiving',
129+
command: 'SHOW_PROGRESS',
130+
title: 'Receiving...',
132131
tokens_per_second,
133-
progress,
134-
total_tokens
132+
progress
135133
})
136134
}
137135
},
138136
on_retry_attempt: () => {
139137
if (params.panel_provider) {
140138
params.panel_provider.send_message({
141-
command: 'SHOW_ACTIVE_EDITOR_INTELLIGENT_UPDATE_MODAL',
142-
title: 'Updating file...',
143-
status: 'thinking'
139+
command: 'SHOW_PROGRESS',
140+
title: 'Thinking...',
141+
show_elapsed_time: true
144142
})
145143
}
146144
},
147145
on_retry: () => {
148146
if (params.panel_provider) {
149147
params.panel_provider.send_message({
150-
command: 'SHOW_ACTIVE_EDITOR_INTELLIGENT_UPDATE_MODAL',
151-
title: 'Updating file...',
152-
status: 'retrying'
148+
command: 'SHOW_PROGRESS',
149+
title: 'Retrying...',
150+
show_elapsed_time: true
153151
})
154152
}
155153
}
@@ -195,7 +193,7 @@ export const handle_active_editor_intelligent_update = async (params: {
195193
} finally {
196194
if (params.panel_provider) {
197195
params.panel_provider.send_message({
198-
command: 'HIDE_ACTIVE_EDITOR_INTELLIGENT_UPDATE_MODAL'
196+
command: 'HIDE_PROGRESS'
199197
})
200198
params.panel_provider.api_call_cancel_token_source = null
201199
}

‎apps/editor/src/views/panel/backend/message-handlers/handle-fix-all-failed-files.ts‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,10 @@ export const handle_fix_all_failed_files = async (
3636
return
3737
}
3838

39-
const failed_files = original_states.filter(
40-
(s) =>
41-
s.apply_failed &&
42-
!s.fixed_with_intelligent_update &&
43-
files_to_fix.some(
44-
(f) =>
45-
f.file_path == s.file_path && f.workspace_name == s.workspace_name
46-
)
39+
const failed_files = original_states.filter((s) =>
40+
files_to_fix.some(
41+
(f) => f.file_path == s.file_path && f.workspace_name == s.workspace_name
42+
)
4743
)
4844

4945
if (failed_files.length == 0) {

‎apps/editor/src/views/panel/backend/panel-provider.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ import {
8181
handle_cancel_intelligent_update_file_in_preview,
8282
handle_get_prune_context_instructions_prefix,
8383
handle_save_prune_context_instructions_prefix,
84-
handle_open_file_and_select,
8584
handle_open_external_url,
86-
handle_hash_sign_quick_pick
85+
handle_hash_sign_quick_pick,
86+
handle_open_file_and_select
8787
} from './message-handlers'
8888
import { SelectionState } from '../types/messages'
8989
import {

‎apps/editor/src/views/panel/frontend/Panel.tsx‎

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import { post_message } from './utils/post_message'
1212
import { ResponsePreview as UiResponsePreview } from '@ui/components/editor/panel/ResponsePreview'
1313
import { Modal as UiModal } from '@ui/components/editor/panel/modals/Modal'
1414
import { ProgressModal as UiProgressModal } from '@ui/components/editor/panel/modals/ProgressModal'
15-
import { ActiveEditorIntelligentUpdateModal as UiActiveEditorIntelligentUpdateModal } from '@ui/components/editor/panel/modals/ActiveEditorIntelligentUpdateModal'
1615
import { ApiManagerModal as UiApiManagerModal } from '@ui/components/editor/panel/modals/ApiManagerModal'
1716
import { QRCodeModal as UiQRCodeModal } from '@ui/components/editor/panel/modals/QRCodeModal'
1817
import { AutoClosingModal as UiAutoClosingModal } from '@ui/components/editor/panel/modals/AutoClosingModal'
@@ -110,8 +109,7 @@ export const Panel = () => {
110109
handle_discard_user_changes_in_preview,
111110
handle_task_forward,
112111
prune_context_instructions_prefix,
113-
handle_prune_context_instructions_prefix_change,
114-
active_editor_intelligent_update_state
112+
handle_prune_context_instructions_prefix_change
115113
} = use_panel(vscode)
116114

117115
const [checkpoint_to_edit, set_checkpoint_to_edit] = useState<
@@ -662,23 +660,6 @@ export const Panel = () => {
662660
</div>
663661
)}
664662

665-
{active_editor_intelligent_update_state && (
666-
<div className={styles.slot}>
667-
<UiActiveEditorIntelligentUpdateModal
668-
title={active_editor_intelligent_update_state.title}
669-
status={active_editor_intelligent_update_state.status}
670-
progress={active_editor_intelligent_update_state.progress}
671-
tokens_per_second={
672-
active_editor_intelligent_update_state.tokens_per_second
673-
}
674-
total_tokens={active_editor_intelligent_update_state.total_tokens}
675-
on_cancel={() => {
676-
post_message(vscode, { command: 'CANCEL_API_REQUEST' })
677-
}}
678-
/>
679-
</div>
680-
)}
681-
682663
{progress_state && (
683664
<div className={styles.slot}>
684665
<UiProgressModal

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { useEffect, useState } from 'react'
22
import { Preset } from '@shared/types/preset'
33
import {
44
BackendMessage,
5-
FileProgressStatus,
65
FrontendMessage,
76
SelectionState
87
} from '../../types/messages'
@@ -132,16 +131,6 @@ export const use_panel = (vscode: any) => {
132131
prune_context_instructions_prefix,
133132
set_prune_context_instructions_prefix
134133
] = useState<string>('')
135-
const [
136-
active_editor_intelligent_update_state,
137-
set_active_editor_intelligent_update_state
138-
] = useState<{
139-
title: string
140-
status?: FileProgressStatus
141-
progress?: number
142-
tokens_per_second?: number
143-
total_tokens?: number
144-
}>()
145134

146135
const handle_instructions_change = (
147136
value: string,
@@ -387,20 +376,6 @@ export const use_panel = (vscode: any) => {
387376
set_tasks(message.tasks)
388377
} else if (message.command == 'PRUNE_CONTEXT_INSTRUCTIONS_PREFIX') {
389378
set_prune_context_instructions_prefix(message.prefix)
390-
} else if (
391-
message.command == 'SHOW_ACTIVE_EDITOR_INTELLIGENT_UPDATE_MODAL'
392-
) {
393-
set_active_editor_intelligent_update_state({
394-
title: message.title,
395-
status: message.status,
396-
progress: message.progress,
397-
tokens_per_second: message.tokens_per_second,
398-
total_tokens: message.total_tokens
399-
})
400-
} else if (
401-
message.command == 'HIDE_ACTIVE_EDITOR_INTELLIGENT_UPDATE_MODAL'
402-
) {
403-
set_active_editor_intelligent_update_state(undefined)
404379
}
405380
}
406381
window.addEventListener('message', handle_message)
@@ -638,7 +613,6 @@ export const use_panel = (vscode: any) => {
638613
handle_configurations_collapsed_change,
639614
handle_remove_response_history_item,
640615
handle_discard_user_changes_in_preview,
641-
handle_prune_context_instructions_prefix_change,
642-
active_editor_intelligent_update_state
616+
handle_prune_context_instructions_prefix_change
643617
}
644618
}

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

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export type FileProgressStatus =
4848
| 'waiting'
4949
| 'thinking'
5050
| 'receiving'
51-
| 'done'
5251
| 'retrying'
5352

5453
// === FROM FRONTEND TO BACKEND ===
@@ -783,20 +782,6 @@ export interface HideApiManagerProgressMessage extends BaseMessage {
783782
command: 'HIDE_API_MANAGER_PROGRESS'
784783
id: string
785784
}
786-
787-
export interface ShowActiveEditorIntelligentUpdateModalMessage extends BaseMessage {
788-
command: 'SHOW_ACTIVE_EDITOR_INTELLIGENT_UPDATE_MODAL'
789-
title: string
790-
status?: FileProgressStatus
791-
progress?: number
792-
tokens_per_second?: number
793-
total_tokens?: number
794-
}
795-
796-
export interface HideActiveEditorIntelligentUpdateModalMessage extends BaseMessage {
797-
command: 'HIDE_ACTIVE_EDITOR_INTELLIGENT_UPDATE_MODAL'
798-
}
799-
800785
export interface ShowAutoClosingModalMessage extends BaseMessage {
801786
command: 'SHOW_AUTO_CLOSING_MODAL'
802787
title: string
@@ -902,5 +887,3 @@ export type BackendMessage =
902887
| TasksMessage
903888
| UpdateFileProgressMessage
904889
| PruneContextInstructionsPrefixMessage
905-
| ShowActiveEditorIntelligentUpdateModalMessage
906-
| HideActiveEditorIntelligentUpdateModalMessage

‎packages/ui/src/components/editor/panel/ResponsePreview/ResponsePreview.module.scss‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,16 @@
127127
align-items: center;
128128

129129
&__name {
130+
flex: 1;
130131
white-space: nowrap;
131132
overflow: hidden;
132133
text-overflow: ellipsis;
134+
135+
> span:last-child {
136+
opacity: 0.7;
137+
margin-left: 0.5em;
138+
font-size: 0.9em;
139+
}
133140
}
134141

135142
&__status {

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ export const ResponsePreview: FC<Props> = (props) => {
9797

9898
const prev_applying_count = useRef(0)
9999
useEffect(() => {
100-
if (prev_applying_count.current > 0 && applying_files.length === 0) {
100+
if (prev_applying_count.current > 0 && applying_files.length == 0) {
101101
set_is_fixing_all(false)
102102
}
103103
prev_applying_count.current = applying_files.length
@@ -127,10 +127,7 @@ export const ResponsePreview: FC<Props> = (props) => {
127127
if (file.apply_status == 'waiting') return 'Waiting...'
128128
if (file.apply_status == 'thinking') return 'Thinking...'
129129
if (file.apply_status == 'retrying') return 'Retrying...'
130-
if (file.apply_status == 'receiving') {
131-
const tps = file.apply_tokens_per_second
132-
return tps ? `${tps} tokens/s` : 'Receiving...'
133-
}
130+
if (file.apply_status == 'receiving') return 'Receiving...'
134131
if (file.apply_status == 'done') return 'Done'
135132
return ''
136133
}
@@ -140,6 +137,11 @@ export const ResponsePreview: FC<Props> = (props) => {
140137
return path.substring(last_slash_index + 1)
141138
}
142139

140+
const get_dir_path = (path: string) => {
141+
const last_slash_index = path.lastIndexOf('/')
142+
return last_slash_index > -1 ? path.substring(0, last_slash_index) : ''
143+
}
144+
143145
const get_instructions_font_size_class = (text: string): string => {
144146
const length = text.length
145147
if (length < 80) {
@@ -179,9 +181,15 @@ export const ResponsePreview: FC<Props> = (props) => {
179181
className={styles['fix-all-progress__item']}
180182
>
181183
<div className={styles['fix-all-progress__header']}>
182-
<span className={styles['fix-all-progress__header__name']}>
183-
{get_file_name(file.file_path)}
184-
</span>
184+
<div className={styles['fix-all-progress__header__name']}>
185+
<span>{get_file_name(file.file_path)}</span>
186+
<span>
187+
{props.has_multiple_workspaces && file.workspace_name
188+
? `${file.workspace_name}${get_dir_path(file.file_path) ? '/' : ''}`
189+
: ''}
190+
{get_dir_path(file.file_path)}
191+
</span>
192+
</div>
185193
<span className={styles['fix-all-progress__header__status']}>
186194
{get_status_text(file)}
187195
</span>
@@ -228,7 +236,6 @@ export const ResponsePreview: FC<Props> = (props) => {
228236
file_path: f.file_path,
229237
workspace_name: f.workspace_name
230238
}))
231-
console.log('xxx', files_to_fix)
232239
props.on_fix_all_failed(files_to_fix)
233240
}}
234241
>

‎packages/ui/src/components/editor/panel/ResponsePreview/components/FileItem/FileItem.tsx‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC } from 'react'
1+
import { FC, useEffect, useState } from 'react'
22
import cn from 'classnames'
33
import { FileInPreview } from '@shared/types/file-in-preview'
44
import styles from './FileItem.module.scss'
@@ -28,7 +28,7 @@ const get_file_message = (file: FileInPreview): FileMessage | null => {
2828
if (file.fixed_with_intelligent_update) {
2929
return {
3030
type: 'success',
31-
text: 'Fixed successfully',
31+
text: 'Applied with Intelligent Update',
3232
show_actions: true
3333
}
3434
} else if (file.apply_failed) {
@@ -49,6 +49,20 @@ const get_file_message = (file: FileInPreview): FileMessage | null => {
4949
}
5050

5151
export const FileItem: FC<Props> = (props) => {
52+
const [elapsed_seconds, set_elapsed_seconds] = useState(0.0)
53+
54+
useEffect(() => {
55+
if (!props.file.is_applying) {
56+
set_elapsed_seconds(0)
57+
return
58+
}
59+
60+
const interval = setInterval(() => {
61+
set_elapsed_seconds((prev) => prev + 0.1)
62+
}, 100)
63+
return () => clearInterval(interval)
64+
}, [props.file.is_applying])
65+
5266
const message_obj = get_file_message(props.file)
5367
const last_slash_index = props.file.file_path.lastIndexOf('/')
5468
const file_name = props.file.file_path.substring(last_slash_index + 1)
@@ -72,6 +86,7 @@ export const FileItem: FC<Props> = (props) => {
7286
return (
7387
<div className={styles.progress}>
7488
<span>{status_text}</span>
89+
<span>{elapsed_seconds.toFixed(1)}s</span>
7590
{props.file.apply_status != 'done' && (
7691
<div
7792
className={styles.progress__cancel}

0 commit comments

Comments
 (0)