Skip to content

feat(cli): add mouse capture override flags - #60943

Draft
axeluhl wants to merge 1 commit into
anomalyco:devfrom
axeluhl:mouse-override
Draft

axeluhl wants to merge 1 commit into
anomalyco:devfrom
axeluhl:mouse-override

Conversation

@axeluhl

@axeluhl axeluhl commented Oct 31, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #60942

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds --no-mouse and --mouse to the full-screen TUI command. I switch between local terminals and SSH and want terminal-native selection and paste on demand.

The optional CLI value overrides cli.json at startup and on config reloads, without writing the override to disk. Omitting both flags preserves the configured behavior.

OPENCODE_CLI_CONFIG_CONTENT already offers an environment-based workaround; these flags make the mouse-only override discoverable in --help.

This is a draft for design review of the linked feature request.

How did you verify your code works?

  • bun run check passed.
  • CLI flag parsing and TUI config tests passed ten consecutive runs each.
  • Real PTY check on this branch: both flags override the opposite config value, survive a file reload, accept bracketed terminal paste, and exit cleanly with Ctrl-C.
  • Documentation typecheck and build passed.
  • Full TUI suite: 1,599 passed, 2 skipped, 1 failed. The go-upsell-art logo assertion also fails on unmodified upstream a5518690fc.

Visual

<svg xmlns="http://www.w3.org/2000/svg" width="240" height="72" viewBox="0 0 240 72" role="img" aria-label="Disable mouse capture to select and paste with the terminal">
  <style>
    @media (prefers-reduced-motion: no-preference) {
      .selection { animation: select 3s ease-in-out infinite; }
      @keyframes select { 0%, 100% { width: 18px; } 45%, 80% { width: 152px; } }
    }
  </style>
  <rect x="1" y="1" width="238" height="70" rx="6" fill="none" stroke="currentColor" opacity=".35"/>
  <text x="12" y="19" fill="currentColor" font-family="monospace" font-size="11">opencode --no-mouse</text>
  <rect class="selection" x="12" y="28" width="152" height="17" rx="2" fill="currentColor" opacity=".22"/>
  <text x="15" y="40" fill="currentColor" font-family="monospace" font-size="11">error: expected foo</text>
  <text x="12" y="61" fill="currentColor" font-family="monospace" font-size="10" opacity=".7">select → PRIMARY → paste</text>
</svg>

Screenshots / recordings

The PTY check verifies mouse-reporting escape sequences and pasted text; this changes input routing rather than layout.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add --no-mouse and --mouse for per-invocation control of terminal mouse capture. Preserve config defaults when absent and retain explicit overrides through config updates without persisting them.

Cover optional flag parsing and reactive config precedence, and document native terminal selection over SSH.
@TOMUIV

TOMUIV commented Nov 4, 2026

Copy link
Copy Markdown

One data point that might make this smaller than a boolean flag: the native terminal session already takes
mouse and mouseMovement as two separate flags, and validates exactly three mouse modes:

setupTerminal({ ..., mouse: this._useMouse, mouseMovement: this.enableMouseMovement, ... })

Session mouse mode must be disabled, drag, or motion

Nothing in the app ever passes enableMouseMovement (so it always resolves to motion), and cli.json's
mouse is z.boolean() — so today the three modes are reachable from nowhere. Wiring the existing literals
through (--mouse=disabled|drag|motion, or a string value in config) would give:

  • motion — today's behaviour, ?1000h ?1002h ?1003h ?1006h
  • drag — ?1002h only: click, drag, wheel and keys still work, no all-motion stream
  • disabled — as today's mouse: false

drag is the useful middle ground for SSH: it keeps application mouse support (unlike --no-mouse, which
forces user-selected text to fall back to the terminal) while removing the continuous motion reports that
feed #60268. Same idea as #60942, just three states instead of two, and no new machinery.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: Add --no-mouse and --mouse CLI overrides

2 participants