@@ -4,7 +4,6 @@ import React, { useCallback, useEffect, useMemo, useState } from 'react'
44
55import { Button } from './button'
66import {
7- DEFAULT_FREEBUFF_MODEL_ID ,
87 FALLBACK_FREEBUFF_MODEL_ID ,
98 FREEBUFF_MODELS ,
109 getFreebuffDeploymentAvailabilityLabel ,
@@ -27,17 +26,7 @@ import {
2726import type { FreebuffModelOption } from '@codebuff/common/constants/freebuff-models'
2827import type { KeyEvent } from '@opentui/core'
2928
30- // Widen the readonly tuple from FREEBUFF_MODELS to FreebuffModelOption[] so
31- // the selector can branch on optional fields (e.g. `warning`) and on
32- // availability values that aren't present in today's set but might be added
33- // later, without TS narrowing the literal types away.
34- const FREEBUFF_MODEL_SELECTOR_MODELS : readonly FreebuffModelOption [ ] = [
35- ...FREEBUFF_MODELS . filter ( ( model ) => model . id === DEFAULT_FREEBUFF_MODEL_ID ) ,
36- ...FREEBUFF_MODELS . filter ( ( model ) => model . id !== DEFAULT_FREEBUFF_MODEL_ID ) ,
37- ]
38- const FREEBUFF_MODEL_SELECTOR_MODEL_IDS = FREEBUFF_MODEL_SELECTOR_MODELS . map (
39- ( model ) => model . id ,
40- )
29+ const FREEBUFF_MODEL_IDS = FREEBUFF_MODELS . map ( ( m ) => m . id )
4130
4231// Section grouping: premium models share one quota pool, unlimited has none.
4332// Putting the tier on a section header lets each row drop its redundant
@@ -56,14 +45,14 @@ const SECTIONS: readonly Section[] = (
5645 {
5746 key : 'premium' ,
5847 label : 'PREMIUM' ,
59- models : FREEBUFF_MODEL_SELECTOR_MODELS . filter ( ( m ) =>
48+ models : FREEBUFF_MODELS . filter ( ( m ) =>
6049 isFreebuffPremiumModelId ( m . id ) ,
6150 ) ,
6251 } ,
6352 {
6453 key : 'unlimited' ,
6554 label : 'UNLIMITED' ,
66- models : FREEBUFF_MODEL_SELECTOR_MODELS . filter (
55+ models : FREEBUFF_MODELS . filter (
6756 ( m ) => ! isFreebuffPremiumModelId ( m . id ) ,
6857 ) ,
6958 } ,
@@ -139,7 +128,7 @@ export const FreebuffModelSelector: React.FC = () => {
139128 // terminals where the secondary details spill to an indented second line.
140129 const { wrapDetails, buttonOuterWidth, nameColumnWidth } = useMemo ( ( ) => {
141130 const nameLen = ( m : FreebuffModelOption ) => m . displayName . length
142- const maxNameLen = Math . max ( ...FREEBUFF_MODEL_SELECTOR_MODELS . map ( nameLen ) )
131+ const maxNameLen = Math . max ( ...FREEBUFF_MODELS . map ( nameLen ) )
143132
144133 const detailsParts = ( model : FreebuffModelOption ) : number [ ] => {
145134 const parts = [ model . tagline . length ]
@@ -160,7 +149,7 @@ export const FreebuffModelSelector: React.FC = () => {
160149 joinedLen ( detailsParts ( model ) )
161150
162151 const maxOneLineOuter =
163- Math . max ( ...FREEBUFF_MODEL_SELECTOR_MODELS . map ( oneLineLen ) ) +
152+ Math . max ( ...FREEBUFF_MODELS . map ( oneLineLen ) ) +
164153 BUTTON_CHROME
165154 if ( maxOneLineOuter <= contentMaxWidth ) {
166155 return {
@@ -184,7 +173,7 @@ export const FreebuffModelSelector: React.FC = () => {
184173 return parts . length === 0 ? 0 : 2 /* indent */ + joinedLen ( parts )
185174 }
186175 const maxTwoLineInner = Math . max (
187- ...FREEBUFF_MODEL_SELECTOR_MODELS . map ( ( m ) =>
176+ ...FREEBUFF_MODELS . map ( ( m ) =>
188177 Math . max ( labelLineLen ( m ) , detailsLineLen ( m ) ) ,
189178 ) ,
190179 )
@@ -239,7 +228,7 @@ export const FreebuffModelSelector: React.FC = () => {
239228 }
240229 if ( ! direction ) return
241230 const targetId = nextFreebuffModelId ( {
242- modelIds : FREEBUFF_MODEL_SELECTOR_MODEL_IDS ,
231+ modelIds : FREEBUFF_MODEL_IDS ,
243232 focusedId,
244233 direction,
245234 } )
0 commit comments