fix(gateway): getattr-guard _status_text for bare-instance adapter tests

Gateway tests build adapters via object.__new__() without __init__ (the
documented bare-instance pattern), so the new _status_text dict must be
accessed through getattr guards in set_status_text, the _keep_typing
finally cleanup, and the Slack send_typing read — same treatment as
other post-hoc __init__ attributes. Fixes CI shard 2/8
(test_active_session_text_merge).
This commit is contained in:
teknium1 2026-07-18 12:07:51 -07:00 committed by Teknium
parent d4396797c3
commit d8fd45e9a8
2 changed files with 14 additions and 4 deletions

View file

@ -2328,10 +2328,17 @@ class BasePlatformAdapter(ABC):
Cheap, in-memory only: the next typing refresh renders the new text.
No-op storage on adapters that never read ``_status_text``.
"""
# getattr-guard: many gateway tests build bare adapters via
# object.__new__() without running __init__ (see AGENTS.md pitfall
# on new __init__ attributes breaking tests).
store = getattr(self, "_status_text", None)
if store is None:
store = {}
self._status_text = store
if text:
self._status_text[str(chat_id)] = text
store[str(chat_id)] = text
else:
self._status_text.pop(str(chat_id), None)
store.pop(str(chat_id), None)
# Whether this adapter can deliver an ASYNC notification back to the agent
# AFTER a turn ends — i.e. wake a fresh turn to surface a background
@ -3976,7 +3983,10 @@ class BasePlatformAdapter(ABC):
except Exception:
pass
self._typing_paused.discard(chat_id)
self._status_text.pop(str(chat_id), None)
# getattr-guard: bare object.__new__() adapters in tests lack
# _status_text (same class of issue as _typing_paused, but that
# one is always present because those tests predate it).
getattr(self, "_status_text", {}).pop(str(chat_id), None)
async def _stop_typing_refresh(
self,

View file

@ -1604,7 +1604,7 @@ class SlackAdapter(BasePlatformAdapter):
}
try:
_status = (
self._status_text.get(str(chat_id))
getattr(self, "_status_text", {}).get(str(chat_id))
or getattr(self.config, "typing_status_text", None)
or "is thinking..."
)