pi-focus-aware-blinking-cursor

Blinking cursor when focused; border dims when the terminal loses focus (pi TUI)

Packages

Package details

extension

Install pi-focus-aware-blinking-cursor from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-focus-aware-blinking-cursor
Package
pi-focus-aware-blinking-cursor
Version
0.1.2
Published
Aug 25, 2026
Downloads
494/mo · 19/wk
Author
tangentyh
License
MIT
Types
extension
Size
12.8 KB
Dependencies
0 dependencies · 2 peers
Pi manifest JSON
{
  "extensions": [
    "./focus-aware-blinking-cursor-and-border.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-focus-aware-blinking-cursor

Blinking cursor + focused/unfocused distinction for the pi TUI:

  • Focused: fake cursor cell blinks on/off at ~2 Hz; border keeps pi's dynamic color (thinking level / bash mode).
  • Unfocused: cursor hidden entirely; border dimmed.
  • Immediate on movement: the blink phase resets when the cursor moves (typing, arrows, word jumps like option+f, scrolling) or when focus returns, so the cursor reappears instantly instead of waiting out the current "off" half of the cycle.

"Focused" is two independent signals, both required for the blink:

  • TUI focus (Editor.focused): the input editor is the active component (loses focus while selectors/overlays are open).
  • Terminal focus: the terminal window itself. pi's TUI consumes the terminal's focus-in/focus-out sequences internally before extension input listeners run, so this extension watches raw stdin for them. In regular (non-fullscreen) mode focus reporting is off and the cursor blinks regardless of window focus.

Install

pi install ./extensions/focus-aware-blinking-cursor-and-border   # local
pi install npm:pi-focus-aware-blinking-cursor           # npm (if published)

pi's git sources clone a whole repository and install what its root package.json declares; the pi-collections root is never published and declares no pi manifest, so there is no git:.../pi-collections/... form. To install just this extension from the repo, clone it and pi install the subdirectory locally, or publish it to npm.

Or add it to the packages array in ~/.pi/agent/settings.json:

{
  "packages": ["./extensions/focus-aware-blinking-cursor-and-border"]
}

Notes

  • Works with scroll-speed in any load order: it delegates to a previously registered editor factory instead of replacing it.
  • Requires fullscreen (alt-screen) TUI mode for the terminal-focus signal.
  • Works with pi's showHardwareCursor setting: the zero-width hardware-cursor marker pi-tui emits next to the fake cursor is stripped on the "off" half of the blink, so the terminal's own (non-blinking) cursor doesn't keep the cell permanently visible.