Resolve the user's currently configured advisor model. Prefers the reactive AppState store if the caller wired one (so a just-issued ``/advisor`` from this session reads its own write without a settings-cache roundtrip), and falls back to the persisted settings — the source of truth
(context: CommandContext)
| 486 | |
| 487 | |
| 488 | def _read_current_advisor_model(context: CommandContext) -> str | None: |
| 489 | """Resolve the user's currently configured advisor model. |
| 490 | |
| 491 | Prefers the reactive AppState store if the caller wired one (so a |
| 492 | just-issued ``/advisor`` from this session reads its own write |
| 493 | without a settings-cache roundtrip), and falls back to the |
| 494 | persisted settings — the source of truth on every restart. |
| 495 | """ |
| 496 | store = getattr(context, "app_state_store", None) |
| 497 | if store is not None: |
| 498 | try: |
| 499 | state = store.get_state() |
| 500 | value = getattr(state, "advisor_model", None) |
| 501 | if value: |
| 502 | return value |
| 503 | except Exception: |
| 504 | pass |
| 505 | try: |
| 506 | from ..settings.settings import get_settings |
| 507 | configured = (get_settings().advisor_model or "").strip() |
| 508 | return configured or None |
| 509 | except Exception: |
| 510 | return None |
| 511 | |
| 512 | |
| 513 | def _write_advisor_model(context: CommandContext, value: str | None) -> None: |
no test coverage detected