Skip to content

Commit c5678ca

Browse files
committed
Simplify web configuration preview button visibility condition to rely only on connection status
- the preview web configuration feature should not require context file selection or prompt text └── apps └── editor └── src └── views └── prompt ├── backend │ ├── message-handlers │ │ ├── handle-preview-web-configuration.ts │ │ └── index.ts │ └── prompt-view-provider.ts ├── frontend │ ├── Prompt.tsx │ └── hooks │ └── use-web-configuration-editing.ts └── types └── messages.ts
1 parent dd3d58f commit c5678ca

1 file changed

Lines changed: 1 addition & 21 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Prompt.tsx‎

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -172,33 +172,13 @@ export const Prompt = () => {
172172
)
173173
}
174174

175-
const get_current_instructions = () => {
176-
let state: { instructions: string[]; active_index: number } | undefined
177-
178-
const prompt_type = mode == MODE.WEB ? web_prompt_type : api_prompt_type
179-
180-
if (prompt_type == 'ask-about-files') {
181-
state = ask_about_context_instructions
182-
} else if (prompt_type == 'edit-files') {
183-
state = edit_files_instructions
184-
}
185-
186-
if (!state) return ''
187-
188-
return state.instructions[state.active_index] || ''
189-
}
190-
191175
const get_current_instructions_state = () => {
192176
const prompt_type = mode == MODE.WEB ? web_prompt_type : api_prompt_type
193177
if (prompt_type == 'ask-about-files') return ask_about_context_instructions
194178
if (prompt_type == 'edit-files') return edit_files_instructions
195179
return undefined
196180
}
197181

198-
const has_instructions = !!get_current_instructions().trim()
199-
const is_preview_disabled =
200-
!is_connected || !has_instructions || token_count == 0
201-
202182
const handle_apply_click = () => {
203183
post_message(vscode, {
204184
command: 'EXECUTE_COMMAND',
@@ -429,7 +409,7 @@ export const Prompt = () => {
429409
}
430410
title="Edit Configuration"
431411
header_slot={
432-
!is_preview_disabled && (
412+
is_connected && (
433413
<UiTextButton on_click={handle_preview_web_configuration}>
434414
Preview
435415
</UiTextButton>

0 commit comments

Comments
 (0)