Skip to content

perf(termux): speed up tui cold start#29419

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-35c28838
May 20, 2026
Merged

perf(termux): speed up tui cold start#29419
teknium1 merged 1 commit into
mainfrom
hermes/hermes-35c28838

Conversation

@teknium1

@teknium1 teknium1 commented May 20, 2026

Copy link
Copy Markdown
Contributor

Salvage of #29404 by @adybag14-cyber onto current main.

Summary

Termux-gated cold-start optimizations. Desktop/CI startup paths are unchanged.

Changes

  • hermes_cli/main.py: new _is_termux_startup_environment() helper; model catalog top-level import (from hermes_cli.models import _PROVIDER_MODELS) deferred on Termux into the handlers that need it (kept eager on desktop/CI); new _tui_need_rebuild() mtime check on TUI source/config inputs; Termux skips npm run build when dist/entry.js is fresh; new _try_termux_fast_tui_launch() parses lightweight top-level parser for unambiguous hermes --tui / hermes chat --tui before building the full subparser tree; migrate added to _BUILTIN_SUBCOMMANDS.
  • Tests: test_tui_npm_install.py (build-skip freshness, Termux-only gating, desktop always-builds), test_tui_resume_flow.py (fast-launch happy path, help fallback, non-Termux fallback).

Validation

  • 78/78 targeted tests pass (test_tui_npm_install.py + test_tui_resume_flow.py + test_startup_plugin_gating.py).
  • Cherry-picks cleanly on current main.
  • python -m hermes_cli.main --version on desktop unchanged.
  • Verified the deferred top-level import (hermes_cli.models) pulls requests (~29ms) + agent.models_dev (~42ms) via python -X importtime on desktop; on a Pixel 5 Termux this is the load-bearing piece for the bare hermes CLI startup win.

Note

Closes #29404. Reported by community user on Termux/Android (Pixel 5) — "hermes" command takes 10-15s to start. The fast TUI launch path only helps --tui invocations; bare hermes/hermes chat startup benefits from the model catalog deferral only (~500ms-1s win, not a full fix for 15s startup).

Infographic

termux cold start shipped

@teknium1 teknium1 merged commit c29b4f5 into main May 20, 2026
17 of 18 checks passed
@teknium1 teknium1 deleted the hermes/hermes-35c28838 branch May 20, 2026 18:41
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-35c28838 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 8983 on HEAD, 8983 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 4740 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/perf Performance improvement or optimization P3 Low — cosmetic, nice to have comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) labels May 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/tui Terminal UI (ui-tui/ + tui_gateway/) P3 Low — cosmetic, nice to have type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants