Skip to content

Bracketed paste is parsed but never enabled — usePaste never fires #19

Description

@adamfratino

Summary

Storm parses bracketed-paste escape sequences (PASTE_START / PASTE_END) inside input/manager.js, exports BRACKETED_PASTE_ENABLE / BRACKETED_PASTE_DISABLE constants from core/ansi.js, and exposes a usePaste hook — but the terminal mode is never actually enabled, so pastes arrive as a stream of ordinary keypress events and usePaste never fires.

Repro

import { render, usePaste, useInput, Text } from "@orchetron/storm";

function App() {
  usePaste((text) => console.log("paste:", text));
  useInput((e) => console.log("key:", e.key, e.char));
  return <Text>ready</Text>;
}

render(<App />, { alternateScreen: true });

Paste any multi-character string. Expected: one paste: log. Actual: a key: log per character, no paste: log.

Cause

grep -rn "BRACKETED_PASTE_ENABLE\|2004h" dist/ shows the constant defined in dist/core/ansi.js but never written anywhere. The terminal stays in non-bracketed mode, so the parser in input/manager.js never sees PASTE_START.

Workaround

Emit the enable sequence manually on app startup:

process.stdout.write("\x1b[?2004h");

After that, usePaste fires correctly with the full pasted string in a single event.

Proposed fix

Screen.start() (or wherever ALT_SCREEN_ENTER / MOUSE_ENABLE are emitted in core/screen.js) should also emit BRACKETED_PASTE_ENABLE, and stop() should emit BRACKETED_PASTE_DISABLE, gated on the terminal capability check that already exists in core/terminal-detect.ts (bracketedPaste: true for known modern terminals).

Environment

  • @orchetron/storm 0.2.0
  • Bun 1.3.11
  • macOS 25.4.0 (Darwin arm64)

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions