Skip to content

Commit 6e21b52

Browse files
committed
Consolidate preview ongoing modal logic into PanelProvider to prevent duplicate modal displays
- instead of [Fragment], the panel provider should have dedicated method that checks if there is a response history item that has 'files' undefined. if so, should not show 'preview ongoing' modal - the logic in panel_provider.show_preview_ongoing_modal doesn't work because the response without 'files' is already there
1 parent c19d090 commit 6e21b52

2 files changed

Lines changed: 17 additions & 3 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
@@ -109,9 +109,7 @@ export const apply_chat_response_command = (params: {
109109

110110
const choice = await new Promise<'Switch' | undefined>((resolve) => {
111111
params.panel_provider.preview_switch_choice_resolver = resolve
112-
params.panel_provider.send_message({
113-
command: 'SHOW_PREVIEW_ONGOING_MODAL'
114-
})
112+
params.panel_provider.show_preview_ongoing_modal()
115113
})
116114
params.panel_provider.preview_switch_choice_resolver = undefined
117115

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,22 @@ export class PanelProvider implements vscode.WebviewViewProvider {
667667
}
668668
}
669669

670+
public show_preview_ongoing_modal() {
671+
const items_without_files_count = this.response_history.filter(
672+
(item) => item.files === undefined
673+
).length
674+
675+
if (items_without_files_count > 1) {
676+
if (this.preview_switch_choice_resolver) {
677+
this.preview_switch_choice_resolver(undefined)
678+
}
679+
} else {
680+
this.send_message({
681+
command: 'SHOW_PREVIEW_ONGOING_MODAL'
682+
})
683+
}
684+
}
685+
670686
async resolveWebviewView(
671687
webview_view: vscode.WebviewView,
672688
_: vscode.WebviewViewResolveContext,

0 commit comments

Comments
 (0)