2879
return { approved: false };
2880
}
2882
if (!answer || answer.state === ChatInputAnswerState.Skipped) {
2883
return { approved: false };
2884
}
2886
>
2887
>
// Determine the selected action and any freeform feedback. The
2888
>
// `single-select` question may carry both (when the user picks an
2889
>
// option AND types feedback), or just freeform text (when the
2890
>
// user types instead of picking). Normalize to one shape.
2891
>
let candidateAction: string | undefined;
2892
>
let feedback: string | undefined;
2893
>
if (value.kind === ChatInputAnswerValueKind.Selected) {
2894
candidateAction = value.value;
2895
const freeform = value.freeformValues?.find(s => s.trim().length > 0)?.trim();
2896
feedback = freeform;
2898
feedback = value.value.trim() || undefined;
2899
} else {
2900
return { approved: false };
2901
}
2903
>
// Clamp `selectedAction` to the SDK's offered set. Anything else
2904
>
// (including freeform text smuggled into the `value` field) falls
2905
>
// back to the recommended action so we never feed the SDK a value
2906
>
// it can't act on.
2907
>
const selectedAction = candidateAction && pending.actions.includes(candidateAction)
2908
? candidateAction
2909
: pending.actions.includes(pending.recommendedAction)