Fix to the jupyterlab terminado issue that when returning to an idle JupyterLab terminal, cursor position report (CPR) escape sequences appear as literal text
Project description
jupyterlab_terminal_cpr_escape_fix
[!TIP] This fix is part of the stellars_jupyterlab_fixes metapackage. Install all Stellars fixes at once:
pip install stellars_jupyterlab_fixes
[!WARNING] This extension provides a workaround for a known JupyterLab/terminado issue. It will be deprecated once JupyterLab addresses this problem in a GA release. Monitor the upstream issue tracker for official fixes.
Fix the JupyterLab terminado issue where returning to an idle terminal causes cursor position report (CPR) escape sequences to appear as literal text. This is particularly noticeable with fish shell, where sequences like [2;2R[3;1R or [?1;2c[>0;276;0c appear at the prompt after reconnecting.
How it works
When a JupyterLab terminal sits idle, the shell (especially fish) periodically queries terminal capabilities. These queries accumulate in terminado's buffer. On reconnect, the buffer drains and the responses appear as literal text because xterm.js can't process them fast enough.
This extension patches TermSocket.on_pty_read() server-side to filter terminal query responses before they reach the browser. It handles both ESC-prefixed sequences and bare remnants where fish shell has stripped the ESC byte.
Filtered sequences (terminal query responses):
- CPR - Cursor Position Report (
ESC[row;colR) - DA/DA2 - Device Attributes (
ESC[?...c,ESC[>...c) - DECRPM - DEC Report Mode (
ESC[?mode;value$y) - OSC 4/10/11/12 - Color query responses
Preserved sequences (functional terminal output):
- All SGR color codes, cursor movement, erase, scroll
- OSC 0 (window/tab title), OSC 7 (cwd), OSC 8 (hyperlinks)
- OSC 52 (clipboard - used by companion clipboard extension)
- OSC 133 (shell integration prompt marks)
- Bracketed paste mode, alternate screen, all DEC private modes
Requirements
- JupyterLab >= 4.0.0
Installation
pip install jupyterlab_terminal_cpr_escape_fix
Uninstall
pip uninstall jupyterlab_terminal_cpr_escape_fix
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jupyterlab_terminal_cpr_escape_fix-1.0.4.tar.gz.
File metadata
- Download URL: jupyterlab_terminal_cpr_escape_fix-1.0.4.tar.gz
- Upload date:
- Size: 354.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2128250e194914828b70db33b093f45060d4d7f9f9c35660c627e0ef92e1a9e
|
|
| MD5 |
07b7d1be2eb2044355c32769489eaa61
|
|
| BLAKE2b-256 |
29da1aaab4935c5c93ab4985662fff5beeba68afb6a2cb5921d11922a3051900
|
File details
Details for the file jupyterlab_terminal_cpr_escape_fix-1.0.4-py3-none-any.whl.
File metadata
- Download URL: jupyterlab_terminal_cpr_escape_fix-1.0.4-py3-none-any.whl
- Upload date:
- Size: 20.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ef643638edf116f6afc1c009f3281bdbaf5066e340fe1e810d5d33d7714b49c3
|
|
| MD5 |
94cb4234edf59634a18d404238fe5703
|
|
| BLAKE2b-256 |
10dbba7d07056829efad055bead83a7c7e35b061859aa9dc44e70de6c72e9f6c
|