Skip to content

mecatui: mouse drag-to-select text inside the prompt textarea (delete / replace / type-over) #770

Closed

Description

@Derek2Tu

Summary

In the TUI prompt input you cannot select a range of text with the mouse to edit it. You should be able to click-drag inside the prompt to highlight a run of text, then delete it, replace it, or have typing replace the selection — the standard GUI editing behavior.

This is the deliberate follow-up to #490, which ships click-to-position caret but explicitly cuts in-input selection ("No word-select in the input in v1 (deliberate cut)"). #490 is the caret; this is the selection.

Behavior requested

  • Click-drag inside the prompt input → highlight the covered range (from the press cell to the release/drag cell).
  • Delete/backspace with an active selection → removes the selection.
  • Typing (or paste) with an active selection → replaces it.
  • Standard escape hatches: click elsewhere / arrow keys collapse the selection to the caret.
  • Scope is the prompt textarea only. Drag-selection over the conversation viewport (copy-out) already exists and is unchanged.

Grounding

  • Alt-screen mouse is already captured; drag/motion/release are routed in cmd/mecatui/ui/update.go (MouseMotionMsg/MouseReleaseMsg, ~update.go:260), and the conversation viewport already implements drag-selection (cmd/mecatui/ui/selection.go, graphemeColForCellX).
  • Caret/cell→(row, rune-col) mapping is the shared hard part with mecatui: click-to-position caret in prompt textarea #490 (bubbles textarea soft-wrap via unexported memoizedWrap, rune-width-aware). This issue depends on that mapping; sequence after mecatui: click-to-position caret in prompt textarea #490 so the press/drag endpoints reuse the same cell→position helper rather than duplicating it.
  • Component gap to verify: bubbles textarea (v1.0.0 in go.mod) exposes SetCursor/SetCursorColumn and cursor movement but no selection model (no selection anchor/range, no "delete selection", no type-over-replace). So this likely needs either a local selection layer wrapping the textarea, or upstreaming selection support to bubbles. Flagging so this isn't scoped as "just wire drag events."
  • Respects --no-mouse (selection.go:105); extend MECATUI_DEBUG_MOUSE to show the selection range.

Open questions

  • Local selection overlay vs. upstream a textarea selection API to bubbles (mirrors mecatui: click-to-position caret in prompt textarea #490's "replicate locally vs. upstream PositionAtCell" choice — ideally decided together).
  • Interaction with existing viewport drag-selection: a drag that starts in the input stays an input selection; decide behavior for a drag that crosses region boundaries (clamp to the region it started in).
  • Word-select on double-click / line-select on triple-click — v2, note but don't require.

Acceptance criteria

  • Click-drag in the prompt highlights the covered range using the mecatui: click-to-position caret in prompt textarea #490 cell→position mapping.
  • Delete/backspace removes the selection; typing/paste replaces it.
  • Arrow keys / click elsewhere collapse the selection.
  • Soft-wrapped and scrolled buffers select correctly; empty buffer → no-op.
  • Conversation-viewport selection is unaffected; --no-mouse disables it.

Related

Activity

  1. added
    enhancement
    tui
    on Aug 26, 2026
  2. self-assigned this
    on Aug 26, 2026
  3. jbeda commented on Aug 31, 2026

    @jbeda
    Contributor

    I think this one is done. Let me know if more needs to be done here.

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

Metadata

Metadata

Assignees

Labels

enhancementtui

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions