|
1 | | -import { useState, useEffect, useRef } from 'react' |
| 1 | +import { useState, useEffect } from 'react' |
2 | 2 | import { Main } from './Main' |
3 | 3 | import { Button as UiButton } from '@ui/components/editor/common/Button' |
4 | 4 | import { Page as UiPage } from '@ui/components/editor/panel/Page' |
@@ -32,6 +32,7 @@ import { use_response_history } from './hooks/panel/use-response-history' |
32 | 32 | import { use_preview_manager } from './hooks/panel/use-preview-manager' |
33 | 33 | import { use_editor_sync } from './hooks/panel/use-editor-sync' |
34 | 34 | import { use_web_configuration_editing } from './hooks/panel/use-web-configuration-editing' |
| 35 | +import { ApiPromptType, WebPromptType } from '@shared/types/prompt-types' |
35 | 36 |
|
36 | 37 | const vscode = acquireVsCodeApi() |
37 | 38 |
|
@@ -113,11 +114,7 @@ export const Panel = () => { |
113 | 114 | handle_remove_response_history_item |
114 | 115 | } = use_response_history(vscode) |
115 | 116 |
|
116 | | - const { |
117 | | - tasks, |
118 | | - handle_tasks_change, |
119 | | - handle_task_delete, |
120 | | - } = use_tasks(vscode) |
| 117 | + const { tasks, handle_tasks_change, handle_task_delete } = use_tasks(vscode) |
121 | 118 |
|
122 | 119 | const { |
123 | 120 | updating_web_configuration, |
@@ -149,14 +146,24 @@ export const Panel = () => { |
149 | 146 | const { viewing_donations, set_viewing_donations, ...donations_state } = |
150 | 147 | use_latest_donations() |
151 | 148 |
|
152 | | - const active_prompt_type = mode == MODE.WEB ? web_prompt_type : api_prompt_type |
153 | | - const [is_find_files_modal_dismissed, set_is_find_files_modal_dismissed] = useState(false) |
| 149 | + const active_prompt_type = |
| 150 | + mode == MODE.WEB ? web_prompt_type : api_prompt_type |
| 151 | + const [previous_web_prompt_type, set_previous_web_prompt_type] = |
| 152 | + useState<WebPromptType>('edit-context') |
| 153 | + const [previous_api_prompt_type, set_previous_api_prompt_type] = |
| 154 | + useState<ApiPromptType>('edit-context') |
| 155 | + |
| 156 | + useEffect(() => { |
| 157 | + if (web_prompt_type && web_prompt_type !== 'find-relevant-files') { |
| 158 | + set_previous_web_prompt_type(web_prompt_type) |
| 159 | + } |
| 160 | + }, [web_prompt_type]) |
154 | 161 |
|
155 | 162 | useEffect(() => { |
156 | | - if (active_prompt_type !== 'find-relevant-files' || token_count > 0) { |
157 | | - set_is_find_files_modal_dismissed(false) |
| 163 | + if (api_prompt_type && api_prompt_type !== 'find-relevant-files') { |
| 164 | + set_previous_api_prompt_type(api_prompt_type) |
158 | 165 | } |
159 | | - }, [active_prompt_type, token_count]) |
| 166 | + }, [api_prompt_type]) |
160 | 167 |
|
161 | 168 | if ( |
162 | 169 | ask_about_context_instructions === undefined || |
@@ -384,7 +391,9 @@ export const Panel = () => { |
384 | 391 | context_file_paths={context_file_paths} |
385 | 392 | web_configurations_collapsed={web_configurations_collapsed} |
386 | 393 | send_with_shift_enter={send_with_shift_enter} |
387 | | - on_web_configurations_collapsed_change={handle_web_configurations_collapsed_change} |
| 394 | + on_web_configurations_collapsed_change={ |
| 395 | + handle_web_configurations_collapsed_change |
| 396 | + } |
388 | 397 | api_configurations_collapsed={api_configurations_collapsed} |
389 | 398 | on_api_configurations_collapsed_change={ |
390 | 399 | handle_api_configurations_collapsed_change |
@@ -504,7 +513,9 @@ export const Panel = () => { |
504 | 513 | <UiPage |
505 | 514 | on_back_click={edit_web_configuration_back_click_handler} |
506 | 515 | footer_slot={ |
507 | | - <EditWebConfigurationFormFooter on_save={edit_web_configuration_save_handler} /> |
| 516 | + <EditWebConfigurationFormFooter |
| 517 | + on_save={edit_web_configuration_save_handler} |
| 518 | + /> |
508 | 519 | } |
509 | 520 | title="Edit Web Configuration" |
510 | 521 | header_slot={ |
@@ -802,18 +813,23 @@ export const Panel = () => { |
802 | 813 | </div> |
803 | 814 | )} |
804 | 815 |
|
805 | | - {active_prompt_type == 'find-relevant-files' && token_count == 0 && !is_find_files_modal_dismissed && ( |
| 816 | + {active_prompt_type == 'find-relevant-files' && token_count == 0 && ( |
806 | 817 | <div className={styles.slot}> |
807 | 818 | <UiModal |
808 | 819 | title="Make rough context selection" |
809 | 820 | icon="info" |
810 | | - on_background_click={() => set_is_find_files_modal_dismissed(true)} |
811 | 821 | footer_slot={ |
812 | 822 | <UiButton |
813 | 823 | is_secondary |
814 | | - on_click={() => set_is_find_files_modal_dismissed(true)} |
| 824 | + on_click={() => { |
| 825 | + if (mode == MODE.WEB) { |
| 826 | + handle_web_prompt_type_change(previous_web_prompt_type) |
| 827 | + } else { |
| 828 | + handle_api_prompt_type_change(previous_api_prompt_type) |
| 829 | + } |
| 830 | + }} |
815 | 831 | > |
816 | | - Close |
| 832 | + Go back |
817 | 833 | </UiButton> |
818 | 834 | } |
819 | 835 | /> |
|
0 commit comments