Handle a user input request from the Copilot CLI. Note: This method is internal and should not be called directly. Args: request: The user input request data from the CLI. Returns: A dictionary containing the user's response.
(self, request: dict)
| 2495 | self._user_input_handler = handler |
| 2496 | |
| 2497 | async def _handle_user_input_request(self, request: dict) -> UserInputResponse: |
| 2498 | """ |
| 2499 | Handle a user input request from the Copilot CLI. |
| 2500 | |
| 2501 | Note: |
| 2502 | This method is internal and should not be called directly. |
| 2503 | |
| 2504 | Args: |
| 2505 | request: The user input request data from the CLI. |
| 2506 | |
| 2507 | Returns: |
| 2508 | A dictionary containing the user's response. |
| 2509 | """ |
| 2510 | with self._user_input_handler_lock: |
| 2511 | handler = self._user_input_handler |
| 2512 | |
| 2513 | if not handler: |
| 2514 | raise RuntimeError("User input requested but no handler registered") |
| 2515 | |
| 2516 | try: |
| 2517 | handler_start = time.perf_counter() |
| 2518 | result = handler( |
| 2519 | UserInputRequest( |
| 2520 | question=request.get("question", ""), |
| 2521 | choices=request.get("choices") or [], |
| 2522 | allowFreeform=request.get("allowFreeform", True), |
| 2523 | ), |
| 2524 | {"session_id": self.session_id}, |
| 2525 | ) |
| 2526 | if inspect.isawaitable(result): |
| 2527 | result = await result |
| 2528 | log_timing( |
| 2529 | logger, |
| 2530 | logging.DEBUG, |
| 2531 | "CopilotSession._handle_user_input_request dispatch", |
| 2532 | handler_start, |
| 2533 | session_id=self.session_id, |
| 2534 | ) |
| 2535 | return cast(UserInputResponse, result) |
| 2536 | except Exception: |
| 2537 | raise |
| 2538 | |
| 2539 | async def _handle_exit_plan_mode_request(self, request: dict) -> ExitPlanModeResult: |
| 2540 | """Handle an exitPlanMode.request callback from the runtime.""" |
nothing calls this directly
no test coverage detected