(self, args: str, context: CommandContext)
| 63 | """ |
| 64 | |
| 65 | async def run(self, args: str, context: CommandContext) -> InteractiveOutcome: |
| 66 | store: Any = context.app_state_store |
| 67 | |
| 68 | current: str | None = None |
| 69 | if store is not None: |
| 70 | try: |
| 71 | current = store.get_state().permission_mode |
| 72 | except Exception: |
| 73 | current = None |
| 74 | |
| 75 | # The single select — same call drives REPL menu and TUI modal. |
| 76 | pick = await context.ui.select( |
| 77 | "Permission mode", |
| 78 | _PERMISSION_MODE_OPTIONS, |
| 79 | current=current, |
| 80 | ) |
| 81 | if pick is None: |
| 82 | # Cancelled — no output (display == 'skip'). |
| 83 | return InteractiveOutcome.skip() |
| 84 | |
| 85 | if store is None: |
| 86 | # No reactive store wired on this surface — report rather than |
| 87 | # silently no-op (mirrors the honest-failure stance of NullUIHost). |
| 88 | return InteractiveOutcome( |
| 89 | message="Permission mode unavailable (no app state store).", |
| 90 | display="system", |
| 91 | ) |
| 92 | |
| 93 | if pick == current: |
| 94 | return InteractiveOutcome( |
| 95 | message=f"Permission mode unchanged ({pick}).", |
| 96 | display="system", |
| 97 | ) |
| 98 | |
| 99 | # Persist: set_state fires on_change -> _on_permission_mode_change, |
| 100 | # which notifies the CCR bridge / SDK status stream. |
| 101 | from src.state.app_state import replace_state |
| 102 | |
| 103 | store.set_state(lambda s: replace_state(s, permission_mode=pick)) |
| 104 | return InteractiveOutcome( |
| 105 | message=f"Permission mode set to {pick}.", |
| 106 | display="system", |
| 107 | ) |
| 108 | |
| 109 | |
| 110 | PERMISSIONS_COMMAND = PermissionsCommand( |
nothing calls this directly
no test coverage detected