@@ -337,96 +337,102 @@ const Sidebar = ({
337337 </ Button >
338338 { showEnvVars && (
339339 < div className = "space-y-2" >
340- { Object . entries ( env ) . map ( ( [ key , value ] , idx ) => (
341- < div key = { idx } className = "space-y-2 pb-4" >
342- < div className = "flex gap-2" >
343- < Input
344- aria-label = { `Environment variable key ${ idx + 1 } ` }
345- placeholder = "Key"
346- value = { key }
347- onChange = { ( e ) => {
348- const newKey = e . target . value ;
349- const newEnv = Object . entries ( env ) . reduce (
350- ( acc , [ k , v ] ) => {
351- if ( k === key ) {
352- acc [ newKey ] = value ;
340+ { Object . entries ( env )
341+ . sort ( ( [ a ] , [ b ] ) => a . localeCompare ( b ) )
342+ . map ( ( [ key , value ] , idx ) => (
343+ < div key = { idx } className = "space-y-2 pb-4" >
344+ < div className = "flex gap-2" >
345+ < Input
346+ aria-label = { `Environment variable key ${ idx + 1 } ` }
347+ placeholder = "Key"
348+ value = { key }
349+ onChange = { ( e ) => {
350+ const newKey = e . target . value ;
351+ const newEnv = Object . entries ( env ) . reduce (
352+ ( acc , [ k , v ] ) => {
353+ if ( k === key ) {
354+ acc [ newKey ] = value ;
355+ } else {
356+ acc [ k ] = v ;
357+ }
358+ return acc ;
359+ } ,
360+ { } as Record < string , string > ,
361+ ) ;
362+ setEnv ( newEnv ) ;
363+ setShownEnvVars ( ( prev ) => {
364+ const next = new Set ( prev ) ;
365+ if ( next . has ( key ) ) {
366+ next . delete ( key ) ;
367+ next . add ( newKey ) ;
368+ }
369+ return next ;
370+ } ) ;
371+ } }
372+ className = "font-mono"
373+ />
374+ < Button
375+ variant = "destructive"
376+ size = "icon"
377+ className = "h-9 w-9 p-0 shrink-0"
378+ onClick = { ( ) => {
379+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
380+ const { [ key ] : _removed , ...rest } = env ;
381+ setEnv ( rest ) ;
382+ } }
383+ >
384+ ×
385+ </ Button >
386+ </ div >
387+ < div className = "flex gap-2" >
388+ < Input
389+ aria-label = { `Environment variable value ${ idx + 1 } ` }
390+ type = { shownEnvVars . has ( key ) ? "text" : "password" }
391+ placeholder = "Value"
392+ value = { value }
393+ onChange = { ( e ) => {
394+ const newEnv = { ...env } ;
395+ newEnv [ key ] = e . target . value ;
396+ setEnv ( newEnv ) ;
397+ } }
398+ className = "font-mono"
399+ />
400+ < Button
401+ variant = "outline"
402+ size = "icon"
403+ className = "h-9 w-9 p-0 shrink-0"
404+ onClick = { ( ) => {
405+ setShownEnvVars ( ( prev ) => {
406+ const next = new Set ( prev ) ;
407+ if ( next . has ( key ) ) {
408+ next . delete ( key ) ;
353409 } else {
354- acc [ k ] = v ;
410+ next . add ( key ) ;
355411 }
356- return acc ;
357- } ,
358- { } as Record < string , string > ,
359- ) ;
360- setEnv ( newEnv ) ;
361- setShownEnvVars ( ( prev ) => {
362- const next = new Set ( prev ) ;
363- if ( next . has ( key ) ) {
364- next . delete ( key ) ;
365- next . add ( newKey ) ;
366- }
367- return next ;
368- } ) ;
369- } }
370- className = "font-mono"
371- />
372- < Button
373- variant = "destructive"
374- size = "icon"
375- className = "h-9 w-9 p-0 shrink-0"
376- onClick = { ( ) => {
377- // eslint-disable-next-line @typescript-eslint/no-unused-vars
378- const { [ key ] : _removed , ...rest } = env ;
379- setEnv ( rest ) ;
380- } }
381- >
382- ×
383- </ Button >
384- </ div >
385- < div className = "flex gap-2" >
386- < Input
387- aria-label = { `Environment variable value ${ idx + 1 } ` }
388- type = { shownEnvVars . has ( key ) ? "text" : "password" }
389- placeholder = "Value"
390- value = { value }
391- onChange = { ( e ) => {
392- const newEnv = { ...env } ;
393- newEnv [ key ] = e . target . value ;
394- setEnv ( newEnv ) ;
395- } }
396- className = "font-mono"
397- />
398- < Button
399- variant = "outline"
400- size = "icon"
401- className = "h-9 w-9 p-0 shrink-0"
402- onClick = { ( ) => {
403- setShownEnvVars ( ( prev ) => {
404- const next = new Set ( prev ) ;
405- if ( next . has ( key ) ) {
406- next . delete ( key ) ;
407- } else {
408- next . add ( key ) ;
409- }
410- return next ;
411- } ) ;
412- } }
413- aria-label = {
414- shownEnvVars . has ( key ) ? "Hide value" : "Show value"
415- }
416- aria-pressed = { shownEnvVars . has ( key ) }
417- title = {
418- shownEnvVars . has ( key ) ? "Hide value" : "Show value"
419- }
420- >
421- { shownEnvVars . has ( key ) ? (
422- < Eye className = "h-4 w-4" aria-hidden = "true" />
423- ) : (
424- < EyeOff className = "h-4 w-4" aria-hidden = "true" />
425- ) }
426- </ Button >
412+ return next ;
413+ } ) ;
414+ } }
415+ aria-label = {
416+ shownEnvVars . has ( key )
417+ ? "Hide value"
418+ : "Show value"
419+ }
420+ aria-pressed = { shownEnvVars . has ( key ) }
421+ title = {
422+ shownEnvVars . has ( key )
423+ ? "Hide value"
424+ : "Show value"
425+ }
426+ >
427+ { shownEnvVars . has ( key ) ? (
428+ < Eye className = "h-4 w-4" aria-hidden = "true" />
429+ ) : (
430+ < EyeOff className = "h-4 w-4" aria-hidden = "true" />
431+ ) }
432+ </ Button >
433+ </ div >
427434 </ div >
428- </ div >
429- ) ) }
435+ ) ) }
430436 < Button
431437 variant = "outline"
432438 className = "w-full mt-2"
0 commit comments