omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Terminal typing lag after opening a new terminal — clears only after a genuine idle pause, tied to mise/starship/zoxide/ble.sh prompt stack

Open djoleluk opened this issue 2 months ago • 1 comments

Environment

  • Omarchy (Hyprland), foot 1.28.0
  • ble.sh: blesh-git 0.4.0_devel4.r2350.d81fd54f-1 (AUR)
  • Default bash rc chain (mise activate, starship init, zoxide init, bash-completion, ble.sh)

Symptom

Typing immediately after opening a new terminal is laggy/stuttery (~100-200ms per keystroke) for the first several commands. The lag does NOT go away just by continuing to type/run commands (tested across 5+ sequential commands). It only clears after a genuine, uninterrupted idle pause of a few seconds with zero input — after that, typing is instant (~10-30ms) for the rest of the session.

What I ruled out (instrumented reproduction, not guesswork)

  • bash history file size — cleared ~/.bash_history entirely, identical lag.
  • ble.sh's term_modifyOtherKeys_external bleopt — changed live, no effect.
  • ble.sh's async history-array-construction / multiline-history-fixup idle tasks — forced both synchronous via a blehook ATTACH!=... hook, no improvement.
  • foot itself — reproduced identically in a bare synthetic pty (Python pty.openpty() + bash -i, no terminal emulator involved at all).

What the lag actually corresponds to

Traced via /proc//wchan + child-process sampling: after every single command, Omarchy's default PROMPT_COMMAND chain spawns mise (hook-env), starship (2-4x per prompt, including the right-prompt call), zoxide, plus stty calls ble.sh makes around external command execution. This whole burst takes ~100-200ms combined in the first few commands after opening a terminal, and drops to ~10-30ms only after a real idle gap. Notably, the lag disappears entirely when the shell runs under strace, suggesting a timing-sensitive race rather than a fixed cost — possibly CPU governor / cgroup CPU-quota related rather than anything in mise/starship/zoxide/ble.sh's own code.

Possibly related

  • #4087 (periodic stalls, delayed keystrokes, CPU governor toggling didn't help)
  • #3685 (mise hook overwritten by starship/zoxide — same rc chain, different bug)
  • #1684 (slow terminal/Nautilus launches on laptop, undiagnosed)

Happy to share the pty reproduction script if useful.

djoleluk avatar Sep 24 '26 19:09 djoleluk

Correction, and closing this — the lag is not caused by Omarchy's own rc chain.

ble.sh is not part of Omarchy's default bash rc (my "Default bash rc chain (..., ble.sh)" line above was wrong — it's a third-party line I add myself in my own ~/.bashrc, sourced after $OMARCHY_PATH/default/bash/rc).

I ran a controlled A/B with the same pty-reproduction harness from the original report:

  • bash --rcfile /usr/share/omarchy/default/bash/rc -i (pure Omarchy chain, no ble.sh): every keystroke echoes in <0.3ms, from the very first character, no warm-up window at all.
  • Same harness, same machine, plain bash -i sourcing my real ~/.bashrc (Omarchy chain + ble.sh attached): reproduces the original lag immediately (individual keystrokes up to ~190ms) until an idle gap.

So the mise/starship/zoxide/bash-completion stack Omarchy ships is not the cause. It's specific to ble.sh's own idle scheduler (and possibly its interaction with starship's BLE_ATTACHED-gated right-prompt / blehook PRECMD integration, which only activates when ble.sh is present). Filing the corrected report at akinomyoga/ble.sh instead, closing this one so it doesn't stay open against the wrong project.

djoleluk avatar Sep 24 '26 20:09 djoleluk