[PR #79] [CLOSED] feat: add focus tracking to hide cursor when terminal loses focus #9533

Closed
opened 2026-02-16 18:13:43 -05:00 by yindo · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/79
Author: @Schniz
Created: 6/12/2025
Status: Closed

Base: devHead: schniz/handle-focus-changes


📝 Commits (3)

  • 3f8f7ec feat: claude 4 opus
  • c554430 Nord theme (#64)
  • f8be9a8 feat: add focus tracking to hide cursor when terminal loses focus

📊 Changes

33 files changed (+468 additions, -137 deletions)

View changed files

📝 cmd/root.go (+12 -3)
📝 cmd/root_test.go (+9 -9)
📝 internal/app/app.go (+2 -2)
📝 internal/diff/diff_test.go (+6 -6)
📝 internal/llm/agent/agent.go (+1 -1)
📝 internal/llm/models/anthropic.go (+15 -0)
📝 internal/llm/models/bedrock.go (+30 -0)
📝 internal/llm/provider/openai.go (+1 -4)
📝 internal/llm/provider/openai_completion.go (+0 -2)
📝 internal/llm/provider/openai_response.go (+4 -7)
📝 internal/llm/tools/batch.go (+3 -3)
📝 internal/llm/tools/batch_test.go (+1 -1)
📝 internal/llm/tools/lsp_code_action.go (+17 -17)
📝 internal/llm/tools/lsp_doc_symbols.go (+8 -8)
📝 internal/llm/tools/lsp_references.go (+0 -1)
📝 internal/llm/tools/lsp_workspace_symbols.go (+1 -1)
📝 internal/llm/tools/shell/shell.go (+2 -2)
📝 internal/tui/components/chat/editor.go (+26 -12)
📝 internal/tui/components/dialog/custom_commands_test.go (+10 -10)
📝 internal/tui/components/dialog/filepicker.go (+1 -1)

...and 13 more files

📄 Description

Implement ANSI escape sequence-based focus tracking to reduce visual distraction when switching between terminal windows or panes. The cursor now automatically hides when the OpenCode terminal is not focused and reappears when returning to it.

Key changes:

  • Add focus tracking utilities using ANSI escape sequences (\x1b[?1004h/l)
  • Implement real-time focus monitoring with escape sequence detection
  • Control cursor visibility in textarea component using cursor.CursorHide/CursorBlink modes
  • Add FocusMsg for communicating focus changes between components
  • Set initial cursor state to blinking (default focused state)

The implementation uses standard ANSI escape sequences, making it compatible with most modern terminals and terminal multiplexers like tmux, screen, etc.

🤖 Generated with opencode
Co-Authored-By: opencode noreply@opencode.ai


🔄 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/opencode/pull/79 **Author:** [@Schniz](https://github.com/Schniz) **Created:** 6/12/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `schniz/handle-focus-changes` --- ### 📝 Commits (3) - [`3f8f7ec`](https://github.com/anomalyco/opencode/commit/3f8f7ec5881640f40490b2f5d17504c6a390f773) feat: claude 4 opus - [`c554430`](https://github.com/anomalyco/opencode/commit/c554430c59171e2dbec4b4d311e5f7d5a8107d0b) Nord theme (#64) - [`f8be9a8`](https://github.com/anomalyco/opencode/commit/f8be9a8a9c83ff5c3f27dc7b8e7de75bd403f1c3) feat: add focus tracking to hide cursor when terminal loses focus ### 📊 Changes **33 files changed** (+468 additions, -137 deletions) <details> <summary>View changed files</summary> 📝 `cmd/root.go` (+12 -3) 📝 `cmd/root_test.go` (+9 -9) 📝 `internal/app/app.go` (+2 -2) 📝 `internal/diff/diff_test.go` (+6 -6) 📝 `internal/llm/agent/agent.go` (+1 -1) 📝 `internal/llm/models/anthropic.go` (+15 -0) 📝 `internal/llm/models/bedrock.go` (+30 -0) 📝 `internal/llm/provider/openai.go` (+1 -4) 📝 `internal/llm/provider/openai_completion.go` (+0 -2) 📝 `internal/llm/provider/openai_response.go` (+4 -7) 📝 `internal/llm/tools/batch.go` (+3 -3) 📝 `internal/llm/tools/batch_test.go` (+1 -1) 📝 `internal/llm/tools/lsp_code_action.go` (+17 -17) 📝 `internal/llm/tools/lsp_doc_symbols.go` (+8 -8) 📝 `internal/llm/tools/lsp_references.go` (+0 -1) 📝 `internal/llm/tools/lsp_workspace_symbols.go` (+1 -1) 📝 `internal/llm/tools/shell/shell.go` (+2 -2) 📝 `internal/tui/components/chat/editor.go` (+26 -12) 📝 `internal/tui/components/dialog/custom_commands_test.go` (+10 -10) 📝 `internal/tui/components/dialog/filepicker.go` (+1 -1) _...and 13 more files_ </details> ### 📄 Description Implement ANSI escape sequence-based focus tracking to reduce visual distraction when switching between terminal windows or panes. The cursor now automatically hides when the OpenCode terminal is not focused and reappears when returning to it. Key changes: - Add focus tracking utilities using ANSI escape sequences (\x1b[?1004h/l) - Implement real-time focus monitoring with escape sequence detection - Control cursor visibility in textarea component using cursor.CursorHide/CursorBlink modes - Add FocusMsg for communicating focus changes between components - Set initial cursor state to blinking (default focused state) The implementation uses standard ANSI escape sequences, making it compatible with most modern terminals and terminal multiplexers like tmux, screen, etc. 🤖 Generated with opencode Co-Authored-By: opencode <noreply@opencode.ai> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
yindo added the pull-request label 2026-02-16 18:13:43 -05:00
yindo closed this issue 2026-02-16 18:13:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9533