@@ -36,6 +36,7 @@ function handsPage() {
3636 _clipboardTimer : null ,
3737 detectedPlatform : 'linux' ,
3838 installPlatforms : { } ,
39+ apiKeyInputs : { } ,
3940
4041 async loadData ( ) {
4142 this . loading = true ;
@@ -110,11 +111,15 @@ function handsPage() {
110111 } else {
111112 this . _detectClientPlatform ( ) ;
112113 }
113- // Initialize per-requirement platform selections
114+ // Initialize per-requirement platform selections and API key inputs
114115 this . installPlatforms = { } ;
116+ this . apiKeyInputs = { } ;
115117 if ( data . requirements ) {
116118 for ( var j = 0 ; j < data . requirements . length ; j ++ ) {
117119 this . installPlatforms [ data . requirements [ j ] . key ] = this . detectedPlatform ;
120+ if ( data . requirements [ j ] . type === 'ApiKey' ) {
121+ this . apiKeyInputs [ data . requirements [ j ] . key ] = '' ;
122+ }
118123 }
119124 }
120125 this . setupWizard = data ;
@@ -283,7 +288,10 @@ function handsPage() {
283288 if ( ! this . setupWizard || ! this . setupWizard . requirements ) return 0 ;
284289 var count = 0 ;
285290 for ( var i = 0 ; i < this . setupWizard . requirements . length ; i ++ ) {
286- if ( this . setupWizard . requirements [ i ] . satisfied ) count ++ ;
291+ var req = this . setupWizard . requirements [ i ] ;
292+ if ( req . satisfied ) { count ++ ; continue ; }
293+ // Count API key reqs as met if user entered a value
294+ if ( req . type === 'ApiKey' && this . apiKeyInputs [ req . key ] && this . apiKeyInputs [ req . key ] . trim ( ) !== '' ) count ++ ;
287295 }
288296 return count ;
289297 } ,
@@ -294,7 +302,34 @@ function handsPage() {
294302 } ,
295303
296304 get setupAllReqsMet ( ) {
297- return this . setupReqsTotal > 0 && this . setupReqsMet === this . setupReqsTotal ;
305+ if ( ! this . setupWizard || ! this . setupWizard . requirements ) return false ;
306+ if ( this . setupReqsTotal === 0 ) return false ;
307+ for ( var i = 0 ; i < this . setupWizard . requirements . length ; i ++ ) {
308+ var req = this . setupWizard . requirements [ i ] ;
309+ if ( req . satisfied ) continue ;
310+ // API key reqs are satisfied if the user entered a value in the input
311+ if ( req . type === 'ApiKey' && this . apiKeyInputs [ req . key ] && this . apiKeyInputs [ req . key ] . trim ( ) !== '' ) continue ;
312+ return false ;
313+ }
314+ return true ;
315+ } ,
316+
317+ getSettingKeyForReq ( req ) {
318+ // Find the matching setting key for an API key requirement.
319+ // Convention: setting key is the lowercase version of the requirement key.
320+ if ( ! this . setupWizard || ! this . setupWizard . settings ) return null ;
321+ var lowerKey = req . key . toLowerCase ( ) ;
322+ for ( var i = 0 ; i < this . setupWizard . settings . length ; i ++ ) {
323+ if ( this . setupWizard . settings [ i ] . key === lowerKey ) return lowerKey ;
324+ }
325+ // Fallback: try matching by check_value lowercased
326+ if ( req . check_value ) {
327+ var lowerCheck = req . check_value . toLowerCase ( ) ;
328+ for ( var j = 0 ; j < this . setupWizard . settings . length ; j ++ ) {
329+ if ( this . setupWizard . settings [ j ] . key === lowerCheck ) return lowerCheck ;
330+ }
331+ }
332+ return null ;
298333 } ,
299334
300335 get setupHasReqs ( ) {
@@ -306,6 +341,10 @@ function handsPage() {
306341 } ,
307342
308343 setupNextStep ( ) {
344+ // When leaving step 1, sync API key inputs into settings values
345+ if ( this . setupStep === 1 ) {
346+ this . _syncApiKeysToSettings ( ) ;
347+ }
309348 if ( this . setupStep === 1 && this . setupHasSettings ) {
310349 this . setupStep = 2 ;
311350 } else if ( this . setupStep === 1 ) {
@@ -315,6 +354,19 @@ function handsPage() {
315354 }
316355 } ,
317356
357+ _syncApiKeysToSettings ( ) {
358+ if ( ! this . setupWizard || ! this . setupWizard . requirements ) return ;
359+ for ( var i = 0 ; i < this . setupWizard . requirements . length ; i ++ ) {
360+ var req = this . setupWizard . requirements [ i ] ;
361+ if ( req . type === 'ApiKey' && this . apiKeyInputs [ req . key ] && this . apiKeyInputs [ req . key ] . trim ( ) !== '' ) {
362+ var settingKey = this . getSettingKeyForReq ( req ) ;
363+ if ( settingKey ) {
364+ this . settingsValues [ settingKey ] = this . apiKeyInputs [ req . key ] . trim ( ) ;
365+ }
366+ }
367+ }
368+ } ,
369+
318370 setupPrevStep ( ) {
319371 if ( this . setupStep === 3 && this . setupHasSettings ) {
320372 this . setupStep = 2 ;
@@ -332,11 +384,24 @@ function handsPage() {
332384 this . setupChecking = false ;
333385 this . clipboardMsg = null ;
334386 this . installPlatforms = { } ;
387+ this . apiKeyInputs = { } ;
335388 } ,
336389
337390 async launchHand ( ) {
338391 if ( ! this . setupWizard ) return ;
339392 var handId = this . setupWizard . id ;
393+ // Sync API key inputs from step 1 into settings values
394+ if ( this . setupWizard . requirements ) {
395+ for ( var i = 0 ; i < this . setupWizard . requirements . length ; i ++ ) {
396+ var req = this . setupWizard . requirements [ i ] ;
397+ if ( req . type === 'ApiKey' && this . apiKeyInputs [ req . key ] && this . apiKeyInputs [ req . key ] . trim ( ) !== '' ) {
398+ var settingKey = this . getSettingKeyForReq ( req ) ;
399+ if ( settingKey ) {
400+ this . settingsValues [ settingKey ] = this . apiKeyInputs [ req . key ] . trim ( ) ;
401+ }
402+ }
403+ }
404+ }
340405 var config = { } ;
341406 for ( var key in this . settingsValues ) {
342407 config [ key ] = this . settingsValues [ key ] ;
0 commit comments