Skip to content

Commit 10cf735

Browse files
moseperobertpiosik
andauthored
Optimize ResponsePreview, fix typo (#454)
* Optimize ResponsePreview and update manifest URLs Refactored ResponsePreview to use useMemo for filtering items and counting aggressive fallbacks, improving performance. Added localhost and 127.0.0.1 URLs to browser manifest for development support. Fixed a typo in the EditPresetForm info text. * Remove localost urls --------- Co-authored-by: Robert Piosik <robertpiosik@gmail.com>
1 parent d1a1a93 commit 10cf735

2 files changed

Lines changed: 14 additions & 8 deletions

File tree

packages/ui/src/components/editor/panel/ResponsePreview/ResponsePreview.tsx

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FC, useRef, useState } from 'react'
1+
import { FC, useRef, useState, useMemo } from 'react'
22
import { FileInPreview, ItemInPreview } from '@shared/types/file-in-preview'
33
import cn from 'classnames'
44
import styles from './ResponsePreview.module.scss'
@@ -69,12 +69,18 @@ export const ResponsePreview: FC<Props> = (props) => {
6969
})
7070
}
7171

72-
const files_in_preview = props.items.filter(
73-
(i) => 'file_path' in i
74-
) as FileInPreview[]
75-
const aggressive_fallback_count = files_in_preview.filter(
76-
(f) => f.diff_application_method == 'search_and_replace'
77-
).length
72+
const files_in_preview = useMemo(
73+
() => props.items.filter((i) => 'file_path' in i) as FileInPreview[],
74+
[props.items]
75+
)
76+
77+
const aggressive_fallback_count = useMemo(
78+
() =>
79+
files_in_preview.filter(
80+
(f) => f.diff_application_method == 'search_and_replace'
81+
).length,
82+
[files_in_preview]
83+
)
7884

7985
const get_instructions_font_size_class = (text: string): string => {
8086
const length = text.length

packages/vscode/src/views/panel/frontend/components/edit-preset-form/EditPresetForm/EditPresetForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ export const EditPresetForm: React.FC<Props> = (props) => {
379379
<Field
380380
label="Thinking Budget"
381381
html_for="thinking-budget"
382-
info="Search for allowd min-max values."
382+
info="Search for allowed min-max values."
383383
>
384384
<Input
385385
id="thinking-budget"

0 commit comments

Comments
 (0)