Skip to content

TUI: session.child.first/parent arrow keys have surprising behavior #56154

Closed as not planned

Description

@Addin

Summary

Pressing Down toggles the composer (or closes it if open); pressing Up navigates to the parent session instantly. Both are surprising for plain arrow keys and unguarded by focus.

Root cause

packages/tui/src/routes/session/index.tsx:1261-1294:

"session.child.first": keybind("down", "Toggle subagent picker"),
"session.child.previous": keybind("right", ...),
"session.child.next": keybind("left", ...),
"session.parent": keybind("up", "Go to parent session"),

These layers have no target/enabled guard, so arrows always toggle composer/navigate parent regardless of focus.

Suggested fix

Add focus guards to these layers, or use different keys that don't conflict with transcript navigation.

Activity

  1. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    Thanks for the report! I looked at the current v2 code, and the Up/Down defaults may not be as unguarded as they look. When the prompt has focus, its own higher-priority keybind layers handle Up/Down first: they move the cursor and step through prompt history. The key only reaches session.child.first (Down) or session.parent (Up) once there's no further history entry in that direction. That fallthrough appears to be intentional (the prompt footer shows the Down shortcut for subagents).

    To see whether something is actually misbehaving, could you add:

    • Your OpenCode version (opencode --version), OS and terminal
    • The exact steps: what had focus when you pressed the arrow key (the prompt, empty or with text, with or without history; a dialog; a permission prompt; the transcript, etc.)
    • What you expected to happen and what happened instead

    You can reply here with the details or edit the issue. If you edit it, please also leave a comment saying you've updated it, so we know you're done.

    I didn't find an exact duplicate. These related issues are ordered by how closely they match:

  2. Addin commented on Oct 16, 2026

    @Addin
    Author

    Thank you for the detailed investigation. You're right that my finding was overstated.

    Looking more carefully at the keymap layers:

    1. The prompt's history navigation layer (component/prompt/index.tsx) has priority: 1 with target: inputTarget, so when the prompt has focus, up/down are handled by the prompt first (cursor movement, then history navigation).
    2. The session.child.first (down) and session.child.previous (right) keybinds from config/keybind.ts:138-139 only fire when the prompt doesn't consume the key.
    3. The composer layer (routes/session/composer/index.tsx:72-82) uses left/right for tab switching, not up/down.

    So when the prompt has focus:

    • down at cursor position > 0: moves cursor down in prompt
    • down at bottom of prompt: navigates prompt history
    • down when composer is open: handled by composer's own logic or falls through

    The behavior is more nuanced than I described. While there may still be edge cases (e.g., when the composer is open with subagent tabs), the basic case works as expected.

    I'll keep this issue open as a minor UX clarification request, but I acknowledge it's not as broken as I initially described. The main concern would be if down in the composer's subagent tab behaves unexpectedly, but that would need separate investigation.

  3. opencode-agent commented on Oct 16, 2026

    @opencode-agent
    Contributor

    Thanks for taking another look and for writing up the layer order. That matches what I see in the code.

    About the remaining case: while the composer is open, it switches the keymap into its own composer mode. Its own layer binds Left/Right to switch tabs and Esc / Ctrl+C to close. Up/Down in the subagent tab should therefore move through that tab's list rather than reach session.child.first / session.parent.

    Without a concrete case where a key does something unexpected, there isn't anything specific for maintainers to act on here. If you do hit unexpected arrow-key behaviour (in the subagent tab or anywhere else), please reply with:

    • your OpenCode version (opencode --version), OS and terminal
    • the exact steps, including what had focus
    • what you expected and what happened instead

    If nothing comes up, this issue will be closed automatically on 2026-10-19 16:12 UTC. You're welcome to open a new issue with those details later.

  4. opencode-agent commented on Oct 19, 2026

    @opencode-agent
    Contributor

    Closing this as not planned. As we worked out above, the prompt handles Up/Down first. The session bindings only take over at the edge of the prompt history, and the composer handles its own keys while it's open. We were waiting for a concrete case where an arrow key does something unexpected (for example in the subagent tab), and none has come in.

    If you run into one, please open a new issue with your opencode --version, OS and terminal, what had focus, and what you expected compared with what happened. Thanks again for looking into the keymap layers so carefully.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions