(
self, context: CommandContext, full_text: str, code_blocks: list[CodeBlock]
)
| 264 | return await self._pick(context, text, code_blocks) |
| 265 | |
| 266 | async def _pick( |
| 267 | self, context: CommandContext, full_text: str, code_blocks: list[CodeBlock] |
| 268 | ) -> InteractiveOutcome: |
| 269 | options: list[UIOption] = [ |
| 270 | UIOption( |
| 271 | value="full", |
| 272 | label="Full response", |
| 273 | description=( |
| 274 | f"{len(full_text)} chars, {full_text.count(chr(10)) + 1} lines" |
| 275 | ), |
| 276 | ) |
| 277 | ] |
| 278 | for i, block in enumerate(code_blocks): |
| 279 | lines = block.code.count("\n") + 1 |
| 280 | desc_parts = [p for p in (block.lang, f"{lines} lines" if lines > 1 else None) if p] |
| 281 | options.append( |
| 282 | UIOption( |
| 283 | value=str(i), |
| 284 | label=_truncate_line(block.code, 60), |
| 285 | description=", ".join(desc_parts) or None, |
| 286 | ) |
| 287 | ) |
| 288 | options.append( |
| 289 | UIOption( |
| 290 | value="always", |
| 291 | label="Always copy full response", |
| 292 | description="Skip this picker in the future (revert via /config)", |
| 293 | ) |
| 294 | ) |
| 295 | |
| 296 | picked = await context.ui.select("Select content to copy:", options) |
| 297 | if picked is None: |
| 298 | return InteractiveOutcome(message="Copy cancelled", display="system") |
| 299 | |
| 300 | if picked in ("full", "always"): |
| 301 | result = _copy_or_write(full_text, RESPONSE_FILENAME) |
| 302 | if picked == "always": |
| 303 | _persist_copy_full_response() |
| 304 | result += "\nPreference saved. Use /config to change copyFullResponse" |
| 305 | return InteractiveOutcome(message=result, display="user") |
| 306 | |
| 307 | block = code_blocks[int(picked)] |
| 308 | result = _copy_or_write(block.code, f"copy{_file_extension(block.lang)}") |
| 309 | return InteractiveOutcome(message=result, display="user") |
| 310 | |
| 311 | |
| 312 | COPY_COMMAND = CopyCommand( |
no test coverage detected