Skip to content

perf(tui): fix hardcoded esbuild output filename causing 6s blocking loop#20322

Closed
yigenhuobah wants to merge 1 commit into
NousResearch:mainfrom
yigenhuobah:patch-1
Closed

perf(tui): fix hardcoded esbuild output filename causing 6s blocking loop#20322
yigenhuobah wants to merge 1 commit into
NousResearch:mainfrom
yigenhuobah:patch-1

Conversation

@yigenhuobah

@yigenhuobah yigenhuobah commented May 5, 2026

Copy link
Copy Markdown

What does this PR do?

This PR fixes a silent performance bug introduced in PR #15351.

In hermes_cli/main.py, the stale check for the TUI frontend was hardcoded to look for ink-bundle.js. However, the actual output file from esbuild is entry-exports.js.

Because ink-bundle.js is never created, the stale check always returns True. This causes a synchronous npm run build (which takes about ~6 seconds) to execute on Uvicorn's main thread every time a user opens the Chat tab and initiates a WebSocket connection. This completely blocks the event loop and leads to severe UI unresponsiveness and WebSocket timeouts.

By correcting the filename to entry-exports.js, the stale check functions correctly, bringing the WebSocket handshake time down from ~6000ms to ~50ms.

Related Issue

N/A (Found during local debugging of TUI websocket timeout issues. Relates to the build changes introduced in PR #15351).

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Updated the bundle variable path in hermes_cli/main.py from ink-bundle.js to entry-exports.js to correctly match the esbuild output.

How to Test

  1. Launch the dashboard using hermes dashboard --tui.
  2. Open the web UI in a browser and navigate to the Chat tab.
  3. Observe the network tab and backend logs: the WebSocket connection (ws://127.0.0.1:9119/api/pty) should now establish instantly (~50ms) instead of hanging the event loop for ~6 seconds to run an unnecessary rebuild.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform: WSL2 / Ubuntu

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

Before:
WebSocket connection hangs for ~5.9s while Uvicorn main thread is blocked by npm run build.

After:
WebSocket handshake completes in ~53ms. UI input is instantly responsive.

@teknium1

Copy link
Copy Markdown
Contributor

Closing as stale — the code path this addresses no longer exists on main.

Triage notes (high confidence):
PR edits function _hermes_ink_bundle_stale and ink-bundle.js path that no longer exist on main; bundle freshness logic was rewritten (hermes_cli/main.py:1209 _tui_need_rebuild, lines 1370-1397 use npm run build). Bundling refactored by merged PR #18036.

If this PR's intent is still relevant against the current code, please rebase or open a fresh PR.

(Bulk-closed during a CLI PR triage sweep.)

@teknium1 teknium1 closed this May 24, 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/) P2 Medium — degraded but workaround exists type/perf Performance improvement or optimization

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants