Skip to content

Fix: Cmd+V makes exit instead of paste #23200

Closed as not planned
Closed as not planned

Description

@zokan121522

Description

When pressing Cmd+V in the prompt textarea, sometimes it triggers app exit instead of paste.

Steps to reproduce

  1. Open OpenCode
  2. Type something in prompt
  3. Copy text to clipboard from another app
  4. Press Cmd+V
  5. Expected: paste text | Actual: exits app

Root cause

In prompt/index.tsx lines 931-957, the handler blocked ALL meta/ctrl keys if clipboard has content, including Cmd+V.

Activity

  1. zokan121522 commented on Apr 17, 2026

    @zokan121522
    Author

    📝 Comment 1: Explore findings

    Exploración completada.

    Archivos analizados:

    • packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx - keyboard handler
    • packages/opencode/src/cli/cmd/tui/component/textarea-keybindings.ts - keybindings

    Root cause: Líneas 931-957 en index.tsx bloqueaban TODOS los keys con meta/ctrl si el clipboard tenía contenido, incluyendo Cmd+V.

  2. zokan121522 commented on Apr 17, 2026

    @zokan121522
    Author

    📝 Comment 2: Spec

    Requisitos:

    1. Cmd+V siempre debe hacer paste (no exit)
    2. Cmd+C debe seguir funcionando (copy)
    3. Exit solo con Escape cuando input vacío
    4. No romper otras funciones de teclado

    Escenarios:

    • Cmd+V con texto en clipboard → pega texto
    • Cmd+V con imagen en clipboard → pega imagen
    • Cmd+V sin contenido → comportamiento normal
    • Escape con input vacío → exit
    • Escape con texto → NO exit
  3. zokan121522 commented on Apr 17, 2026

    @zokan121522
    Author

    📝 Comment 3: Design

    Approach técnico:

    Modificar handler onKeyDown para:

    1. Específicamente detectar e.meta && e.name === "v" (Cmd+V)
    2. Si es Cmd+V → leer clipboard y manejar paste
    3. Si NO es Cmd+V → bloquear (previene exit accidental)
    4. Eliminar lógica compleja de "mightBePaste"

    Antes:

    if (e.meta || e.ctrl) {
      const mightBePaste = e.name === "v" || e.name === "c" || keybind.match("input_paste", e)
      if (mightBePaste) { ... }
      e.preventDefault() // ← bloqueaba TODO
      return
    }

    Después:

    if (e.meta && e.name === "v") {
      // Handle paste specially
      ...
    }
    if (e.meta || e.ctrl) {
      e.preventDefault() // ← solo bloquea otros
      return
    }
  4. zokan121522 commented on Apr 17, 2026

    @zokan121522
    Author

    📝 Comment 4: Tasks checklist

    • 1. Analizar código existente
    • 2. Identificar root cause
    • 3. Implementar fix en index.tsx
    • 4. Testear Cmd+V para paste
    • 5. Testear Escape para exit
    • 6. Verificar que Cmd+C funciona
  5. zokan121522 commented on Apr 17, 2026

    @zokan121522
    Author

    📝 Comment 5: Apply (implementación)

    Fix aplicado en:

    • Rama: fix/cmd-v-paste
    • Archivo: packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx
    • Líneas: 931-953

    Cambios:

    • Simplificada la lógica de detección
    • Cmd+V ahora siempre hace paste
    • Otros meta/ctrl combos bloqueados para prevenir exit accidental
  6. zokan121522 commented on Apr 17, 2026

    @zokan121522
    Author

    📝 Comment 6: Verify

    Resultado inicial: El fix funciona en testing inicial.

    Pendiente testing completo:

    • Cmd+V con diferentes tipos de contenido
    • Cmd+C copy sigue funcionando
    • Escape exit funciona
  7. github-actions commented on Apr 17, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:


    For keybind-related issues, please also check our pinned keybinds documentation: #4997

  8. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions