Skip to content

Commit 50f4844

Browse files
committed
Add force_model_selection option to intelligent file updates for manual model selection
1 parent 3ca969b commit 50f4844

5 files changed

Lines changed: 18 additions & 8 deletions

File tree

‎apps/editor/src/views/panel/backend/message-handlers/handle-intelligent-update-file-in-preview.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const handle_intelligent_update_file_in_preview = async (
2424
panel_provider: PanelProvider,
2525
message: IntelligentUpdateFileInPreviewMessage
2626
): Promise<void> => {
27-
const { file_path, workspace_name } = message
27+
const { file_path, workspace_name, force_model_selection } = message
2828
const file_name = path.basename(file_path)
2929

3030
const original_states = panel_provider.context.workspaceState.get<
@@ -95,7 +95,7 @@ export const handle_intelligent_update_file_in_preview = async (
9595
)
9696
const config_result = await get_intelligent_update_config(
9797
api_providers_manager,
98-
false,
98+
force_model_selection ?? false,
9999
panel_provider.context
100100
)
101101
if (!config_result) return

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,8 @@ export const Panel = () => {
587587
post_message(vscode, {
588588
command: 'INTELLIGENT_UPDATE_FILE_IN_PREVIEW',
589589
file_path: file.file_path,
590-
workspace_name: file.workspace_name
590+
workspace_name: file.workspace_name,
591+
force_model_selection: file.force_model_selection
591592
})
592593
}}
593594
on_cancel_intelligent_update={(file) => {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ export interface IntelligentUpdateFileInPreviewMessage extends BaseMessage {
347347
command: 'INTELLIGENT_UPDATE_FILE_IN_PREVIEW'
348348
file_path: string
349349
workspace_name?: string
350+
force_model_selection?: boolean
350351
}
351352

352353
export interface CancelIntelligentUpdateFileInPreviewMessage extends BaseMessage {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ type Props = {
1313
on_intelligent_update: (file: {
1414
file_path: string
1515
workspace_name?: string
16+
force_model_selection?: boolean
1617
}) => void
1718
on_cancel_intelligent_update: (file: {
1819
file_path: string
@@ -299,10 +300,11 @@ export const ResponsePreview: FC<Props> = (props) => {
299300
content: file.ai_content!
300301
})
301302
}
302-
on_intelligent_update={() =>
303+
on_intelligent_update={(force_model_selection) =>
303304
props.on_intelligent_update({
304305
file_path: file.file_path,
305-
workspace_name: file.workspace_name
306+
workspace_name: file.workspace_name,
307+
force_model_selection
306308
})
307309
}
308310
on_cancel_intelligent_update={() =>

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type Props = {
1414
on_toggle: (checked: boolean) => void
1515
on_discard_user_changes: () => void
1616
on_preview_generated_code: () => void
17-
on_intelligent_update: () => void
17+
on_intelligent_update: (force_model_selection?: boolean) => void
1818
on_cancel_intelligent_update: () => void
1919
on_go_to_file: () => void
2020
}
@@ -163,7 +163,9 @@ export const FileItem: FC<Props> = (props) => {
163163
title="Fix with Intelligent Update API tool"
164164
on_click={(e) => {
165165
e.stopPropagation()
166-
props.on_intelligent_update()
166+
props.on_intelligent_update(
167+
!!props.file.fixed_with_intelligent_update
168+
)
167169
}}
168170
/>
169171
)}
@@ -227,7 +229,11 @@ export const FileItem: FC<Props> = (props) => {
227229
{!props.file.is_applying && (
228230
<div
229231
className={styles['message__actions__item']}
230-
onClick={props.on_intelligent_update}
232+
onClick={() =>
233+
props.on_intelligent_update(
234+
!!props.file.fixed_with_intelligent_update
235+
)
236+
}
231237
title={'Fix with Intelligent Update API tool'}
232238
>
233239
<span className="codicon codicon-sparkle" />

0 commit comments

Comments
 (0)