@@ -3307,28 +3307,32 @@ async function testTool(toolId) {
3307
3307
3308
3308
// Field label - use textContent to avoid double escaping
3309
3309
const label = document . createElement ( "label" ) ;
3310
- label . textContent = keyValidation . value ;
3311
3310
label . className =
3312
3311
"block text-sm font-medium text-gray-700 dark:text-gray-300" ;
3312
+
3313
+ // Create span for label text
3314
+ const labelText = document . createElement ( "span" ) ;
3315
+ labelText . textContent = keyValidation . value ;
3316
+ label . appendChild ( labelText ) ;
3317
+
3318
+ // Add red star if field is required
3319
+ if ( schema . required && schema . required . includes ( key ) ) {
3320
+ const requiredMark = document . createElement ( "span" ) ;
3321
+ requiredMark . textContent = " *" ;
3322
+ requiredMark . className = "text-red-500" ;
3323
+ label . appendChild ( requiredMark ) ;
3324
+ }
3325
+
3313
3326
fieldDiv . appendChild ( label ) ;
3314
3327
3315
3328
// Description help text - use textContent
3316
3329
if ( prop . description ) {
3317
3330
const description = document . createElement ( "small" ) ;
3318
- description . textContent = prop . description ; // NO escapeHtml here
3331
+ description . textContent = prop . description ;
3319
3332
description . className = "text-gray-500 block mb-1" ;
3320
3333
fieldDiv . appendChild ( description ) ;
3321
3334
}
3322
3335
3323
- // Input field with validation
3324
- const input = document . createElement ( "input" ) ;
3325
- input . name = keyValidation . value ;
3326
- input . type = "text" ;
3327
- input . required =
3328
- schema . required && schema . required . includes ( key ) ;
3329
- input . className =
3330
- "mt-1 block w-full rounded-md border border-gray-500 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 text-gray-700 dark:text-gray-300 dark:border-gray-700 dark:focus:border-indigo-400 dark:focus:ring-indigo-400" ;
3331
-
3332
3336
if ( prop . type === "array" ) {
3333
3337
const arrayContainer = document . createElement ( "div" ) ;
3334
3338
arrayContainer . className = "space-y-2" ;
@@ -3343,18 +3347,17 @@ async function testTool(toolId) {
3343
3347
schema . required && schema . required . includes ( key ) ;
3344
3348
input . className =
3345
3349
"mt-1 block w-full rounded-md border border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 dark:bg-gray-900 text-gray-700 dark:text-gray-300 dark:border-gray-700 dark:focus:border-indigo-400 dark:focus:ring-indigo-400" ;
3346
- if ( prop . items && prop . items . type === "number" ) {
3350
+
3351
+ if ( prop . items ?. type === "number" ) {
3347
3352
input . type = "number" ;
3348
- } else if (
3349
- prop . items &&
3350
- prop . items . type === "boolean"
3351
- ) {
3353
+ } else if ( prop . items ?. type === "boolean" ) {
3352
3354
input . type = "checkbox" ;
3353
3355
input . value = "true" ;
3354
3356
input . checked = value === true || value === "true" ;
3355
3357
} else {
3356
3358
input . type = "text" ;
3357
3359
}
3360
+
3358
3361
if (
3359
3362
typeof value === "string" ||
3360
3363
typeof value === "number"
@@ -3386,7 +3389,13 @@ async function testTool(toolId) {
3386
3389
arrayContainer . appendChild ( createArrayInput ( ) ) ;
3387
3390
} ) ;
3388
3391
3389
- arrayContainer . appendChild ( createArrayInput ( ) ) ;
3392
+ if ( Array . isArray ( prop . default ) ) {
3393
+ prop . default . forEach ( ( val ) => {
3394
+ arrayContainer . appendChild ( createArrayInput ( val ) ) ;
3395
+ } ) ;
3396
+ } else {
3397
+ arrayContainer . appendChild ( createArrayInput ( ) ) ;
3398
+ }
3390
3399
3391
3400
fieldDiv . appendChild ( arrayContainer ) ;
3392
3401
fieldDiv . appendChild ( addBtn ) ;
@@ -3401,19 +3410,35 @@ async function testTool(toolId) {
3401
3410
// Add validation based on type
3402
3411
if ( prop . type === "text" ) {
3403
3412
input . type = "text" ;
3404
- } else if ( prop . type === "number" ) {
3413
+ } else if (
3414
+ prop . type === "number" ||
3415
+ prop . type === "integer"
3416
+ ) {
3405
3417
input . type = "number" ;
3406
3418
} else if ( prop . type === "boolean" ) {
3407
3419
input . type = "checkbox" ;
3408
3420
input . className =
3409
3421
"mt-1 h-4 w-4 text-indigo-600 dark:text-indigo-200 border border-gray-300 rounded" ;
3422
+ } else {
3423
+ input . type = "text" ;
3410
3424
}
3425
+
3426
+ // Set default values here
3427
+ if ( prop . default !== undefined ) {
3428
+ if ( input . type === "checkbox" ) {
3429
+ input . checked = prop . default === true ;
3430
+ } else {
3431
+ input . value = prop . default ;
3432
+ }
3433
+ }
3434
+
3411
3435
fieldDiv . appendChild ( input ) ;
3412
3436
}
3413
3437
3414
3438
container . appendChild ( fieldDiv ) ;
3415
3439
}
3416
3440
}
3441
+
3417
3442
openModal ( "tool-test-modal" ) ;
3418
3443
console . log ( "✓ Tool test modal loaded successfully" ) ;
3419
3444
} catch ( error ) {
0 commit comments