@@ -10,7 +10,6 @@ import { use_ghost_text } from './hooks/use-ghost-text'
1010import { use_drag_drop } from './hooks/use-drag-drop'
1111import { use_keyboard_shortcuts } from './hooks/use-keyboard-shortcuts'
1212import { use_edit_format_compacting } from './hooks/use-edit-format-compacting'
13- import { use_prune_context_instructions } from './hooks/use-prune-context-instructions'
1413import { DropdownMenu } from '../../common/DropdownMenu'
1514import { use_is_mac } from '@shared/hooks'
1615import {
@@ -73,13 +72,13 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
7372 const [ hovered_edit_format , set_hovered_edit_format ] =
7473 useState < EditFormat | null > ( null )
7574
76- const { prune_instructions, set_prune_instructions } =
77- use_prune_context_instructions ( {
78- prune_context_instructions_prefix :
79- props . prune_context_instructions_prefix ,
80- on_prune_context_instructions_prefix_change :
81- props . on_prune_context_instructions_prefix_change
82- } )
75+ const [ prune_instructions , set_prune_instructions ] = useState (
76+ props . prune_context_instructions_prefix
77+ )
78+
79+ useEffect ( ( ) => {
80+ set_prune_instructions ( props . prune_context_instructions_prefix )
81+ } , [ props . prune_context_instructions_prefix ] )
8382
8483 const toggle_invocation_dropdown = useCallback ( ( ) => {
8584 set_is_invocation_dropdown_open ( ( prev ) => ! prev )
@@ -330,6 +329,14 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
330329 onChange = { ( e ) => {
331330 set_prune_instructions ( e . target . value )
332331 } }
332+ onBlur = { ( e ) => {
333+ props . on_prune_context_instructions_prefix_change (
334+ prune_instructions
335+ )
336+ if ( ! e . target . value ) {
337+ set_prune_instructions ( props . prune_context_instructions_prefix )
338+ }
339+ } }
333340 onClick = { ( e ) => e . stopPropagation ( ) }
334341 />
335342 ) }
@@ -541,38 +548,42 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
541548 { ( ! props . is_web_mode ||
542549 ( props . is_web_mode && props . is_connected ) ) && (
543550 < >
544- < div
545- className = { styles [ 'footer__right__invocation-count' ] }
546- ref = { invocation_dropdown_ref }
547- >
548- < button
549- className = { cn (
550- styles [ 'footer__right__submit__button' ] ,
551- styles [ 'footer__right__invocation-count__button' ]
552- ) }
553- onClick = { ( e ) => {
554- e . stopPropagation ( )
555- set_is_invocation_dropdown_open ( ( prev ) => ! prev )
556- close_dropdown ( )
557- } }
558- title = { `Invocation count ${ is_mac ? '(⌥X 1-5)' : '(Alt+X 1-5)' } ` }
551+ { ! (
552+ props . prompt_type == 'prune-context' && ! props . is_web_mode
553+ ) && (
554+ < div
555+ className = { styles [ 'footer__right__invocation-count' ] }
556+ ref = { invocation_dropdown_ref }
559557 >
560- { props . invocation_count } ×
561- </ button >
562- { is_invocation_dropdown_open && (
563- < DropdownMenu
564- items = { [ 1 , 2 , 3 , 4 , 5 ] . map ( ( count ) => ( {
565- label : `${ count } ×` ,
566- checked : count == props . invocation_count ,
567- shortcut : is_mac ? `⌥X ${ count } ` : `Alt+X ${ count } ` ,
568- on_click : ( ) => {
569- props . on_invocation_count_change ( count )
570- set_is_invocation_dropdown_open ( false )
571- }
572- } ) ) }
573- />
574- ) }
575- </ div >
558+ < button
559+ className = { cn (
560+ styles [ 'footer__right__submit__button' ] ,
561+ styles [ 'footer__right__invocation-count__button' ]
562+ ) }
563+ onClick = { ( e ) => {
564+ e . stopPropagation ( )
565+ set_is_invocation_dropdown_open ( ( prev ) => ! prev )
566+ close_dropdown ( )
567+ } }
568+ title = { `Invocation count ${ is_mac ? '(⌥X 1-5)' : '(Alt+X 1-5)' } ` }
569+ >
570+ { props . invocation_count } ×
571+ </ button >
572+ { is_invocation_dropdown_open && (
573+ < DropdownMenu
574+ items = { [ 1 , 2 , 3 , 4 , 5 ] . map ( ( count ) => ( {
575+ label : `${ count } ×` ,
576+ checked : count == props . invocation_count ,
577+ shortcut : is_mac ? `⌥X ${ count } ` : `Alt+X ${ count } ` ,
578+ on_click : ( ) => {
579+ props . on_invocation_count_change ( count )
580+ set_is_invocation_dropdown_open ( false )
581+ }
582+ } ) ) }
583+ />
584+ ) }
585+ </ div >
586+ ) }
576587 < button
577588 className = { cn (
578589 styles [ 'footer__right__submit__button' ] ,
0 commit comments