Skip to content

Commit c298c95

Browse files
committed
Display info notification when switching to find-relevant-files mode and add info icon support to modals
- when switched to 'find relevant files' prompt type, show auto closing modal : 'Context temporarily cleared, make rough selection on the file tree'. - add support for info icon
1 parent 03aae3c commit c298c95

4 files changed

Lines changed: 35 additions & 4 deletions

File tree

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState } from 'react'
1+
import { useState, useEffect, useRef } from 'react'
22
import { Main } from './Main'
33
import { Button as UiButton } from '@ui/components/editor/common/Button'
44
import { Page as UiPage } from '@ui/components/editor/panel/Page'
@@ -155,6 +155,30 @@ 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)
160+
161+
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) {
172+
set_auto_closing_modal_data({
173+
title:
174+
'Context temporarily cleared, make rough selection on the file tree',
175+
type: 'info'
176+
})
177+
}
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])
181+
158182
if (
159183
ask_about_context_instructions === undefined ||
160184
edit_context_instructions === undefined ||

apps/editor/src/views/panel/frontend/hooks/use-modal-manager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export const use_modal_manager = () => {
2727
>({})
2828

2929
const [auto_closing_modal_data, set_auto_closing_modal_data] = useState<
30-
{ title: string; type: 'success' | 'warning' | 'error' } | undefined
30+
| { title: string; type: 'success' | 'warning' | 'error' | 'info' }
31+
| undefined
3132
>()
3233

3334
const [

packages/ui/src/components/editor/panel/modals/Modal/Modal.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@
3939
&--error {
4040
color: var(--cwc-text-color-red);
4141
}
42+
43+
&--info {
44+
color: var(--vscode-notificationsInfoIcon-foreground);
45+
}
4246
}
4347

4448
.title {

packages/ui/src/components/editor/panel/modals/Modal/Modal.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import cn from 'classnames'
33
import { Scrollable } from '../../Scrollable'
44
import styles from './Modal.module.scss'
55

6-
export type ModalIconType = 'success' | 'warning' | 'error'
6+
export type ModalIconType = 'success' | 'warning' | 'error' | 'info'
77

88
type Props = {
99
title?: string
@@ -54,9 +54,11 @@ export const Modal: React.FC<Props> = (props) => {
5454
'codicon-check': props.icon == 'success',
5555
'codicon-warning': props.icon == 'warning',
5656
'codicon-error': props.icon == 'error',
57+
'codicon-info': props.icon == 'info',
5758
[styles['icon--success']]: props.icon == 'success',
5859
[styles['icon--warning']]: props.icon == 'warning',
59-
[styles['icon--error']]: props.icon == 'error'
60+
[styles['icon--error']]: props.icon == 'error',
61+
[styles['icon--info']]: props.icon == 'info'
6062
})}
6163
/>
6264
)}

0 commit comments

Comments
 (0)