Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@ dist-ssr
*.njsproj
*.sln
*.sw?

# maafw
interface.json
28 changes: 26 additions & 2 deletions src/components/FormControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ interface TextInputProps {
disabled?: boolean;
hasError?: boolean;
className?: string;
type?: 'text' | 'number';
inputMode?: React.HTMLAttributes<HTMLInputElement>['inputMode'];
step?: number;
integerOnly?: boolean;
}

export function TextInput({
Expand All @@ -80,14 +84,34 @@ export function TextInput({
disabled,
hasError,
className,
type = 'text',
inputMode,
step,
integerOnly,
}: TextInputProps) {
return (
<input
type="text"
type={type}
value={value}
onChange={(e) => onChange(e.target.value)}
onChange={(e) => {
if (!integerOnly) {
onChange(e.target.value);
return;
}
const raw = e.target.value;
if (raw === '' || raw === '-') {
onChange(raw);
return;
}
Comment on lines +102 to +105
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integer input validation allows the user to enter just a minus sign ("-"), which will be passed to the pipeline override generation. In pipelineOverride.ts line 69, when inputVal is "-", the expression inputVal || '0' evaluates to "-" (since it's truthy), resulting in invalid JSON when injected into the pipeline override. Consider changing the early return condition to only allow empty string, or parse and validate the value before allowing it through. For example: if (raw === '') { onChange(raw); return; } and handle the minus sign case by preventing it or treating it as '0' or '-0'.

Suggested change
if (raw === '' || raw === '-') {
onChange(raw);
return;
}
if (raw === '') {
onChange(raw);
return;
}
if (raw === '-') {
// Prevent a bare minus sign from being stored as the value.
// This avoids propagating "-" into downstream JSON generation.
return;
}

Copilot uses AI. Check for mistakes.
const cleaned = raw.replace(/[^\d-]/g, '');
const hasLeadingMinus = cleaned.startsWith('-');
const normalized = `${hasLeadingMinus ? '-' : ''}${cleaned.replace(/-/g, '')}`;
onChange(normalized);
}}
placeholder={placeholder}
disabled={disabled}
inputMode={inputMode}
step={step}
className={clsx(
'px-3 py-1.5 text-sm rounded-md border',
'bg-bg-secondary text-text-primary',
Expand Down
4 changes: 4 additions & 0 deletions src/components/OptionEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,10 @@ function InputField({
disabled={disabled}
hasError={!!validationError}
className="flex-1"
type={input.pipeline_type === 'int' ? 'number' : 'text'}
inputMode={input.pipeline_type === 'int' ? 'numeric' : undefined}
step={input.pipeline_type === 'int' ? 1 : undefined}
integerOnly={input.pipeline_type === 'int'}
/>
)}
</div>
Expand Down
Loading