Fix fieldset radios: validate answers against options, fix checkbox skip, fix authorization match

Tested against Webflow (4311307116) and Scout Global (4378934058):
- Webflow: reaches Review page with all radios checked and checkbox group selected
- Scout Global: already applied successfully with select fix

Three fixes:
1. Fieldset radio answers validated against available options - prevents
   experience pattern returning "7" when options are Yes/No
2. Checkbox groups no longer skipped when one checkbox already checked -
   was preventing multi-select from working on retry
3. "authoriz" pattern matches both "authorized" and "authorization"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 14:05:02 -08:00
parent 053c0b1242
commit b0a2eb3746

View File

@@ -96,7 +96,7 @@ export class FormFiller {
// Work auth
if (l.includes('sponsor') || l.includes('visa')) return p.work_authorization?.requires_sponsorship ? 'Yes' : 'No';
if (l.includes('relocat')) return p.willing_to_relocate ? 'Yes' : 'No';
if (l.includes('authorized') || l.includes('eligible') || l.includes('legally') || l.includes('work in the u') || l.includes('right to work')) {
if (l.includes('authoriz') || l.includes('eligible') || l.includes('legally') || l.includes('work in the u') || l.includes('right to work')) {
return p.work_authorization?.authorized ? 'Yes' : 'No';
}
if (l.includes('remote') && (l.includes('willing') || l.includes('comfortable') || l.includes('able to'))) return 'Yes';
@@ -422,10 +422,13 @@ Answer:`;
return raw;
}).catch(() => '');
if (!leg) continue;
const anyChecked = await fs.$('input:checked');
if (anyChecked) continue;
// Detect if this is a checkbox group (multi-select) vs radio group
const isCheckboxGroup = (await fs.$$('input[type="checkbox"]')).length > 0;
// For radios: skip if any already checked. For checkboxes: never skip (multiple can be selected)
if (!isCheckboxGroup) {
const anyChecked = await fs.$('input:checked');
if (anyChecked) continue;
}
// Collect option labels for AI context
const labels = await fs.$$('label');
const optionTexts = [];
@@ -434,6 +437,12 @@ Answer:`;
if (t) optionTexts.push(t);
}
let answer = this.answerFor(leg);
// Validate answer against available options (e.g. got "7" but options are Yes/No)
if (answer && optionTexts.length > 0) {
const ansLower = answer.toLowerCase();
const matches = optionTexts.some(o => o.toLowerCase() === ansLower || o.toLowerCase().includes(ansLower) || ansLower.includes(o.toLowerCase()));
if (!matches) answer = null;
}
if (!answer) {
answer = await this.aiAnswerFor(leg, { options: optionTexts });
if (answer) this.saveAnswer(leg, answer);