Skip to content

Commit a467ad6

Browse files
committed
Remove response history from the home view and restrict its display to edit files mode in the main view
- responses history should be only shown in 'edit' prompt type, in main view (remove from home)
1 parent 36ae562 commit a467ad6

4 files changed

Lines changed: 25 additions & 70 deletions

File tree

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

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import { KeycapWrapper as UiKeycapWrapper } from '@ui/components/editor/prompt/K
77
import cn from 'classnames'
88
import { post_message } from '../utils/post-message'
99
import { BackendMessage } from '@/views/prompt/types/messages'
10-
import { Responses as UiResponses } from '@ui/components/editor/prompt/Responses'
11-
import { ResponseHistoryItem } from '@shared/types/response-history-item'
1210
import { Separator as UiSeparator } from '@ui/components/editor/prompt/Separator'
1311
import { AsciiArtEffect } from '@ui/components/editor/prompt/AsciiArtEffect'
1412
import { Translation, use_translation } from '../i18n/use-translation'
@@ -27,11 +25,6 @@ type Props = {
2725
on_chatbots_click: () => void
2826
on_api_calls_click: () => void
2927
version: string
30-
response_history: ResponseHistoryItem[]
31-
on_response_history_item_click: (item: ResponseHistoryItem) => void
32-
selected_history_item_created_at?: number
33-
on_selected_history_item_change: (created_at: number) => void
34-
on_response_history_item_remove: (created_at: number) => void
3528
is_setup_complete: boolean
3629
is_connected: boolean
3730
on_donate_click: () => void
@@ -43,7 +36,6 @@ export const Home: React.FC<Props> = (props) => {
4336
const [active_workspace_root, set_active_workspace_root] = useState<string>()
4437
const {
4538
has_scrolled_past_target_button,
46-
responses_ref,
4739
target_ref,
4840
handle_scroll
4941
} = use_has_scrolled_past_target_button(props.is_active)
@@ -201,30 +193,6 @@ export const Home: React.FC<Props> = (props) => {
201193
<UiScrollable on_scroll={handle_scroll} top_shadow>
202194
<div className={styles.content}>
203195
<div className={styles.inner}>
204-
{props.response_history.length > 0 && (
205-
<div className={styles.inner__responses} ref={responses_ref}>
206-
<UiResponses
207-
response_history={props.response_history}
208-
on_response_history_item_click={
209-
props.on_response_history_item_click
210-
}
211-
selected_history_item_created_at={
212-
props.selected_history_item_created_at
213-
}
214-
on_selected_history_item_change={
215-
props.on_selected_history_item_change
216-
}
217-
on_response_history_item_remove={
218-
props.on_response_history_item_remove
219-
}
220-
translations={{
221-
applied_manually: t('common.applied-manually'),
222-
reject: t('action.reject')
223-
}}
224-
/>
225-
</div>
226-
)}
227-
228196
<div className={styles.inner__target} ref={target_ref}>
229197
<AsciiArtEffect />
230198
<UiKeycapWrapper

‎apps/editor/src/views/prompt/frontend/Home/hooks/use-has-scrolled-past-mode-button.ts‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { useState, useRef, useCallback } from 'react'
33
export const use_has_scrolled_past_target_button = (is_active: boolean) => {
44
const [state, set_state] = useState<'normal' | 'sticky'>('normal')
55
const normal_height = useRef(0)
6-
const responses_ref = useRef<HTMLDivElement>(null)
76
const target_ref = useRef<HTMLDivElement>(null)
87

98
const has_scrolled_past_target_button = state !== 'normal'
@@ -12,7 +11,6 @@ export const use_has_scrolled_past_target_button = (is_active: boolean) => {
1211
(top: number) => {
1312
if (!is_active) return
1413

15-
const r_height = responses_ref.current?.clientHeight || 0
1614
const m_height = target_ref.current?.offsetHeight || 0
1715

1816
if (m_height == 0) return
@@ -24,7 +22,7 @@ export const use_has_scrolled_past_target_button = (is_active: boolean) => {
2422
const height_to_use = has_scrolled_past_target_button
2523
? normal_height.current
2624
: m_height
27-
const is_past = top > r_height + height_to_use + 4
25+
const is_past = top > height_to_use + 4
2826

2927
set_state((prev) => {
3028
if (!is_past) {
@@ -41,7 +39,6 @@ export const use_has_scrolled_past_target_button = (is_active: boolean) => {
4139

4240
return {
4341
has_scrolled_past_target_button,
44-
responses_ref,
4542
target_ref,
4643
handle_scroll
4744
}

‎apps/editor/src/views/prompt/frontend/Main/MainView/MainView.tsx‎

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -274,27 +274,30 @@ export const MainView: React.FC<Props> = (props) => {
274274

275275
<UiSeparator height={2} />
276276

277-
{props.response_history.length > 0 && (
278-
<UiResponses
279-
response_history={props.response_history}
280-
on_response_history_item_click={
281-
props.on_response_history_item_click
282-
}
283-
selected_history_item_created_at={
284-
props.selected_history_item_created_at
285-
}
286-
on_selected_history_item_change={
287-
props.on_selected_history_item_change
288-
}
289-
on_response_history_item_remove={
290-
props.on_response_history_item_remove
291-
}
292-
translations={{
293-
applied_manually: t('common.applied-manually'),
294-
reject: t('action.reject')
295-
}}
296-
/>
297-
)}
277+
{props.response_history.length > 0 &&
278+
(props.target == TARGET.WEB
279+
? props.web_prompt_type
280+
: props.api_prompt_type) == 'edit-files' && (
281+
<UiResponses
282+
response_history={props.response_history}
283+
on_response_history_item_click={
284+
props.on_response_history_item_click
285+
}
286+
selected_history_item_created_at={
287+
props.selected_history_item_created_at
288+
}
289+
on_selected_history_item_change={
290+
props.on_selected_history_item_change
291+
}
292+
on_response_history_item_remove={
293+
props.on_response_history_item_remove
294+
}
295+
translations={{
296+
applied_manually: t('common.applied-manually'),
297+
reject: t('action.reject')
298+
}}
299+
/>
300+
)}
298301

299302
<div className={styles['chat-input']}>
300303
<UiPromptField

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,6 @@ export const Prompt = () => {
386386
set_chat_input_focus_key((k) => k + 1)
387387
}}
388388
version={version}
389-
response_history={response_history}
390-
on_response_history_item_click={
391-
handle_response_history_item_click
392-
}
393-
selected_history_item_created_at={
394-
selected_history_item_created_at
395-
}
396-
on_selected_history_item_change={
397-
set_selected_history_item_created_at
398-
}
399-
on_response_history_item_remove={
400-
handle_remove_response_history_item
401-
}
402389
is_setup_complete={is_setup_complete}
403390
on_donate_click={() => set_viewing_donations(true)}
404391
/>

0 commit comments

Comments
 (0)