Skip to content

Commit 988710a

Browse files
committed
Refactor prompt type tracking to use a single ref for active mode instead of separate refs
1 parent c68c14d commit 988710a

1 file changed

Lines changed: 13 additions & 15 deletions

File tree

  • apps/editor/src/views/panel/frontend

‎apps/editor/src/views/panel/frontend/Panel.tsx‎

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -155,29 +155,27 @@ export const Panel = () => {
155155
const { viewing_donations, set_viewing_donations, ...donations_state } =
156156
use_latest_donations()
157157

158-
const prev_web_prompt_type = useRef(web_prompt_type)
159-
const prev_api_prompt_type = useRef(api_prompt_type)
158+
const prev_active_prompt_type = useRef(
159+
mode == MODE.WEB ? web_prompt_type : api_prompt_type
160+
)
160161

161162
useEffect(() => {
162-
const switched_web =
163-
web_prompt_type == 'find-relevant-files' &&
164-
prev_web_prompt_type.current != 'find-relevant-files' &&
165-
prev_web_prompt_type.current !== undefined
166-
const switched_api =
167-
api_prompt_type == 'find-relevant-files' &&
168-
prev_api_prompt_type.current != 'find-relevant-files' &&
169-
prev_api_prompt_type.current !== undefined
170-
171-
if (switched_web || switched_api) {
163+
const active_prompt_type =
164+
mode == MODE.WEB ? web_prompt_type : api_prompt_type
165+
166+
if (
167+
active_prompt_type == 'find-relevant-files' &&
168+
prev_active_prompt_type.current != 'find-relevant-files' &&
169+
prev_active_prompt_type.current !== undefined
170+
) {
172171
set_auto_closing_modal_data({
173172
title:
174173
'Context temporarily cleared, make rough selection on the file tree',
175174
type: 'info'
176175
})
177176
}
178-
prev_web_prompt_type.current = web_prompt_type
179-
prev_api_prompt_type.current = api_prompt_type
180-
}, [web_prompt_type, api_prompt_type])
177+
prev_active_prompt_type.current = active_prompt_type
178+
}, [web_prompt_type, api_prompt_type, mode])
181179

182180
if (
183181
ask_about_context_instructions === undefined ||

0 commit comments

Comments
 (0)