Skip to content

feat(solid): expose terminal focus events via hooks#811

Merged
simonklee merged 3 commits intoanomalyco:mainfrom
nybble73:feat/terminal-focus-hooks
Mar 20, 2026
Merged

feat(solid): expose terminal focus events via hooks#811
simonklee merged 3 commits intoanomalyco:mainfrom
nybble73:feat/terminal-focus-hooks

Conversation

@nybble73
Copy link
Copy Markdown
Contributor

Closes #766

The renderer already emits "focus" and "blur" events when the terminal window gains/loses focus (via DECSET 1004), but there's no way to consume them from the SolidJS layer.

This adds three hooks following existing patterns:

  • onFocus(callback) / onBlur(callback) — callback style, mirrors onResize
  • useTerminalFocus()Accessor<boolean> — signal style, mirrors useTerminalDimensions

Use case: opencode plugins need to know if the user is looking at the terminal to decide whether to send OS notifications. Currently done via osascript polling — this replaces it with the event-driven signal the terminal already provides.

@nybble73 nybble73 force-pushed the feat/terminal-focus-hooks branch from d36595a to 5332607 Compare March 19, 2026 18:10
@simonklee simonklee merged commit f04840e into anomalyco:main Mar 20, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Ability to detect when TUI's terminal window is out of focus

2 participants