@@ -202,6 +202,22 @@ export function getProviderOptionDescriptors(input: {
202202 ) ;
203203}
204204
205+ function getReportedOptionValue (
206+ id : string ,
207+ selection ?: ModelSelection | null ,
208+ reportedSelection ?: ModelSelection | null ,
209+ ) {
210+ if (
211+ ! selection ||
212+ ! reportedSelection ||
213+ selection . instanceId !== reportedSelection . instanceId ||
214+ selection . model !== reportedSelection . model ||
215+ selection . options ?. some ( ( option ) => option . id === id )
216+ )
217+ return undefined ;
218+ return getRawSelectionValueById ( reportedSelection . options , id ) ;
219+ }
220+
205221export function getProviderOptionCurrentValue (
206222 descriptor : ProviderOptionDescriptor | null | undefined ,
207223 selection ?: ModelSelection | null ,
@@ -212,16 +228,8 @@ export function getProviderOptionCurrentValue(
212228 }
213229 const hasExplicitOption = selection ?. options ?. some ( ( option ) => option . id === descriptor . id ) ;
214230 // Reported values are display-only; callers that build dispatch options omit this context.
215- if (
216- selection &&
217- reportedSelection &&
218- selection . instanceId === reportedSelection . instanceId &&
219- selection . model === reportedSelection . model &&
220- ! hasExplicitOption
221- ) {
222- const reportedValue = getRawSelectionValueById ( reportedSelection . options , descriptor . id ) ;
223- if ( reportedValue !== undefined ) return reportedValue ;
224- }
231+ const reportedValue = getReportedOptionValue ( descriptor . id , selection , reportedSelection ) ;
232+ if ( reportedValue !== undefined ) return reportedValue ;
225233 if ( descriptor . id === "variant" && selection && ! hasExplicitOption ) return undefined ;
226234 if ( descriptor . type === "boolean" ) {
227235 return descriptor . currentValue ;
@@ -250,7 +258,11 @@ export function getProviderOptionCurrentLabel(
250258 const currentValue = getProviderOptionCurrentValue ( descriptor , selection , reportedSelection ) ;
251259 return (
252260 descriptor . options . find ( ( option ) => option . id === currentValue ) ?. label ??
253- ( currentValue === "default" ? "Default" : descriptor . id === "variant" ? "Unknown" : undefined )
261+ ( getReportedOptionValue ( descriptor . id , selection , reportedSelection ) === "default"
262+ ? "Default"
263+ : descriptor . id === "variant"
264+ ? "Unknown"
265+ : undefined )
254266 ) ;
255267}
256268
0 commit comments