Skip to content

Commit e6cd6a8

Browse files
committed
Replace VSCode warning messages with auto-closing modals
1 parent cf073e4 commit e6cd6a8

4 files changed

Lines changed: 40 additions & 27 deletions

File tree

‎apps/editor/src/views/panel/backend/message-handlers/handle-edit-context.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,11 @@ export const handle_edit_context = async (
326326
let instructions = panel_provider.current_edit_context_instruction
327327

328328
if (!instructions) {
329-
vscode.window.showWarningMessage(
330-
dictionary.warning_message.INSTRUCTIONS_CANNOT_BE_EMPTY
331-
)
329+
panel_provider.send_message({
330+
command: 'SHOW_AUTO_CLOSING_MODAL',
331+
title: 'Instructions cannot be empty',
332+
type: 'warning'
333+
})
332334
return
333335
}
334336

@@ -411,9 +413,11 @@ export const handle_edit_context = async (
411413
})
412414

413415
if (!collected_files) {
414-
vscode.window.showWarningMessage(
415-
dictionary.warning_message.CONTEXT_CANNOT_BE_EMPTY
416-
)
416+
panel_provider.send_message({
417+
command: 'SHOW_AUTO_CLOSING_MODAL',
418+
title: 'Context cannot be empty',
419+
type: 'warning'
420+
})
417421
return
418422
}
419423

‎apps/editor/src/views/panel/backend/message-handlers/handle-prune-context.ts‎

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -305,9 +305,11 @@ export const handle_prune_context = async (
305305
let instructions = panel_provider.current_prune_context_instruction
306306

307307
if (!instructions) {
308-
vscode.window.showWarningMessage(
309-
dictionary.warning_message.INSTRUCTIONS_CANNOT_BE_EMPTY
310-
)
308+
panel_provider.send_message({
309+
command: 'SHOW_AUTO_CLOSING_MODAL',
310+
title: 'Instructions cannot be empty',
311+
type: 'warning'
312+
})
311313
return
312314
}
313315

@@ -389,9 +391,11 @@ export const handle_prune_context = async (
389391
})
390392

391393
if (!collected_files) {
392-
vscode.window.showWarningMessage(
393-
dictionary.warning_message.CONTEXT_CANNOT_BE_EMPTY
394-
)
394+
panel_provider.send_message({
395+
command: 'SHOW_AUTO_CLOSING_MODAL',
396+
title: 'Context cannot be empty',
397+
type: 'warning'
398+
})
395399
return
396400
}
397401

‎apps/editor/src/views/panel/backend/message-handlers/handle-send-to-browser.ts‎

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,11 @@ async function show_preset_quick_pick(params: {
493493
!preset.promptPrefix &&
494494
!preset.promptSuffix
495495
) {
496-
vscode.window.showWarningMessage(
497-
dictionary.warning_message.TYPE_SOMETHING_TO_USE_PRESET
498-
)
496+
params.panel_provider.send_message({
497+
command: 'SHOW_AUTO_CLOSING_MODAL',
498+
title: 'Type something to use this preset',
499+
type: 'warning'
500+
})
499501
}
500502
do_resolve(null)
501503
} else {
@@ -631,9 +633,11 @@ async function resolve_presets(params: {
631633
!preset.promptPrefix &&
632634
!preset.promptSuffix
633635
) {
634-
vscode.window.showWarningMessage(
635-
dictionary.warning_message.TYPE_SOMETHING_TO_USE_PRESET
636-
)
636+
params.panel_provider.send_message({
637+
command: 'SHOW_AUTO_CLOSING_MODAL',
638+
title: 'Type something to use this preset',
639+
type: 'warning'
640+
})
637641
}
638642
return { preset_names: [] }
639643
}
@@ -694,9 +698,11 @@ async function resolve_presets(params: {
694698
!p.promptSuffix
695699
)
696700
if (any_disabled_due_to_instructions) {
697-
vscode.window.showWarningMessage(
698-
dictionary.warning_message.TYPE_SOMETHING_TO_USE_GROUP
699-
)
701+
params.panel_provider.send_message({
702+
command: 'SHOW_AUTO_CLOSING_MODAL',
703+
title: 'Type something to use this group',
704+
type: 'warning'
705+
})
700706
return { preset_names: [] }
701707
}
702708
}
@@ -734,9 +740,11 @@ async function resolve_presets(params: {
734740
!item.promptPrefix &&
735741
!item.promptSuffix
736742
) {
737-
vscode.window.showWarningMessage(
738-
dictionary.warning_message.TYPE_SOMETHING_TO_USE_PRESET
739-
)
743+
params.panel_provider.send_message({
744+
command: 'SHOW_AUTO_CLOSING_MODAL',
745+
title: 'Type something to use this preset',
746+
type: 'warning'
747+
})
740748
}
741749
return { preset_names: [] }
742750
} else {

‎packages/shared/src/constants/dictionary.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,10 @@ export const dictionary = {
133133
'Cannot copy prompt in code completion mode with an active selection.',
134134
CANNOT_COPY_PROMPT_IN_CODE_COMPLETION_WITHOUT_EDITOR:
135135
'Cannot copy prompt in code completion mode without an active editor.',
136-
CONTEXT_CANNOT_BE_EMPTY: 'Context cannot be empty.',
137-
INSTRUCTIONS_CANNOT_BE_EMPTY: 'Instructions cannot be empty.',
138136
CANNOT_PREVIEW_IN_CODE_COMPLETION_WITHOUT_EDITOR:
139137
'Cannot preview in code completion mode without an active editor.',
140138
BROWSER_EXTENSION_NOT_CONNECTED:
141139
'Browser extension is not connected. Please install or reload it.',
142-
TYPE_SOMETHING_TO_USE_PRESET: 'Type something to use this preset.',
143140
PRESETS_NOT_RUN_DUE_TO_MISSING_INSTRUCTIONS:
144141
'Some presets were not run due to missing instructions.',
145142
TYPE_SOMETHING_TO_USE_GROUP: 'Type something to use this group.',

0 commit comments

Comments
 (0)