Skip to content

[Bug]: OpenCode falls back to plain Enter for Ctrl+Enter on Windows Local ConPTY #25372

Closed

Description

@abarabakuhatsu

Operating system

Windows

Orca version

v1.4.220

Details

[Bug]: Ctrl+Enter is sent as plain Enter for OpenCode on Windows Local ConPTY

Environment

  • Orca 1.4.220
  • OpenCode 1.18.34
  • Windows Terminal 1.24.2741.0 (Microsoft Store)
  • Windows + Nushell

Problem

Ctrl+Enter works correctly with OpenCode in WSL and in Windows Terminal, but becomes a plain Enter when OpenCode runs in Orca's Windows embedded terminal.

I verified this independently of OpenCode with a Node.js raw-input test after explicitly enabling the Kitty keyboard protocol:

Windows Terminal:
Ctrl+Enter → 1b 5b 31 33 3b 35 75  (CSI 13;5u)

Orca:
Ctrl+Enter → 0d  (CR)

Therefore the modifier information is lost in Orca before OpenCode receives the input.

Windows Terminal workaround

Windows Terminal does not provide this behavior automatically in my setup. I explicitly configured these actions:

{
    "actions": [
        {
            "command": {
                "action": "sendInput",
                "input": "\u001b[13;5u"
            },
            "id": "User.sendInput.CtrlEnterCustom"
        },
        {
            "command": {
                "action": "sendInput",
                "input": "\u001b[13;2u"
            },
            "id": "User.sendInput.ShiftEnterCustom"
        }
    ]
}

With this configuration, Windows Terminal sends the expected CSI-u sequences to OpenCode.

Reproduction

Using a small Node.js raw-input test program that explicitly enables the Kitty keyboard protocol:

Windows Terminal:
Enter       → 0d
Ctrl+Enter  → 1b 5b 31 33 3b 35 75
Shift+Enter → 1b 5b 31 33 3b 32 75

Orca:
Enter       → 0d
Ctrl+Enter  → 0d
Shift+Enter → 1b 0d

This demonstrates that the issue occurs in Orca's terminal input handling rather than in OpenCode's keybinding configuration.

Related issues

This appears related to #12329, #12462, and the earlier Ctrl+Enter handling in #5966 / #6383.

#12329 reported that Orca unconditionally sent CSI-u for Ctrl+Enter on Windows Local ConPTY. #12462 changed this behavior so that ordinary Windows Local ConPTY panes fall back to CR, while CSI-u can still be used for active/trusted TUI panes.

The current behavior appears to leave OpenCode on the CR fallback path, so Ctrl+Enter becomes indistinguishable from Enter.

In Orca 1.4.220, OpenCode is present in tui-agent-config.ts, but does not specify:

ctrlEnterEncoding: 'csi-u'

while some other TUI clients do.

Suggested fix

Could Orca provide a way for OpenCode to receive Ctrl+Enter as CSI-u on Windows Local ConPTY?

For example, OpenCode could potentially be treated as a trusted CSI-u consumer, similar to other supported TUI clients, or Orca could provide an explicit terminal shortcut/input mapping that sends:

Ctrl+Enter → ESC [ 13 ; 5 u

I am not suggesting reverting the compatibility behavior introduced by #12462 for unsupported Windows TUIs. The issue is that OpenCode currently cannot receive Ctrl+Enter as a distinct key combination in Orca, while the same OpenCode installation works correctly when the terminal explicitly sends the CSI-u sequence.

Activity

  1. added
    bug
    on Oct 5, 2026
  2. paoValle commented on Oct 5, 2026

    @paoValle
    Contributor

    Taking this one — and your diagnosis is right, including the file it points at. Traced the full chain; it also explains the one detail in your report that looked like a second bug.

    Why Ctrl+Enter becomes CR on local Windows ConPTY

    1. src/renderer/src/lib/pane-manager/terminal-keyboard-protocol.ts — shouldDisableKittyKeyboardForTerminal() withholds vtExtensions.kittyKeyboard from xterm on a local native Windows ConPTY pane, for every agent except grok (the #2434 protection for CSI-u-blind CLIs).
    2. src/renderer/src/components/terminal-pane/pty-connection/connect-pane-pty.ts:172 builds the TerminalKittyKeyboardModeTracker with exactly that option: kittyKeyboard: pane.terminal.options.vtExtensions?.kittyKeyboard === true. With the protocol withheld, the tracker ignores CSI > u entirely and flags stays 0 forever.
    3. src/renderer/src/components/terminal-pane/terminal-shortcut-policy.ts:189 decides the chord:
      const canSendCsiU =
        !localWindowsConpty ||
        (getKittyKeyboardFlagsActivePane?.() ?? 0) > 0 ||
        hasCtrlEnterCsiUAuthority?.() === true
      On a local ConPTY pane the first two are unreachable, so only the third can produce \x1b[13;5u.
    4. terminal-ctrl-enter.ts resolves that authority as TUI_AGENT_CONFIG[agent].ctrlEnterEncoding === 'csi-u'. Today that is droid and grok only. OpenCode is absent → \r.

    The detail that looked like a second bug

    Your Node raw-input test still received 0d after explicitly enabling the Kitty protocol. That is step 2: because Orca withholds the advertisement on this pane type, its own tracker is constructed to ignore the protocol, so an application-side CSI > u cannot reach the negotiation route either. There is no second defect — the negotiation route is simply closed on local ConPTY by design, which is why droid needed an explicit opt-in instead.

    What I'll change

    Treat OpenCode like Droid, which is the existing precedent for this exact situation: it decodes CSI-u but is not a candidate for re-advertising KKP globally.

    • src/shared/tui-agent-config.ts: ctrlEnterEncoding: 'csi-u' on the opencode entry.
    • Test pinning opencode in the trusted-consumer list in terminal-ctrl-enter.test.ts.

    Not changing the global ConPTY withhold (that is the #2434 protection), and not touching Shift+Enter — Esc+CR is what OpenCode receives today and your report does not list it as broken.

    Evidence that OpenCode decodes CSI-u, without needing a Windows host: it already works in Orca's WSL pane, where the same policy emits \x1b[13;5u because !localWindowsConpty is false there; and in Windows Terminal with your explicit sendInput action.

    One limitation I will record in the PR: the authority is pane-scoped, so this depends on the pane carrying agent evidence (a launch, a process read, or a title that resolves to opencode), the same condition Droid's and Grok's chord already has. A hand-started OpenCode in a pane whose title identifies nothing will keep falling back to \r.

    I'll open the PR shortly and link this issue with Fixes.

  3. paoValle commented on Oct 10, 2026

    @paoValle
    Contributor

    Housekeeping note on my own claim: #25505 is closed. I had seven small PRs open here at once and
    this was the four-line one, so I let it go rather than carry it — the diagnosis in this issue is
    unchanged and still actionable
    (the 0d arriving instead of the CSI-u sequence). Say the word and
    I reopen the PR, or anyone is welcome to take it.

  4. Pr1p commented on Oct 24, 2026

    @Pr1p
    Contributor

    I’m picking this up with the narrow existing-precedent approach: first I’ll pin the Windows Ctrl+Enter regression in a focused test, then grant OpenCode CSI-u authority without changing the global local-ConPTY safeguard for other terminals.

  5. added a commit that references this issue on Oct 25, 2026
    a289c98
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

    bugos:Windows

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions