omp packages

pi-copy-soft-wrap0.1.2

Pi extension that fixes unwanted newlines when copying soft-wrapped text from the fullscreen TUI

hburaktasyurek Published 1 month ago MIT ~172 downloads/mo

Untested on omp

This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

pi-copy-soft-wrap

Copy text, not terminal wraps.

Fix unwanted newlines when copying mouse selections from Pi's fullscreen TUI.

npm version Pi package license

Before and after: wrapped Pi output pastes with unwanted newlines before the extension and as clean text after it

The problem

Long Pi responses wrap to fit the terminal. In fullscreen mode, copying a mouse selection can turn those visual wraps into real newlines:

A sentence that only wrapped because it reached the terminal
edge pastes as multiple lines.

pi-copy-soft-wrap cleans the selection before it reaches your clipboard. It joins likely visual wraps while keeping obvious paragraphs, lists, block quotes, tables, and code on separate lines.

No command or new keybinding is required. Select text and copy as usual.

Quick start

1. Install

pi install npm:pi-copy-soft-wrap

2. Use Pi in fullscreen mode

Try it once:

pi --tui-mode fullscreen

Or make it permanent in ~/.pi/agent/settings.json:

{
  "tuiMode": "fullscreen"
}

3. Restart Pi and copy normally

Drag to select text with your mouse, then paste it anywhere. The extension runs automatically.

Already using fullscreen mode? Install the package, restart Pi, and you are done.

What it handles

  • Wrapped prose is joined with spaces.
  • Long URLs are joined without inserting spaces.
  • Blank lines and Markdown structure stay on separate lines.
  • Lists, block quotes, tables, and obvious code keep their line breaks.

Limitations

Pi currently does not expose whether each rendered row ended with a visual wrap or a real source newline. This extension therefore uses a conservative heuristic rather than changing Pi's stored messages.

  • Fullscreen only: regular-mode selection is owned by your terminal and cannot be intercepted by a Pi extension.
  • Ambiguous text: an intentional single newline inside plain prose may be treated as a visual wrap.
  • Private API: the extension patches Pi's internal fullscreen selection method. A future Pi update may require a compatibility update.

The original session content is never modified—only the selected clipboard text is normalized.

Troubleshooting

Copying still adds newlines

Confirm that Pi is running in fullscreen mode:

pi --tui-mode fullscreen

Then restart Pi after installing or updating the package.

Disable or uninstall

pi remove npm:pi-copy-soft-wrap

Restart Pi afterward. If a Pi update breaks the extension, open an issue with your Pi version, terminal, and a short copy/paste example.

How it works

In fullscreen mode, Pi owns text selection through TuiAltScreen. The extension wraps its internal getActiveSelectionText() method and normalizes the selected text immediately before Pi copies it. It does not patch Pi's files, replace clipboard tools, or alter model/session data.

Relevant upstream discussions: #5931, #8019, PR #7721, and PR #8407.

Development

npm test
pi -e . --tui-mode fullscreen

License

MIT