Skip to content

Commit fa17bdd

Browse files
committed
Return success status from preview_preset and handle conditional modal display
1 parent 8146234 commit fa17bdd

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

‎apps/editor/src/services/websocket-manager.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,14 +460,14 @@ export class WebSocketManager {
460460
preset: Preset
461461
raw_instructions: string
462462
prompt_type: any
463-
}): Promise<void> {
463+
}): Promise<boolean> {
464464
if (!this.has_connected_browsers) {
465465
throw new Error('Does not have connected browsers.')
466466
}
467467

468468
const target_browser_id = await this._select_browser()
469469
if (target_browser_id === undefined) {
470-
return
470+
return false
471471
}
472472

473473
const config = vscode.workspace.getConfiguration('codeWebChat')
@@ -552,5 +552,6 @@ export class WebSocketManager {
552552
})
553553

554554
this.client?.send(JSON.stringify(message))
555+
return true
555556
}
556557
}

‎apps/editor/src/views/panel/backend/message-handlers/handle-preview-preset.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,16 +263,18 @@ export const handle_preview_preset = async (
263263
new_url: message.preset.new_url
264264
}
265265

266-
panel_provider.websocket_server_instance.preview_preset({
266+
const sent = await panel_provider.websocket_server_instance.preview_preset({
267267
instruction: text_to_send,
268268
preset: preset_for_preview,
269269
prompt_type: panel_provider.web_prompt_type,
270270
raw_instructions: current_instructions
271271
})
272272

273-
panel_provider.send_message({
274-
command: 'SHOW_AUTO_CLOSING_MODAL',
275-
title: 'Opened in the connected browser',
276-
type: 'success'
277-
})
273+
if (sent) {
274+
panel_provider.send_message({
275+
command: 'SHOW_AUTO_CLOSING_MODAL',
276+
title: 'Opened in the connected browser',
277+
type: 'success'
278+
})
279+
}
278280
}

0 commit comments

Comments
 (0)