@@ -8,6 +8,7 @@ import { use_dropdown } from './hooks/use-dropdown'
88import { use_ghost_text } from './hooks/use-ghost-text'
99import { use_drag_drop } from './hooks/use-drag-drop'
1010import { use_keyboard_shortcuts } from './hooks/use-keyboard-shortcuts'
11+ import { use_edit_format_compacting } from './hooks/use-edit-format-compacting'
1112import { DropdownMenu } from '../../common/DropdownMenu'
1213import { use_is_narrow_viewport , use_is_mac } from '@shared/hooks'
1314import {
@@ -252,6 +253,15 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
252253 }
253254 } , [ is_mac ] )
254255
256+ const {
257+ container_ref,
258+ compact_step,
259+ format_whole_ref,
260+ format_truncated_ref,
261+ format_before_after_ref,
262+ format_diff_ref
263+ } = use_edit_format_compacting ( )
264+
255265 return (
256266 < div className = { styles . container } >
257267 { props . has_active_selection && props . is_in_code_completions_mode && (
@@ -386,21 +396,37 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
386396 } }
387397 >
388398 { props . show_edit_format_selector && (
389- < div className = { styles [ 'footer__right__edit-format' ] } >
399+ < div
400+ className = { styles [ 'footer__right__edit-format' ] }
401+ ref = { container_ref }
402+ >
390403 { ( [ 'whole' , 'truncated' , 'before-after' , 'diff' ] as const ) . map (
391- ( format ) => {
392- const button_text = is_narrow_viewport
404+ ( format , index ) => {
405+ const is_compact =
406+ ( format === 'before-after' && compact_step >= 1 ) ||
407+ ( format === 'truncated' && compact_step >= 2 ) ||
408+ ( format === 'whole' && compact_step >= 3 ) ||
409+ ( format === 'diff' && compact_step >= 4 )
410+
411+ const button_text = is_compact
393412 ? format == 'before-after'
394- ? 'B/A '
395- : format . charAt ( 0 ) . toUpperCase ( )
413+ ? 'b/a '
414+ : format . charAt ( 0 )
396415 : format == 'before-after'
397416 ? 'before/after'
398417 : format
399418 const is_selected = props . edit_format == format
400419 const should_underline = is_alt_pressed && ! is_selected
401420
421+ let ref = null
422+ if ( format === 'whole' ) ref = format_whole_ref
423+ if ( format === 'truncated' ) ref = format_truncated_ref
424+ if ( format === 'before-after' ) ref = format_before_after_ref
425+ if ( format === 'diff' ) ref = format_diff_ref
426+
402427 return (
403428 < button
429+ ref = { ref }
404430 key = { format }
405431 className = { cn (
406432 styles [ 'footer__right__edit-format__button' ] ,
@@ -417,18 +443,17 @@ export const PromptField: React.FC<PromptFieldProps> = (props) => {
417443 onMouseEnter = { ( ) => set_hovered_edit_format ( format ) }
418444 onMouseLeave = { ( ) => set_hovered_edit_format ( null ) }
419445 >
420- { is_narrow_viewport &&
421- hovered_edit_format == format && (
422- < Tooltip
423- message = {
424- format == 'before-after'
425- ? 'Before and After'
426- : format . charAt ( 0 ) . toUpperCase ( ) +
427- format . slice ( 1 )
428- }
429- align = "center"
430- />
431- ) }
446+ { is_compact && hovered_edit_format == format && (
447+ < Tooltip
448+ message = {
449+ format == 'before-after'
450+ ? 'Before and After'
451+ : format . charAt ( 0 ) . toUpperCase ( ) +
452+ format . slice ( 1 )
453+ }
454+ align = "center"
455+ />
456+ ) }
432457 < span
433458 className = {
434459 styles [ 'footer__right__edit-format__button__spacer' ]
0 commit comments