( response: RequestPermissionResponse, approval: ApprovalResponse, options: readonly PermissionOption[], )
| 301 | * worrying about TS strict-readonly fields. |
| 302 | */ |
| 303 | export function attachSelectedLabel( |
| 304 | response: RequestPermissionResponse, |
| 305 | approval: ApprovalResponse, |
| 306 | options: readonly PermissionOption[], |
| 307 | ): ApprovalResponse { |
| 308 | const outcome = response.outcome; |
| 309 | if (outcome.outcome !== 'selected') return approval; |
| 310 | // Phase 13.2: plan_review optionIds already carry selectedLabel from |
| 311 | // the mapper. Short-circuit so this canonical-table lookup never |
| 312 | // strips an already-attached label. |
| 313 | if ( |
| 314 | outcome.optionId.startsWith('plan_opt_') || |
| 315 | outcome.optionId === PLAN_APPROVE_OPTION_ID || |
| 316 | outcome.optionId === PLAN_REVISE_OPTION_ID || |
| 317 | outcome.optionId === PLAN_REJECT_AND_EXIT_OPTION_ID |
| 318 | ) { |
| 319 | return approval; |
| 320 | } |
| 321 | const matched = options.find((o) => o.optionId === outcome.optionId); |
| 322 | if (!matched) return approval; |
| 323 | return { ...approval, selectedLabel: matched.name }; |
| 324 | } |
no outgoing calls
no test coverage detected