MCPcopy Create free account
hub / github.com/MoonshotAI/kimi-code / attachSelectedLabel

Function attachSelectedLabel

packages/acp-adapter/src/approval.ts:303–324  ·  view source on GitHub ↗
(
  response: RequestPermissionResponse,
  approval: ApprovalResponse,
  options: readonly PermissionOption[],
)

Source from the content-addressed store, hash-verified

301 * worrying about TS strict-readonly fields.
302 */
303export 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}

Callers 2

handleApprovalMethod · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected