Skip to content

The agent that grows with you

perf(gateway): prewarm /model picker cache on TUI startup

ZachariahChubdc82e39e983
diff --git a/tui_gateway/entry.py b/tui_gateway/entry.py
index cfd714b258b..0a44c32c6d2 100644
--- a/tui_gateway/entry.py
+++ b/tui_gateway/entry.py
@@ -455,6 +455,17 @@ def main():
# Live-apply skins Hermes activates mid-conversation.
server._ensure_skin_watcher()
+ # Warm the /model picker's provider-models cache off-thread during this
+ # idle window (gateway.ready sent, user about to type). Mirrors the classic
+ # CLI run() loop — the stdio TUI otherwise never prewarms, so the first
+ # /model open blocks on serial /v1/models fetches. Fire-and-forget,
+ # guarded once-per-process, fully exception-isolated.
+ try:
+ from hermes_cli.model_switch import prewarm_picker_cache_async
+ prewarm_picker_cache_async()
+ except Exception:
+ logger.debug("picker cache prewarm (tui) failed to start", exc_info=True)
+
while True:
raw = sys.stdin.readline()
if not raw: