[PR #811] feat(solid): expose terminal focus events via hooks #1581

Open
opened 2026-03-14 09:44:22 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/811
Author: @nybble73
Created: 3/13/2026
Status: 🔄 Open

Base: mainHead: feat/terminal-focus-hooks


📝 Commits (1)

  • e041239 feat(solid): add onFocus, onBlur, and useTerminalFocus hooks

📊 Changes

1 file changed (+20 additions, -0 deletions)

View changed files

📝 packages/solid/src/elements/hooks.ts (+20 -0)

📄 Description

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.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/811 **Author:** [@nybble73](https://github.com/nybble73) **Created:** 3/13/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `feat/terminal-focus-hooks` --- ### 📝 Commits (1) - [`e041239`](https://github.com/anomalyco/opentui/commit/e041239ce47d6d1ccb765a5c1471277f9c8719ea) feat(solid): add onFocus, onBlur, and useTerminalFocus hooks ### 📊 Changes **1 file changed** (+20 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/solid/src/elements/hooks.ts` (+20 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1581
No description provided.