Skip to content

Keyboard and mouse support #869

Closed
1 of 1 issue completed
Closed

Description

@ivanfenenko

People using an iPad, Android tablet or Chromebook with a hardware keyboard and a mouse or trackpad can drive opencode sessions without touching the screen.

Builds on #358, which added Toggle Sidebar, Next/Previous Session and Focus Composer on both platforms. Every item applies to iOS and Android, with the same gating as the existing shortcuts: nothing fires while another text field, sheet or dialog has focus.

Model

Two layers:

  1. Standard focus navigation for everyone. It works like any desktop app or web page, with nothing to learn. Tab / Shift+Tab moves between controls, arrows move within a group (a list, a row of buttons), Return or Space presses the focused control, and Esc backs out. A visible focus ring shows where you are, and disabled controls are skipped. Every feature has to be fully usable this way.
  2. Shortcuts for power users on top. Chords such as ⌘N, or ⌘⏎ on a prompt, speed things up but are never required. They are listed in the iPad menu bar and hold-⌘ overlay, and in the Android shortcut helper. Where the opencode TUI already has a binding, use the same one.

Prompt safety rule: when a permission or question prompt replaces the composer, nothing in it is focused. A stray Return, Space or letter typed into the composer cannot answer the prompt. The first Tab or arrow key moves focus into it.

Decided with a prototype. Variant D (standard navigation) was chosen over A (TUI-style cursor), B (single-key keycaps) and C (chords only). In a typing-collision test, A's stray Return allowed the edit, B's letters denied or always-allowed it even with a 0.6 s guard, and C was safe but hard to discover. D was safe with no guard. Prototype: branch prototype/869-prompt-keyboard-keys (published 2026-10-27, shared privately).

Acceptance

Tier 1: keyboard navigation everywhere

  • Design-system interactive components can receive keyboard focus and show a focus ring: buttons, list items, prompt options, chips, pills, the session dock. On iOS this goes through the iPadOS focus system; on Android, through Compose focus and Material 3 focus indication. Components that use custom tap or long-press handlers are made focusable too.
  • Main screens have a logical Tab order and arrow movement within groups: Home, Session Chat, Settings, sheets and dialogs. Return or Space activates; Esc closes the topmost sheet or dialog, or clears focus.
  • Permission and question prompts follow the same model:
    • Nothing is focused when a prompt appears, and the first Tab or arrow moves in.
    • Arrows move between options and between buttons; Return or Space presses.
    • In "Type your own answer", Return saves and moves focus to Next / Submit, and Esc leaves the field.
    • A short "Press Tab to answer with the keyboard" hint shows only while a hardware keyboard is connected and nothing is focused.
  • With a hardware keyboard, the Session Chat composer sends on Return and adds a new line on Shift+Return. Soft-keyboard behaviour stays the same.
  • Esc interrupts a running turn, matching the opencode TUI. It applies only when Esc isn't already closing a sheet or clearing focus.

Tier 2: power-user shortcuts and mouse basics

  • Prompt shortcuts:
    • Permissions: ⌘⏎ allows once, ⌥⌘⏎ always allows, ⌘⌫ denies.
    • Questions: ⌘⏎ goes next / submits, ⌘⌫ dismisses, and 1–9 picks an option, but only once focus is inside the prompt.
    • On Android, Ctrl replaces ⌘.
  • App shortcuts: new session, model picker or command palette, settings, switch project 1–9, and ↑ in an empty composer to recall the last prompt.
  • A secondary click (right-click or two-finger click) opens the same actions as a long-press: messages, list items, the session dock. It also offers project remove, which today is swipe-only.
  • Design-system interactive components show hover feedback under a pointer: .hoverEffect on iOS; a hover state layer and pointer icon on Android.

Tier 3: polish and reach

  • The Android manifest declares android.hardware.touchscreen with required="false" so Play lists the app on Chromebooks without a touchscreen. Pointer-only and keyboard-only use work there.
  • Files and images dragged onto the composer become attachments.
  • Message text can be selected and copied with a mouse wherever it can be with touch, including code blocks and tool output.
  • Deny with a note: moved to Deny a permission with a note #946.

Remaining:

  • Tier 1: focusable design-system components with focus rings (iOS, Android)
  • Tier 1: Tab order and arrow groups on Home, Session Chat, Settings, sheets and dialogs (iOS, Android)
  • Tier 1: prompts use focus navigation with nothing focused on arrival, plus the keyboard-only hint (iOS, Android)
  • Tier 1: Return sends, Shift+Return adds a new line, with a hardware keyboard (iOS, Android)
  • Tier 1: Esc interrupts a running turn (iOS, Android)
  • Tier 2: prompt power-user shortcuts (iOS, Android)
  • Tier 2: app shortcuts, TUI-aligned and discoverable (iOS, Android). Search sessions (⌘F) moved to Search sessions on Home #929, since there is no session search yet
  • Tier 2: secondary click opens long-press and swipe actions (iOS, Android)
  • Tier 2: hover feedback in design-system components (iOS, Android)
  • Tier 3: touchscreen not required in the Android manifest (ChromeOS device check not done; no ChromeOS device available)
  • Tier 3: drag-and-drop attachments onto the composer (iOS, Android); iOS declined-drop card tracked in iOS: declined-drop card stays on the composer after the drag ends #951
  • Tier 3: mouse text selection and copy in messages (iOS, Android)
  • Tier 3: deny with a note moved to Deny a permission with a note #946

Sub-issues

Sub-issues

1 of 1 Issues completed
Loading 1 sub-issues

Activity

  1. added
    enhancement
    ios
    android
    tablet
    backlog
    priority: medium
    on Oct 27, 2026
  2. added
    todo
    and removed
    backlog
    on Oct 27, 2026
  3. added 6 commits that reference this issue on Nov 1, 2026
  4. ivanfenenko commented on Nov 3, 2026

    @ivanfenenko
    CollaboratorAuthor

    Status

    All three tiers are implemented on iOS and Android in #928, one commit per tier. CI passes (iOS Checks, Android Checks, secret scan, CodeQL). It is waiting for review, and merging it closes this issue.

    Done

    Tier 1: keyboard navigation everywhere

    • Design-system controls take keyboard focus and show one focus ring, only for keyboard focus.
    • Tab order and arrow groups on Home, Session Chat, Settings, sheets and dialogs. Return or Space activates. Sheets keep Tab inside and give focus back to the control that opened them.
    • Permission and question prompts arrive with nothing focused, so a stray key cannot answer them, including when one queued request replaces another. The first Tab enters at the first enabled control. "Press Tab to answer with the keyboard" shows while a hardware keyboard is connected.
    • With a hardware keyboard, Return sends and Shift+Return adds a line. Not while the @ / / list is open or IME text is composing.
    • Esc: close the top sheet or dialog → leave focus → "Esc again to interrupt" → a second Esc within 5 s stops the turn, as in the TUI. On Android, Esc otherwise acts as Back.

    Tier 2: shortcuts and mouse basics (Android uses Ctrl where iPad uses ⌘)

    • New Session ⌘N, Command Palette ⌘K, Choose Model ⌘⇧M, Settings ⌘, and Show ‹project› ⌘1–9.
    • Prompts: ⌘⏎ Allow Once / Next Question / Submit Answers, ⌥⌘⏎ Always Allow, ⌘⌫ Deny / Dismiss Question. They never repeat while held, and ⌘⌫ keeps deleting text in "Type your own answer".
    • Bare 1–9 picks a question option once focus is inside the prompt.
    • ↑ in an empty composer recalls this session's sent prompts.
    • Listed in the iPad menu bar and hold-⌘ overlay, and in the Android Keyboard Shortcuts Helper.
    • Right-click opens the long-press actions on messages, list rows and the session dock, and a Remove menu on projects. Right-click never presses a plain control.
    • Hover feedback in design-system controls, pointer only.

    Tier 3: polish and reach

    • The Android manifest declares the touchscreen optional, so Play can list the app on Chromebooks without one.
    • Checked with a pointer on both platforms: dropping files onto the composer, and selecting and copying text wherever touch can select.
    • Mouse clicks on message text place or clear the selection instead of opening actions (Android). Right-click opens actions on plain assistant messages too (iOS).

    Moved to separate issues

    Left

    • Before merge: rebase #869 Keyboard and mouse support #928 onto main. Recent main changes rework the Session Chat composer (Morph the Session Chat composer and smooth the Android keyboard animation #963, Keep the iOS question body its size inside the morphing composer #964, Move the iOS Session Chat list and composer with the keyboard #965). They merge without conflicts, but the prompt focus, Return-to-send and Esc code lives in the same files, so the rebase needs a build, tests and a quick device check.
    • Known gaps (listed in #869 Keyboard and mouse support #928, not filed separately):
      • iOS split view: Tab follows screen position, so it mixes the sidebar and the detail pane.
      • Android: five feature-local tappable views outside the design system still treat a right-click as a click (Servers screen, retry countdown, failure banner, pending prompts sheet, connection setup fields).
      • Android: Ctrl+N does nothing while Files or Changes is pushed over the chat in the split pane.
      • iOS: message text cannot be range-selected with touch or pointer; Copy goes through message actions. Selecting inside messages would need rendering changes.
    • Not checked on device:
      • Real hardware keyboards and mice, including double-click word selection.
      • ChromeOS: keyboard-only and pointer-only use.
      • Hover on a real iPad; the simulator does not render it.
      • Japanese IME composition with Return and Esc.
      • iOS Full Keyboard Access.
      • Tier 1 against a classic v1 server. Tier 2 and 3 were checked on both v1 and v2.
      • One queued prompt replacing another while focused. Unit-tested only.
      • An accepted drop without a temporary change; the test models take no attachments.
  5. added 6 commits that reference this issue on Nov 3, 2026
  6. added a commit that references this issue on Nov 4, 2026
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

    androidenhancementiospriority: mediumtablettodo

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions