Compare commits

...

3 Commits

Author SHA1 Message Date
claude[bot]
85b86a7088 fix(frontend): address review comments for numeric enum handling
- Use parseInt for integer types instead of parseFloat to ensure proper truncation
- Add NaN validation to handle invalid parsed values gracefully
- Rename variable to effectiveValue for clearer data flow
- Add explanatory comment for the type assertion cast

Co-authored-by: Nicholas Tindle <ntindle@users.noreply.github.com>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-19 16:26:23 +00:00
Nicholas Tindle
a3d23cb42c Merge branch 'dev' into codex/fix-frontend-crash-on-add-item-click 2025-12-18 11:59:59 -06:00
itsababseh
536a2c2d60 fix(frontend): support numeric enums in select inputs 2025-12-18 17:22:23 +00:00

View File

@@ -1123,13 +1123,33 @@ const NodeStringInput: FC<{
className,
displayName,
}) => {
value ||= schema.default || "";
// Note: BlockIOStringSubSchema's type definition does not include numeric types,
// but this component can receive numeric schemas with enums (e.g. via NodeFallbackInput
// or other code paths). We use an `any` cast here to detect numeric enum schemas
// and parse selected values as numbers.
const schemaType = (schema as any).type;
const isNumeric = schemaType === "number" || schemaType === "integer";
const effectiveValue = value || schema.default || "";
const normalizedValue = String(effectiveValue);
return (
<div className={className}>
{schema.enum && schema.enum.length > 0 ? (
<Select
defaultValue={value}
onValueChange={(newValue) => handleInputChange(selfKey, newValue)}
defaultValue={normalizedValue}
onValueChange={(newValue) => {
let nextValue: string | number = newValue;
if (isNumeric) {
const parsed =
schemaType === "integer"
? parseInt(newValue, 10)
: parseFloat(newValue);
// Only use parsed value if valid, otherwise fall back to string
if (!Number.isNaN(parsed)) {
nextValue = parsed;
}
}
handleInputChange(selfKey, nextValue);
}}
>
<SelectTrigger>
<SelectValue placeholder={schema.placeholder || displayName} />
@@ -1137,11 +1157,14 @@ const NodeStringInput: FC<{
<SelectContent className="nodrag">
{schema.enum
.filter((option) => option)
.map((option, index) => (
<SelectItem key={index} value={option}>
{beautifyString(option)}
</SelectItem>
))}
.map((option, index) => {
const optionStr = String(option);
return (
<SelectItem key={index} value={optionStr}>
{beautifyString(optionStr)}
</SelectItem>
);
})}
</SelectContent>
</Select>
) : (
@@ -1152,7 +1175,11 @@ const NodeStringInput: FC<{
<LocalValuedInput
type="text"
id={selfKey}
value={schema.secret && value ? "*".repeat(value.length) : value}
value={
schema.secret && effectiveValue
? "*".repeat(effectiveValue.length)
: effectiveValue
}
onChange={(e) => handleInputChange(selfKey, e.target.value)}
readOnly={schema.secret}
placeholder={