[PR #907] [CLOSED] fix: tab key inserts character when toast notification is visible #9741

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

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opencode/pull/907
Author: @rossirpaulo
Created: 7/12/2025
Status: Closed

Base: devHead: fix/tab-key-toast-notification


📝 Commits (1)

  • f78dc4b fix: process tab key as command before text input to prevent tab insertion when toast is visible

📊 Changes

1 file changed (+25 additions, -23 deletions)

View changed files

📝 packages/tui/internal/tui/tui.go (+25 -23)

📄 Description

Fix: Tab key inserts character instead of switching modes when toast notification is visible

Problem

When a toast notification (e.g., update notification) is displayed in the TUI, pressing the Tab key inserts a tab character into the editor instead of switching between plan/execute modes as expected.

Root Cause

The issue occurs due to the input processing order in tui.go:

  1. When a key with text content (including tab) is pressed, it was being processed by the editor component first (for "maximum responsiveness")
  2. Command processing happened later in the update cycle
  3. Since tab has text content (\t), it was caught by the editor before the command system could handle it as SwitchModeCommand

Reproduction Steps

  1. Start opencode TUI
  2. Wait for or trigger a toast notification (e.g., update notification, error toast)
  3. While the toast is visible, press Tab
  4. Bug: A tab character appears in the editor instead of switching modes

Solution

Reordered the input processing logic to check for commands before processing printable characters:

// Before: Step 4 was printable character processing
// After: Step 5 is now command checking (including tab for mode switching)
matches := a.app.Commands.Matches(msg, a.app.IsLeaderSequence)
if len(matches) > 0 {
    // Handle commands first
    return a, util.CmdHandler(commands.ExecuteCommandsMsg(matches))
}

// Step 6 is now printable character processing (was step 4)
if msg.Text != "" {
    updated, cmd := a.editor.Update(msg)
    a.editor = updated.(chat.EditorComponent)
    cmds = append(cmds, cmd)
    return a, tea.Batch(cmds...)
}

Changes Made

  • Moved command matching logic before printable character processing
  • Updated the fallback comment to reflect that tab is no longer handled there

🔄 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/907 **Author:** [@rossirpaulo](https://github.com/rossirpaulo) **Created:** 7/12/2025 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/tab-key-toast-notification` --- ### 📝 Commits (1) - [`f78dc4b`](https://github.com/anomalyco/opencode/commit/f78dc4b1679cf71714a29ea5f4ab6641f33fcb8d) fix: process tab key as command before text input to prevent tab insertion when toast is visible ### 📊 Changes **1 file changed** (+25 additions, -23 deletions) <details> <summary>View changed files</summary> 📝 `packages/tui/internal/tui/tui.go` (+25 -23) </details> ### 📄 Description # Fix: Tab key inserts character instead of switching modes when toast notification is visible ## Problem When a toast notification (e.g., update notification) is displayed in the TUI, pressing the Tab key inserts a tab character into the editor instead of switching between plan/execute modes as expected. ### Root Cause The issue occurs due to the input processing order in `tui.go`: 1. When a key with text content (including tab) is pressed, it was being processed by the editor component first (for "maximum responsiveness") 2. Command processing happened later in the update cycle 3. Since tab has text content (`\t`), it was caught by the editor before the command system could handle it as `SwitchModeCommand` ### Reproduction Steps 1. Start opencode TUI 2. Wait for or trigger a toast notification (e.g., update notification, error toast) 3. While the toast is visible, press Tab 4. **Bug**: A tab character appears in the editor instead of switching modes ## Solution Reordered the input processing logic to check for commands before processing printable characters: ```go // Before: Step 4 was printable character processing // After: Step 5 is now command checking (including tab for mode switching) matches := a.app.Commands.Matches(msg, a.app.IsLeaderSequence) if len(matches) > 0 { // Handle commands first return a, util.CmdHandler(commands.ExecuteCommandsMsg(matches)) } // Step 6 is now printable character processing (was step 4) if msg.Text != "" { updated, cmd := a.editor.Update(msg) a.editor = updated.(chat.EditorComponent) cmds = append(cmds, cmd) return a, tea.Batch(cmds...) } ``` ## Changes Made - Moved command matching logic before printable character processing - Updated the fallback comment to reflect that tab is no longer handled there --- <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:14:05 -05:00
yindo closed this issue 2026-02-16 18:14:05 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#9741